Ladder Logic

Status
Not open for further replies.
Nice article, well done.

Here is the feedback>
First a few typos:


Should be
Before we go any further, let me just explain a relay (just in case) - A relay is an electromechanical switch. It has a set of contacts, light your typical household light switch, PLUS a solenoid-type mechanism that operates the switch. So your house lights are switched by your hand, and a relay is switched by sending current through it's coil. There are a zillion types of relays, but this tutorial focuses mainly on the general purpose type, which have one coil, and at least one set of contacts (common, normally open, normally closed).

Then a bit later on you say:
The problem here is highlighted in bold.
Connecting to 0v will not do anything for the back EMF from a coil, what is needed is a diode to dissipate the back EMF. Exactly as you have explained towards the end of the article.
Can I suggest that you remove or rewrite the text which I have highlighted.

Apart from that, a very good article.

JimB
 
Hi strantor, very much enjoyed it and a very nice job. Funny how many of us see ladder logic every day and never really give it much thought. Very good job of presenting it in an easy to read and understand fashion with good examples.

Ron
 
really good job, it presents important basics. you can add further examples on how to wire some functions.
 
Ladder logic is often looked at by electronics technicians as stupid stuff. I was one of those, and the main problem is trying to equate it to television and oscilloscope schematics. But that's apples and oranges. Once I got into teaching industrial motor controls, ladder logic was absolutely wonderful stuff for me and I'm a champion of it. It's hard to find good texts on the subject, so anything to help deliver the concepts is welcome.
 
nice post,


PLCs are usually programmed in ladder (most still only support ladder) but there are variety of other languages as well, particularly on newer products. ladder is very good for what it does because it allows visualising logic. this is particularly useful at run time (online monitoring) when one look at piece of code tells what is missing to energize an output, without even reading labels or comments on contacts or coils. this is where ladder is excellent. parts where ladder logic code is messy is computation. anyone who tried to do FOR-NEXT loop in a ladder, or calculating complex expression will know how clunky and unreadable this becomes.

back to the blog feedback:
A relay is an electromechanical switch. It has a set of contacts, light your typical household light switch
i am pretty sure you meant "like your typical..."


this is incorrect because placement of contacts before or after coil has no effect on arcing - it is simply series circuit and order of components makes no difference. arcing is present any time current to load is interrupted. this is just more obvious with inductive loads when they don't have suppressor.

real reason to not use switching contacts after load (at 0V or neutral) is fail safe operation. healthy circuit will work as intended regardless if switching device is before or after load (as mentioned, this is just series circuit). the problem is when things go wrong - and they do go wrong more often than people imagine, specially in harsh environments (industrial, automotove etc.).

the most common example of things going wrong is unwanted short to ground. ground is practically everywhere, enclosures, conduits etc are grounded (there are reasons for this but this not important at the moment). as insulation becomes compromised, those accidental shorts to grounds are increasingly more likely. for example insulation breakdown due ageing is common in old material, also occurs for wiring exposed to certain environments (oil, moving or flexible cabling, welding sparks, metal chips and shavings, mechanical vibrations etc.). anyway, the point is that if we do get accidental short to ground, any switch that is after load (low voltage side) will be bypassed. this results in unwanted or uncontrolled operation and can be very dangerous. if the same happens to wires that are on high side (before load), then same situation will cause short circuit (which in this case is good and desirable) and trip overcurrent device. as a result we get circuit that is no longer powered. this is exactly what we want from faulty circuit - to turn itself off. replacing fuse or resetting circuit breaker will cause the same result - it will trip again until faulty wiring is repaired.

but if the circuit was not grounded, the failure would not cause trip. in fact that would potentially energize parts of circuit that was not intended to carry electrical current (conduits, machine framework etc.) which is not just electrical hazard (if circuit is higher voltage such as AC for example) but it would allow fault to remain undetected (and allow faults to accumulate, leading to even more dangerous situations).

this is one reason why low voltage circuits and secondary of transformers is usually grounded. it is not that 24VDC is life threatening by itself, it is that signals carried by the circuit represent. it could mean command that involves motion of large peace of equipment (start conveyor, hydraulic lift or whatever) and that is dangerous.

