FLIP-FLOP or FLIPFLOP or FLIP FLOP or TOGGLE or ONE BUTTON or ONE-BUTTON

I like Gerry's and have done it this way.

I usually have a lot more reasons to reset a toggle than to set one. That is, the PB can turn it on or off, but a multitude of conditions may turn it off. It is easily done here by addding parallel conditions to the OS in the unlatch rung.
 
Terry Woods said:
And to you, rta53...

I didn't "hijack" your thread. "Hijacking" occurs within the thread. I simply started a new thread, of my own, that directly addressed the search-issue and the universal-solution-issue.

Do you have a problem with me helping those that don't have your particular favorite brand?

If so... too bad. This ain't the rta53 site.

Don't take it personally... except to the extent that you really need to reconsider your attitude about this issue.

Damn! I hate using sharp daggers! But sometimes...


Thanks for setting me straight. I feel so much better now.
 
Passing along a hearty "Hi-Ho! Thanks"

I have been putzing around with the toggle scenario and not getting anywhere. The generic solutions work well as does the counter solution. Since I am using SLC500's, that is my preferred method but they all have taught me something.

Again... Thanks.
John
 
FWIW I have only used the XOR toggle for some years now.

I like that:

1. It switches on the button release, as do most software HMI buttons.

2. It is totally universal, well at least it works on every PLC I've tried.

3. It uses only XIC, XIO and OTE's.

4. It only uses three BOOLs of memory.

5. It looks cute.
 
as far as i remember toggles using xor out of contacts and
coils behaves slightly diferently from built in xor instruction.

version using ote coils gets reset on powerup which might be
desirable sometimes but this is not always the case.
using logic with latches can address this issue.

it's good to see so many flip flop variations and programming
styles but when it comes to this problem i'm sold on word level xor.
nothing beats it's simplicity and efficiency - single rung with three
instructions and you get 16 or 32 toggles. all of this with just one
auxilary bit wasted.

just one extra rung to selectivly reset some or all of them on powerup if needed.

no lengthy code, timers or counters... bunch of toggles with three
instructions in one rung.

i know that this was intended for newcomers because this topic
returns like clockwork. which is somewhat annoying. let's make it interesting.
what is one toggle after all? most equipment these days has tons of
functionality. let's start another tread with chalenge:
who can write most efficient logic for 100 or 1000 toggles?

i like tidbits, let's do something creative and achive more
using little, not achive little with a lot.

🤞🏻
 
Last edited:
Yeah finally!!!

panic mode said:
i like tidbits, let's do something creative and achive more
using little, not achive little with a lot.
🤞🏻
I am glad someone is listening. I know because you used the magic word. I have stayed away from this thread. I was willing to wait till someone remembered. Sometimes I think no one listens or remembers.

Not much has changed since this post.
http://www.plctalk.net/qanda/showpost.php?p=2177&postcount=14
My word solution would meet Terry's specs. That was four years ago. I could improve on this a little now that I know there are andnot instructions. However, since many microcontrollers and PLCs did not have andnot instructions so I did think in terms of using an andnot. Now, my DSP and STL have an andnot instruction so this can be improved by one instruction. Look at the REACTION to my post 4 years ago. Not much has changed.

BTW, I did find this thread amusing watching everyone re-invent the wheel and not even very round ones at that. Using counters for toggles? Give me a break. That is very wasteful let alone violating Terry's specifications.

Panic mode, why don't you share your Rockwell version and mark it with the magic word so we can find it latter? What about the "first in first out" thread? I have stayed away from that one too. Some one must remember the efficent way to find the least significant or most signficant bit in a word.

There is a challenge.
 
I use to use this a lot, back in my Allen Bradley days, and below is my Siemens equivalent.

toggle_pw.JPG



Similar to someone elses, but the latch is done on a single network
 
this should work for 16 buttons. plcs that support 32-bit registers can obviously do more. one can also add branches around NEQ and XOR instructions if memory is at premium and one can't find one more bit for next OSR.
note that in this example all outputs are retentive. if this is not desired, simple AND instruction can reset individual bits on first scan. if range of bits is to be cleared CLR or FLL will do the job.
i consider this to be advantage since most of the toggles i use are on HMI's setup screens (enable or bypass this or that, setup recipes etc.) and I want this to stick even after machine was powered down.
possible disadvantage is that if all those toggles are buttons distributed among different stations, they might interfere and prevent each other from toggling if one guy keeps his finger on his button. if this was the case, i would separate them so each station uses differnt word (and one shot).
if one wants to toggle just one button, all it need to be done is enter mask in one of the XOR arguments (source B) and use XIC as condition instead of NEQ. all other bits remain unaffected.
it sure works for me... (y)


