2. Computer Interfacing
• 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
2.1 Digital Signals
• read by the computer, and interpreted as ON or OFF.
• Examples of Inputs
• Examples of Outputs,
solid state relays (e.g. for power to motor)
• Within this signal type there are two categories of signal,
Discrete binary: such as a switch which will be thrown once
Pulse data: a continuous stream of pulses. The frequency, period, or duty cycle will control the signal value. A pulse from a tachometer for every revolution will indicate the motor speed.
• The electrical connections for these signals quite often require some additional circuitry. This includes,
latches: used to capture fast changing values (74163?)
schmitt triggers: pull a signal that may not be 0 or 5V to a reasonable logic level. It also uses a dead zone to reduce random switching. (7414?)
flip flops: we can toggle these (7421?)
inverters: gives the signal strength an buffers (7404?)
opto-isolators: eliminates electrical connections for circuit safety. These are basically an LED and phototransistor in one package.
triacs: allows DC signals to switch AC
relays: allows electrical switching that is electrically isolated with mechanical devices.
line drivers: converts low current signals to higher current (7485?)
op-amps: allow high impedance buffering between inputs and outputs. (741)
RC network: a resistor capacitor pair can be used to pass only high/low frequency signals, and filter out noise/DC.
pull-up resistors: can keep inputs/outputs from floating.
• Consider the example below,
Problem 2.1 Design some circuitry for a fuel injection computer control unit that is to read pulses from a tachometer mounted on an engine, and then control fuel injection, and spark timing. The setpoint is determined by the gas pedal.
2.3 Analog Signals
• 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%.
2.3.1 Analog to Digital Conversion
• 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).
• 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.
18.104.22.168 - Flash A/D Converter
• On type of A/D converter is the flash converter shown below,
• These converters are very fast, but they are hard to build for high resolutions.
• The conversion rates for these devices are limited by inherent capacitance, and transistor switching times.
2.3.2 Digital to Analog Conversion
• 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 board, 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.
• Consider the example below,
Problem 2.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?
• Timing is significant in computer controlled processes. If we think of a simple example, a fixed sample period means that the computer program must arrange to read the analog value at a consistent time.
• Various schemes for timing include,
interrupts: fairly efficient, but requires some timing hardware inside
by computer clock: a regular interrupt for the operating system
programmable timer: a timer that is told to call an interrupt after some time
by external trigger: asynchronous timing, potentially unstable
by external clock: an external synchronous clock
delay loops: consumes a large number of clock cycles
wait for clock value: reasonable time, but prone to software problems
count cycles: quite stable, but the computer cannot do anything else
whenever possible: this ‘non-real-time’ approach can become unstable
trigger and scan: a special input board can be set to read one or more values when timing or triggering conditions met
• Values are simply read from/written to locations in memory for both analog and digital values. When the process takes more than a single CPU cycle there will be a flag set to indicate when the operation is done. One example is reading analog values. This process may take hundreds of CPU cycles. We have three options,
1. continually check the ‘done’ flag/bit in memory
2. have the A/D converter trigger an interrupt when done
3. have the program perform other tasks for a period of time longer than the longest scan time.
• There are three fundamental properties of interrupts used for timing,
Hardware: These are actual pins on the outside of the CPU. When a change occurs the CPU will save its current status, and go to a subroutine. When done the system status is restored, and the computer programs resumes where it was interrupted. The number of hardware interrupts is often severely limited, but extra hardware can be added to expand the hardware interrupts. A computer keyboard and mouse typically use hardware interrupts.
Software: These are similar to hardware interrupts, except they are started by a call in software. These are plentiful, and used in all aspects of modern operating systems. MS-Dos makes extensive use of these software interrupts.
Maskable: These interrupts can be turned off by software. When running a critical process we may not want an interrupt to occur (and stop our program temporarily).
Non-Maskable: these interrupts cannot be disabled and will always cause the processor to stop.
We can set priorities for interrupts. If multiple interrupts occur at the same time the highest priority interrupt will be executed first. This allows critical processes to be addressed first.
Other Topics of interest
Clocks and Timers
Watch Dog Timers
REGISTER LEVEL PROGRAMMING
2.6 Computer Control of Processes
• Functions of a Process I/O Interface,
Control the scanning and processing of all the inputs and outputs between the process and the computer.
Provide conversions of signal levels, compensation for sensor range, and linearization of signals.
Provide signal and sensor validity checks.
Provide signal pre-processing and filtering.
Provide measurements to the various other programming packages which have been converted to engineering units or interpreted in other ways.
Provide alarm limit checks input-by-input.
• Some features found in computer control systems,
timer initiated events: such as clock based sampling periods for a control loop
Process initiated interrupts: Prioritized interrupt signals can be used to alert computers to standard notifications, or to initiate an emergency sequence when a critical failure has occurred.
Control software: directs the operating points for the control system
System and program initiated events: these are for system house keeping, and for communication to other computer systems in a network.
Operator initiated events: requests for reports, changing of operating parameters, checking quality, etc.
Each computer has the ability to process interrupts.
These interrupts can stop the microprocessor, and make it execute other subroutines.
If no interrupts are received, the computer will always run the same program
When interrupts are received, they are processed as urgent, or non-urgent.
When an interrupt is processed, a small subroutine is run, and then execution returns to the original point in the interrupted program.
If interrupts are not used, then the computer must continuously scan all of its inputs to see if any are critical. But this is not practical for real time processing.
• Linear Computer Controllers,
Linear control theory can be converted into computer programs.
Canonical form (Laplace/frequency domain) control rules can be converted into a form suitable for computers by using ‘z-transforms’
State space control laws can be converted into computer code using matrix techniques, along with numerical integration.
For example the PID control law has been used in many computer control programs to date.
• The figure below depicts a compute controlled process.
• Advanced topics include,
Feed forward controllers
Non-linear control systems
Multi-input/Multi-output control systems
• An example of Computer-process interface
2.7 Batch Processing
• The nature of Batch processes,
Batch processes deal with discrete quantities of raw materials or products.
batch processes allow the tracking of these discrete quantities of materials or products
batch processes allow more than one type of product to be processed simultaneously, as long as the products are separated by the equipment layout.
Batch processes entail movement of discrete product from processing area to processing area
Batch processes have recipes (or processing instructions) associated with each load of raw material to be processed into product.
Batch processes have more complex logic associated with processing than is found in continuous processes
Batch processes often include normal steps that can fail, and thus also include special steps to be taken in the event of a failure.
• The nature of steps in a batch process,
Each step can be simple or complex in nature, consisting of one or more operations
Generally, once a step is started it must be completed to be successful.
It is not uncommon to require some operator approval before leaving one step and starting the next.
There is frequently provision for non-normal exits to be taken because of operator intervention, equipment failure or the detection of hazardous conditions.
Depending on the recipe for the product being processed, a step may be bypassed for some products.
The processing operations for each step are generally under recipe control, but may be modified by operator override action.
• A typical process step.
• Functions of all Process Control Systems
There must be an I/O interface between the processes and the control. The I/O interface passes all the information moving between the two parts of the total system.
The control system must provide continuous control functions to regulate appropriate portions of the process.
The control system must provide sequential control functions. A properly designed batch control system should make it easy to describe the sequence of operations and the checks that must take place.
The control system must provide displays and interfaces which the operator can use to monitor and direct process activity.
• Additional functions found only in Digital control systems
An advanced control system should allow the process to handle a range of products, and not just a single product. The use of recipes is a concise and convenient method to describe the process steps for each product.
An advanced control system should provide a multiprogramming environment in which each specific task can be programmed in a simple stand-alone fashion. The system should also allow more than one unit in the plant to be controlled at the same time.
An advanced control system should provide displays which are oriented toward the total process rather than toward individual parameters.
An advanced control system should automatically detect and correct process upsets and equipment failures.
An advanced control system should provide for device operations which reduce the complexity of the logic that the user must deal with. There are many mundane and repeated operations and error checking functions which must be done in manipulating valves, pumps, motors, fans, and so on which can best be handled in device packages which standardize such operations.
2.8 Computer Process Monitoring
• Process Data,
can ensure dangerous situations are avoided
variables such as temperature, pressures, forces, concentrations of chemicals, etc.
Can help track process progress, and allow corrections
• Equipment Data,
Data related to equipment
Can avoid dangerous and costly operating conditions
• Product Data,
Allows on line monitoring of process output,
variables can be, quality, yield, production rate, etc.
2.9 Implementing a Computer Control System
• The steps below are typically essential for replacing an existing/new control system with a computer control system:
1. do an analysis of the existing/similar system.
2. clearly list control objectives
3. list outputs required to meet objectives
4. list inputs required to meet objectives
5. determine logical relationships between the inputs and outputs
6. write programs for relationships found in last step
7. document all aspects of the system
• SCADA (System Control And Data Acquisition) systems are based around a central computer.
• The central computer communicates with remote computers/PLCs/sensors to issue control commands and collect data.
Problem 2.3 A video voltage signal is to be digitized by an A/D converter. The maximum voltage range is 15V. The A/D converter has a 6-bit capacity. Determine the number of quantizing levels the quantization level spacing, and the quantization error.