Programming in LAD graphic language 

LAD (Ladder Diagram) is a simple programming method used to edit PLC programs. As the basic language standard principles are maintained, the application of that language should cause no problems to users who are familiar with a similar programming method. The users of NEED relay who work with it for the first time will have the possibility to get acquainted with and use that programming method which refers to „drawing” of electric circuit diagrams.

Symbols in LAD

Ladder diagram language (LAD) is based on symbols of contact and relay logics. It enables representation of contacts (input elements), two-state outputs (reflecting the relay coils) and function outputs.
Basic LAD language symbols to represent the inputs are presented in Fig. 1.


Fig. 1. Basic LAD language elements- inputs.

Functional outputs are Timers - Fig. 2. and Counters – Fig. 3. 


Fig. 2. LAD language elements – Timers.


Fig. 3. LAD language elements - Counters.

LAD language symbols to represent outputs are presented in Fig. 4.


Fig. 4. LAD language elements – outputs.

LAD language symbols to represent Markers are presented in Fig. 5.


Fig. 5. LAD language elements – Markers.

Inputs 

From the point of view of the LAD program, not only a physical contact of an electric device (discrete input) can be an input but also a state (logical level) of Timer, Counter, Clock, Marker or even output. Since those elements, during their operation, are assigned two-state values (‘0’ or ‘1’) it is possible to check them and make the output operation dependant on them.

Note: Output check consists only in acquiring program information on the state of the register which controls that physical output. That means that the efficiency of the relay and of execution system of the output are not taken into account.

Outputs

The simplest arrangement involves a two-state element such as a relay with powered or unpowered coil. In such a case the relay is active if the relay coil is powered, i.e. a specific logical state is assumed for it. Our case employs a “positive” logics which means that the state ‘1’ represents an active output while the inactive output is that of the logical state ‘0’.
Depending on the function assigned (see Table 1) an output may be set to be continuously dependent on the outputs (‘=’ instruction) which is analogous to an active relay, if the coil is powered. Functioning of both SET and RESET outputs is different as, once the conditions are met, the logical state ‘1’ is set permanently (‘S’ instruction). Such a state is maintained until a resetting operation (R) is executed which is corresponding to the functioning of a backed-up relay.
LAD outputs also do not need to have corresponding physical outputs in the relay structure, they are so-called functional outputs which enable the use of such elements as Timer, Counter, Clock, Marker. The elements are set similarly to physical outputs (they take on state ‘0’ or ‘1’) depending on functions assigned to them (see Table 1).

LAD program structure

Symbols are placed in networks. Networks are placed in a ladder in a rung-like manner. Successive networks (ladder rungs) are read one by one from the top to the bottom. After the last rung has been reached the program tracking process is started from the beginning.
The network is limited on the left and right by current rails . The right rail may be either visible in the drawing or invisible. Due to analogy to relay diagram, LAD programs can be read as the passage of current from the left vertical line to the right (e.g. left side being the power supply, right side being the ground potential) through individual networks.


Fig. 6. Sample application in LAD language

LAD network structure.

Network must have appropriate format and syntax. Below please find several main principles:

Prohibited connections

Sample prohibited connections are presented below:

Description of elements used.

The logical element (symbol – see Table 1), which performs the function of a signal input or output in the LAD language can be assigned different variables i.e. the signal input can be not only the voltage supplied to hardware inputs (designated as I1..I8) but also the state of Timer, Counter, Clock or output. The assignment is made according to the description on the element symbol. The designation digit is the number of input to be checked. Similarly, not only the physical inputs but also Markers (outputs without physical leads) and states of Timers, Counters etc. can be set. Symbols of the LAD language including description and permissible signal XY variables for the specific element (X – input, Y – output) are presented in Table 1.
Active input – an input the state of which allows signal flow (logical ‘1’ for the NO input, logical ‘0’ for the NC input)
Active output – an output the logical signal of which is ‘1’.

Table 1. Basic symbols of LAD language

LAD

Description

Variable

 

Normally open input.

Active input (contact closed), when the logical value of the variable assigned is ‘1’.

X: I, A, H, Q,M, T, C

n: number of possible inputs of a specific type

 

Normally closed input.

Active input (contact open), when the logical value of the variable assigned is ‘0’.

 

Pulse relay

Performs the function of a flip-flop triggered by the leading edge.
Each leading pulse changes the output state to opposite. (FP)

Y: Q, M
m: number of the  outputs of the specific type

 

Assigning output

Sets the value of the assigned variable to ‘1’ when the signal is applied to the output. Equivalent of an open-contact relay (copying of the input state to the output)

Y: Q, M
m: number of the  outputs of the specific type

Set output

Sets the value of the assigned variable to ‘1’ when the signal is applied to the output and maintains the state until “Reset” instruction is executed or the programmable relay is powered off (backed-up relay).

Y: Q, M
m: number of the  outputs of the specific type

