Session 3 – Analogue sensors and output devices

Tutor name......

Course......

Student name......

Session3 complete (signed by tutor)...... date......

Analogue Sensors

As we have seen with digital sensors they produce a logic 1 (+24V) or a logic 0 (0V)

However there are times when the PLC needs to know an exact value of whatever it is measuring.

What is the exact temperature?

What is the exact pressure?

What is the exact level?

With an analogue sensor the PLC receives a signal that can be anything between a maximum and a minimum value.

Because the PLC is a microprocessor based system the signal needs to be in the form of a binary code.

So what do we need in order for the PLC to receive the correct binary value?

Voltage Binary code

  • The sensing element needs some interface circuitry to produce a voltage proportional to the variable being measured.
  • The Analogue to Digital Converter (ADC) converts the voltage at its input into binary code.

Example

The sensor measures temperature.

The interface circuit produces a voltage of 0V at 00C, 0.5V at 500C and 1V at 1000C etc

  • The analogue to digital converter (ADC) converts the voltage at its input into a binary code at its output.
  • This then goes into the PLC and is stored in RAM for use by the ladder logic program.
  • In this way the PLC knows exactly what the temperature is as a binary code.
  • The accuracy the temperature can be measured to depends upon the number of bits in the binary code. Most PLC’s have ADC’s that produce a 12 bit code.
  • The ADC comes as a module that is connected to the PLC via a ribbon cable (for modular systems). The ADC is continually converting the sensor signal so that the PLC always knows what the sensor is doing.

A few examples of analogue sensors

Temperature - RTD (resistor temperature dependant), Thermocouple, Thermister, Integrated circuit type.

RTD Thermocouple Thermister IC

Force, stress, pressure – strain gauge

Speed, velocity – tachogenerator

Signal sampling using an ADC

The job of the ADC is to convert the analogue voltage value, Ain, into a binary code that the PLC can understand.

It is not necessary for you to know how the PLC functions internally but it may be beneficialthat you know how it is driven, its performance and what type to use for specific applications.

SOC or CC

RD

Ain

EOCDn

Ain = Analogue input signal being sampled

SOC or CC = Start Of Conversion – This tells the ADC to start a conversion( 0-1-0 pulse)

(CC = Convert Command)

EOC = End of conversion – Tells the PLC the conversion is complete

RD = Read – Allows the binary conversion data to be read by the PLC

D0 to Dn = data lines – The binary value of the conversion will be put on these lines when the read line tells the ADC to do so.

The ADC comes as a module or is embedded in a unitary PLC. All the connections between the various lines of the ADC and the PLC are done for you if it part of the unitary PLC. If its modular the module will look after itself and do the conversions. In addition the PLC will send and receive the correct signals and provide the conversion value for you in a data register within the PLC RAM memory.

Sequence of events

  1. The PLC sends a signal to the SOC line to tell the ADC to start a conversion.
  1. The PLC monitors the EOC line which tells it when the conversion has been completed.
  1. When the conversion has been completed the PLC sends a signal to the ADC to tell it to put the binary conversion value onto the data lines D0 to Dn.
  1. The PLC then stores the binary value in RAM.

Conversion time – The ADC is a complex circuit which takes time to do a conversion. The time it takes depends upon the ADC used. The times vary from 10’s of microseconds to sub micro-second for high speed applications. The speed of conversion can be set by the PLC or you just set it for the fastest time.

A typical value for a reasonably fast ADC is about 10µS.

We will look again at speed of conversion later as it has a profound implication on signal sampling.

Resolution or quantization error

When an ADC is sampling a voltage signal the accuracy it measures a signal to dependson two things.

  1. Number of bits the ADC converts to.
  1. Sampling rate

So let’s look at the first item the number of bits.

Let’s say we have a 3-bit ADC. The voltage range each binary code recognises is shown below.

D2 D1 D0 / Voltage range (V)
0 0 0 / -0.5 to +0.5
0 0 1 / 0.5 to 1.5
0 1 0 / 1.5 to 2.5
0 1 1 / 2.5 to 3.5
1 0 0 / 3.5 to 4.5
1 0 1 / 4.5 to 5.5
1 1 0 / 5.5 to 6.5
1 1 1 / 6.5 to 7.5

