TIAPortal HMI how to have a button change functions when a value is changed

Heh: reduced it by one more instruction and got rid of the intermediate DInt (PMotor_Speed_0_or_100), but I had to give the ugly stick an encore to get there.

Still HMI "Sets and forgets" i.e. HMI only ever writes a 1 for any button press.

Without the TOF:

xxx.png
 
Last edited:
For education

Hmmm strange it worked for me in a simulator - maybe you could show what you did?

@walkerist: even though the problem is solved, I suggest doing what @moggie asked.

As you have stated you want to learn about PLCs, exercises such as these are well worth the time.

Also, can you describe to us what the following circuit does, and how it operates? Toggle_Me_Elmo is the output; from time to time, the input Set_And_Forget_from_HMI bit value will be assigned a 1 by a process or device external to the PLC.

xxx.png
 
@walkerist: even though the problem is solved, I suggest doing what @moggie asked.

As you have stated you want to learn about PLCs, exercises such as these are well worth the time.

You are right, I do want to learn more about PLCs. I currently learn a lot from what you guys tell me, what i do to solve the problem, what i search on the internet, what i read on the F1 and a lot more. I will post what i did shortly

Also, can you describe to us what the following circuit does, and how it operates? Toggle_Me_Elmo is the output; from time to time, the input Set_And_Forget_from_HMI bit value will be assigned a 1 by a process or device external to the PLC.

Hmm. Weird. Is this really working was my first question. So lemme see. So we check if Elmo is energized and not energized at the same time. But if i am correct on this this works sort of like a pulse right? There is both a latch and latch release sort of thing going on here. If we just keep Set_And_Forget_from_HMI at 1 wont Toggle_Me_Elmo pulse like crazy? Not exactly pulse because there is not rythm to it but you get it. It turns to 1 first and 0 first then 1 again then 0 again and so on.

But i dont think that this is the way we use this logic. So there is a press and release type of click and the Set_And_Forget_HMI turns to 1 instantly and goes back to 0. At that point the Toggle_Me_Elmo just got energized but the Elmo on the top just got nullified because it is energized. However Elmo doesnt go away because Elmo down below just got energized with the Elmo on the right. With the one click of a button we made ELMO go from 0 to 1

If we press the Set_And_Forget_HMI button again then HMI at the top gets energized but cant go anywhere because ELMO at the top is 1 so no energy passes from there. The real deal happens at the rung below this time. Remember that ELMO below that was energized and is now keeping the ELMO at the right on 1? yeah now because we energized HMI Button he has no juice left so he has to let go. And now with another click of a button we made ELMO on the right go from 1 to 0.

Sorry i couldnt explain it in a more scientific manner. That's just who i am i guess :)
 
I don't believe i've said Elmo this much in a conversation or in a chat before. For that achievement and your lesson i would like to humbly thank you @drbitboy
 
I have a question @drbitboy. Wouldnt the system work the same if you just removed that reset? Are you solving the turning to 1 forever by one click with that logic?
 
I don't believe i've said Elmo this much in a conversation or in a chat before. For that achievement and your lesson i would like to humbly thank you @drbitboy

Haha!

Well done! You analyzed and described it perfectly. I especially agree with your observation that there are both latch a latch-release aspects to the circuit, i.e. it's related to the Sealed-In, State/Fault, and Start/Stop patterns (cf. this link; the Start/Stop pattern is the one almost every introduction to ladder logic uses).

Generically that circuit is an implementation of an XOR (eXclusive OR: [a AND NOT b] OR [NOT a AND b]; also [a OR b] AND NOT [a AND b]).

Practically, with the condition that the Set_And_Forget_from_HMI boolean is a one-shot trigger (i.e. true for one program scan only at a time), it's called a flip-flop i.e. it inverts (flips from 0 to 1 or flops from 1 to 0) the output from its initial state for each scan when the trigger is 1. So the upper branch [NO trigger NC output] does double-duty, i.e. executing EITHER a flip OR a flop, on the single scans when trigger is 1, and the lower branch [NC trigger NO output] does the latch or "seal-in" on all other scans, i.e. when trigger is 0.