Reset output

Sets the value of the assigned variable to ‘0’ when the signal is applied to the output and maintains the state until “Set” (S-STL) instruction is executed or the programmable relay power supply is cut off (output resetting).

Delayed turn-on Timer

Sets the value of Tn = ‘1’ after the preset time „N” has elapsed counted from the time of activation.

 

Delayed turn-off Timer

Maintains the value of Tn = ‘1’ for the preset time „N” after the activation signal has ceased.

 

Single pulse Timer

After activation a single pulse is generated of the duration of „N”.

 

Pulse Timer

If active, a square wave is generated (pulses) with pulse-width modulation of 50% (pulse high state duration time „N” and low state duration time „N”).

 

Counter up

Pulses are counted on activation – Counter state is increased at the input assigned to the specific Counter. After the current Counter has reached the threshold of „N” the Counter state goes to ‘1’.

 

Counter down

Pulses are counted on activation – Counter state is decreased at the input assigned to the specific Counter. After the  current Counter value has gone below the threshold of „N” the Counter state goes to ‘1’.

 

Configuration

Configuration of inputs

Each input in the program (network) must be assigned a type and a variable. The type is assigned in a graphic manner – by selecting the normally open or normally closed contact, the variable is placed above the graphic symbol. The variable which defines the input type is composed of a letter designation and a number.
The following variables are available:
I - inputs,
H - Clocks,
A – analogue comparisons,
Q – states of outputs,
M – states of Markers,
C – states of Counters,
T – states of Timers.
HC – fast meter/gauge of frequencies 0-20 kHz.
MDIR – system phase direction marker.


Fig. 7. Configuration of inputs.

Configuration of outputs

Physical outputs are presented using graphic symbols illustrated in Fig. 5.2.7.2. Expected output behaviour determines the graphic symbol to be used. Above the graphic symbol the letter Q is put which designates the output and its number.



Fig. 8. Configuration of outputs

Configuration of Markers

Markers, just like the outputs, are presented using the same graphic symbol by replacing Q with M (as illustrated in Fig. 8).
Expected Marker behaviour determines the graphic symbol to be used inside the graphic designation of the Marker. Above the graphic symbol the letter M is put which designates the Marker, and its number

 
Fig. 9. Configuration of Markers.

Configuration of Timers

Timers are presented using the same graphic symbols which are used for outputs – see Fig. 8
Expected Timer operation determines the symbol to be used inside the graphic designation of the Timer. A letter T and a Timer number are put above the graphic symbol.

 
Fig. 10. Configuration of Timers.

For measuring time for Timers, it is possible to use the values of voltages read from the I7, I8 analog inputs in the NEED-12DC-x1-08-4, NEED-24DC-x1-08-4 version or I14, I15, I16 in the NEED-12DC-x1-16-8, NEED-24DC-x1-16-8 version. 

Configuration of Counters

Counters are presented using the same graphic symbol which are used for outputs – see Fig. 8. Expected Counter operation determines the symbol to be used inside the graphic designation of the Counter. The letter C, which stands for Counter, and Counter number are placed above the graphic symbol.

 
Fig. 11. Configuration of Counters.

The voltage values read from analog inputs I7, I8 for NEED-12DC-x1-08-4, NEED-24DC-x1-08-4 or I14, I15, I16 for NEED-12DC-x1-16-8, NEED-24DC-x1-16-8, may be used for setting the Meter threshold.


The Quick Counter
The DC NEED..-x1-16-8 versions are equipped with a HC1 Counter HC1 counting pulses with a frequency of up to 20kHz. HC1 is a hardware-based Counter, counting pulses appearing on the I11 input. The CU, CD inputs, in addition to the counting function, also provide the function for activating the Quick counter.
The Quick Counter can run in the frequency mode – it counts pulses appearing at the I11 input during 1second.
The  Quick counter never overflows. The counting threshold can be set in the range of 0..65535. Performing a Reset operation of a Quick counter rests the status and number of counted pulses.
For the NEED-230AC-x1-16-8 version the HC1 Quick Counter measures the network frequency (50Hz or 60Hz), if the I11 input is active.

Fast meter may be used as an additional timer because the network frequency is known and constant. If threshold = 1000, then in the case of 50Hz the meter will switch after 100 x 20ms = 20s.

Sample configurations

Example 1: SL Timer – Pulses (Pulse generator)


Fig. 12. Sample configuration of SL Timer.

Example 2: Timer reset


Fig. 13. Sample Timer reset.

Element location rules 

Fig.  14. illustrates a very simple program network including the arrangement of elements according to the structure described above. To make the illustration clearer the examples indicate discrete inputs and outputs.


Fig. 14. LAD network

Generally the network is composed of the input part (conditional, preceding part) and the output part (executive, succeeding part). The first part determines the conditions that must be satisfied in order for the output to be activated (executive element).
Input elements can be interconnected in various ways, the number of such connections being dependent only on the legibility of the program and editing possibilities.

