Ladder Logic:

Thread Starter

TheButtonThief

Joined Feb 26, 2011
237
Hi guys. I appreciate not many people are experienced with ladder vs. the text based languages but the same goes for me. I've been tasked with writing a ladder program (I'm definitely no stranger to ladder) for a programmable relay. I feel like I could bang out a programme within just a few lines if it were C++ but I'm really stuck here and would love some help.

I'm working on an electric heating system. 6 elements are used to heat a large area and are each controlled by their own thermostat (I know it sounds silly but it's actually quite complicated and this is putting it very simply). It's a domestic supply to the heating system and so I'm limited to drawing 63A at any given time. Each element draws about 25A and so I can't have more than 2 elements on at once.

I want to write a programme which will cycle through the outputs one by one, making an output (heating coil) high if the signal for the corresponding input (thermostat) is high, keep it high for 5 minutes, turn it off and then continue the cycle. So, if 3 inputs are high, the routine may look something like this:

Read I1 - I1 is high - turn on Q1 and start T1(5m) - T1 expires - turn off Q1
Read I2 - I2 is high - turn on Q2 and start T2(5m) – T2 expires - turn off Q2
Read I3 – I3 is low - do nothing
Read I4 – I4 is low - do nothing
Read I5 – I5 is high - turn on 5 and start T5(5m) – T5 expires - turn off Q5
Read I6 – I6 is low - do nothing

Rinse, wash, repeat.

I’m not asking anyone to simply supply me with the programme of course, but any advice would be appreciated. It’s the “do nothing” bit that I’m struggling with. Unlike a language like C++, ladder is not line-by-line executed and so this is messing with my mind. I’ve written about 5 different programmes that kinda-sorta work, though (in the example above) if Q2 is high and I3 goes high in the middle of Q2’s timer, Q3 will turn high regardless unless I put some sort of x-or logic in which fixes that problem but brings other problems like recursion errors.

I'm using Siemens Comfort Soft for a Logo! 8.2 and so because it's not a "proper" PLC, its pretty limiting.

I feel like I need to start from scratch with some fresh ideas >.<

Cheers
 

RobNevada

Joined Jul 29, 2019
66
You can also use the contactor's normal open (97, 98) normal closed (95,96)to control whether another unit can run at the same time. I would break all the units on separate rungs. If one and let's say two are on that would open the remaining units coil outputs on the ladder. Thermostats would be open contacts on the same rung. So to run both the thermosat and control contact would have to be closed. Air handler would then turn on.
 

peterdeco

Joined Oct 8, 2019
484
In basic your program would look something like this - assuming porta are inputs and portb are outputs. Also you could create a gosub for "if flag = 2 then start" to shorten the program.

powerup:

clear ' all variables = 0

start:

if portb = 0 then clear 'all coils are off - reset timer and flag variables

if flag > 0 then gosub heatertimer '1 or 2 coils are on

if flag = 2 then start '2 coils are on do nothing more

if porta.0 = 1 then high portb.0 : let flag = flag + 1 'flag that alerts coils are on

if flag = 2 then start '2 coils are on do nothing more

if porta.1 = 1 then high portb.1 : let flag = flag + 1

if flag = 2 then start '2 coils are on do nothing more

if porta.1 = 1 then high portb.1 : let flag = flag + 1

if flag = 2 then start '2 coils are on do nothing more

if porta.2 = 1 then high portb.2 : let flag = flag + 1

if flag = 2 then start '2 coils are on do nothing more

if porta.3 = 1 then high portb.3 : let flag = flag + 1

if flag = 2 then start '2 coils are on do nothing more

if porta.4 = 1 then high portb.4 : let flag = flag + 1

if flag = 2 then start '2 coils are on do nothing more

if porta.5 = 1 then high portb.5 : let flag = flag + 1

if flag = 2 then start '2 coils are on do nothing more

goto start

heatertimer:

pause 1000 'wait 1 second

let timer = timer+1

if timer >= 300 then let portb = 0 'after 5 minutes shut off everything

return
 
Last edited:

Marley

Joined Apr 4, 2016
502
If I remember correctly, Siemens Logo is programmed with simulated logic gates? So you need to start by thinking about the logic of your task. Limiting: Yes!
 

Thread Starter

TheButtonThief

Joined Feb 26, 2011
237
Appreciate ythe input guys but unfortunately, I'm still stuggling.

A PLC can't really be programmed with the same thought process as anything that can be programmed in a text based language like C++ or BASIC.
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
As observed there are a few methods of programming PLC type controllers, all differ slightly according to manuf.. but the traditional Ladder type display can generally be switched over to the Boolean statement type format.
As Marley observed, Smart Relay versions generally use the logic gate method.
I too find the traditional ladder format Much easier to arrive at a solution.
After a few trials, I switched to a smallest version of the manuf. version I use.
Max.
 

panic mode

Joined Oct 10, 2011
2,715
"A PLC can't really be programmed with the same thought process as anything that can be programmed in a text based language like C++ or BASIC."

i STRONGLY disagree.... LOGIC does not change just because you use different language. logic is ALWAYS the same, using physical relays, PLCs, pneumatic valves, Rube Goldberg contraptions, mechanical devices like strand beast or C++. it's not the programming language... it's how you use it... and logic is ALWAYS the same. only expression form (syntax) changes. when you study LOGIC, you learn about gates and truth tables etc. those are all CONCEPTS and do not apply to one specific technology. implementation could be in any form.

digital and mechanical wrist watch have SAME components, just use different form. (energy storage, oscillator, counter, display). there is a direct equivalent of everything in each of them.

and if you want to learn about automation and sequence control, compare that with Drum Sequencer (aka simple mechanical music box). nothing but central part of FSM.
 
Last edited:

MaxHeadRoom

Joined Jul 18, 2013
28,619
. Unlike a language like C++, ladder is not line-by-line executed and so this is messing with my mind.
Actually it does, sort of.
The typical PLC reads the condition of each logic ladder line and stores the result in a data table, once the total scan is complete, the data table updates all the 'output' conditions.
George Boole came up with the style of math that came to be known as Boolean logic, unfortunately there was no real use for it at the time, until well after his death in 1864!
The computer changed that!
Max.
 

panic mode

Joined Oct 10, 2011
2,715
yes, scan order exist and it is to be observed. it is left to right and top to bottom.
for example these two rungs may look similar but they are VERY different.
in first case Q1 is always off...
in second case Q1 is usually off but - it is on at the moment input changes from false to true (detect rising edge of input)

1582301783860.png
 

Thread Starter

TheButtonThief

Joined Feb 26, 2011
237
Ok... spent many hours on it, came up with this (attached is a PDF spat out from Siemens V8) and it works very well.

The programme sequences through 6 steps, at each step a bistable is latches in. If the condistions for that rung are met <True> (thermostat is high) then a timer starts. If the conditions are not met <False> then the bistable is un-latched (prety much instantly after it was pulled in) on the live rung and the bistable on the next rung is activated. When the timer expires, the conditions are forced from <True> to <false> (same as if the conditions weren't met in the first place.

This may be prety hard to follow and so I may upload the project file if anyone would like to load it in Comfort Soft for the Logo! V8
 

Attachments

Top