Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Programmable logic controllers. Methods and Applications (Hackworth J., Prentice Hall).pdf
Скачиваний:
870
Добавлен:
12.08.2013
Размер:
6.34 Mб
Скачать

Chapter 7 - Analog I/O

Chapter 7 - Analog I/O

7-1. Objectives

Upon completion of this chapter, you will know

the operations performed by analog-to-digital (A/D) and digital-to-analog (D/A) converters.

some of the terminology used to describe analog converter performance parameters.

how to select a converter for an application.

the difference between a unipolar and bipolar converter.

some common problems encountered with analog converter applications.

7-2. Introduction

Although most of the operations performed by a PLC are either discrete I/O or register I/O operations, there are some situations that require the PLC to either monitor an analog voltage or produce an analog voltage. As example of an analog monitoring function, consider a PLC that is monitoring the wind speed in a wind tunnel. In this situation, an air flow sensor is used that outputs a DC voltage that is proportional to wind speed. This voltage is then connected to an analog input (also called A/D input) on the

PLC. As an example of an analog control function, consider an AC variable frequency motor drive (called a VFD). This is an electronic unit that produces an AC voltage with a variable frequency. When connected to a 3-phase AC induction motor, it can operate the motor at speeds other than rated speed. VFD’s are generally controlled by a 0-10 volt DC analog input with zero volts corresponding to zero speed and 10 volts corresponding to rated speed. PLCs can be used to operate a VFD by connecting the analog output (also called D/A output) of the PLC to the control input of the VFD.

Analog input and output values are generally handled by the PLC as register operations. Input and output transfers are usually done at update time. Internally, the values can be manipulated mathematically and logically under ladder program control.

7-3. Analog (A/D) Input

Analog inputs to PLCs are generally done using add-on modules which are extra cost items. Few PLCs have analog input as a standard feature. Analog inputs are available in unipolar (positive input voltage capability) or bipolar (plus and minus input voltage capability). Standard off-the-shelf unipolar analog input modules have ranges of

7-1

Chapter 7 - Analog I/O

0-5 VDC and 0-10 VDC, while standard bipolar units have ranges of -5 to +5 VDC and

-10 to +10 VDC.

Specifying an Analog Input

There are basically three characteristics that need to be considered when selecting an analog input. They are as follows.

Unipolar (positive only) or bipolar (plus and minus)

This is a simple decision. If the voltage being measured cannot be negative, then a unipolar input is the best choice. It is not economical to purchase a bipolar input to measure a unipolar signal.

Input range

This is relatively simple also. For this specification, you will need to know the type of output from the sensor, system, or transducer being measured. If you expect a signal greater then 10 volts, purchase a 10 volt input and divide the voltage to be measured using a simple resistive voltage divider (keep in mind that, if necessary, you can restore the value in software by a simple multiplication operation). If you know the measured voltage will never exceed 5 volts, avoid purchasing a 10 volt converter because you will be paying extra for the unused additional range.

Number of Bits of Resolution

The resolution of an A/D operation determines the number of digital values that the converter is capable of discerning over its range. As an example, consider an analog input with 4 bits of resolution and a 0-10 volt range. With 4 bits, we will have 16 voltage steps, including zero. Therefore, zero volts will convert to binary 0000 and the converter will divide the 10 volt range into 16 increments. It is important to understand that with four binary bits, the largest number that can be provided is 11112 or 1510. Therefore, the largest voltage that can be represented by a 10 volt 4-bit converter is 10 / 16 * 15 = 9.375 volts.

In other words, our 10 volt converter is incapable of measuring 10 volts. All converters are capable of measuring a maximum voltage that is equal to the rated voltage (sometimes called VREF) times (2n-1)/(2n), where n is the number of bits. Since our converter divides the

10 volt range into 16 equal parts, each step will be 10/16=0.625 volt. This means that a binary value of 0001 (the smallest increment) will correspond to 0.625 volt. This is called the voltage resolution of the converter. Sometimes we refer to resolution as the number of bits the converter outputs, which is called the bit resolution. Our example converter has a bit resolution of 4 bits. It is important to remember that the bit resolution (and voltage resolution) of an A/D converter determines the smallest voltage increment that the converter can determine. Therefore, it is important to be able to properly specify the

7-2

Chapter 7 - Analog I/O

converter. If we use a converter with too few bits of resolution, we will not be able to correctly measure the input value to the degree of precision needed. Conversely, if we specify too many bits of resolution, we will be spending extra money for unnecessary resolution.

For a unipolar converter, the voltage resolution is the full scale voltage divided by 2n, where n is the bit resolution. As a rule of thumb, you should select a converter with a voltage resolution that is approximately 25% or less of the desired resolution. Increasing the bit resolution makes the voltage resolution smaller.