Note: The maximum number of NEED relay input elements placed in one line is 3 (n=3) i.e. there can be only 3 elements (contacts) in one series, with the maximum number of parallel elements being m=150. That means that 150 rows can be assigned to one network. There can be a maximum of 150 output elements (1 per horizontal line). Program limitation is the number of 150 horizontal lines (maximum of 862 bytes after compilation).


Fig. 15. Maximum number of elements in one network.

Connection types

Control system design requires a program which combines the relations between input and output signals in a suitable manner.
Basic connection types are presented below. 

Mapping the input to the output.

I1 input state will be „copied” to the Q1 output. The Q1 output will be active (Q1=’1’) if the logical state of the I1 input is ‘1’.







Negated I1 input state will be copied to the Q1 output. The Q1 output will be active (Q1=’1’) if the logical state of the I1 input is ‘0’.




Series connection
The above circuit performs the function of a logical product (AND operation). The Q2 output will be active (Q2=’1’) if both inputs (I1 and I2) are in the logical state ‘1’.



Other types of series connections are presented below

The Q2 output will be active (Q2=’1’) if the I1 input state is ‘1’ and the I2 input state is ‘0’.





Series connection of 3 elements.
The Q2 output will be active (Q2=’1’) if logical states of all inputs (I1..I3) are ‘1’.




Series connection of 3 elements.
The Q2 output will be active (Q2=’1’) if the I1 input state is ‘1’ and the states of I2 and I3 inputs are ‘0’.




Parallel connections

The circuit presented beside performs the function of a logical sum. The Q3 output will be active (Q3=’1’) if one of the inputs (I1 and I2) or both of them are in the logical state ‘1’.








Other types of parallel connections are presented below

The Q3 output will be active (Q3=’1’) if one of the inputs (I1 or I2) or both of them are in the logical state ‘0’








The circuit presented beside performs the function of a logical sum of 3 elements. The Q3 output will be active (Q3=’1’) if at least one of the inputs (I1, I2 or I3) is in the logical state ‘1’












Logical sum of 3 elements.
The Q3 output will be active (Q3=’1’) if the I1 input is active (state ‘1’) or one of the inputs (I2 or I3) or both of them are in the logical state ‘0’











Series-parallel connection

In order to present the control circuit, the basic connections described above can be combined as long as the permissible numbers of horizontal input elements (3) and vertical input elements (150) are not exceeded, according to connection rules.
If, in order to control the output, the algorithm requires a greater number of input elements to be used, then the connection ladder must be modified respectively, using Markers i.e. the tasks must be divided into smaller tasks.
Sample circuits employing combinations of series-parallel connections, including function interpretation, are presented below.

Circuit incorporating serial connection of I1 element with parallel-connected I2 and I3 elements.
The Q1 output functioning is as follows:
Q1=’1’ if I1 is active (state ‘1’) and the logical state of one of the I2 and I3 inputs (or both) is ‘1’.






Circuit incorporating serial connection of I1 element with parallel-connected I2 and I3 elements and further series-connected I4. The Q3 output functions as follows: Q3=’1’ if I1 and I4 are active (state ‘1’) and one of the I2 and I3 inputs (or both) is inactive (state ‘0’)







A circuit equivalent to that above can be presented in a different form: serial connection of I1, I4 comes first and is followed by a series connection of I2 and I3.








Symbolic names

For the NEED  relays it is possible assign symbolic names to variables. This way the program is easier to analyze and clearer.
It is possible to toggle the variable/symbolic name view. Fig. 16. shows the circuit in ordinary notation and below with symbolic names.


Fig. 16. Example of symbol use in LAD.

LAD program

The program is composed of networks. The simplest program can include only one network (program line). A program composed of 3 networks is presented below.


 Fig. 17. Sample LAD program.

Program description:
The first network, as per Fig. 17., employs inputs which are connected directly to the programmable relay. The first input (I1) is of NC type, the second (I2) of NO type which means that the Timer is turned on if I1 = ‘0’  and I2 = ‘1’.
States of T1 Timer (which is set in the network 1) and I3 input are checked in the second network (T1, I3, Q1). If the Timer is turned on (after 500ms counted from the time point when the condition of I1=’0’ and I2 =’1’has been met) and the I3 input is active (I3 = ‘1’) then the Q1 output will be at high state (powered). Once the I3 input is turned off (I3=’0’) the Q1 output will be deactivated.
Network No. 3 is used to „remember” the turn-on of the Q1 input. Once the Q1 input state goes to ‘1’ then the M1 Marker is permanently set (M1 = ‘1’).
It should be noted that the program actually ends with setting the M1 Marker, as further M1 Marker operations (e.g. resetting) are not performed.
Converted from CHM to HTML with chm2web Pro 2.7 (unicode)