flip flop logic

Yeesh

RS: Knock off the melodrama. For crying out loud, nobody wants to see you quit the forum. I have no problem with Chako’s posting a link, rather than an image. I’ve never mastered the image thing myself, either. And if he increases traffic to his website, more power to him – it’s a PLC site. I have a site too, but it’s not PLC-related, hence, no self-promotion.

I think perhaps you are feeling sensitive about that nameless guest who jumped you for trying to sell/trade some surplus equipment. Personally, I don’t want to see ads from tradesmen here, but I have no difficulty with a little “garage sale” now and then. So take a deep breath and calm down.

Chako : don’t think you’re getting away unscathed here, buddy. RS’s reply was politely phrased and seemed genuinely interested in discussing the issue – you took it to the next level, and that was uncalled-for. You had a defensible point, but decided to turn it into a pi$$ing contest. Not every dissenting opinion is a personal challenge to you.

On the subject of programming versus maintenance, I program for maintenance, but there has to be a balance. If I can do something in three steps instead of one, and the three is easier to follow, I’ll go that route. But if it’s fifteen steps instead of three to accomplish the same thing, then I do it my way and comment the heck out of it in hopes maintenance will be able to follow along.

That’s my two bits.

TM
 
Chako : don’t think you’re getting away unscathed here, buddy. RS’s reply was politely phrased and seemed genuinely interested in discussing the issue – you took it to the next level, and that was uncalled-for. You had a defensible point, but decided to turn it into a pi$$ing contest. Not every dissenting opinion is a personal challenge to you.

Eh? I wasn't rude or anything to RS was I? I even said sorry too...gesh..I never degraded or said anything bad about RS, I would never do that, unless I've met you in person. I agree however, lose the politics and most people will enjoy life better.

RS said that my link showed "no outputs". Clearly to me he didn't even look at the link, so I was clarifing what the file was, and it was even up on the site two days before this post was ever started.

Now I should give RS the benifit of the doubt, maybe he was referring to the fact that my examples shows internal BIT files, or B3 files rather than a actual OUTPUT file, like an O:xx number....But I guess to me, my example shows the B3 file "acting" as an output so I guess I don't see his point of view saying that my file didn't have any outputs. Really that's all I was trying to clarify. It's a simple misunderstanding an nothing more.

RS: Your link was AB specific and showed no outputs. How does that explain/show a one PB to turn off/on an output.

As far as the website traffic thing, traffic back to www.plcs.net is in place and is highly recommended at mrplc.com.

Allen Bradley even uses mrplc.com to host some files for them.
http://www.ab.com/raise/autocad.html

Mainly that is the "core" of mrplc.com, is downloadable examples, not a forum board.

Hope that helps and try and have a good day at work today. Also thanks for the feedback. I'll try and work on my "pi$$ing"....
 
Ron:

I know that you've been attacked several times lately (unjustly, in my opinion), but do try to calm down and slough it off.

I've been aware for some time that Peter tends to program in either STL (which is the language posted), or sometimes (I think) in 'C', (which probably means he's one of THOSE that favor PC control over PLC control.

No matter.

The only reason you can't understand what he posted is that you haven't been exposed to it. It's really no different than if suddenly a Modicon 984 showed up in your plant, and you'd have to learn all it's little quirks, like Traffic Cop, Networks, and the unique way it scans logic.

STL is no better, and no worse, than ladder. It's just different. It suffers from not being graphical.

But once you learn the language, it's easy to understand. The big thing about it is that it works with a buffer memeroy (which ladder does too, it's just more subtle about it.)

The first thing you have to do is load something in the buffer memory. That's the LD (for LoaD - "when in doubt, leave out a vowel"). On a bit level, it's absolutely no different than --| |--.

His next command is a oneshot, which I'm sure you're familiar with.

The next command is XOR, or eXclusive OR, which is a boolean command not usually found in ladder. But it means Either A or B, but not both. In other words, "A but not B, or B but not A". In ladder, that's:

A B
--+---| |---|/|---+--
| |
| B A |
+---| |---|/|---+



The buffer memory has to go somewhere, and that's the STore command, which of course is the ladder --( )--.

Putting the whole thing together, and you get

PB PB-ONS
---| |-----|ONS|------( )

PB-ONS Lamp Lamp
--+---| |----|/|---+---( )
| |
| PB-ONS Lamp |
+---|/|----| |---+



Which should look very familiar.

Peter's second posting is the same thing, Only done on the Word (or, since he's doing 32-bit, Long Integer) level.