So the resolution the ADC can measure to is +0.5V or 1V.

Or

we have a total voltage range of -0.5V to 7.5V = 8V

Divide this by the 8 binary levels and we get 8V/8 = 1V

Below shows the relationship between the voltage levels to be sampled and the corresponding binary conversion values.

Voltage

Ok, so the question is how do we measure more accurately over the voltage range to say +0.25V or 0.5V?

Just add another bit. So our table now looks like this. Complete the table.

D3 D2 D1 D0 / Voltage range (V)
0 0 0 0 / -0.25 to +0.25
0 0 0 1 / 0.25 to 0.75

Every time we add a bit the resolution is doubled

Ok, so why is it important to know the resolution of the ADC when measuring a signal?

Well it’s a bit like trying to use a rule which is marked in millimeters.

If we need to measure something to within a cm then it is more than adequate.

If we need to measure something to within a millimeter then it is just adequate.

If we want to measure to 0.1 millimeters then it is not fit for purpose.

So, let’s look at measuring a signal value.

We want to sample the signal at time t1 and t2. As you can see from the diagram below the voltage does a little dip at this point.

V

Voltage at sample time t1 = just below 4.0V

Voltage at sample time t2 = just above 3.5 V

Voltage difference less than 0.5V

t1 t2 t

If we use a 3 bit converter then:

The reading would be the same in both cases, at 100B, (or binary 4 - 3.5V to 4.5V) and the ADC does not see the dip. (See your table for the 3-bit converter)

If we use a 4 bit converter then:

This would give a reading of:

1000B or binary 8 for t1

0111B or binary 7 for t2

The ADC sees the dip.

To be safe it’s better to use a converter with a much better resolution. At least 8 bit.

Examples of ADC resolution

An 8-bit ADC able to measure a maximum voltage of 10V has a resolution

= =

A 10-bit ADC able to measure a maximum voltage of 10V has a resolution

= =

A 12-bit ADC able to measure a maximum voltage of 10V has a resolution

= =

A 14-bit ADC able to measure a maximum voltage of 10V has a resolution

= =

As can be seen by increasing the number of bits of the ADC, the resolution is improved by a factor of 2 every time a bit is added or reduced.

So let’s look at a design problem

Example 1 - A voltage sensor gives out a voltage of 0v at 00C and 2.5V at 1000C. Select a suitable ADC that will measure the voltage to an accuracy of 0.10C. Assume the ADC voltage range is 2.5V.

First – find the resolution needed in terms of voltage.

So the voltage for every 0.10C rise in temp = 2.5V = 2.5mV 1000

Second – Find the number of bits the ADC requires.

Using Resolution = Voltage range

2n

Rearrange for n = lg(voltage range/res)

lg(2)

n = lg(2.5/2.5x10-3)

lg(2)

n= 9.97

So we can use a 10 bit ADC but better to use a 12 bit ADC as it would give more accuracy.

Example 2 – A 14 bit ADC is used to measure a 3.75V signal. If the ADC can measure a maximum voltage of 5V what is the binary code the PLC will receive from the ADC.

Decimal code = 3.75 x (214– 1) = 12287D

5

Convert to binary = 10111111111111B or 2FFFH

You should be able to do the decimal to binary conversion – see work done already on this topic.

Conversion time/sampling rate and the Nyquist criteria

Getting the sampling rate correct is of the utmost importance to getting a correct digital representation of a signal.

The faster the signal is changing (higher frequency) the more important it is.

So let’s look at some examples below

In this instance the sampling rate is high so the digital representation is good.

In this instance the sampling rate is less frequent so the digital representation is poorer.

In this instance the sampling rate is low so the digital representation is poor.

From the above it can be seen that if the sampling rate is not high enough then some of the detail of the signal will not be “seen” by the ADC. This usually means not seeing subtle fluctuations. If it is important to see such fluctuations then the sampling rate must be increased.

