0% found this document useful (0 votes)
63 views

Programmable Logic Controller Outcome1

This document provides an introduction to programmable logic controllers (PLCs) and covers number systems used in digital electronics. It discusses binary, octal, and hexadecimal number systems. Binary numbers are represented using bits and can have different values based on whether the bit is high or low. Octal and hexadecimal are based on cycles of 8 and 16, respectively. The document provides examples of converting between decimal, binary, octal, and hexadecimal numbers. It also discusses analog to digital and digital to analog conversion as PLCs must communicate with external devices.

Uploaded by

James Habib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Programmable Logic Controller Outcome1

This document provides an introduction to programmable logic controllers (PLCs) and covers number systems used in digital electronics. It discusses binary, octal, and hexadecimal number systems. Binary numbers are represented using bits and can have different values based on whether the bit is high or low. Octal and hexadecimal are based on cycles of 8 and 16, respectively. The document provides examples of converting between decimal, binary, octal, and hexadecimal numbers. It also discusses analog to digital and digital to analog conversion as PLCs must communicate with external devices.

Uploaded by

James Habib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

UNIT 22: PROGRAMMABLE LOGIC CONTROLLERS

Unit code: A/601/1625 QCF level: 4 Credit value: 15


TUTORIAL – OUTCOME 2 Part 1
This work covers part of outcome 2 of the Edexcel standard module. 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

2 Understand PLC information and communication techniques


Forms of signal: analogue (0-10 V dc. 4-20 digital
Digital resolution and relationships: 9-bit; 10-bit 12-bit
Number systems: decimal; binary; octal; hexadecimal; Binary-Coded Decimal (BCD)
Evaluate communication standards: comparison of typical protocols used in signal communication
Evaluate networking methods and standards: master to slave; peer to peer; ISO; IEE; MAP
Logic functions: writing programmes using logic functions based on relay ladder logic (AND; OR;
EXCLUSIVE OR; NAND; NOR)

Learning outcomes Assessment criteria for pass


On successful completion of The learner can:
this unit a learner will:
L02 Understand PLC information 2.1 evaluate the different forms of signal used in programmable logic
and communication control
techniques
2.2 describe the resolution and relationship between analogue inputs
and outputs and word length
2.3 express numbers using different number systems
2.4 describe typical protocols used in signal communication and
evaluate networking methods and networking standards

CONTENTS

1. INTRODUCTION

2. NUMBER SYSTEMS
2.1 Binary Numbers
2.2. Octal and Hexadecimal
2.3 Conversion to/from Binary
2.4 Decimal to Octal Conversion
2.5 Decimal to Hex Conversion
2.6. Applications
2.7. Manipulation
2.8. Binary Decimal Codes

3. REGISTERS

4. ANALOGUE TO DIGITAL and DIGITAL TO ANALOGUE CONVERSION

 D.J.Dunn www.freestudy.co.uk 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, 32 and 64. 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. The minimum value is 0 when they are all low so there
are 256 possible values.

 D.J.Dunn www.freestudy.co.uk 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 1100 1101 1110 1111
DENARY
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

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 www.freestudy.co.uk 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 www.freestudy.co.uk 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 starting on the right.

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 www.freestudy.co.uk 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 70 = &46

 D.J.Dunn www.freestudy.co.uk 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 www.freestudy.co.uk 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 www.freestudy.co.uk 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 memory 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 = 1 1 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 calculator. Computers do it in binary and the answers are usually expressed
in Decimal, Octal or Hex.

 D.J.Dunn www.freestudy.co.uk 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 www.freestudy.co.uk 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 BCD pattern

Figure 7
Answer 695

 D.J.Dunn www.freestudy.co.uk 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 left 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 www.freestudy.co.uk 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 such as -5V to +5 V. 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 www.freestudy.co.uk 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 255 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 1 oC is very small and a fine
resolution is needed. Other instruments fall in this category. Digital Analogue Converters (DACs)
are usually on a single chip and commonly have 9, 10 or 12 bit resolution.

Figure 10
10 bit DAC chip and technical specification

10BIT DAC DUAL


Resolution (Bits): 10bit
Sampling Rate: 93kSPS
Input Channel Type: Serial
Supply Voltage Range: 2.7V to 5.5V
Digital IC Case Style: SOIC
No. of Pins: 8
Data Interface: 3 Wire, Serial
Supply Current: 1.6mA
Operating Temperature Min: -40oC
Operating Temperature Max: 85oC
SVHC: No SVHC (19-Dec-2012)
Base Number: 5617
IC Case Style: SOIC
IC Generic Number: 5617
Input Type: Serial
Linearity Error: 0.1%
Linearity Error ADC / DAC +: 0.5LSB
Linearity Error ADC / DAC -: 0.5LSB
No. of Bits: 10
No. of Channels: 2
No. of DACs: 2
Operating Temperature Range: -40oC to +85oC
Output Type: Voltage
Package / Case: SOIC
Sample Rate: 0.093MSPS
Sample Rate: 93kSPS
Settling Time: 2.5µs
Supply Voltage Max: 5.5V
Supply Voltage Min: 2.7V
Supply Voltage Range - Analogue: 2.7V to 3.3V, 4.5V to 5.5V
Supply Voltage Range - Digital: 2.7V to 3.3V, 4.5V to 5.5V
Termination Type: SMD

 D.J.Dunn www.freestudy.co.uk 14
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 www.freestudy.co.uk 15

You might also like