1 Introduction
Analog signals output from sensors typically require preprocessing such as amplification, attenuation, and filtering before being sent to an ADC for analog-to-digital conversion. In fields like automatic control and intelligent instruments, this processing must be software-controlled, automatically adjusting amplification or attenuation factors, setting the cutoff frequency of the low-pass filter, and transmitting these parameters to the CPU for measurement correction. Most commercially available data acquisition boards lack analog signal preprocessing capabilities, requiring external, manually controlled amplification and filtering devices, thus hindering automation. The author developed this microcontroller-based intelligent analog signal preprocessing system to address these issues. Of course, this system can also be used as a general amplifier and filter.
2 Hardware Circuit
Figure 1 shows a simplified diagram of the analog signal preprocessing circuit. A programmable amplifier/attenuator is constructed using the dual-current-output DAC chip AD7528 and an operational amplifier. Its principle utilizes the internal R-2R resistor network of the DAC, with one resistor acting as the input resistor of the DAC and the other as the feedback resistor. The equivalent resistance of R-2R can be written as:
RDACA=256RLDA/NA; RDACB=256RLDB/NB
RLDA and RLDB are the R-2R ladder network resistors for DCA and B, respectively, and NA and NB are the decimal DAC input digits (1-255). The circuit gain is: Vout/Vin = -(RLDB/RLDA) × (NA/NB). The AD7528 is a dual precision-matched DAC, where RLDB = RLDA. Therefore, the circuit gain is: Vout/Vin = -NA/NB, showing that it is entirely determined by the input digital value. Thus, this circuit can achieve precise amplification without external precision resistors. The amplification range is 1/255 to 255 (-48dB to +48dB). The chip select signals for the two AD7528s are provided separately by the decoder; therefore, the amplification of the two channels can be set independently.
The amplified or attenuated analog signal is buffered and then input to the switched-capacitor filter RF5609. The RF5609 is a seven-pole, six-zero elliptic function low-pass filter with a cutoff frequency of 1/100th of the operating clock frequency, a variable range of 0.1Hz to 25kHz, a passband ripple of 0.2dB, and a stopband attenuation of 100dB/octave. MAXIM's MAX291-295 series switched-capacitor low-pass filters can also be used. The filter's operating clock is provided by a programmable timer/counter 8254A. An 8MHz crystal provides the input clock to the 8254A via an oscillator circuit. The 8254A operates in square wave generator mode, with OUT0 and OUT1 providing the filter operating clock for channels 1 and 2 respectively. Therefore, the two channels can be set to the same or different low-pass cutoff frequencies.
The RC circuit following the filter is used to eliminate interference from the operating clock. The preprocessed analog signal is then output after passing through a buffer.
Figure 1 Analog signal preprocessing
Figure 2 shows the keyboard and display circuit. The PA and PB of the 8255 controller control the 6-digit LED digital display. The PA and PC control the 18-key keyboard, including the numeric keys "0-9", the division sign "÷", the up key "Up", the down key "Down", the local/remote key "Local/Remote", the amplifier/filter key "PGA/LPF", the channel key "Channel1/Channel2", the auto setting key "Auto", and the Enter key "Enter".
Figure 2 Keyboard and Monitor
Figure 3 shows the CPU circuit. An 8031 CPU is used, with an EPRO-M2764 as the program memory; an 8751 can also be used instead. Since the system does not require storing large amounts of data during operation, a data memory is not included. Address lines A13-A15 are decoded by a 74LS138 decoder to form chip select lines CS0-CS4, which control the 8254, two AD7528 chips, the 8255, and the DAC-0808, respectively. The purpose of the DAC is to allow the system to automatically adjust the amplifier's gain based on the required output analog signal level or the ADC's half-range value when the system is set to "automatic setting." Additionally, an RS232 transceiver circuit is included for remote control.
Figure 3 CPU Circuit
3 Software Process
The main software can be divided into three parts: "Local Control" software, "Remote Control" software, and "Automatic Setting" software. Figure 4 shows the "Local Control" process. "LDCAL" indicates that the system is in "Local Control" mode. Users can set the amplification factor of the dual channels and the cutoff frequency of the low-pass filter via the keyboard. "Attenuation 1/200" is displayed as "1-200", and the input is 1÷200.
Figure 4. Flowchart of "Local Control"
Figure 5 illustrates the "remote control" process. "232C" indicates that the system is controlled by the main controller via an RS232 serial port. It only recognizes five commands sent by the main controller in the form of numbers 0-4 and performs corresponding actions. When the main controller requests "automatic setting," the system will automatically set the amplification factor and then transmit the set value back to the main controller for calibration. Note that this system cannot automatically set the cutoff frequency of the low-pass filter; it can only use the default value or a value set previously.
Figure 5 Flowchart of "Remote Control"
Figure 6 illustrates the "Automatic Setting" process. Based on the amplifier output voltage sent by the main controller or set via the keyboard, and the range of the ADC0800 (±10V), the required input value can be calculated. For example, if the output voltage is set to 2500mV, the input data must be greater than or equal to 192 for positive voltages and less than or equal to 64 for negative voltages. If these values are not met, the amplification factor is increased by one stage, and the acquisition and judgment process continues. Although the amplification factor may increase in steps of 1/255, to speed up the process, larger step sizes or a geometric progression can be used.
Figure 6. Flowchart of "Automatic Setup"
4. Summary
This system organically combines analog signal preprocessing with a microcontroller, and with its comprehensive control functions, it realizes intelligent processing of analog signals. It has played an outstanding role in the research and development of equipment modification, automatic control, and intelligent instruments.