Nyquist criteria.

This is a very simple rule. It states that:-

The sampling frequency must be a minimum of twice the highest signal frequency that is to be sampled.

Example – a signal of frequency 10KHz is to be sampled. What is the minimum sampling rate to satisfy the Nyquist criteria?

= 2 x 10KHz = 20KHz

To calculate the time period between samples = 1 = 1 = 50µS

Sampling frequency 20 x 103

Aliasing

The meaning of aliasing is when someone or something is one thing but is manifesting itself as something different. This has profound implication for signal sampling.

It is usually a problem of having too low a sampling frequency or high frequency elements in the signal not being removed in the first place by filtering.

As can be seen from the above – a high frequency sine wave is being sampled by an ADC at a low frequency.

The sampling frequency is such that the ADC hits upon a set of sampled voltages that generate a much lower frequency sine wave.

The ADC thinks it is looking at a much lower frequency signal.

So what are the implications?

Example – a speed sensor generates a signal frequency proportional to speed. As the speed increases so does the frequency. This signal is used to control the speed of the motor. The ADC monitors the signal and at low to medium speed gets a reasonable representation. However at very high speed the sampling rate is too low. An alias signal is generated whereby the PLC via the ADC thinks the speed has suddenly dropped. It therefore increases the speed of the motor when in reality it needs do no such thing. Control has been lost!!!!

  • ADC performance is dictated primarily by the number of bits (resolution) and the sampling rate.
  • High speed video flash ADC’s can sample at sub micro second rates.
  • A good successive approximation ADC has a minimum sample time of around 10µS.
  • All ADC’s will have accuracy and resolution performance data available from the manufacturers.
  • The range of voltages that an ADC can sample is pre-settable.

Practicalities of connecting sensors to a real PLC

Passive and activesensors sourcing

PLC sinking

This is the most common set up.

You must make sure that the active sensor you buy is the correct type for the PLC in sinking mode.

It will be labelled as having a PNP output.

Passive and active sensors sinking

PLC sourcing

Note- the active sensor will be labelled NPN when purchasing.

Note- The above PLC cannot be set up to be sourcing and sinking at the same time. You have to choose one or the other.

Industry standard is to have the PLC sinking the sensors sourcing.

Actuators (or output devices)

Sensors tell the PLC what is happening in a system.

Actuators are the devices the PLC uses to control the system and change the way it performs.

Examples

  • If the PLC wants to divert a box on a conveyor belt it can use a:-

Hydraulic ram (high power/force)

Pneumatic ram (high power/force)

Solenoid (low power/force)

  • If the PLC wants to make a conveyor belt move it can use an :-

Electric motor (AC or DC)

  • If the PLC wants to heat a liquid it can use an:-

Electrical heating element

Gas Burner

  • If the PLC wants to move a volume of liquid it can use:-

Electrical pump

Hydraulic pump

Again, just like sensors we can control actuators:-

  • Digitally (on-off)
  • Analogue which is continuously variable between two limits (off and fully on)

Digital control

So let’s say we want to turn a motor on.

Let’s assume the motor voltage is +24V

There are two ways to connect the motor to the PLC.

  • Sourcing
  • Sinking

Ok, so the next thing you have to take into account is whether the PLC has:-

  • Relay outputs
  • Transistor outputs

The PLC model number tells you usually. For Mitsubishi its:-

FX0 MR20FX0 MT20

R means relay with 20 T means transistor with 20

inputs and outputs inputs and outputs

Outputs are given the designation Y0, Y1, Y2……..etc

Each relay output needs a common designated Com0, Com1, …..etc

Each transistor output needs a common designated +V0, +V1, …..etc

For the relay output the maximum current for each output is 2A

For the transistor output the maximum currentfor each output is 0.5A

Relay Sourcing model Relay Sinking model

0V

24V

0V 24V

Sourcing-When the PLC closes the relay connection between the COM0 and Y0, current will flow from +24V through the PLC relay, through the motor to 0V.