FlipFlop.jpg
 
... My old tried & true.
 
PB T1 T2 T3
--] [----]/[----] [----( )

PB T1 T3 T2
--] [----]/[----]/[----( )
| |
| T2 |
-] [----------

PB T1
--] [------------------( )


1.) T2 is the output Toggle Bit
2.) Any permits to enable the Toggle (such as a reset or ESR) goes in the first rung before the PB
3.) Any causes for an un-latching of the toggle (such as an alarm or fault) goes in the second rung after the NOT T3.

I have found this works pretty much on any plc ... not to say I've seen 'em all ... I haven't. But, this is a simple XIO, XIC and OTE solution in just 3 rungs, 1 PB, and 3 bits.

... just my 2 cents.
- Tony
 
Last edited:
Tony...

If you are going to try to post code by typing, do this...

Write your code in WORD (or whatever word processor you have), and do so in COURIER! DON'T USE TABS!!!

[LADDER]
PB T1 T2 T3
--] [----]/[----] [----( )

PB T1 T3 T2
--] [----]/[----]/[----( )
| | I'm not even gonna
| T2 | try to guess where
-] [---------- this stuff goes.

PB T1
--] [------------------( )
[/LADDER]



Oh, yeah... then, when you're happy with what you see in WORD, cut-n-paste the whole thing into the post-window.

Your normal text, outside of the Ladder, will look OK, but, your Ladder-Code will NOT look OK! Don't worry about it!

DO A PREVIEW! Your Text and Ladder should look just as you wrote it in WORD.

If not... do your edits in the WORD version... not on the post-window. Then cut-n-paste again.

A simpler, cleaner, easier, and more indicative, way to "draw" your code would be like this...

[LADDER]
PB T1 T2 T3
--| |-----|/|-----| |-----( )

PB T1 T3 T2
--| |--+--|/|-----|/|--+--( ) << Notice the "Plus-Signs"...
| | ...they show connection points.
| | And the "Uprights" are easier than trying to
| T2 | use square-brackets in a reverse manner.
+--| |----------+ Besides, they are a lot more traditional.

PB T1
--| |---------------------( )
[/LADDER]



Do what you will...
 
Last edited:
Yeah ... I just got the hang of the TEXT / LADDER thing. Sorry for any confusion. I tried to fix it. Will do better next time.
- Tony
 
However, skip the preview if you use the ladder tags. When you use those tags and do a preview you will get this. The code below is code I entered befor pressing preview:


A B C
-+--] [--+--] [------( )-
| |
| D |
+--] [--+




But it should have looked like this:

A B C
-+--] [--+--] [------( )-
| |
| D |
+--] [--+



In the preview it looked fine, but in the final post it won't.
 
The previous post was made by first entering the code I wanted, then hitting preview. In the preview pane it looks fine, but if you look down to the editor window it will be all messed up. Before I hit preview I made a copy of the code as it should have been and then pasted that code in and hit submit so you can see how it should have looked. Preview and Edit will mess up the code, so rather than edit the previous post, I added this post. Terry made a good suggestion about using Word. I do this as well. If you do need to edit don't try and fix the text in the post editor, it doesn't work right. Just delete it and paste in the corrected version from Word.
 
Last edited:
So... Money4Nothing...

You sound like a "typical" process-guy to me...

How exactly are you making your money4nothing?
 

Similar Topics

I am having this issue trying to figure out how to do this. I have a Hydraulic ram that travels when a machine is running. The ram extends to the...
Replies
31
Views
9,456
Hi everyone, I'm learning ladder logic and have built a flip flop circuit (see pic) from an online tutorial. Closing the switch A is meant to...
Replies
19
Views
6,887
I found and fixed issue. B3:3 was used in MOV.
Replies
11
Views
2,555
I am calculating power factor from samples of voltage and current. Calculation is done by multiplying voltage and current samples. What Im...
Replies
0
Views
1,632
Hi all, my first post here, I've been lurking for a while. I'm a beginner and I hit a wall on one of my first projects I'm working on. I know it...
Replies
6
Views
2,529
Back
Top Bottom