02-PLC (Forms of Signal) PDF
02-PLC (Forms of Signal) PDF
02-PLC (Forms of Signal) PDF
The material is quite suitable for anyone wishing to study this interesting subject.
This tutorial requires basic mathematical skills and a reasonable knowledge of digital
electronic terminology. An industrial background will also be of great benefit to
students. Obviously, access to suitable computer software such as Pneusim Pro or
Bytronics simulation software will be a great help.
SYLLABUS
Networking methods and standards: master to slave, peer to peer, ISO, IEE, MAP
D.J.DUNN 1
1. INTRODUCTION
Programmable logic controllers are digital devices and using the same kind of internal structure as
computers. The information is processed internally in digital forms using data and address busses.
They must communicate with external devices such as other computers and programming panels.
The digital communication must conform to industrial standards. In industrial applications there are
many analogue signals and these must be converted into or from the digital form before they can be
received or sent by the PLC.
We first need to look at digital information and how it forms numbers of various forms.
2. NUMBER SYSTEMS
A number may be represented in digital form by a simple pattern. The pattern may be generated for
example with a row of lights switched on by an electric current. The pattern will also exist in the
wires connected to the light bulbs. In digital electronics the pattern exists as a voltage relative to
zero. Ideally in a typical computer, 5V is on or high and zero is off or low but to make a clear
distinction, a voltage of over 3 is regarded high and below 2 is regarded as low. The patterns were
originally developed in computers for 8 lines and then this became 16 and now it is 32. Consider a
pattern of 8 lines. We indicate on or high with a 1 and off or low with a 0. Each line carries a bit of
information as on or off and so the line is referred to as a bit.
In the denary system the digit that represents the highest value is on the left (e.g. the 3 in 32 or the 4
in 461). The digit representing the lowest value is on the right. These are called the most significant
digit and least significant digit. In binary numbers we adopt the same idea with the bit on the left
being the most significant bit (MSB) and the one on the right being the least significant bit (LSB).
Figure 1
The total pattern is called a word and the one shown is an 8 bit word. The pattern may be stored in a
register so it is also referred to as an 8 bit register. A register is a temporary store where the word
may be manipulated.
Each bit has a value of zero when off (low) or the denary value shown when on (high). The denary
value of the pattern is found by adding them all up. The maximum value for an 8 bit word is when
all the bits are high and corresponds to 255.
D.J.DUNN 2
WORKED EXAMPLE No.1
Figure 2
SOLUTION
128 + 64 + 8 + 2 = 202
Write down the decimal value represented by the following 8 bit patterns.
1 0 1 0 1 0 1 1 ________________________________
1 0 0 1 0 0 1 0 ________________________________
0 1 0 0 1 0 1 1 ________________________________
Here is a small table of binary numbers with the equivalent denary values.
BINARY
00 01 10 11 100 101 110 111 1000 1001 1010 1011 110 1101 1110 1111
DENARY
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
CONVERSION
A way of converting decimal into binary is to keep dividing the number by 2 as follows.
Convert decimal 12 into binary form.
12 ÷ 2 = 6 remainder 0
6÷2=3 remainder 0
3÷2=1 remainder 1
1÷2=0 remainder 1
D.J.DUNN 3
Another way to express the value of each bit comes about by realising that each bit is 2 raised to the
power of the bit number.
Figure 3
2.2. OCTAL and HEXADECIMAL
Octal is a numbering system based on cycles of 8. It is quite easy to convert a digital number into
octal and for this reason it is used by programmers to address memory locations and port addresses
(printer port, com port, CD driver address and so on). Early computers used words with 8 bits so
octal was convenient to use.
Hexadecimal is a numbering system based on 16 and was introduced for the same reasons as octal
when computers were developed with 16 bit registers. Hexadecimal Numbers are of far greater
importance in modern computing. One Nibble (4 bits) is represented by 1 Hex digit. One Byte is
represented by 2 Hex Digits.
In octal we have no need for the figures 9 as the cycle restarts after 7.
In hexadecimal, we need extra figures and the letters A, B, C, D, E and F are used.
D.J.DUNN 4
2.3 CONVERSION TO/FROM BINARY
Whereas Decimal seems to have no connection with Binary, from this table we can see that Octal
and Hexadecimal are linked to Binary. The first digit in Octal corresponds to the first three digits in
it's Binary equivalent, and so on. The same is true for Hexadecimal, but this time each digit
represents four Binary digits.
(It may be useful to note that 8 = 23 , and 16 = 24 ).
An advantage of knowing this is that is makes conversion to/from Binary very easy.
SOLUTION
Octal:
Split the number into groups of 3 starting from the L.S.B. on the right.
1 111 101
Now convert each group immediately into one Octal digit, i.e. 1 becomes 1, 111 becomes 7,
101 becomes 5.
Hexadecimal:
Split the number into groups of 4.
111 1101
Convert each group immediately into one Hex digit, i.e. 111 becomes 7, 1101 becomes D.
D.J.DUNN 5
2.4 DECIMAL TO OCTAL CONVERSION
This is done in a similar way to converting Decimal to Binary. Repeatedly divide the decimal
number by 8 and read off the remainders in reverse order.
SOLUTION
70 ÷ 8 = 8 Remainder 6
8÷8=1 Remainder 0
1÷8=0 Remainder 1
So 70 = @106
SOLUTION
125 ÷ 8 = 15 Remainder 5
15 ÷ 8 = 1 Remainder 7
1÷8=0 Remainder 1
So 125 = @175
This again is done by repeatedly dividing the Decimal number by 16 and reading off the remainders
in reverse order.
SOLUTION
70 ÷ 16 = 4 Remainder 6
4 ÷ 16 = 0 Remainder 4
So 0 = &46
D.J.DUNN 6
WORKED EXAMPLE No.6
SOLUTION
125 ÷ 16 = 7 Remainder D
7 ÷ 16 = 0 Remainder 7
So 125 = &7D
An application of Hexadecimal numbers is for representing bit patterns. For example the letter "A"
is represented in ASII codes as 0100 0001 or more conveniently &41. Similarly, the letter "B" is
represented as &42.
D.J.DUNN 7
2.6. APPLICATIONS
Consider the basic operation of a computer memory ship. The chip has an address bus and a data
bus. It also has a read or write command
line.
The diagram shows 8 lines in each bus. When they are all low the decimal value is 0. When they are
all high the decimal value is 255 so there are 256 different values that can be represented.
When the R/W line is set to write, the binary pattern on the data bus is transferred into a store at the
address represented by the binary pattern on the address line. This store is also called a register and
the binary pattern is contained in this register.
When the R/W line is set to read, the pattern stored in the register at the address on the address bus
is transferred to the data bus.
Write down the data value in decimal and the address in octal for the case shown.
Figure 5
D.J.DUNN 8
2.7. MANIPULATION
Numbers stored in registers may be added or subtracted to a number stored in another register. This
is done in a processing chip. The number from two memory locations is transferred into data
registers. A command to the processor makes it add them and the result is placed in a third data
register and perhaps transferred to a me mory location.
ADDING IN DECIMAL
235+
926
1161
ADDING IN BINARY
01101101 +
11011001
101000110
ADDING IN OCTAL
332 +
167
521
Adding in HEX is more difficult as you need to remember the values of ABCDEF
It is best to do it on the calcula tor. Computers do it in binary and the answers are usually expressed
in Decimal, Octal or Hex.
D.J.DUNN 9
SELF ASSESSMENT EXERCISE No.4
D.J.DUNN 10
2.8. BINARY DECIMAL CODES
BCD is yet another way of presenting digital data as a number and it is used in industrial
applications (e.g. to code or decode a digital signal from a position transducer).
The digital pattern in a register is converted into a 3 digit BCD as follows. The first 4 bits are turned
into a normal (denary) number and this number is the units. The next 4 bits are the tens and the next
4 bits are the hundreds. The units cannot exceed a total of 9. The tens cannot exceed a total of 90
and the hundreds cannot exceed a total of 900. The maximum number which can be represented is
999.
Figure 6
SOLUTION
Figure 7
Answer 695
D.J.DUNN 11
3. REGISTERS
A register is a memory location containing a digital number. The difference between a register and
any other memory location is that the bits may be manipulated under control of the programme.
Hence the bits may be shifted right or left or rotated. Depending on the programme, the new bit may
be a 1 or a 0.
SHIFTING
Consider the example below where the register is shifted right with a 1 being added.
Each bit of the register may be used to control an output so if a bit changes from 0 to 1 the output
connected to the bit is turned on. There are many uses for shifting; one of them is to produce a
counter.
ROTATING
Rotating is similar to shifting but the bit that drops off the end reappears as the new bit.
D.J.DUNN 12
COMPARISON
The contents of two registers may be compared to see if they are the same.
Other arithmetical operations may be done such as square roots and differentiation depending on the
PLC. The actual operation is much more complicated than discussed here and the result leads to
carry over or borrowing of bits. There are special flags that are switched on to indicate these things.
FLAGS are single bits in a register that are switched on to indicate the status of something. They
are not physical outputs. They can be addressed and used within a programme. PLCs often contain
flags that are automatically switched on when a certain event happens such as illustrated below.
Figure 8
Analogue to digital conversion is a process of turning an analogue voltage or current into a digital
pattern that can be read by a computer and processed.
A typical module for a PLC is shown below. There are two A/D channels and one D/A channels.
The module is connected to the PLC by a ribbon cable or plugs directly to the PLC.
Figure 9
The analogue signals are 4 to 20 mA in a modern system but 0 – 10 volts is still common and
others are possible. The appropriate signal must be connected to the appropriate terminal (V for
Volts, I for current and C common). To read an analogue signal into the PLC a routine must be
executed within the programme to read the appropriate input. The module produces the conversion
and the digital number representing the analogue signal is read into a designated register of the
PLC.
To produce an analogue output, a routine must be executed to take a digital value in a designated
register and put it out to the module where it is converted into a voltage or current.
D.J.DUNN 13
RESOLUTION
When a digital number is converted into a voltage, each increment of the binary value corresponds
with an increment in the voltage output. The value of this increment is the resolution.
Consider an 8 bit system. The minimum and maximum number that can be stored is 0 and 255 so
there are 255 steps. An analogue voltage in the range 0 to 10 V van be divided up into 254 steps so
the resolution is 10/255 = 0.0392 V. This is adequate for most purposes but if very small changes in
voltages are to be detected, a higher resolution is needed. A/D and D/A systems commonly
available use anything from 4 bits to 32 bits depending on the resolution required. For example if a
thermocouple is used to measure temperature, the voltage change for 1o C is very small and a fine
resolution is needed. Other instruments fall in this category.
SOLUTION
An analogue instrument produces a signal with a range 4 to 20 mA. It is processed with a 9 bit
A/D converter. What is the smallest current change that ca be detected.
Answer 0.0313 mA
D.J.DUNN 14