Sinking-When the PLC closes the relay connection between the COM0 and Y0, current will flow from +24V through the motor, through the PLC relay to 0V.

Opto-isolators

An opto-isolator is a device that allows the transmission of data via a light signal. As the signal is light there is no electrical connection between the input and the output of the opto-isolator.

This allows the delicate low current and voltage of the PLC internal circuitry to be protected against much higher current and voltages of the system outside of the PLC.

There are opto-isolators on both the inputs and outputs of the PLC.

Inputoutput

With the op-isolator connected this is what the sourcing output looks like as far as connections are concerned.

PLC Microprocessor 24V

output port Relay

COM0

Y0

0V

The sinking version has exactly the same opto-isolator connections.

The transistor version is similar but not in the scope of this module.

As you can see the output due to the opto-isolator has nothing to do with the internal electronics of the PLC so this gives great flexibility when connecting actuators up to different voltages they require.

Below shows a Mitsubishi PLC with loads connected in sourcing mode for +24V, +100V and 230v AC.

Very important – COM 2 is the common for Y2, Y3, Y4, Y5. Whatever you connect to all these outputs must all operate at the same voltage. Also the total current must not exceed 2A through COM2.

The beauty of the system is that different voltages in terms of AC and DC and voltage quantities can be accommodated using the same PLC.

Ok, so what happens if the actuator takes more than 2A which is the maximum the PLC relay contacts can handle?

The answer is to use an external relaythat can handle the larger current to switch in the load,

The example below shows a 10A, 230V AC motor being driven by Y0.

Analogue Actuators

So far we have looked at actuators in a simple digital way. They are either on or off.

However we need something in order to have control of the actuator between ON and OFF.

Example

A motor can run at anywhere between 0 RPM and 100 RPM

To run at 100 RPM it requires a voltage of 10V.

To run at 50 RPM it requires a voltage of 5V.

And so on…..

The problem is the PLC works in a binary numbering system.

So what we need is some electronics to convert binary code into a proportional voltage.

It’s the reverse of the ADC!

Binary code Voltage

The power amplifier is used to boost the current and if necessary the voltage if it’s not +24VDC (maybe even AC).

Session-3 knowledge check – Analogue sensors and output dervices

1)What is the difference between a digital sensor and an analogue sensor?

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

2)What is needed to allow a PLC to read an analogue sensor value? Draw a block diagram.

3)An Analogue to Digital Converter (ADC) is used to sample a signal. The binary code is 4 bit. It is decided that the ADC is not accurate enough. The accuracy needed needs to be 8 times better. How many bits must the ADC binary code have to be this accurate? Justify your answer.

……………………………………………………………………………………………..

……………………………………………………………………………………………..

4)When using an ADC to accurately sample a signal, one of the parameters that has to be taken into account is the number of bits the ADC has in it binary code. What is the other?

……………………………………………………………………………………………..

……………………………………………………………………………………………..

5)A temperature sensor is connected to a 12-bit ADC module. The sensor has a range of 00C to 1000C. At 1000C the sensor voltage is 5V(assume a linear relationship between temperature and voltage). At a temperature of 34.580C. what will be the:-

Binary code from the ADC.

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

What is this in Octal code?

……………………………………………………………………………………………..

What is this in Hexadecimal code?

……………………………………………………………………………………………..

What is this in BCD code?

……………………………………………………………………………………………..

Is the resolution of the ADC good enough to measure this voltage? Justify your answer.

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

6)Using the diagram below show how you would connect a passive sensor to X5 and an active sensor to X2. Assume the sensors are sourcing type.

7)For the output devices below show an application they could be used for by drawing a line.

Hydraulic ramMove a conveyor belt

HeaterLet fluid into a vessel

MotorDivert parcels on a conveyor belt

ValveIncrease the temperature of a fluid

8)Explain the purpose of an opto-isolator and how does it work. Draw a diagram.

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

……………………………………………………………………………………………..

9)Using the diagram below show how you would connect up the following:-

24V 1A DC heater to Y1

230V 2A AC motor to Y0

230V 5A AC motor to Y4