Consider the table below for a 4 bit 10 volt unipolar converter.

Step10

Step2

Vout

0

0000

0.000

 

 

 

1

0001

0.625

 

 

 

2

0010

1.250

 

 

 

3

0011

1.875

 

 

 

4

0100

2.500

 

 

 

5

0101

3.125

 

 

 

6

0110

3.750

 

 

 

7

0111

4.375

 

 

 

8

1000

5.000

 

 

 

9

1001

5.625

 

 

 

10

1010

6.250

 

 

 

11

1011

6.875

 

 

 

12

1100

7.500

 

 

 

13

1101

8.125

 

 

 

14

1110

8.750

 

 

 

15

1111

9.375

The leftmost column shows the sixteen discrete steps that the converter is capable of resolving, 0 through 15. The middle column shows the binary value. The rightmost column

7-3

Chapter 7 - Analog I/O

shows the corresponding voltage which is equal to the step times the rated voltage times

(2n-1)/(2n). For our converter, this will be the step times 10 volts x 15/16. Again, notice that even though this is a 10 volt converter, the highest voltage that it can convert is 9.375 volts, which is one step below 10 volts.

Example Problem:

A temperature sensor outputs 0-10 volts DC for a temperature span of 0-100 degrees C. What is the bit resolution of a PLC analog input that will digitize a temperature variation of 0.1 degree C?

Solution:

Since, for the sensor, 10 volts corresponds to 100 degrees, the sensors outputs 10V / 100 degrees = 0.1 volt/degree C. Therefore, a temperature variation of 0.1 degree would correspond to 0.01 volt, or 10 millivolts from the sensor. Using our rule of thumb, we would need an analog input with a voltage resolution of 10 mV x 25% = 2.5 mV (or less) and an input range of 0-10 volts. This means the converter will need to divide its 0-10 volt range into 10 V / 2.5 mV = 4000 steps. To find the bit resolution we find the smallest value of n that solves the inequality 2n>4000. The smallest value of n that will satisfy this inequality is n=12, where 2n = 4096. Therefore, we would need a 12-bit 10 volt analog input. Now we can find the actual resolution by solving for a 12-bit 10 volt converter. The resolution would be 10v / 212 = 2.44 mV. This voltage step would correspond to a temperature variation of 0.0244 degree. This means that the digitized value will be within plus or minus 0.144 degree of the actual temperature.

Determining the number of bits of resolution for bipolar uses a similar method. Bipolar converters generally utilize what is called an offset binary system. In this system, all binary zeros represents the largest negative voltage and all binary ones represents the largest positive voltage minus one bit-resolution. To illustrate, assume we have an A/D converter with a range of -10 volts to +10 volts and a bit resolution of 8 bits. Since the overall range is 20 volts, the voltage resolution will be 20 volts / 28 = 78.125 mV. Therefore, the converter will equate 000000002 to -10 volts and 111111112 will become

+10 V - 0.078125 V = 9.951875 V. Keep in mind that this will make the binary number 100000002, or 12810 (called the half-range value) be -10 V + 128 x 78.125 mV = 0.000 V.

Consider the table below for a 4 bit 10 volt unipolar converter.

7-4

Chapter 7 - Analog I/O

Step10

Step2

Vout

0

0000

-10.000

 

 

 

1

0001

-8.750

 

 

 

2

0010

-7.500

 

 

 

3

0011

-6.250

 

 

 

4

0100

-5.000

 

 

 

5

0101

-3.750

 

 

 

6

0110

-2.500

 

 

 

7

0111

-1.250

 

 

 

8

1000

0.000

 

 

 

9

1001

1.250

 

 

 

10

1010

2.500

 

 

 

11

1011

3.750

 

 

 

12

1100

5.000

 

 

 

13

1101

6.250

 

 

 

14

1110

7.500

 

 

 

15

1111

8.750

The leftmost column shows the sixteen discrete steps that the converter is capable of resolving, 0 through 15. The middle column shows the binary value. The rightmost column shows the corresponding voltage which is equal to the step times the voltage span times (2n-1)/(2n). For our converter, this will be the step times 20 volts x 15/16. Notice that digital zero corresponds to -10 volts, the half value point 10002 corresponds to zero volts, and the highest voltage that it can convert is 8.750 volts, which is one step below +10 volts.

It is important to understand that expanding the span of the converter (span is the voltage difference between the minimum and maximum voltage capability of the converter) to cover both positive and negative voltages increases the value of the voltage resolution which in turn detracts from the precision of the converter. For example, an 8-bit 10 volt unipolar converter has a voltage resolution of 10 / 28 = 39.0625 mV while an 8-bit bipolar 10 volt converter has voltage resolution of 20 / 28 = 78.125 mV.

7-5