I do the same thing with AB CPT block. All my HMI inputs (which are in consecutive bits in word HMI_PB) are converted to one-shots. The HMI writes to the address, the PLC resets it after one scan, like this:

+-------------------- CPT ---+
---+---| Dest: HMI_ONS |
| | Expression: |
| | (HMI_PB AND (NOT HMI_LAST) |
| +----------------------------+
|
| +---- MOV --+
+---| HMI_PB |
| HMI_LAST |
+-----------+



And so forth.
It's similar logic to what Peter posted, just in a different format (I'm not trying to toggle anything with this. This rung is roughly the equivalent of my first rung)
You could put the same sort ox XOR logic into an AB CPT block, and get the same thing as Peter.

Again, it's not hard, just different. You haven't been trained. Once you are, I think you'll find that you still prefer ladder.

WHICH IS PERFECTLY OK !! . It's not "dumbing down the code". It's just easier (for you. For Peter, STL is easier).
 
Last edited:
OK I apologize for my rant.

Allen that is why I stated (I am the exception to the rule). I am a maintenance tech that actually took a 2 year course in Electronics. I understand Boolean math, phrases etc. I understand LD OR etc etc BUT its not as easy to me as ladder when applied to a machine, nor for alot of people.

My point was, what you were/are eloquent enough to state in another post, that ladder is overall just as effective AND that more people that are trained in hardwiring can understand it.

This is personal opinion but I am going to stand by this. As you stated, ladder is a graphical representation used to show hardwiring and represent the actions of a plc. Why cant that be expanded? Is it that much different than flow charts etc?

To me its a case of Manufacturers/OEMs/some engineers that want it to be so high level that the working man can not deal with it, which in turn puts more money in their pocket.

Allen pls note that I dont include you and many others in my assessments...ie the following diatribe.

NO I do not want to "dumb" down machines/devices I have to deal with, I want it as advanced as it can be. I want to learn about every advancement in technology that affects me. I want to be able to walk up to that machine and "quickly" find where the problem is. The old days of relay logic didnt allow that. The interim days of plc's have allowed that. The path plc's/programmers etc are taking once again is getting away from the "maintenance/electrician". HELL wont be long at this rate they will remove the pretty red/green lights.

I will state this and let this **** die. Ignorant YES (I am not as lucky as you guys that know it all), I am what is called in the US a "redneck" "biker" (to some its known as ignorant redneck, ignorant hillbilly, ignorant biker or any combination thereof). YES I ride Harley's. I have long hair. I am physically disfigured. I am kind of large (to some but not fat), I have a large family, I dont see any reason to do anything small. I have dug ditches, worked for carnivals(grew up on 1 and another 12 yrs with another), and computers. Idiot? NO. Opinionated (who isnt)?

I disagree with the way things have been done here and will follow my own path...right or wrong. This is an excellent site with the capabilities to share so much information. That is one thing the Linux crowd has going for them, the willingness to share.

I will make mistakes but I am sure that some of you will gladly clarify the issue when I am wrong. I am looking forward to it.

BTW I still have issues with anger management but that is ONE reason I like this place, it has helped me immensely.

With all this said and done. IF any of you are in the NASHVILLE, TN (US) area then give me a holler (in English thats translates to give me a phone call or email) and let me buy you a beer/dinner. Darn good way to get away from that LARGE family I mentioned.
 
I just wanted to make a few comments about the code that Allen found...

Code:
   PB       CHECK   LIGHT     LIGHT
---| |---+---|/|-----|/|---+---(L)
         |                 |
         |                 |  CHECK
         |                 +---( )
         |
         |  CHECK   LIGHT     LIGHT
         +---|/|-----| |---+---(U)
         |                 |
         |                 |  CHECK
         |                 +---( )
         |
         |                    CHECK
         +---------------------( )