for example in electronics projects it is very common to wire inputs to ground, while outputs are usually sinking (I am sure all of you have seen something that looks like attached circuit).

this is fine for low energy devices (like many circuits on this board) or self-contained devices. it is also used all the time in domestic appliances (TVs, printers etc.) where low cost is driving factor (and they are self-contained, aside from power cord and signal cable nothing comes out).

but this is a big no-no for industrial wiring where energy levels and risks are much higher and circuits are rarely contained (and the longer wire or cable is, the more chance that something can affect or damage it). for example that rookie forklift driver pushing skids against the equipment, not noticing that they are pinching the cables or conduits (btw, anyone watched the german forklift safety video?)

suppose that outputs in shown circuit are used to drive valves to press or lift or whatever. suppose there is a short to ground at input a for example. the equipment would move, because this looks like valid control signal (note that is is just low energy circuit with some inputs). this motion could have hurt or kill someone as circuit didn't recognise that there was a problem. perhaps someone saw it happen, and quickly pressed stop. perhaps the logic in the controller was written in such a way to give priority to stop signal and our victim was saved. but what is same happened to any other part of circuit, for example at output (f or g). then equipment would keep on moving and no action by user (such as pressing stop) would have saved the victim.

critics would argue that circuits should be isolated because sharing common ground is avenue for noise and if this circuit was not grounded, our victim would survive. noise is a problem and need to be dealth with using proper techniques that do not compromise safety. also isolating circuit from ground, would have (maybe) prevent unwanted function of equipment in case of one failure as mentioned above. the problem is that such isolated failure would remain unnoticed. there would be nothing to stop another (and another) same or similar failure to happen later. eventually we have the same problem. and failures tend to occur more frequently as equipment gets older so something that was working without issue for ten years, can have several problems within a year. so avoiding only single failure is not going to help - worse, it only builds confidence (and then hits even harder because nobody expected anything).

part of solution is to ground circuit. another part is to carefully choose which parts of circuits are sourcing and which sinking. in western world, it is common that common of inputs is tied to positive rail and common of outputs is tied to negative and negative side is grounded. then described failure results in blowing fuse or tripping breaker and the poor employe gets to see another day.

problem is when people design circuits and don't understand consequences, for example when they pick lower cost hardware (cost saving is good) or what customer wanted (for example to keep stock of common spare parts) but never consider all aspects of change, or when they do not use properly sized circuit protection. many simply pat themselves on the back with a big smile "of course i could make that work", without realising this is different cup of tea and that they are way out of their little sandbox and comfort zone. using NPN is just fine as long as one uses it correctly. not many on this side of the planet are not used to it and don't think much about it. there can be a world of difference between two seemingly same products - all depending on who was the designer in charge. problem is also when circuit is designed ok, but it is not implemented that way and nobody checks it (it works, lets ship it to the customer).

as mentioned, not everyone uses same polarity I/O. western countries (Europe, America) standardize on sourcing I/O (by many refered to as "PNP output"), Japan is the opposite - unless you pick Japanese hardware that is "world" edition (term used by Mitsubishi for example). Many factoris here are also using Japanese devices or at least sinking or "NPN" I/O (Honda, Toyota etc.) so just be aware. It is not just PLC I/O, many sensors are made in Japan and hence with 'NPN' outputs. It is not un-common that there are multiple power supplies, and even in same panel one has positive rail grounded, and the one next to it has negative grounded. one with positive terminal grounded is used for control circuits where sink I/O (NPN output) is used. PSU with negative terminal grounded is used for safety circuits and or circuits with PNP I/O. Not grounded (isolated) circuits exist as well but are less common (usually dedicated circuits). Also if you are dealing with PLCs, be careful with terminology, "sink" and "source" may mean opposite polarity because manufacturers don't use same conventions (it depends if they refer to circuit inside the I/O card or external circuitry that connects to it).

