Файл: Programmable logic controllers. Methods and Applications (Hackworth J., Prentice Hall).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 15.06.2025

Просмотров: 2132

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

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


Chapter 7 - Analog I/O

Example Problem:

A 10-bit bipolar analog input has an input range of -5 to +5 volts. If the converter outputs the binary number 01101111012 what is the voltage being read?

Solution:

First we find the voltage resolution of the converter. Since the span is 10 volts, the resolution is 10 / 210 = 9.7656 mV. Next we convert the output binary number to decimal (01101111012 = 44510) and multiply it by the resolution to get 10 / 210 x 445 = 4.3457 V. Finally, since the converter uses offset binary, we subtract 5 volts from the result to get

4.3457 V -5 V = -0.6543 V.

The impedance of the source of the voltage to be measured must also be a consideration. However, this factor usually does not affect the selection of the analog input because generally all analog inputs are high impedance (1 Megohm or higher). Therefore, if the source impedance is also high, the designer should exercise caution to make sure the analog input does not load the source and create a voltage divider. This will cause an error in the reading. As a simple example, assume the voltage to be read has a source impedance of 1 Megohm and the analog input also has an impedance of 1 Megohm. This means that the analog input will only read half the voltage because the other half will be dropped across the source impedance. Ideally, a 1000:1 or higher ratio between the analog input impedance and the source impedance is desirable. Any lower ratio will cause a significant error in the measurement. Fortunately, since most analog sensors utilize operational amplifier outputs, the source impedance will generally be extremely low and loading error will not be a problem.

7-4. Analog (D/A) Output

When selecting an analog output for a PLC, most of the same design considerations are used as is done with the analog input. Most analog outputs are available in unipolar 0 to 5 V and 0 to 10 V, and in bipolar -5 to +5 V and -10 to +10 V systems. The methods for calculating bit resolution and voltage resolution is the same as for analog inputs, so the selection process is very similar.

However, one additional design consideration that must be investigated when applying an analog output is load impedance. Most D/A converters use operational amplifiers as their output amplifiers. Therefore, the maximum current capability of the converter is the same as the output current capability of the operational amplifier, typically about 25 mA. In most cases, a simple ohm’s law calculation will indicate the lowest impedance value that the D/A converter is capable of accurately driving.

7-6

Chapter 7 - Analog I/O

Example Problem:

A 12-bit 10 volt bipolar analog output has a maximum output current capability of 20 mA. It is connected to a load that has a resistance of 330 ohms. Will this system work correctly?

Solution:

If the converter were to output it’s highest magnitude of voltage, which is -10 volts, the current would be 10 V / 330 ohms = 30.3 mA. Therefore, in this application, the converter would go into current limiting mode for any output voltage greater than

20 mA x 330 ohms = 6.6 V (of either polarity).

7-5. Analog Data Handling

As mentioned earlier, analog I/O is generally handled internally to the PLC as register values. For most PLCs the values can be mathematically manipulated using software math operations. For more powerful PLCs, these can be done in binary, octal, decimal or hexadecimal arithmetic. However, in the lower cost PLCs, the PLC may be limited in the number systems it is capable of handling, so designer may be forced to work in a number system other then decimal. When this occurs, simple conversions between the PLC’s number system and decimal will allow the designer to verify input values and program output values.

Example Problem:

An voltage of 3.500 volts is applied to an 8-bit 5 volt unipolar analog input of a PLC. Using monitor software, the PLC analog input register shows a value of 2638. Is the analog input working correctly?

Solution:

First, convert 2638 to decimal. It would be 2 x 82 + 6 x 81 + 3 x 80 = 179. For an 8-bit

5 volt unipolar converter, 179 would correspond to 179 x 5 / 28 = 3.496 volts. Since the resolution is 5 / 28 = 0.0195 volts, the result is within ½ of a bit and is therefore correct.

7-6. Analog I/O Potential Problems

After installing an analog input system, it sometimes becomes apparent that there are problems. Generally these problems occur in analog inputs and fall into three categories, a constant offset error, percentage offset error, or an unstable reading.

7-7