Industrial Applications
Industrial Applications
Industrial Applications
381
382 ◾ Introduction to Industrial Automation
Normal operation
Red 10 s
15 s
Green
3s
Yellow
Night operation
1s 1s
+24 V DC
RS
Normal Night
operation operation 0V
Inputs
I2.0 I2.2
PLC
Q0.0 Q0.2 Q0.4
Outputs
h1 h2 h3
+24 V DC
0V
4
3 Top view
White
PC1 PC2
Black
2
1
M1 M2 Metallic M3
plate
PC1 PC2
Side view
+24 V DC
Start PC1 PC2
0V
Inputs
I0.1 I0.3 I0.4
PLC
Q2.0 Q2.2 Q2.4 Q2.6 Q3.0
Outputs
C1 C2 C3 C4 C5
+24 V DC
0V
contains an object, and the next coming object has the same color, then the buffer M2 must be
moved to an empty position or to a position with an object of different color. The arrival of objects
is random but suppose that it is impossible to find more than four objects of the same color. The
conveyor system starts to operate after a momentary signal from the push of a START button and
stops similarly through the push of a STOP button. Write the required program for a PLC.
◾◾ With the momentary signal START, the machine produces 15 packets of 6 items (90 balls)
and waits for the next start signal.
◾◾ Each ball, coming from the corresponding feeding pipe, falls on an inclined plane only if
the solenoid SLi is energized, and is detected by the photo-switch Fi. After detection, the
solenoid is deactivated in order to block the falling of the same second ball, since the packet
must contain different balls (i = 1–12).
◾◾ Each ball falling on the plane rolls towards to point A and is detected by the photo-switch
F0. The completion of six balls is verified by the permanent activation of photo-switch F0.
◾◾ Just after six balls fall, the other balls stop falling, and after the completion of six balls, the
wrapping is started at point A. The wrapping is performed by rotating the geared motor M
by 360°, and the end of rotation is detected by the proximity switch S0.
◾◾ If during the production of 90 balls, the number of balls from the same feeding line is
greater or equal to 21, then this kind of ball is excluded from the next two sets of 90 balls in
production and is reverted normally in the following set of 90.
Twelve different
colors and designs
Wrapping machine
SL1 SL2 SL3 SL12
S0
F1 F2 F3
M F12
A Oblique plane
F0
Six-pack of balls
After making a diagram of the I/O devices connection to a PLC, the required program may be
written in Boolean or Instruction List language.
Silo
Granular material
Outlet
door
R0 + ∆R
C1
R0 Weight
C2 analog
C3 sensor
R0 – ∆R
3-Speed
DC motor
+24 V DC
Start Stop
0V
Digital Analog
inputs inputs
I0.0 I0.2 Ch.1 Ch.2
PLC
Q1.0 Q2.0 Q3.0 Q4.0 Ch.1 Ch.2
Digital Analog
outputs outputs
+24 V DC
C1 C2 C3 C4
0V
Low Normal High Outlet
speed speed speed door
Figure 10.4 Conveyor system for transferring granular material with weight control.
Industrial Applications ◾ 385
transducer measures the weight of the granular material in the indicated position. It is desired
that the conveyor belt operates at normal speed when the measured weight is equal to a pre-
defined value of 1 Kg.
The normal speed is achieved by the activation of output Q2.0 (C2). Due to irregular quantities
of the material falling from the silo, the measured weight may vary. When the measured weight is
less than 1 Kg, the conveyor speed decreases to “low” by energizing the output Q1.0 (C1), which
adds resistance to the motor coils. If the measured weight is greater than 1 Kg, the conveyor speed
increases to “high” by energizing the output Q3.0 (C3), which subtracts resistance from the motor
coils. Obviously, only one of the three outputs connecting the resistors to the motor coils must be
energized each time. The conveyor system starts to operate by momentary pressing the START
button and then the conveyor belt turns on, and the outlet door opens. By pressing the STOP but-
ton at any phase of the operation, the conveyor stops and the door closes immediately. A program
for the PLC implementation may regulate the speed of the conveyor belt automatically according
to the above specifications.
1. The outlet doors of silos open for feeding the weighing scales via the activation of the pneu-
matic cylinders C1, C2, and C3, which are extended at the rest state. Each cylinder is retracted
by the activation of the corresponding PLC output.
2. Each raw material falls on the corresponding weighing scale with a slaw rate of 100 gr/s.
The electronic weighing scales have an SPST (NO) output, which is energized at each Kg of
weight according to the graph shown in Figure 10.5b.
3. The existent raw material on each scale after weighing, falls in the conical tank vessel
via the activation of pneumatic cylinders C4, C5, and C6, which at rest state are also
extended.
4. The drum blender and the dosing pump have direct starting motors. At the bottom of the
tank vessel there is a level sensor for viscous material with an SPST output that is NO when
there is no material in the tank vessel.
5. The conveyor belt operates with a direct starting motor (M1) and brings the plastic contain-
ers to be filled at specific positions.
386 ◾ Introduction to Industrial Automation
Mince
cucumber Yogurt Mince garlic
Silos with
feedstock
C1 C2 C3
Digital
balances
Z1 C4 Z2 C5 Z3 C6
Blender
Mixture tank
Level sensor
Dosing pump Balance
SPST output
Closed
Weight
Packaging belt conveyor Open Kg
1 2 3 4
M1
F1 F2
(a) (b)
+24 V DC
Start
LS F1 F2 Z1 Z2 Z3
0V
Inputs
I0.0 I1.0 I2.0 I2.1 I7.1 I7.2 I7.3
PLC
Q1.1 Q1.2 Q1.3 Q1.4 Q1.5 Q1.6 Q3.0 Q4.1 Q4.2 Q5.0
Outputs
C1 C2 C3 C4 C5 C6 BL DP M1 H
+24 V DC
0V
(c)
Figure 10.5 Machine for production of tzatziki salad (a), digital balance output (b), I/O device
connections in PLC (c).
Operation specifications. The production procedure includes three phases: weighing the raw
materials, the feeding and mixing phase, and the packaging phase, which are performed sequen-
tially according to the following specifications:
1. The production process starts with a momentary signal START from the push of a button.
Then, the outlet doors of the silos open for feeding weighing scales until the required quan-
tity of material is completed at each scale. After the completion of a material quantity, the
corresponding outlet door closes.
2. When the three required quantities have all been completed on the weighing scales, the
cylinders C4, C5, and C6 are retracted by activation of the corresponding outputs and cause
them to fall in the tank vessel. The three cylinders remain retracted for 5 s in order to be sure
that the viscous yogurt has fallen.
3. At the end of the time interval of 5 s, the rotation of the blender starts and keeps on for
12 min.
4. After the end of the mixing procedure, the dosing pump and the conveyor belt start to oper-
ate simultaneously. The pump and the conveyor are synchronized by construction during
the overall operation.
Industrial Applications ◾ 387
5. Two photoelectric switches (with SPDT outputs) detect the presence of the plastic con-
tainer below the outlet of the dosing pump. The two photoelectric switches are necessary
due to the small gap between the two successive containers. When there is no plastic
container below the pump outlet, the pump stops and operates only the conveyor until
it brings the container below the pump outlet. Then the dosing pump starts to operate
again.
6. The applied recipe requires 80 Kg yogurt, 20 Kg minced cucumber, and 5 Kg garlic
pulp.
7. The filled containers must be counted. The applied recipe corresponds to approximately
300 filled containers. If for any reason there are fewer than 300 filled containers, then the
indication lamp H turns on.
8. After the emptying of the tank vessel, all parts of the system stop or reset and the machine
is ready for the next START signal.
It is recommended to write the required program in Boolean or IL language and use modular
programming.
LS2 +24 V DC
LAD
Start/ LS2 LS1
stop I0.2 I0.1 Q1.0
0V
Q1.0
Inputs
I0.0 I0.1 I0.2 I0.1 I0.2 Q2.0
PLC
Q1.0 Q2.0
Outputs I2.0
C1 C2
+24 V DC
LS1
0V
M C1 = Up, C2 = Down
operation. Write a program for a PLC to achieve the continuous reciprocating movement of the
worktable, and present the retentive property, either by modifying the LAD program suitably or
writing a new one.
1. During the game, balls fall from the four corners of the table and are detected by four photo
switches F1, F2, F3, and F4, while all are gravity-driven to the ball box. Of course, how many
balls are going to fall at each corner is a quite random event.
2. The table operates with a coin slot machine. In order for a coin to be accepted by the coin box,
it is necessary for button b to be pressed, and all nine balls to be present in the ball box. Also,
the solenoid SL must be energized in order for the coin to be driven to the coin box. If for
any reason the SL is not energized, the coin comes out in the coin return slot.
3. Just after the detection of a coin by the photo switch F5, the SL must be deactivated because
during the game, the slot machine does not accept other coins but returns them to the
player.
+24 V DC
Feeder On Off F1 F2 F3
PN1 PN2 0V
F1 F2 F3
Inputs
M PN1 PN2 FD
M
+24 V DC
A B C
0V
F1, F2 F3, F4 F6
H1, H2
(1)
Balls box
SL Coins box
F5
M
(1)=Coins return place
+24 V DC
b
F1 F2 F3 F4 F5 F6
0V
Inputs
SL C H1 H2
(M) +24 V DC
0V
4. With the same conditions in Step 3, two more actions must take place:
a. The motor M starts to operate, the balls are detected and counted by the photo switch
F6 and sent to the table. The motor M stops when the F6 detects nine balls.
b. The red indicating lamp H1 turns on, which means that the game is in progress.
5. When nine balls have fallen in the ball box, the red lamp turns off and the green lamp H2
turns on, which means a new game can be started.
The required program has to be written for the I/O addressing shown in the figure.
1. The automatic filling of the tanks is energized/de-energized by pressing the ON and OFF
buttons respectively. The indication lamp H0 shows the operation state.
2. Only one milk tank may be filled at a time. If the two tanks are simultaneously empty, then
the first tank fills first.
390 ◾ Introduction to Industrial Automation
V0
H0 V1 V2
On
S2 S4
Off
Tank no.1
Tank no.2
S1 S3
3. When the PLC receives an “empty” signal (S1 or S3), then the electrovalve V1 or V2 opens
immediately and the central electrovalve V0 opens after 5 s. Then, when the signal “fill” (S2
or S4) is received, the electrovalve V0 closes immediately and the electrovalve V1 or V2 closes
after 10 s.
4. All electrovalves close immediately after the press of the OFF button.
Design a diagram with the connection statuses of the I/O devices and the corresponding addresses,
and subsequently, write the required PLC program.
Repairing station
Reinsertion P123
Reject
S4
1 2 3 4 5 6
S1 P1 P2 P3 S2 P4 P5 P6 S3
Q1.5 RP Outputs
Q1.6 GR
Q1.7 RR 0V +24 VDC
= Red light = Green light G R GA RA GP RP GR RR
Light color
GA = Green Amiens
Destination place
RP Amiens (A)
Rouen (R)
GP
R
RR
G
RA GR
GA
Paris (P)
+24 V DC
PC1 PC2
M2 0V
Inputs
I1.0 I1.3
PLC
PC2 Q0.0 Q0.2 Q0.4
M1 Outputs
C1 H C2
+24 V DC
0V
PC1
+24 V DC
Start/stop Cancel
0V
Inputs
I2.0 I2.1
PLC
Q1.0 Q2.0 Q3.0
Outputs
C Preheating
wait 3 min +24 V DC
0V Resistors
Figure 10.13 I/O device connections to PLC for the application of Section 10.13.
LS1
M
H
Up and down
limit positions
b
LS2
pressing of the button b0. The indication light H0 is turned on during the cleaning procedure.
After making a diagram of the connection of the I/O devices to a PLC, write the required program
in the LAD language.
+24 V DC
b1 b2
RS
0V
Inputs
Figure 10.15 The step motor is controlled by the PLC through a driver.
Step. For each pulse applied to the step input of the driver, the motor turns one step ahead. For
a series of pulses the motor turns by an equal number of steps. The frequency of the pulse
waveform defines the rotation speed of the step motor.
Direction. A logic high signal applied to the direction input of the driver determines one direc-
tion, while a logic low signal causes the opposite direction of rotation.
Full half step. The full or half step mode of rotation is determined by a logic high or low signal
respectively.
Enable. A logic high signal applied to the enabled input of the driver enables the motor to rotate
if the previous three signals have been applied. A logic low signal disables the step motor that
cannot rotate, even if the previous three signals are applied.
The above signals can be produced from a PLC equipped with a suitable digital output mod-
ule. Write a program in Boolean language so that the following operations are achieved:
1. With the press of button b1 and the RS switch open, the motor rotates left with a full step.
2. With the press of button b2 and the RS switch open, the motor rotates right with a full step.
3. With the press of button b1 and the RS switch closed, the motor rotates left with a half step.
4. With the press of button b2 and the RS switch closed, the motor rotates right with a half step.
Step motor
Object
50 cm
write a complementary one so that the PLC accomplishes the sequence of the step motor
motions shown in Figure 10.16 and specified as follows:
◾◾ With the first pressing of b0, the platform goes down 50 cm and returns to its upper location.
◾◾ With the second pressing of b0, the platform goes down 45 cm and returns to its upper
location.
◾◾ With the third pressing of b0, the platform goes down 40 cm and returns to its upper location.
◾◾ With the tenth pressing of b0 the platform goes down 5 cm and returns to its upper location.
◾◾ With the eleventh pressing of b0 the platform, as in first pressing, goes down 50 cm and
returns to its upper location.
Suppose that the rotation of motor axis by 1° causes a linear displacement of the platform of 1 mm.
The b0 is an NO button connected to an additive input I1.0 (not shown) of the PLC, while the
outputs are as shown in Figure 10.15.
3 Suction cups
Initial position
42 cm 42 cm
Plates have thickness 2 cm
PC
Conveyor
PC
0V Up (*)
Step
motor
1
Inputs Down
I0.3
PLC
Q1.0 Q2.0 Q2.2 Q3.1 Q3.2
Outputs
Vacuum 2
Vacuum Step Direction Step Direction
Right
+24 V DC Step
Step motor driver 1 Step motor driver 2
motor
3
Left
0V
Positioning cycle
Figure 10.17 Robotic arm for pickup and placement of light objects.
the figure. Using the programs developed in the previous applications in Sections 10.15 and 10.16,
write a PLC program so that each arrived object (signal from the photocell PC) is grasped by the
robot and placed on the pallet, creating a stack of 20 objects. Particularly at each signal PC, the
diagram of the robot movements shown in the figure must be accomplished, as well as the vacuum
creation for suction cup feeding.
Indication of
H0 non-closed door
b0 Open
PS1 PS2
b1 Close
b2 Emergency
STOP
PC
M
Closing door. The door closes automatically after 30 s. The door can also close manually before
the completion time of 30 s, by momentary pressing of button b1. The indication light H0
turns on either during the door movement or by being in the open state.
Emergency actions. If during the door closes, the photocell PC is activated, the door stops
immediately, while the door continues to close if the photocell is deactivated. The move-
ment of the door, either opening or closing, is interrupted permanently by the pressing of
emergency button b2.
After making a diagram of the I/O device connections to a PLC, write the required program.
Then the machine operates and the hour meter records the time of operation. Any handling
from the other two control panels must cause no action. The machine operation stops either by
the operator by pressing the STOP button, or by a sensor detecting a critical temperature. After
defining the I/O devices and their connections to a PLC, write the required program. Examine
also, if it is possible to have the same operation with only one pair of START-STOP buttons com-
mon for the three shift works.
398 ◾ Introduction to Industrial Automation
Start-stop
buttons
Hour meter
1. The system is set ready for operation with the switch RS0-1, otherwise nothing can work.
2. Subsequently, the operator must choose the desired number of parts, which is marked on the
control panel.
3. With the condition that the number of parts has been selected, and by pressing momentary
the START button, the disk rotation begins and continues to feed the selected number of
components, and then stops.
Bucket Components Groove
+24 VDC
b1 b2 b3 Start PS
Number of components
RS0-1
0V
4 8 12 Inputs
If at any time the switch RS0-1 is opened, the system stops and all are reset.
Write the required PLC program in Boolean language.
In addition to the main programming task, tasks also include an additive digital output (not shown
in the PLC) to be activated when the desired limits are violated, and write the overall PLC program.
+24 V DC
START STOP PC
0V
Digital Analog
inputs inputs
outputs outputs
+24 V DC
SS SC SP
RS0-1
0V
Coil 1 SC ‘6’ ‘12’ ‘G’ ‘Y’
Inputs
+24 V DC
SHM Start Stop ENC
SS1–2
ENC 0V
50 cm 100 cm
Inputs
C1 C2 C3
+24 V DC
0V
M M SHM
+24 V DC
M1 M2
PS1 PS2 RS0–1 PS1 PS2
Processing
station 0V
Inputs
M1 M2
+24 V DC
0V
+24 V DC
Thickness
Start Stop transducer
F0A F0B
0V
Hot metal
Digital Analog
inputs inputs
I0.0 I0.2 Ch.1 d
PLC
Q1.0 Q2.0 Q3.0 Q4.0 Q5.0 Ch.1 Pressing B
Digital
outputs
Analog
outputs A rollers
Produced
C4, C5 metal plate
+24 V DC
C1 C2 C3 C4 C5 C1, C2, C3
0V
F-1A F0A F+1A F0B F+1B
which is stored in the word memory MW100 of the PLC. Write the required PLC program in
Boolean language that will adjust the thickness of the produced sheet (the conditions are never
optimal) in accordance with the following specifications:
1. When the measured thickness is d = 5 mm, then the nominal forces F0A and F0B are applied.
2. When 5 < d ≤ 5.1 mm, the applied force is increased in roller B.
3. When d > 5.1 mm, the applied force is increased in both rollers.
4. When d < 5 mm, the applied force is decreased in roller A, while roller B applies the nominal
force.
5. The operation starts by pressing the START button, and initially the nominal forces F0A and
F0B are applied. By pressing the STOP button, both rollers cease to operate.
M2
P
+24 V DC Air
Reset
RS0–1 PC Painting
liquid
0V 0–10 V
Digital Analog
inputs inputs
V
I0.0 I0.2 I0.4 Ch.1
PLC
Q1.0 Q2.0 Q3.0 Q4.0 Ch.1 PC
Digital Analog
outputs outputs
M1
+24 V DC
0V
M1 M2 V H
5. When 100 objects have been painted, the indicator H lights turn on and the conveyor belt
stops. The pressure inside the tank continues to be controlled. By pressing the reset button,
the conveyor belt starts again for the painting of the second 100 objects and so on.
The painting layout is controlled by a PLC, and for this operation, the overall automation should
be programmed in a preferable language.
Packing station
So1 So2 So3
b1 b2 b3
M4
S1 M0
S2 S3
M0
+24 V DC
RS0-1
Stop S1 S2 S3 S4 b1 b2 b3
0V
Inputs
0V
If any operating accident happens, then the pressing of the pushbutton emergency stop causes a
general discontinuation, regardless of the point at which the packaging process is running.
The packaging process refers to the complete execution of a packaging order including a triple
of crates from all the produced products (e.g., n1, n2, and n3), depending on each customer’s desire.
This means that after closing the switch RS0-1, the station will have to pack n1 crates with products
from M1, n2 crates with products from M2, and n3 crates with products from M3.
A PLC program for this industrial application should be parametric to n1, n2, and n3. As a first
approach to the problem however, you are prompted to write the required program that imple-
ments a specific order such as (2, 1, and 3).
+24 V DC
Start Stop PC
Level Bulk material silo
switch Run
0V
Inputs Standby
I1.0 I1.1 I2.0 I3.0
PLC
Q4.0 Q5.0 Q6.1 Q6.2 Q6.3 Full
Outputs
+24 V DC Stop
0V Knife gate valve
Start
coil
Motor
Valve
Run
barrel
Standby
Full
Level
switch
Motor
PC
the standby indicator turns off. The filling process and the conveyor belt cease to operate
if the STOP button is pressed. Then the run and standby indicators change their status of
indication.
3. When a barrel reaches the proper position, which is detected by the photocell PC, the con-
veyor belt stops. With the barrel in the correct position, and the conveyor belt stopped, the
knife gate valve is energized, and the dry bulk material falls into the barrel.
4. The knife gate valve will be disabled and the filling of the barrel will stop when the level
switch is energized. Then, the indicator full turns on and will remain lit until the filled barrel
is removed from the PC.
5. Once a barrel is filled (level sensor signal), the conveyor belt operates again in order to
remove the filled barrel and to bring the next empty barrel, and so on. The next barrel arrival
is a timely random event.
This automation problem can be further extended by adding the need for the kind of product and
filling recipe selection in the PLC program.
Injection
M1
machine
molding
FETA
+24 V DC
PS2
PS1 Start Stop
PS1 PS2
0V
FETA M1 M1 M2 V
+24 V DC
Down Up
0V
M2
Start
ON
PS1
OFF
Suction
V
Down
M1 motion
10 times
Repeat
Up
motion
ON
PS2
OFF
M2 3s
Figure 10.29 Electro-pneumatic system for pickup and lay down of plastic containers.
and vertical position of the bracket M1, and the conveyor belt M2 for deposition and removal of
container stacks. The sequence of evolved operations is as follows:
◾◾ With the bracket in horizontal position and by pressing the START button, a vacuum is
created (V=On).
◾◾ The plastic container is sucked from the injection molding machine. Following a delay of 1 s,
the bracket (M1) moves downward, and once detected by PS2, the vacuum stops (V=Off).
◾◾ Following a delay of 1 s, the bracket moves upwards.
◾◾ Once detected by the PS1 the vacuum is activated again (V=On), and the same process is
repeated 10 times.
408 ◾ Introduction to Industrial Automation
◾◾ The conveyor belt M2 operates for a time window of 3 s, removing the stack of 10 plastic
containers that has been created.
◾◾ After 3 s passes, the entire process is repeated to create the second stack of containers and
so on.
◾◾ After pressing the STOP button, at any current stage of the operation, the mechanism stops
and the bracket comes to a horizontal position.
The exact sequence of the individual actions is illustrated in detail in the diagram shown in
Figure 10.29. It is recommended that the required PLC program be written in Boolean or IL
language.
Appendix A: Arithmetic
Systems
409
410 ◾ Appendix A
Decimal number 6 0 5 3 . 6 2
1/100
1000
1/10
100
Position value
10
1
Position value as
10–1
10–2
103
102
101
100
power of 10
6000
Multiplication of 0
decimal digit and 50
position value 3
0.7
0.02
Decimal number 6053.62
Binary number 1 1 1 0 1 1 1 1
2
Position value
128
64
32
16
8
4
2
1
Position value as
power of 2 27 26 25 24 23 22 21 20
Multiplication of binary
128
64
32
16
8
4
2
1
Figure A.2 Binary system of numbers and their conversion to the decimal system.
Appendix A ◾ 411
239
119 Remainder 1
2
119 59 Remainder 1
2
59
29 Remainder 1
2
29
14 Remainder 1
2
14
7 Remainder 0
2
7
3 Remainder 1
2
3
1 Remainder 1
2
1
0 Remainder 1
2
a binary number with the lowest position value is called the “least significant bit” or LSB, while
the digit with the highest position value is called the “most significant bit” or MSB. In order to
convert a decimal number to a binary one, the procedure illustrated in Figure A.3 is followed. This
means dividing successively the decimal number by 2 and denoting the remainders 0 or 1 as digits
of the binary number.
A.3.1 Negative Numbers
The CPU of various PLCs process the analog values in a binary form only. Analog input modules
convert the analog process signal into digital form, and analog output modules convert the digital
output value into an analog signal. The representation of a digitized analog value depends on the
number of used bits (resolution), which has to include both positive and negative numbers. In the
decimal arithmetic system, negative or positive numbers are denoted with a minus or plus sign
in front of them, which means that each number has two parts: the sign that is a symbol and the
magnitude. Therefore, this method of digitized value representation is not applicable in a digital
device like the PLC.
The simplest method to represent a negative number as a binary number is to use an extra digit,
called a “sign bit”, which usually is the fifteenth bit (MSB) for a 16-bit resolution. If the sign bit is
0 (1), this means that the number is positive (negative), such as the signed binary numbers shown
in Figure A.4.
A second method for the representation of negative numbers in a digital device is to use
the complement of a binary number, and particularly the one’s complement or two’s comple-
ment. When a binary number, has the value 1 the complement is 0 and vice versa, that is called
the one’s complement. For example, the one’s complement of the binary number 0110 is 1001.
412 ◾ Appendix A
Binary Decimal
number number
Magnitude
Sign
0 1 1 1 +7
0 1 1 0 +6
0 1 0 1 +5
0 1 0 0 +4
0 0 1 1 +3
0 0 1 0 +2
0 0 0 1 +1
0 0 0 0 +0
1 0 0 1 –1
1 0 1 0 –2
1 0 1 1 –3
1 1 0 0 –4
1 1 0 1 –5
1 1 1 0 –6
1 1 1 1 –7
The magnitude of a negative number represented with regard to one’s complement is the one’s
complement of the corresponding positive number magnitude. Some examples of negative num-
bers represented in one’s complement, are shown in Figure A.5.
The two’s complement of a binary number is the sum of one’s complement plus 1, as expressed
by Equation A.1,
Figure A.5 Representation of negative numbers using the complement of a binary number
(one’s complement).
Appendix A ◾ 413
PLCs use the two’s complement to perform subtraction of two binary numbers, which means
that the subtraction is replaced by an additive operation, as clarified by Equation A.2,
The subtraction operation using the two’s complement facilitates its implementation in a PLC,
since the same digital circuit will perform both addition and subtraction.
01002 01012
In the past, computer systems had specific units for the execution of the arithmetic operations
between BCD numbers in order to overcome memory storage problems. In some PLCs today, the
BCD arithmetic system is even supported since it is compatible with the operation of some output
devices as an indication display device, or input devices as an arithmetic switch. Figure A.6 shows
an example of converting a BCD number to an equivalent decimal number.
BCD number 0 1 0 0 0 0 1 1 1 0 0 1
Position value 8 4 2 1 8 4 2 1 8 4 2 1
Position value as
power of 2 23 22 21 20 23 22 21 20 23 22 21 20
Multiplication of BCD
0 4 0 0 + 0 0 2 1 + 8 0 0 1 +
digit and position value
Octal number 2 5 7
8
Position value 64 8 1
Position value as
power of 8 82 81 80
Multiplication of octal
128
40
7
digit and position value +
power of 8. Figure A.7 shows an example of converting an octal number to an equivalent decimal
number and the three first-position values.
The conversion of a decimal number to an octal number is performed by successive divisions
of the decimal number by 8 and denoting the remainders as digits of the octal number. The first
remainder corresponds to the least-significant digit of the octal number. An example of such a
conversion procedure is the following:
Since the largest one-digit number of the octal system is 7, three binary bits are enough to repre-
sent each of the eight digits of the octal system. The conversion of an octal number to an equiva-
lent binary number is performed by replacing each octal digit by its 3-bit binary equivalent, as
shown in Figure A.8.
The octal arithmetic system is the most user-friendly, since it is harmonized to the 8-bit general
digital structure, independently of the 8-bit or 16-bit or 64-bit structure of memories and micro-
processors. The manufacturers of large industrial PLCs use the octal arithmetic system to address
words and bit locations in their memory as also digital I/O modules usually in groups of 4, 8, and
16 inputs/outputs. Therefore, is easy for a user to know an individual single bit of the memory to
which digital input or output corresponds among the various I/O modules.
Octal number 2 5 7
8
Binary
0 1 0 1 0 1 1 1 1
number 2
0 0 0 0 0 0
1 0 0 0 1 1
2 0 0 1 0 2
3 0 0 1 1 3
4 0 1 0 0 4
5 0 1 0 1 5
6 0 1 1 0 6
7 0 1 1 1 7
8 1 0 0 0 8
9 1 0 0 1 9
A 1 0 1 0 10
B 1 0 1 1 11
C 1 1 0 0 12
D 1 1 0 1 13
E 1 1 1 0 14
F 1 1 1 1 15
416 ◾ Appendix A
Hexadecimal number 1 2 3 E
16
4096
Position value
256
16
1
Position value as
power of 16 163 162 161 160
Multiplication of
4096
512
48
14
hexadecimal digit and +
position value
divisions of the decimal number by 16, and by denoting the remainders of divisions as the digits
of the hexadecimal number, as in the following example for decimal 4670:
A.6.1 Parity Checking
Arithmetic digital data, independently of the utilized arithmetic system and the way that they
are represented, do not stay static at some memory location of a digital device, but instead they
are transported from one point to another. Digital data are transferred continuously, especially in
PLCs, mainly due to the real-time control that PLCs perform (such as from a PLC to a peripheral
device, from a PLC to another PLC via a communication network, etc.). It is very likely for a single
bit of binary data to change value from 1 to 0, due to electromagnetic noise or a transitional phe-
nomenon, or any other imponderable reason. For the proper detection of a possible error during
the transmission or storage of binary data, the parity checking technique is applied which consists
of adding an extra bit, called a parity bit, in the transferred data word.
Even Parity. The parity bit is added to the transferred data is such way that the total number of
units (1) are even. For example, if the byte 01010100 is transmitted, then the parity bit 1 has
to be added and becomes 010101001.
Odd Parity. The parity bit is added to the transferred data in such a way that the total number
of units (1) are odd. For example, if the byte 01010100 is transmitted, then the parity bit 0
has to be added and becomes 010101000.
Appendix A ◾ 417
When receiving or reading the transmitted data word, the total number of units (1) are checked
if they are even or odd, and thus it is determined whether there was an error in data transmission.
When establishing a communication connection between two PLCs, the user is usually invited to
select an even or odd parity in the corresponding software environment.
A.7 ASCII Code
A digital device, such as a computer or a PLC, should have the ability to process anything, except
for numbers and letters, since this functionality is needed for enabling the programming of the
PLC with text commands (e.g., an instruction AND). As in the case of numbers being represented
based on an arithmetic system in a binary form that can be processed by a PLC, letters should
also be represented in binary format. For this purpose, the coding of the letters of the alphabet
and other symbols used to write text has been provided by the introduction of the ASCII code
(American Standard Code for Information Language). Based on the ASCII code, 7 bits were ini-
tially used to represent the various letters and symbols. Since the number of letters and symbols
surpassed the maximum 128 (27), which could cover the 7 bits, an eighth bit was added. A table
with ASCII codes is not listed here, because it is a well-known issue and they appear in many
books for someone who would like more details.
A.8 Gray Code
Gray code is a binary encoding method that does not use the position weighting of a digit like the
other arithmetic systems do. Gray code defines only the transition from one number to the next
where only one bit changes its status, and for this reason is not applicable in any types of arith-
metical operations. However, it does have some applications in analog to digital converters and in
some input/output devices as the encoders. In binary coding, two or more contiguous bits change
their status to express a decimal number incremented by one; for instance, when going from 7
to 8 (0111 to 1000) there are four bits changing their state. In Gray coding, only one bit changes
its status to express the same increment. For this reason, Gray code is ideal for use in PLCs and
computers. In principle, it is the code that shows the minimum possible error because when only
one bit changes from one state to another, the probability of error is drastically reduced. For the
same reason, the transmission speed of Gray code is comparatively higher than others such as the
BCD code. In Table A.2, Gray 4-bit codes are shown in relation to the equivalent binary codes
for comparison purpose.
In the industrial world, automation technology, robotics, and especially in PLCs, Gray code
is encountered often because the position encoders that base their operation on it may be input
devices of a digital controller or PLC simultaneously. The position encoders (rotary and linear,
absolute and incremental) have all been presented in Section 2.3.7. In general, position encoders
connected to a PLC apply a pulse in an input module, which follows Gray code, i.e., only one bit
changes at each step of a shaft rotation (rotary encoders) or linear movement of a machine carriage
(linear encoders).
This appendix will end with a brief reference to the digital representation form of the num-
bers in PLCs. Generally in computers, the numbers are represented either as fixed-point or
418 ◾ Appendix A
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1
0 0 1 1 0 0 1 0
0 0 1 0 0 0 1 1
0 1 1 0 0 1 0 0
0 1 1 1 0 1 0 1
0 1 0 1 0 1 1 0
0 1 0 0 0 1 1 1
1 1 0 0 1 0 0 0
1 1 0 1 1 0 0 1
1 1 1 1 1 0 1 0
1 1 1 0 1 0 1 1
1 0 1 0 1 1 0 0
1 0 1 1 1 1 0 1
1 0 0 1 1 1 1 0
1 0 0 0 1 1 1 1
floating-point numbers. In PLCs, both arithmetic possibilities are offered to a user. Specifically,
most medium or large PLCs support the processing of:
◾◾ Single-precision integers (16-bit numbers with a range of values from –32768 to 32767)
◾◾ Double-precision integers (32-bit numbers with a range of values from –2147438648 to
2147438647)
◾◾ Floating point real numbers of single precision (32-bit numbers with a range of values from
–3,402823E+38 to 3,402824E+38)
It should be noted that the alteration of an arithmetic operation from another one (e.g., for
single-precision integers from the corresponding double-precision integers) is performed using dif-
ferent programing instructions, such as the instructions +I and +D for this example, respectively.
In Chapter 7, instructions have not been included for all kinds of numeric representation for the
same reasons that have been explained regarding the advisability of the instructions included in
Table 2.1.
Appendix B: Analog I/O
Values Scaling
What is needed in the sequence, is to determine which voltage values correspond to the tem-
perature limits (250 °C and 300 °C) that are controlled in order not to be violated. The calculation
is based on Equation B.1, which is solved for “Input Voltage”,
419
420 ◾ Appendix B
PLC
16 16 16 4
C DO DO DO AI C C
P P P
PS U 1 2
B
Scaling 010010100110
156 kg
Load cell
Figure B.1 The scaling of an analog value is a necessary procedure to convert numeric data
into meaningful units of the corresponding physical variable.
Maximum
Scaling into physical variable value
scaled 500 °C
value
Minimum
scaled 100 °C
value
Low High
0 = 0 V DC 32767 = 10 V DC
limit limit
Minimum input value Maximum input value
Input value
Applying Equation B.4 for the two temperature limit values, it is derived that,
and
In some PLCs, system function blocks perform the required scaling operation. Otherwise,
based on the above scaling equations, one has to program either the control of the temperature or
any other simpler application as the indication of temperature in a digital panel, and then incor-
porate the required instructions to the whole PLC program of the automation.