so it looks like we may have covered why not to place switching devices near zero potential. yet as surprising as it may be, it is used in certain cases - for example some overload relays (NEMA) use normally closed contact that is on 'low' side of the contactor coil. European overloads (IEC) expose both terminals of the NC contact on overload relays. therefore one can choose where to wire it (before or after contactor coil). careful here, NEMA style overloads only expose one terminal and the other is short non-replaceable wire that can only reach to contactor coil (cannot reach back panel of the enclosure for example).

i mentioned "perhaps the logic in the controller was written in such a way to give priority to stop signal...". this is not just programming issue, it applies to hardwired circuits as well. your circuits with relay and white lamp is actually nice example of convenient "efficient" wiring diagram for start/stop logic where relay terminals are close (CR1 terminals 3 and 6 are on same circuit). the problem with this configuration is that it fails the priority of input signals. if one was to press both start and stop simultaneously - circut would run. same would happen if PB1 fails (for example stuck button would mean that it is impossible to stop the machine or process) - a dangerous design. second attachment shows better circuit where stop button is in series with the rest of the circuit. top side is traditional design, bottom one is the same thing but relay contact and coil are closer to each other.

about suppressors:
there are different ones and selection depends on type of circuit and operating voltage.

most control circuits nowdays are 24VDC and most used suppressor is diode. advantage is low cost, small size, it can be used with different voltages and normally there is no particular sizing involved - you cannot go "too big" (diodes with large breakdown voltages are commonly available and current rating is not as critical as device operation is not continuous). in most cases the 1N400x is commonly used, specially on 24VDC. disadvantage of diode is that polarity matters, it cannot be used in ac circuits and it slows switch off time of load (relay, contactor, solenoid, valve).

next popular suppressor is MOV. it can be used in both AC and DC circuits and polarity does not matter but it has to be selected according to circuit voltage.

then there is RC circuit. commonly used in AC circuits so polarity does not matter.

there is also zener and back to back zener but they are not common.

also important thing is where to install suppressor. just because it is in parallel with load is not good enough - it has to be as close as possible to the inductive load (directly across load terminals).


i've been designing and programming machines for years so i felt it would be helpful to offer some insight and "why" rather than "just do it this way", because this board mainly deals with electronics. there is a distinction between what is common in electronics and what is acceptable in industrial automation. unfortunately some people who do automation (sometimes for many years) never learn the difference. btw. this reply was only dealing with control circuits. one should really write an article on safety circuits as this is one part where i see many mistakes (specially with redundancy and monitoring).

hmm, sorry for lengthy reply and if this drifted to other topics... hope it was not boring. any comments are welcome.
 
Last edited:
Wow Panic mode, awesome reply. Thank you so much; You've taught me a few points here. What you said about unintentional grounding & low side switches makes total sense and I appreciate the correction. I've noticed the NEMA OL contacts on the low side before and wondered about it, but forgot to mention it in the article - BTW is there a reason for it? May I copy & paste your words (cited, of course) into my article?
 
you can use it any way you like, just don't copy any typos or spelling mistakes, i've been fixing this 3-4 times already ;-)

reason for NEMA overload NC wiring is simpler wiring for reversing contactors. "reversing contactors" is pair of ganged contactors with one common overload. when first contactor is on, motor runs one way. when you turn it off and turn on the second one, motor runs the other way (reverse). since the PLC cards usually have bunch of outputs that are grouped together (commons of 8 or 16 outputs), it is not good to place OL before common of the outputs because tripped overload would kill all outputs in that group. someone eventually decided that it is simpler to kill low side of both contactors and thus not affect the remaining plc outputs. one alternative would be to make OLs with more than one NC contact but for whatever reason this didn't sit well with someone and they came up with special little wire that is short enough and can't reach anything but contactor it is mounted on.
NC is meant to kill contactors when OL trips, NO contact is meant for indication (turn on some lamp or PLC input).

here is the link to that forklift video:
https://www.youtube.com/watch?v=Tqd4aPs5WTA

my favourite part is when the guy snaps the blade of the box opener that fell on his head
(brings childhood memory of similar accident which fortunately ended well, whew...)
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…