If you search for "flip-flop electronics" you will find several versions of a specific integrated circuit; this is closest to the the "T flip-flop," with the trigger signal "T" called the "clock" or "strobe."

There are other ways to code it, and I think there is an ancient thread on this forum that has a few dozen different approaches; to me this has the best aesthetic. Note that that the SUB instruction in my final approach, Output = 100 - Output, where Output is only either 0 or 100, is in itself a form of flip-flop when triggered by the _ONS tag (consider B = 1 - B, where B is only ever 0 or 1 i.e. a Boolean).

The reason I bring it up is that I tried very hard to use this particular arrangement in the current thread, but it just wouldn't fit for this application.

Also, I wanted you to see that a flip-flop was more or less what you were looking for. And although @Steve Bailey already covered this ground, this provides an alternate path to understanding why the logic could not be split, as you were initially trying to do, between the HMI and PLC after the introduction of the analog I/O field: because the flip-flop needs to know the initial state of the output (motor speed), where the Start/Stop 1/0 button in the HMI was simply writing values to the PLC without regard to the state of the motor.
 
I have a question @drbitboy. Wouldnt the system work the same if you just removed that reset? Are you solving the turning to 1 forever by one click with that logic?


No and Yes.

TL;DR

When the trigger is driven by a PLC-internal event and no HMI is involved, the trigger of a flip-flop is usually the output of a one-shot driven by that event. That works differently when the trigger is driven by PLC-external source such as an HMI Set-And-Forget pattern. My assumption is that the Set_And_Forget_From_HMI boolean trigger is only ever changed to a 1 by the HMI; I use Set-And-Forget, as mentioned earlier, because it is (in my experience) the most reliable way to pass boolean information about single HMI button presses from the HMI to the PLC. Set-And-Forget requires the PLC to assign a 0 to the value of the bit; doing it immediately ensures the trigger is a one-shot, because as you noted in your analysis, if that trigger is not RESet and stays as a 1, the output would toggle (flip and flop) state on every scan, and in the motor application the output speed would continually toggle between 0 and 100.

The beauty (to me) of the flip-flop is that the trigger/clock/_ONS does not know about the initial state of the output bit: when the trigger is 1, it tells (triggers) the rest of the circuit to "invert the output on this scan;" when the trigger is 0, it tells the rest of the circuit to "leave the output as-is on this scan."
 
There are other ways to code it, and I think there is an ancient thread on this forum that has a few dozen different approaches; to me this has the best aesthetic. Note that that the SUB instruction in my final approach, Output = 100 - Output, where Output is only either 0 or 100, is in itself a form of flip-flop when triggered by the _ONS tag (consider B = 1 - B, where B is only ever 0 or 1 i.e. a Boolean).

I need to find that post im gonna search it quickly. But wait a minute. I am stumbled there. I wanted to ask you that but i was too caught up on the elmo question there. How does that subtraction work on my case though? Normally if we were talking about a normal 0 to 1 1 to 0 i would've said ok or hell even if its a 0 to 100 and 100 to 0 flip-flop(Now i understand what a flip-flop is and i can understand why everyone keeps bringing up the flip-flops. Thank you for that important lesson :D ) i would have been fine with it. But mine wasnt like that and it still works and i have no idea why.

So I've tried various kinds of ways on this. I tried 7-8 approaches on this and none of them worked including @moggie's way(still gonna post that when i get home). None of the solutions that work uses a real one shot trigger which is P_trig and i centered my entire plan on using that which didnt work btw.

How does that really work? Lets say i modified the PMotor_Speed_Perct without clicking the ONS button. Now it is 60. And i click on the button now and it became a 0? why? how? i mean if you just subtract 100 from 60 you just get 40 and your PMotor_Speed_Perc becomes 40 no?

I am bamboozled, either i am too tired or im too stupid to get this :D
 
