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

PLC Analog Input and Output Programming PLC Academy

This document discusses analog input and output signals in PLC programming. It explains that analog signals are continuous values between 0-10 volts or 4-20 mA, while PLCs can only understand digital 0s and 1s. To represent analog signals digitally, PLCs use binary numbers with bits and bytes. The document also covers analog to digital conversion, resolution, and defining the input and output ranges to include over and under thresholds.

Uploaded by

ustun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
180 views

PLC Analog Input and Output Programming PLC Academy

This document discusses analog input and output signals in PLC programming. It explains that analog signals are continuous values between 0-10 volts or 4-20 mA, while PLCs can only understand digital 0s and 1s. To represent analog signals digitally, PLCs use binary numbers with bits and bytes. The document also covers analog to digital conversion, resolution, and defining the input and output ranges to include over and under thresholds.

Uploaded by

ustun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Learn PLC Programming Online (For Free)

···
PLC Programming

All About PLC Analog


Input and Output Signals
and Programming
by PETER
MARCH 21, 2018

Do you know how to scale your analog input? Or wire


your analog output?

Many people struggle with analog signals in PLC


programming. The wiring and how to use an analog
input or output in your PLC program can be tricky. Most
often you will see digital example PLC programs and in
my Structured Text Tutorial most of the examples are
digital programs.

I’m writing this article because many of you wanted to


learn how to use analog signals in PLC programming.
Analog signals are used widely in PLC programs but also
often used in a SCADA system. So how do you connect
that 4-20mA analog transmitter to your PLC and use it in
your PLC program? How do you scale an analog signal in
Function Block Diagram? This article will give you
answers to this and much more.

···

In this article you will learn about:

Analog Signals in the PLC


Representing Analog Signals
with Binary Numbers
Bits and Bytes
A/D Converter
Resolution of Analog Signals
Analog Signal Range
Analog Inputs
Wiring of PLC Analog Inputs
Voltage Analog Inputs
Current Analog Inputs
2-wire Analog Input
3-wire Analog Input
4-wire Analog Input
Analog Input Scaling
Analog Outputs
Wiring of PLC Analog Outputs
Voltage Analog Outputs
Current Analog Outputs
Analog Output Scaling /
Unscaling

But first, let me start out with some basics about analog
signals and how they work in a PLC.

···

Analog Signals in the PLC


!
First of all,
Menu ! we are going to look at some numbers. If
you’ve read my article about combinatorial logic you
will know that a PLC works with boolean values. A PLC
can only work with the values 0 and 1.

This is great for digital signals. They are either 0 or 1 and


thereby relatively easy to work with. But what about
analog signals? As Wikipedia writes, analog signals are
continuous signals that can vary over time.

For example you can have a 0-10 volt analog signal. This
signal can vary from 0 to 10 volts and have any voltage
level in between. And since analog signals are
continuous, this signal will always at any time represent
a voltage level. If you look at the diagram below, you will
see that the analog signal can have any value between 0
and 10 volts.

···

0-10 Volt Analog Signal

The question is now: how do a PLC deal with all these


different values? Let’s say you have an analog signal at
5 volts going into the PLC. We cannot represent it with
boolean values, because they can only have the values
0 and 1.

The answer is binary numbers!

Representing Analog Signals


with Binary Numbers
As mentioned before a PLC can only work with the two
values 0 and 1. But that does stop us from working with
analog signals. Because what is really going on, is that
the PLC works with binary numbers. This is due to the
fact that a PLC or a microcontroller is really just
advanced electrical circuits made out of transistors.
Since a transistor can only be either on or off, these two
states will then represent the values 0 and 1.

···

But this only gives us two states. Very useful for digital
signals, but not for analog. To understand how analog
inputs work in a PLC you have to understand binary
numbers.

Binary numbers is the numbering system used by a PLC


or any other computer. The system only has two
numbers, compared to our 10-base numbering system
where we have 10 numbers from 0 to 9. Binary is just
another way of writing numbers. I would recommend
that you take a look at this tutorial on binary numbers, if
you don’t know how they work.

The media could not be loaded, either because the server or n

X
PLC Learni… Insights int…

The media could not be loaded, either because the


server or network failed or because the format is not
supported.

Bits and Bytes


A binary number with one digit is called a bit. One bit
can hold either a 0 or a 1. As mentioned, this is how
digital inputs work. But if you combine these bits and
thereby create multiple digit numbers, things start to get
interesting.

In many PLC’s an analog signal is represented by a word.


A word in binary is 8 zeros’ in a row or two bytes (4
zero’s). Just like this:

00000000 00000000

If you remember a little bit about binary numbers you


will know, that a binary number with 16 digits can
represent values from 0 to 65.535. This is only half the
truth for PLC’s though. Because the first bit is used for
signing the number, giving it either a positive or
negative value.

So with 1 bit for signing we have 15 bits left for


representing the analog value. The binary number can
therefore represent values from -32.768 to 32.767.

A/D Converter
When the analog input signal enters the PLC it goes
through an A/D converter or analog to digital converter.
This is the component in the PLC analog input card that
transforms the analog signal to digital signals. It is these
digital signals that will eventually give our binary value
representation in the PLC.

Before getting to know about the A/D converter it’s


important to understand what type of analog signal
you’re dealing with. In this article I will focus on these
three types of analog signals in PLC programming:

Voltage
Current
Resistance
The reason we need to know about the type of signal is
because we need to know the range of the signal.

