Sign in to follow this  
Followers 0
gleblanc

Convoluted ladder logic

17 posts in this topic

So, I ran across this line of ladder logic in one of the PLC programs that we have here, and after staring at it for a while, figured out what it's supposed to do. I'm thinking of replacing it with two separate lines that are a bit more straightforward, but first I wanted to see if it was immediately obvious to folks who have seen a lot more code than I have, and if it's a "common" way to write things. So, here it is!

Share this post


Link to post
Share on other sites
Looks like a standard latching circuit to me, pretty simple. You could group all of the errors, like low pressure and the not ready bits, together but it's actually not too bad the way it's written now. At least everything is labeled so you can tell what it is!

Share this post


Link to post
Share on other sites
I tend to put all of the elements that break the seal on the top horizontal line to the right of the branch end, but there's nothing wrong with the way its written. What are the two rungs you plan to replace this with? A latch and unlatch?

Share this post


Link to post
Share on other sites
This kind of logic is normally used for starting and stopping a motor. The logic is that when pressing the start button, the output will be activated (M10), this in-turn will be used to keep the command even after releasing the start button (the second branch starting with contact M10). Pressing Stop will de-energize M10. Error signals were used to stop this "latching" action, the logic in my guess is that if there's an error feedback from the motor, the output will not be kept active as long as the proper feedback was not received.

Share this post


Link to post
Share on other sites
Yeah, a latch and an unlatch. I'm not a huge fan of having the same device as both a contact and a coil on the same line of ladder. I mean, I know it works, and how it works, but it seems far more straightforward to explicitly latch and unlatch (or set and reset, depending on whether you do relays or digital logic).

Share this post


Link to post
Share on other sites
I show the seal-in logic and the latch/unlatch to attendees at my PLC training sessions. I explain that both methods use the same amount of memory and that an observer of the machine who doesn't have access to the ladder logic will be unable to tell which method is in use. Given that, your choice of which method to use is strictly a matter of personal preference. To me, more important than the method used is that you understand whether your particular PLC brand will treat latched or sealed logic as retentive and if there is a difference in behavior between the two methods when you cycle power to the PLC.

Share this post


Link to post
Share on other sites
I'll second the comment from my distinguished colleague, Steve Bailey: here are some rather detailed threads along those lines which might help you make up your mind about whether you really want to stay with your current SEAL-IN arrangement or switch to a LATCH/UNLATCH arrangement ... http://www.plctalk.net/qanda/showthread.php?postid=70681#post70681 http://www.plctalk.net/qanda/showthread.php?p=71786&postcount=1 going a little bit further with the rung you posted ... the instructions for X2 and X0 are capable of preventing M10 from "running" at all ... AND ... those same instructions can also "drop out" the seal-in once M10 has been started ... BUT ... the instructions for M12 and M13 are ONLY capable of "dropping out" the seal-in ... specifically, those two instructions are NOT capable of preventing M10 from "running" in the event that the instruction for X1 is TRUE ... in simplest terms, it makes a difference whether you position the various instructions in the "main line" or in the "seal-in branch" ... in other words, when it comes to programming, one size does NOT fit all ... you need to carefully consider exactly how you want the machinery to operate in ALL possible conditions ... (and yes, I realize just how "tedious" that sounds) ... I hope this is helpful ... Edited by Ron Beaufort

Share this post


Link to post
Share on other sites
What if I want to be able to jog the output by holding in the start button even if the pressure isn't okay? That is a good reason to put the "Pressure OK" breaks in the seal and not the main branch. Maybe you have to jog for a few seconds in order to acheive good pressure on this machine? There's nothing necessarily wrong with that logic at all, and be very careful to maintain logical equivalence if you make changes.

Share this post


Link to post
Share on other sites
Most circuits you will encounter in a relay panel will use a wired contact from the relay to seal in the relay coil - this ladder logic resembles that. The seal in circuit is familiar to most electricians and maintenance techs as almost all commercial motors starters wire that way, and there is a lot to be said for that. Ladder logic is unfamiliar enough to Bubba and Gomer as it is, so the more they can understand the less likely you are to get a phone call at 3:00 am.

Share this post


Link to post
Share on other sites
The existing logic is getting scrapped and re-written (since the control algorithm doesn't work, the documentation is in JapanEnglish, and the logic is all spaghetti), so as long as I'm consistent across all the different instances of this code, I think I'll be alright. On this system, the pressure OK/NG indications are meaningless if the system isn't running, so having them in the latch probably makes sense. Thanks, Greg

Share this post


Link to post
Share on other sites
I think you'll find that most PLC "training" is forced to concentrate on just getting things to "work" ... all of the "what if" scenarios are seldom if ever covered ... said another way: your PLC "training" will be a never-ending process ... tip: keep a scratchpad of things that you run across and find interesting – but don't currently have time to explore ... then check each subject off your list when you finally have enough spare time to dig into the facts in detail ... finally, if you found the links I gave you earlier helpful, you might also be interested in the free "E-mail Quizzes" available on my website ... scroll down near the bottom of the "Sample Lessons" page ... no registration is ever required ... good luck with your project ...

Share this post


Link to post
Share on other sites
just be aware that there is difference between latch and seal-in: bit set by regular coil is cleared on power-up, while memory set by latches is (normally) retentive. in case of Mitsubishi this may or may not apply depending if bit is in retentive (latched) area (depends on plc). for example in FX PLCs some of the M bits are retentive and some are not. on bigger PLCs. retentive area is called L. you probably don't want machine to start on it's own after power comes on (after brownout/blackout or just because someone turned power on after weekend for example).

Share this post


Link to post
Share on other sites
Greg you said something that caught me as odd. Spaghetti code. BE CAREFULL. I am not trying to insult your knowledge. Just offering my half a cent worth of knowledge. Not long after some junk PLC training I was ready to change logic on a "Spaghetti code" system. Looking back now I just about follow that style of HMI interfacing, recipes, calling recipes, etc. It was well thought out. Another system I followed up on was "Kludge code" is was all over the place double coils here and there. "Rat race logic" as I like to call it. I spent weeks working bugs out of the logic after I started changing things because I thought I was righting good solid code. The operators didn't like the logic changes because they had to change the way they do work. Look up "learning to program great" both here and PLCs.net read them 2 or 3 times.

Share this post


Link to post
Share on other sites
Something like Just because the IT Dept placed all the previous PLC Guru's stuff on a drive named "JUNK" don't assume it's trash, eh Jeff?
1 person likes this

Share this post


Link to post
Share on other sites
Yea I found several of your spreadsheets on the 7.5 south that had conduit layouts. used them over and over when the Radyne went down because of stop button on a lift conver was hit. I still have nightmares about that shop. You?

Share this post


Link to post
Share on other sites
I've read before (and just read again) that thread here. Haven't found it on PLCs.net yet, though. Thanks, it's always a good read. Greg P.S. I hope that my writing isn't completely incomprehensible. Been at work too long already, and my brain has gone a bit soft by this time in the evening.

Share this post


Link to post
Share on other sites
Seal in is fine, set, reset require special attention and an understanding of how they work, including how they work in different plcs You would be wise to read rons post more than once and have a play See if you can get on one of his courses, it will pay dividends.....

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0