Yep, the whole thing in one rung of logic!
Of course, it uses multiple coils, which is something of a no-no (the middle one could be eliminated, but it's more ethetically pleasing the way it is.)

Just passing it on, FWIW. This is NOT intended for either student or real use..

It won't work in all PLCs, of course (it would fail miserably in a Modicon 984 for example, with its Left-to-Right, Top-to-Bottom.
scanning method.

As I said, just for jollies (Well, I thought it was funny!).

What you are looking at is a direct implementation of a FlowChart. Who can't underatand a FlowChart?

The only thing I would change is... CHECK --> WAS PB
For those that know, I'm kinda anal about "names". The name should be conceptually correct.

3d11164066966401.gif


And YES!, this FlowChart translates into a single rung!

And NO!, the middle one can NOT be eliminated. It can not be eliminated, regardless of whether or not it is "esthetically" pleasing!

While it's TRUE that this will not work on PLC's that do not have recursive processing abilities, it certainly WILL work on those that DO HAVE recursive processing abilities!

As far as having multiple cases of the same coil... NOT A PROBLEM!
At least, not with PLC's that can do recursive processing.

Older PLC's execute from Left to Right and QUIT the rung at the very first opportunity that it can process from the Left to the Right rail -- No Parallel Outputs!

Later PLC's allowed for parallel outputs; as in...

Code:
  INPUT-1
----| |------+----(OUT-1)
             |
             +----(OUT-2)

Then came recursive type processors. They allow the following...

Code:
  INPUT-1
----| |------+--------------(OUT-1)
             |   INPUT-2
             +-----| |------(OUT-2)

Just passing it on, FWIW. This is NOT intended for either student or real use..
This certainly IS for REAL USE!

The S7-200 allows this kind of processing. This kind of processing (recursive) allows LITERAL translations of FlowCharts!

While it will fail on the Grand-Fathers of the industry (Modicon 984, and yes, even my beloved old TI, and those PLC wannabe's), it will not fail on the more modern, more robust systems!

As I said, just for jollies (Well, I thought it was funny!).
FUNNY? I think not! I think, more like, "ABOUT TIME!" PC's did this FOREVER!
 
Quote:
<hr color="red">
Just passing it on, FWIW. This is NOT intended for either student or real use..

This certainly IS for REAL USE!
<hr color=red>

No, it's NOT!

Oh, sure, the code works just fine on most modern PLCs (and without the middle coil - the bit that it might set/reset will be set by the last branch regardless.).

But I really, sincerely do not advocate it's use.

Why? For students, it sets a bad precident of multiple coils. Sure, there's nothing logically wrong with doing them (and I've done it myself many times (although I'm more likely to simply unlatch a bit that's used in a sealing coil)). But how many times has someone come to this site asking for help because of multilple coils?

As for "For Real", there are at least a half dozen different ways to do this logic. When I do it (which is almost never - I use SCADA/HMIs mostly theses days, so having a single address do double duty like this is closer to 'bad design' than 'an elegant solution'), I (and most programmers, judging from the number of instances) usually prefer the one-shot logic that I posted before. In some cases, I'll use the Karanugh map generated code (for lurkers, go to the old forum archives, and search for "Brain Teaser" by Archie to view that solution.)

As Ron Doran pointed out, just who are we coding for? Your situation is different from mine, Terry. You are coding for yourself (and those who you train). I'm an integrator. I code for some unknown maintenance guy. Once startup is over, I never see that code again (God willing), unless it's to add new stuff.

And there's things in this code that would bug many people. Multiple coils. Latch/Unlatch of an output. Should it bug them? No. But people shouldn't be bothered by loud-mouthed opinions expressed on this site, either. But some are.

Since there are other ways of doing the same thing - not better ways, not worse - then why not use them instead?

Again, it's not "dumbing down the code". It's manners. Being polite to the people who are going to follow you. When I go camping, I make sure the site is clean when I leave (while I stay, for that matter). When I code, I try to keep things clean, too.

I consider that code to be messy.

(It also tickled my funny bone, for some reason. "Funny" was too much. "Amusing" perhaps.)

But so what if PCs could do it for forever. It's only recently that PCs have been suitable for process control. Recursive PLCs have been around longer than affordable solid state hard drives and PCs who don't wilt under the conditions that PLCs routinely live under.
 
Last edited:
Terry Woods said:

Then came recursive type processors. They allow the following...

Code:
  INPUT-1
----| |------+--------------(OUT-1)
             |   INPUT-2
             +-----| |------(OUT-2)
Terry, this is NOT recursion. Recursion occurs when a subroutine or function calls itself either directly or indirectly. No decent PLC should have problems with that rung. It is very straight forward.

ld INPUT-1
st OUT-1
and INPUT-2
st OUT-2

No parantheses, temporary coils, pushes and pops are required.

Allen, I use IL on this forum:
1. To provide an alternative that is part of the IEC spec.
2. To get feedback on acceptance of IL.
3. I can write code much faster in IL than in LD. This forum does not
make it easy to write ladder. It is still a text based forum.
4. The syntax and number of reserved words is very small, therefore easy to remember. I consider IL to be the least common denominator of all the PLC programming languages.
5. LD is more limiting than IL. Where are the bitwise Exclusive ORs in ladder?

My previous post was meant show an alternative. To be a subtle dig at those that don't comment their STL or IL. To show those that complain that tags do not provide data type that it can be done. Many C programmers put the data type at the beginning of each variable or tage name. To get a subtle dig at PLC manufacturers that don't provide bit wise exclusive or contracts. I don't expect the PLC manufactures to make that change just for me.
[/B]
 
Last edited:
Ok Maybe (finally) I have an area that may make sense to others like me. This is an example of something that doesnt make sense.

Allen posted this as a jolly(fun) thing that has multiple "coils" but it has been stated that this kind of logic should be a good thing.
Code:
 PB       CHECK   LIGHT     LIGHT
---| |---+---|/|-----|/|---+---(L)
         |                 |
         |                 |  CHECK
         |                 +---( )
         |
         |  CHECK   LIGHT     LIGHT
         +---|/|-----| |---+---(U)
         |                 |
         |                 |  CHECK
         |                 +---( )
         |
         |                    CHECK
         +---------------------( )

I understand the flow chart Terry but not how the ladder applies to it I guess. I have overall no problem with the flow chart for a method to develop a plc program but still like ladder which follows relay logic in that multiple coils should NOT be possible/used.

Please dont take this wrong. I am looking for an understanding of your concepts...nothing more. Maybe tone down (jes a little) your explanations into more simplistic terms.

I know you feel/think that maintenance men should be as capable as engineers or not screw with/use the plc at all BUT I think the PLC is a good troubleshooting tool and maintenance/electricians (qualified of course but sometimes not) should be able to follow the programming along with the schematics (with the belief that they can look similar). The combination of the two (2) make it an awesome TOOL for any industrial plant.

I can relate to using things that make life simpler for you, I just paid near to $800 for a refurbished Fluke scopemeter to hopefully make my troubleshooting needs simpler. I can not relate to making life simpler for me (ie programming) over the needs of the many (ie the maintenance/operators that have to deal with the machines daily), of course I have weak moments too. Following that concept tho, isnt that the same as writing spaghetti code? Cant understand it, what good is it?

I am lazy in another way, I want the guys I work with to KNOW how to find the problem. Makes life simple for me, or should I say less physical?

FYI I am in line for an IT position. Actually I am the person that will fill the IT position when it is created. Regardless of what you think of IT it will take me away from the need to follow plc's and its technology, therefore not here. SO wish me luck in my endeavor.
 
The slickest thing I've seen is using the ACC bit of a counter to control the on/off state.

Momentary PB
I:1
----| |------------------Counter--
1 C5:0

Light
C5:0.ACC O:0
----| |------------------( )------
0 0
 
yeah, OK, that works.

Until the counter is done.

But, no problem, you'll just do a RES on the .DN.

Fine.

Quiz:

So that you don't miss a beat, should the counter preset be EVEN, or ODD? Or does it depend?
 
What a load of waffle !! I dread to think what you lot would be like with something a bit complicated rather than just a plain and simple flip-flop . You can stick it all on one line of logic .What is really concerning is that you post this rubbish and still get it wrong!! What would happen if this was a 50tonne press or something that could go bang . Before performing like little girlies and popping at each other , try to ensure that you post simple and easy solutions , that are above all correct.
 
my two cents

I would like to start by saying that I love Allen's CPT example. It will work great the next time I have numerous momentary buttons in an HMI.

I don't understand the "load of waffle" comment.

What is Easy?

I don't think that the flip-flop is easy. It is simpler for me now since I have seen so many different posts on the subject and would immediately recognize a flip flop circuit in ladder logic. If it was so easy, then why does it keep popping up as a topic?

The first time you saw a flip flop circuit in a PLC, I bet you all the money in the world, that you didn't say "Oh, that is easy", and hit the page down button. If you are like most people, you had to stare at it for a little while.

What makes something easy?
- I believe that it is recognition of something that you know.

While coil logic (ladder logic written in N.O., N.C., and coils) has its place and def. makes certain things easier to comprehend by all, it can be at some times the hardest thing in the world to understand, especially if it is not organized. For example, write a FIFO using normally open and closed contacts and coils, who would understand that?

The more things you have to consider, the more complicated it gets. i.e. Is there more than one HMI toggling the pushbutton? If I lose the HMI will the coil's logical state remain the same? If the PLC loses and regains power will I have to run around to every OIT and put all the PID loops back in Auto? Does this particular PLC automatically reset its coils to zero on power up, what if the coil is a word address and not a bit address? Does the HMI reading and writing to this address have a power on state. Can I specify that I don't want a power on state in the HMI software (ex. panel view using any other comunication protocal other than DH+ seems to write either a one or zero on power up -ugh)

The tricky part is making code easy to understand, functional, and easy to troubleshoot.

I believe that instruction list and structured text could have its place along side of ladder logic but not as a replacement. For example, double clicking on the user created function block below, would display the structured text for that function block.


HMI FLIP/FLOP
PB F_in ----------------F_out Auto/Man
-| |--------|Strucuted Text| ------ ( )
----------------


When the electrician/maintenance man viewed the ladder logic online, he could watch the coil turn on and off with the push of the button. He wouldn't have to understand the structured text language in order to troubleshoot. Black Box troubleshooting techniques of "good IN" and "good out" would apply.

Because the "user created function block" is written in text, a book of comments could be written inside the function block. For example.

// This function block toggles the state of the output
// Each "NEW" push of the pushbutton turns the output either on or off
// If the addresss of the output coil is a bit address (ex. B3/0)
then the coil will be autmatically turned off on a power up of the PLC
// If the address of the output coil is an integer bit address
(ex. N7:0/0) then the output will return to its last state on PLC power up
// Any questions please call my cell phone at



My History:
4 years as an Electrician in the Navy
1 year as an operator
1 year as a non union construction electrician
2 years as a factory electrician/maintenance man
1 year as a non degreed engineer at the same factory
6 years a a PLC Programmer/contractor for an electrical engineering firm while going to college on the GI bill.
1 year as a systems analyst (what ever that means)

-It is still difficult, and has been a struggle for me the whole way.
- I don't know everything
- I do not have an above average intelligence (of course, that defunct IQ test cd said I did; If anyone wants a self esteem booster, I'll email you the cd.
- I learn something new every day
- And yes, Rsdoran, I am over paid, hee hee
 
Originally posted by fareast

What a load of waffle !!

Waffle? I don't know that one. Is it regional to where you are, or just a way of avoiding sensorship, as in "We're in deep yogurt."


I dread to think what you lot would be like with something a bit complicated rather than just a plain and simple flip-flop .
A toggle is neither "simple" nor "complicated". Which is why it is such a classic student exercise. That's all this was - a student asking for help on his homework.


You can stick it all on one line of logic .
You could stick the entire PLC program on one line, if you want! But I don't recommend it. Or did you have a one-line solution in mind?


What is really concerning is that you post this rubbish and still get it wrong!!
I've looked back on every post, and all code posted is correct (with the possible exception of Vetteboy's, and I pointed the flaw in that one). There is no single right answer, and there are some that didn't appear in this thread, but have at others, when the topic up.
Or do you think we misinterpreted the original question. "....[M]omentary input/"maintianed on state" then the same momentary input for fot the maintained off state.... sounds like a toggle to me.

What would happen if this was a 50tonne press or something that could go bang .
If it were a type of system where safety was involved, every last one of use 'gurus' would NOT multitask an input. Period. You always want the operator to know what happens when a button is pushed. A toggle button is dangerous in that regard. It's action varies depending on the state of the system.


Before performing like little girlies and popping at each other , try to ensure that you post simple and easy solutions , that are above all correct.
Let's see, you've "popped at" us 4 times in just your one post, and posted no solution, right or wrong.

I'm wondering why you bothered.
 
I tell you why I bothered. I thought that the idea of your forums was to discuss PLC hardware and software issues and where possible share knowledge to the betterment of everyone .Instead , on reading this post and subsequent threads it seems that the primary purpose of the forums is for a couple of members of a select little club to show just how clever and superior they are and to tell each other how good they are and how many children they have (can't work out the relevence of that) .
The point I was attempting to make before you went off on a tangent was that this is supposed to be interesting and enjoyable , a way to pick up tricks and share knowledge - we all have something to learn .
I read these forums to learn , not to listen to some of the pathetic behaviour exhibited by some of your contributors - sorry , but some of these guys behave like little children.
 

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,602
Hi, i am trying to use a different method of using one pushbutton to start/stop a system. I know how to do it using two rungs and a one shot. I...
Replies
12
Views
9,195
U
how can i create a flip flop in ladder logic? It needs to be triggered by one input and has two out puts that flip flop with no time limit for...
Replies
20
Views
55,408
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,974
I found and fixed issue. B3:3 was used in MOV.
Replies
11
Views
2,625
Back
Top Bottom