...
How does that really work? Lets say i modified the PMotor_Speed_Perct without clicking the ONS button. Now it is 60. And i click on the button now and it became a 0? why? how? i mean if you just subtract 100 from 60 you just get 40 and your PMotor_Speed_Perc becomes 40 no?

I am bamboozled, either i am too tired or im too stupid to get this :D

There is nothing wrong with you, the fault is entirely mine: I am a terrible programmer who cares more about the number of instructions than having clean, easily understood code.

Rather than explain my code golf ledgerdemain, I VERY STRONGLY suggest that you watch @Ron Beaufort's Most Excellent PLC bootcamp videos, starting at this link; they take about 10-11 minutes each, the whole series takes less than 2h; it will save you ten times those 2h time in the next month, and thousands of times that over your career. Pay particular attention to how @Ron reads a ladder diagram, which you will see in the second or third video: yes it's slow; yes it's pedantic; yes it's repetitive; yes it's boring; but it's accurate and unambiguous, and it is all you will ever need to reliably understand ladder.

Once you have done that, go back and read my rung where you don't (yet!) see how it goes from 60 to 0 by subtracting 100, every instruction, the way @Ron taught you to, left to right, top to bottom, and the scales will fall from your eyes.
 
Once you have done that, go back and read my rung where you don't (yet!) see how it goes from 60 to 0 by subtracting 100, every instruction, the way @Ron taught you to, left to right, top to bottom, and the scales will fall from your eyes.

Ok i get it now master. I watched RonBeaufer's videos and i gotta say, i was disappointed to see that they only have 11 videos there :( . I cant even reach the website

So when we energize the HMI_PMotor_Start_Button_ONS it becomes 1 and then we go to the Auto_run and see if its a 0 or not(btw dont forget about that ONS Reset :D ). If its 0 then we can move without a problem and we check to see if our PMotor_Speed_Perc is bigger than 0, if it is not which means our motor speed is 0 we subtract 100 from our 0 and we get 100.

Lets say our value is 55 like on the screenshot you just posted. If thats the case then we move 100 to our PMotor_Speed_Perc and after that we Subtract 100 from PMotor_Speed_Perc which is now 100.

So at the first glance i thought the move command at the top was the command that gave us 100 with the ONS click. And i thought Subtraction was what gave us 0. I mean i wasnt completely wrong on that but my thought was if my speed is 20 then im gonna subtract 100 from 20 and get 80 and subtract it again and again and again until it becomes a 0 and since everything happens nearly instantly in the program i wouldnt notice that with my human eyes.

Maybe i looked at it with different eyes or probably it was @Ron Beaufort or you @drbitboy i see it differently now. So my mistake was looking at it like a flow of water. I thought it went everywhere at the same time, Thats why i was kinda bamboozled. Instead i needed to read it sort of like a book.
left to right, top to bottom
Just as master @Ron taught me to do :D
 
see if it's a 0 or not
Instead i needed to read it sort of like a book.
The penny drops; it's that moment of dawning comprehension we live for; etc.

It is rewarding to be a part of this process; thank you for persevering.

And well done (y)! PLCs are now an open book, a side issue, a set of well-understood tools, and you can focus on what you want to do.

@Ron's stuff is awesome.
 

Similar Topics

Hello everyone, I dont know if this is a common error or if im wrong but whenever i create a screen i am allways afraid of my life with this...
Replies
4
Views
2,030
Does anyone know if there's a technical reason why Siemens HMIs can't have the program uploaded from them into TIAPortal as a project file, or is...
Replies
5
Views
772
I have a nice project in Visilogic that I have been asked to re-create in Tiaportal/Siemens. (Bosses / maintenance want to standardise on one...
Replies
2
Views
1,281
Hi All, which the best way to do the indirect addressing in an optimize DB? Ccurrently this is my partial code inside an FB...
Replies
7
Views
2,252
Hello everyone, I am currently trying to build a HMI(KTP400 basic) for myself. I have some UDT data and use these UDT data for 20~...
Replies
7
Views
1,238
Back
Top Bottom