One very used type of analog signal is the 4-20mA.

4-20 mA Analog Signal

We have to know our type of signal. Because in this


example we now know that the analog signal has a
range of 16mA. An analog value is often put in a 16-bit
double word in a PLC. This is because the A/D converter
converts the analog signal to a digital value of 16 bits
long.

You can buy analog input cards with different


resolutions. That depends on how many bits the A/D
converter has to work with. More bits gives us more
numbers to represent the analog signal.

Resolution of Analog Signals


The number of bits you have to save the analog value is
in fact called the resolution. Think of it like your TV. It
also only has a certain amount of pixels to represent a
picture. The same goes with analog to digital conversion.

Just like we call it resolution when talking about the


number of pixels on out television, we also call it
resolution when talking about analog values
represented with a number.

The resolution is very important when dealing with


analog signals in PLC programming. When entering the
analog input card the analog signal will be split into a
value between 0 and 32.767. Dividing the analog value
into 32.767 gives us a certain resolution.

Every time our value increases by 1, it means that the


analog signal has increased with x mA.

We can’t quite yet calculate the mA. Because most PLC’s


has something called over- and under range, when
talking about analog signals. Let’s have a closer look at
the ranges for analog signals in PLC programming.

Analog Signal Range


Now things start to become vendor specific. In this
article I will take Siemens as example. But don’t worry.
This principle applies to most PLC vendors.

Analog signals tends to be very sensitive. Although it is


our intention that a signal range should be from 4-
20mA, the signal can sometimes peak or drop. When
that happens we want to be able to see that in the PLC.
Although it is not always the case these peaks and drops
can mean that there is something wrong. To be able to
detect these in out PLC program we need what is called
over- and under range.

Analog Signal Range for Siemens PLC’s

Our normal range or rated range is 4-20mA. But on top


and below that Siemens had added some extra mA in
the range. They divide the over range in these two
categories:

Overshoot range (overrange)


Overflow
And the under range in these two:

Undershoot range (underrange)


Underflow
What this means is that instead of a 4-20 mA range we
now have a 1.185 – 22.96 mA range. The same applies
to the other types of analog signals. E.g. the 0-10V range
is 0 – 11.852 V range.

All in all this means that our analog signal ranges can
be illustrated like this:

PLC Value Measuring Range

Dec Hex 0-10 V 4-20


mA

32767 7FFF 11.852 22.96 Overflow


V mA

32512 7F00

32511 7EFF 11.759 22.81 Overshoot


V mA Range

27649 6C01

27648 6C00 10 V 20 Rated


mA Range

20736 5100 7.5 V 16


mA

1 0001 361.7 4 mA
μV +
578.7
nA

0 0000 0V 4 mA

-1 FFFF No Undershoot
Negative Range
-4864 ED00 Values 1.185
mA

-4865 ECFF Underflow

-32769 8000
With the over- and underflow in mind, we can now start
to calculate the real resolution of our analog signal. But
instead of just using the 22.96-1.185 mA or the 11.852
V ranges there is one number you should notice here:

27.648

As you can see in the table above this is where our rated
range ends. Our resolution for a 0-10 V signal should
therefore be calculated like this:

10 V / 27658 = 361.7 μV

Or for our 4-20 mA signal:

16 mA / 27648 = 578.7 nA

These two numbers are the minimum values we can


represent in out PLC with the digital value. In most cases
these steps are small and precise enough. Keep in mind
also that the higher resolution you want, the more
expensive PLC analog input and output modules.

Analog Inputs
With a little bit of theory in mind let’s dig into it by
looking at the analog inputs in a PLC.

Analog inputs can come from a variety of sensors and


transmitters or both. For example one one the
thermocouple types connected to a transmitter, which is
then connected to a PLC analog input. You can measure
a whole bunch of different things. The job of the sensor
or transmitter is to transform that into an electrical
signal. Here are a few of the things you can measure
with analog sensors:

Level
Flow
Distance
Viscosity
Temperature
Of course there are many other things you can measure.
The main point here is that we (the sensor or
transmitter) will transform those physical values into an
analog signal. It is that signal we can use in out PLC as
an analog input.

An example here could be a temperature transmitter


with a 4-20 mA output. Connected to the transmitter is a
temperature sensor. The transmitter is then calibrated
to a range of e.g. 0-100 degrees. What this means is that
when the temperature is 0 degrees the output of the
transmitter will be 4 mA, and 20 mA by 100 degrees.

A transmitter is often needed because the sensor in


itself cannot provide us with an analog signal. Or at least
not one that fits a PLC analog input. It is possible to buy
analog input modules where you can connect a
temperature sensor for example directly. But most often
you will have a voltage or current input module where
you connect a transmitter.

Calibration is very important when talking about


transmitters. You have to know how much those mA or
volts represents in the physical value.

Wiring of Analog Inputs


Before you start wiring any PLC analog module I highly
recommend that you not only read the manual, but also
know what type of signal you’re dealing with. Wiring a
PLC analog input is a bit different depending on the type
of signal.

In this tutorial I will cover wiring of the two most basic


analog input signals:

Voltage
Current
The reasons I divide the analog input signals in these
two categories are not only because they are the most
used signals. It is also because the wiring of them are
different. Since these two types of analog signals works
in very different ways, you will also have to wire them
differently on the analog input module. Mistakes in the
wiring can potentially destroy the input module, so be
careful!

Both types analog signals have one thing in common.

Resistance.

You might also like