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

Terry Woods

Member
Join Date
Apr 2002
Posts
3,170
FLIP-FLOP or FLIPFLOP or FLIP FLOP or TOGGLE or ONE BUTTON or ONE-BUTTON

This will work in ANY PLC. It is the "generic" solution for any PLC. It's only four Rungs in length and is totally transparent, to ANY PLC user, even Bubba! (OSR's can be confusing to some.)

The Flipping (Toggling) action takes place in only one scan.

This Rung watches for the PB to be pressed. When the PB transitions from NOT Pressed (OFF) to Pressed (ON), "FLIP-BIT" goes ON to flip the "TARGET BIT". "FLIP BIT" goes ON for no more time than it takes to scan the next two Rungs. And possibly, for as little time as it takes to scan the next one Rung.

SET-ting "WAS PB" prevents "FLIP BIT" from being re-activated, in subsequent scans, while the PB is still being pressed.


WAS
PB PB
---| |-------|/|---+---( ) FLIP-BIT
|
+---(SET) WAS PB



If the PB is just-now pressed, and the "TARGET BIT" is ON, then "TARGET BIT" is RESET (Turned OFF). Then, the driving signal, "FLIP BIT", is RESET (Turned OFF). If "FLIP BIT" is turned OFF in this Rung, then the next Rung is prevented from operating on the "TARGET BIT".


FLIP TARGET
BIT BIT
---| |-------| |---+---(RST) TARGET BIT
|
+---(RST) FLIP-BIT



If the PB is just-now pressed, and "FLIP BIT" is still ON (not RESET in the previous Rung), and "TARGET BIT" is OFF, then "TARGET BIT" is SET (Turned ON). Then, the driving signal, "FLIP BIT", is RESET (Turned OFF). Since "WAS PB" was SET (Turned ON), Rung-1 is prevented from being activated.


FLIP TARGET
BIT BIT
---| |-------|/|---+---(SET) FLIP-BIT
|
+---(RST) FLIP-BIT



When the signal from PB finally goes OFF, after having been ON ("WAS PB" is ON), then run that pair of conditions through a short-termed Timer (1-second). After timeout, RESET (Turn OFF) "WAS PB". That produces a "debouncing" effect. When "WAS PB" goes OFF, the first Rung is allowed to "watch" for the next pressing of PB.


WAS
PB PB +---------+
---|/|-------| |----+ TIMER +---(RST) WAS PB
| 1-Sec |
+---------+



.
 
4 rungs for a flip flop?

Personally I disagree with the use of the term flip flop.

In many cases the descripton of one input used to alternatte an output is called a JK flip flop...that is just wrong.

One rung with many branches is not innovative..especially when talking about an S7-200...it has a "toggle" instruction.

I posted examples of "toggle" or flip flop with Terry's flowchart to help.

Flip flop's are electronic devices used for a specific purpose, a PLC can simulate it BUT it is not one...it can do more.
 
Last edited:
toggle2.JPG


This AB logic. It is a simple toggle
!st time input is true CTU=1 Output is on
2nd time input is true CTU=2,resets,CTU=0 Output is off
Is there an easier way to post pics or drawings? Thanks
 
Our you can do it like this,

1flip.jpg




You can call it...JK-Flip-Flop, RS-Flip-Flop, JFK-Flip-Flop
What ever you want, as long as your output is true when you want it to be.

PS. Tsmith... my neck hurts ;)





edit: I cant seem to get the pic to insert??, but here is a PDF
Edit: Got it...you must read, hmmm
 
Last edited:
"I guess Terry has settled the background noise for a month!?"

Apparently not.

Yes Ron, there are indeed four rungs.

Ron... A rose by any other name is still a rose.
I just used what seemed to be the most common names for the sake of searching.

The point of my post was to present a "flip-flop-toggle-whatever-thingee" that would work in ANY PLC. The only element that might be considered exotic is the timer. However, even Smart Blocks (Smart Relays) have timers.

I've always been bothered by brand-specific solutions. A solution created for a particular brand of PLC might be so unique that it can't be applied to other PLCs. This code will apply to any PLC. Any programmer can read it and understand it. The concept is apparent. Having understood the concept... any programmer can then use those unique tools in his particular tool-box to realize the concept in any manner he wishes... or, with only one caveat, he can use the code exactly as I have presented it. The caveat is in regards to the timer. It appears that most PLCs handle timers differently. So, apply the timer in the manner required for your particular PLC.

"One rung with many branches is not innovative..especially when talking about an S7-200...it has a "toggle" instruction."

One rung?
I thought we just agreed that it was four rungs.

S7-200?
I thought I made it clear that this code is for use in ANY PLC.

So Ron... what's your point?

(From "Never-Never-Land"... where believing in yourself can produce some pretty amazing results!)
 
Terry,

Look at your third rung. The logic does do not match with the description.

Shouldn't it be |---+---(SET) TARGET-BIT ?
 
The best laid plans of mice and men...

Damn it Jim! You are so right.

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


