02-PLC (Forms of Signal) PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

PROGRAMMABLE LOGIC CONTROLLERS

TUTORIAL – OUTCOME 2 Part 1

This work covers part of outcome 2 of the Edexcel standard module:

UNIT 21799P PROGRAMMABLE LOGIC CONTROLLERS

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.

The shaded areas are covered in this tutorial.

SYLLABUS

Investigate programmable logic controller information and communication techniques

Forms of signal: analogue (0-10 V dc, 4 - 20mA), digital, discrete

Resolution and relationships: 9-bit,10-bit,12-bit

Number systems: decimal, binary, octal, Hexadecimal, BCD

Protocols: RS232, IEE4BB, RS422, 20Ma

Networking methods and standards: master to slave, peer to peer, ISO, IEE, MAP

Logic functions: AND, OR, EXCLUSIVE OR, NAND, NOR

Outcome Assessment Criteria

Outcome 2 Describe the different forms of signal used in programmable


logic control.
Information and
communication techniques. Describe the resolution and relationship between analogue
inputs and outputs and word length.

Express numbers using different number systems.

Investigate the typical protocols used in signal


communication.

Investigate networking methods and networking standards.

Derive simple programs using logic functio ns based on relay


ladder logic.

 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

2.1 BINARY NUMBERS

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

What is the denary value of the digital pattern below?

Figure 2
SOLUTION

128 + 64 + 8 + 2 = 202

SELF ASSESSMENT EXERCISE No.1

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

The binary pattern is hence 1 1 0 0

 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.

Here is the beginning of a conversion table:

Decimal Binary Octal Hexadecimal


0 00000 0 0
1 00001 1 1
2 00010 2 2
3 00011 3 3
4 00100 4 4
5 00101 5 5
6 00110 6 6
7 00111 7 7
8 01000 10 8
9 01001 11 9
10 01010 12 A
11 01011 13 B
12 01100 14 C
13 01101 15 D
14 01110 16 E
15 01111 17 F
16 10000 20 10
· · · ·
· · · ·
· · · ·

 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.

WORKED EXAMPLE No.2

Convert :1111101 Into Octal and Hexadecimal

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.

So :1111101 = @175 (@ is the prefix indicating an Octal number)

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.

So :1111101 = &7D (& is the prefix indicating a Hexadecimal number)

Conversion from Octal and Hexadecimal to Binary is similarly easy.

 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.

WORKED EXAMPLE No.3

Convert 70 Into Octal.

SOLUTION

70 ÷ 8 = 8 Remainder 6
8÷8=1 Remainder 0
1÷8=0 Remainder 1

So 70 = @106

WORKED EXAMPLE No.4

Convert 125 into Octal

SOLUTION

125 ÷ 8 = 15 Remainder 5
15 ÷ 8 = 1 Remainder 7
1÷8=0 Remainder 1

So 125 = @175

2.5 DECIMAL TO HEX CONVERSION

This again is done by repeatedly dividing the Decimal number by 16 and reading off the remainders
in reverse order.

WORKED EXAMPLE No.5

Convert 70 into Hexadecimal

SOLUTION
70 ÷ 16 = 4 Remainder 6
4 ÷ 16 = 0 Remainder 4
So 0 = &46

 D.J.DUNN 6
WORKED EXAMPLE No.6

Convert 125 into Hexadecimal

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.

SELF ASSESSMENT EXERCISE No.2

1. Convert 45 into Hex.

2. Convert 20 into Octal

3. Convert 125 into Binary.

Note that most scientific/engineering calculators are able to do these conversions.

 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.

Each line in the bus can be on (high) or


off (low) so the system is based on
binary patterns. Older equipment had 8
lines in each bus and so Octal became
useful. Later this increased to 16 lines so
hexadecimal became useful. It has since
moved on to 32 and 64 lines.

Clearly to use larger numbers, you need


more lines in the bus.
Figure 4

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.

SELF ASSESSMENT EXERCISE No.3

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

Starting with the LSB 5 + 6 = 11 write down 1 carry 1


Next 3 +2 + carry 1 =6 write down 6 carry 0
Next 2 + 9 + carry 0 = 11 write down 1 carry 1
Next start a new column and write down carry 1

ADDING IN BINARY

The process is the same.

01101101 +
11011001
101000110

Starting the LSB, 1+1 = 10 write down 0 carry 1


Moving to bit 1 0+0 + carry = 1 write down 1 carry 0
Moving to bit 2 1+0 + carry 0 = 1 write down 1 carry 0
Moving to bit 3 1+1+ carry 0 = 10 write down 0 carry 1
Moving to bit 4 0+1+ carry 1 = 10 write down 0 carry 1
Moving to bit 5 1+0+ carry 1 = 10 write down 0 carry 1
Moving to bit 6 1+1+carry 1 = 11 write down 1 carry 1
Moving to bit 7 0+1+carry 1 = 11 Write down 1 carry 1
Moving to bit 8 which does not exist there is an implied 0 + 0 + carry 1 so write down 1. Clearly to
store this number you would need a register with more than 8 bits.

ADDING IN OCTAL

This is similar but remember that it is based on 8.

332 +
167
521

Starting with the LSB 2+7=11 write down 1 carry 1


Next 3 + 6 + carry 1=12 write down 2 carry 1
Next 3+1+ carry 1 = 5 write down 5

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

Use your calculator to do the following calculations.

Binary Octel Hexadecimal

11011 x 01101= @27 x @35= &2D5 x &3A1=

11100 + 101100= @326 + @667= &5CE + &9EF=

11000 – 01011= @642 – @341= &FF5 – &3DE=

 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.

WORKED EXAMPLE No.7

Deduce the value of the BCD pattern.

Figure 6
SOLUTION

The first 4 bits decode to 4 + 2 = 6


The second 4 bits decode to 2 + 1 = 3
The third 4 bits decode to 4 + 1 = 5

The decimal value represented is hence 536

SELF ASSESSMENT EXERCISE No.5

Deduce the value of this pattern

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.

What is the decimal value before the shift? _________________________

What is the decimal value after the shift? _________________________

Now consider the same problem with a right shift.

What is the decimal value before the shift? _________________________

What is the decimal value after the shift? _________________________

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.

Numbers stored in registers can be manipulated.

ADDING and SUBTRACTION


The contents of one register are added or subtracted to/from the contents of another and the result
placed in a third register.

MULTIPLICATION and DIVISION


The contents of one register may be multiplied or divided by the contents of another and the result
placed in a third register.

INCREMENTING AND DECREMENTING


The decimal value of the register is increased by 1 when incremented and decreased by 1 when
decremented.

 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

4. ANALOGUE TO DIGITAL and DIGITAL TO ANALOGUE CONVERSION

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.

Digital to analogue conversion is the reversed process.

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.

WORKED EXAMPLE No.8

An analogue instrument produces a variable voltage of 0 to 10 V. It is processed with an A/D


converter using 5 bits. Calculate the minimum change in voltage that can be detected.

SOLUTION

5 bits has maximum value of 1 + 2 + 4 + 8 + 16 = 31 so the smallest voltage detectable is 10/31


= 0.322V

SELF ASSESSMENT EXERCISE No.6

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

You might also like