• Interfacing for Acquisition of Signals from Sensors and Generation of Signals for Actuators

• Used by Computers, PLC’s, PID Controllers, etc.

• Computers are designed to handle both input and output (I/O) data

• Two main types of data I/O for computers

Analog

Digital • A Continuous signal is sampled by the computer

• The computer uses approximation techniques to estimate the analog value during the sampling window.

• An example of an A/D, D/A control of a process is shown below • Multiplexers are used when a number of signals are to be input to a single A/D converter. This allows each of a number of channels to be sampled, one at a time

• Signal conditioners are often to amplify, or filter signals coming from transducers, before they are read by the A/D converter.

• Output drivers and amplifiers are often required to drive output devices when using D/A

• Sampling problems occur with A/D conversion. Because readings are taken periodically (not continually), the Nyquist criterion specifies that sampling frequencies should be twice the frequency of the signal being measured, otherwise aliasing will occur.

• Since the sampling window for a signal is short, noise will have added effect on the signal read. For example, a momentary voltage spike might result in a higher than normal reading.

• When an analog value is converted to or from digital values, a quantization error is involved. The digital numbering scheme means that for an 8 bit A/D converter, there is a resolution of 256 values between maximum and minimum. This means that there is a round off error of approximately 0.4%. #### 26.1.1 Analog To Digital Conversions

• When there are analog values outside a computer, and we plan to read these to digital values, there are a variety of factors to consider,

when the sample is requested, a short period of time passes before the final sample value is obtained.

the sample value is ‘frozen’ after a sample interval.

after the sample is taken, the system may change

sample values can be very sensitive to noise

the continuous values of the signal loose some accuracy when conversion to a digital number

• Consider the conversion process pictured below, • Once this signal is processes through a typical A/D converter we get the following relations (these may vary slightly for different types of A/D converters). Problem 26.1 We are given a 12 bit analog input with a range of -10V to 10V. If we put in 2.735V, what will the integer value be after the A/D conversion? What is the error? What voltage can we calculate?

• In most applications a sample is taken at regular intervals, with a period of ‘T’ seconds.

• In practice the sample interval is kept as small as possible. (i.e., tau << T)

• If we are sampling a periodic signal that changes near or faster that the sampling rate, there is a chance that we will get a signal that appears chaotic, or seems to be a lower frequency. This phenomenon is known as aliasing.

• Quite often an A/D converter will multiplex between various inputs. As it switches the voltage will be sampled by a ‘sample and hold circuit’. This will then be converted to a digital value. The sample and hold circuits can be used before the multiplexer to collect data values at the same instant in time.

• A simple type of A/D converter is shown below. It is known as a successive approximation type. #### 26.1.2 Analog Inputs With a PLC

• To input analog values into a PLC we use the block transfer commands. These allow control information to the input card and retrieve results.

• The example below shows ladder logic to do an analog input. • The block that needs to be written to an 1771-IFE analog input card is shown below. This is a 12 bit card, so the range will have up to 2**12 = 4096 values. • After the input card reads the values, the results are returned in a block. The structure of the block is shown below. 26.2 Analog Outputs

• After we have used a controller equation to estimate a value to put into our process, we must convert this from a digital value in the computers memory, to a physical voltage.

• This voltage is typically limited to 20mA in most computer boards, and drawing near this current reduces accuracy and life of the board.

• A simple circuit is shown below for a simple digital to analog converter. • The calculations for the A/D converter resolution and accuracy still apply.

Problem 26.2 We need to select a digital to analog converter for an application. The output will vary from -5V to 10V DC, and we need to be able to specify the voltage to within 50mV. What resolution will be required? How many bits will this D/A converter need? What will the accuracy be?

#### 26.2.1 Analog Outputs With A PLC

• An example of an output card is 1771-OFE.

• To output a value we only need to write a single value to the output card • The format for the block that is to be written to the card is shown below. 26.3 Design Cases

#### 26.3.1 Oven Temperature Control

• Design an analog controller that will read an oven temperature, and when it passes 1200 degrees the oven will be turned off. The voltage from the thermocouple is passed through a signal conditioner that gives 1V at 500F and 3V at 1500F. The controller should have a start button and E-stop.

#### 26.3.2 Statistical Process Control (SPC)

• We can do SPC checking using analog inputs, and built in statistics functions.

• Recall the basic equations for a control chart. • The general flow would be,

1. Read sampled inputs.

2. Randomly select values and calculate the average and store in memory. Calculate the standard deviation of the stored values.

3. Compare the inputs to the standard deviation. If it is larger than 3 deviations from the mean, halt the process.

4. If it is larger than 2 then increase a counter A, or if it is larger than 1 increase a second counter B. If it is less than 1 reset the counters.

5. If counter A is =3 or B is =5 then shut down.

6. Goto 1.

26.4 Problems

Problem 26.3 Write a program that will input an analog voltage, do the calculation below, and output an analog voltage. Problem 26.4 The following calculation will be made when input ‘A’ is true. If the result ‘x’ is between 1 and 10 then the output ‘B’ will be turned on. The value of ‘x’ will be output as an analog voltage. Create a ladder logic program to perform these tasks.  Problem 26.5 You are developing a controller for a game that measures hand strength. To do this a ‘START’ button is pushed, 3 seconds later a ‘LIGHT’ is turned on for one second to let the user know when to start squeezing. The analog value is read at 0.3s after the light is on. The value is converted to a force ‘F’ with the equation below. The force is displayed by converting it to BCD and writing it to an output card (O:001). If the value exceeds 100 then a ‘BIG_LIGHT’ and ‘SIREN’ are turned on for 5sec. Use a structured design technique to develop ladder logic.  