This will work in ANY PLC. It is the "generic" solution for any PLC. It's only four Rungs in length and is totally transparent, to ANY PLC user, even Bubba! (OSR's can be confusing to some.)

The Flipping (Toggling) action takes place in only one scan.

This Rung watches for the PB to be pressed. When the PB transitions from NOT Pressed (OFF) to Pressed (ON), "FLIP-BIT" goes ON to flip the "TARGET BIT". "FLIP BIT" goes ON for no more time than it takes to scan the next two Rungs. And possibly, for as little time as it takes to scan the next one Rung.

SET-ting "WAS PB" prevents "FLIP BIT" from being re-activated, in subsequent scans, while the PB is still being pressed.


WAS
PB PB
---| |-------|/|---+---( ) FLIP-BIT
|
+---(SET) WAS PB




If the PB is just-now pressed, and the "TARGET BIT" is ON, then "TARGET BIT" is RESET (Turned OFF). Then, the driving signal, "FLIP BIT", is RESET (Turned OFF). If "FLIP BIT" is turned OFF in this Rung, then the next Rung is prevented from operating on the "TARGET BIT".


FLIP TARGET
BIT BIT
---| |-------| |---+---(RST) TARGET BIT
|
+---(RST) FLIP-BIT




If the PB is just-now pressed, and "FLIP BIT" is still ON (not RESET in the previous Rung), and "TARGET BIT" is OFF, then "TARGET BIT" is SET (Turned ON). Then, the driving signal, "FLIP BIT", is RESET (Turned OFF). Since "WAS PB" was SET (Turned ON), Rung-1 is prevented from being activated.


FLIP TARGET
BIT BIT
---| |-------|/|---+---(SET) TARGET BIT
|
+---(RST) FLIP-BIT




When the signal from PB finally goes OFF, after having been ON ("WAS PB" is ON), then run that pair of conditions through a short-termed Timer (1-Second). After timeout, RESET (Turn OFF) "WAS PB". That produces a "debouncing" effect. When "WAS PB" goes OFF, the first Rung is allowed to "watch" for the next pressing of PB.


WAS
PB PB +---------+
---|/|-------| |----+ TIMER +---(RST) WAS PB
| 1-Sec |
+---------+

 
Last edited:
An even more universal solution. No Set/Resets. No Latch/Unlatch. No Counters. No Timers. No Time delay to deal with.

 
PB Target R1
--] [-+-]/[--+--------------------( )-
| |
R1 | PB |
--] [-+-]/[--+


PB R1 Target
--]/[-+-] [--+--------------------( )-
| |
Target| PB |
--] [-+-] [--+


1) Target and R1 starts out both off
2) PB is pressed and held. Only R1 is on
3) PB is released. Both R1 and Target are on
4) PB is pressed and held. R1 drops out
5) Button is released. Both R1 and Target are off as in step 1
 
Last edited:
How about this for generic.
Some very basic / stone-age PLC's don't support multiple outputs on a rung. And even those have input filtering, so a debounce is redundant (unless the operator has Parkinson's).
Still 4 rungs though

PB aux OS
----] [-------]/[-----------------( )--

PB aux
----] [---------------------------( )--

OS TOGGLE TOGGLE
----] [-------]/[-----------------(L)--

OS TOGGLE TOGGLE
----] [-------] [-----------------(U)--



Slightly less generic using output branching:
Down to 2 rungs. (This one's better if I/O is asynchronous)

PB aux OS
----] [---+---]/[-----------------( )--
|
| aux
+-----------------------( )--

OS TOGGLE TOGGLE
----] [---+---]/[-----------------(L)--
|
| TOGGLE TOGGLE
+---] [-----------------(U)--

 
Last edited:
I agree with the concept of less rungs is better. I do not have the experience of the major posters here, but I learned early on, you can get so fancy that it does't work.
 
Tsmith said "you can get so fancy that it does't work" - well put.

Terry, If the brewmaster had intended the beer to be flat, he wouldn't have put in the bubbles in the first place.
 
Archie,
Yours will work, however, isn't it kinda weird to operate a light or motor by "releasing" a push-button? And it is not exactly what I would call easy to decipher. Bubba would probably get dizzy trying to figure it out.

And by the way Archie, the conditions that cause the need for "debouncing" should not be considered frivolous.

Gerry,
Neither of yours will ever work in the vast majority of PLCs. If the light is ON you can turn it OFF.. however, the problem is that the light can never be turned ON!

Gerry said...
"Some very basic / stone-age PLC's don't support multiple outputs on a rung. And even those have input filtering, so a debounce is redundant (unless the operator has Parkinson's)."

Gerry, if you were hired to create a One-Button Toggle-Function that would work in ANY PLC, would your statement have any validity at all? Notice that the key-word is "ANY"... that would include all of those "...very basic / stone-age PLC's...". Even those that don't have built-in filtering!


Jim...
Since I paid for those bubbles... I prefer to keep them for myself rather than letting them bubble away into the atmosphere!

If ya can't get a good healthy buuuurrrrp.... out of them bubbles, then what the hell is the point of havin' 'em?
 
Last edited:

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,455
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,886
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