Translate

Sunday, June 26, 2016

A 16 channels 12 bits acquisition system

Today many microcontrollers have one or two 10-bit or more built in AD converters with a multi-channel multiplexer, but the quality of conversion is rather poor because of the considerable background noise always present together with a low linearity. So, I think it will be useful the proposed system, since the components are still readily available and the results obtained are at a professional level.
However I think that even with a different ADC hardware, the software used is still valid, as a result of years of experience. The system design is a front end controlled remotely via a serial link that can be the standard RS232 / RS422, or wireless.

In the years '80 I had designed a digital acquisition system (DAS16) based on the classic 12 bit analog to digital converter AD574, from Analog Devices. In addition to this device I was using a 16-channel multiplexer HI506 followed by a sample and hold circuit based on HA2425. The diagram of this board is visible in Figure 1.  I used it with various computers and microcontrollers, including the IBM PC, through the parallel interface, the Apple II with a my own interface card and finally, with a 80196 microcontroller. The system remained unused for several years, then in 2007, I designed a new controller based on a PIC to interface it with computers or tablets via a serial interface. The system was slower, but the parallel interface was disappearing from laptops.


The counter CD40193 can be used to load the starting address of the channel and then to generate the subsequent scanning addresses by means of a simple clock.
The two 74LS367, hex buffers with 3-state outputs, are required to create an 8 or 4 bit data bus from the 12 bits parallel output of the converter. The 4-bit bus, was necessary for the printer interface of the first PC, which had not yet become an 8-bit bidirectional bus (standard IEEE 1284).
The board must be powered at +/- 15V and a LM7805 is mounted on it to power logic devices. A reed relay (K1) is used to change the range from +/- 5V to +/- 10V, under software control. A 31 pins male connector (DIN 41617) was used in my board.

The DAS controller

I used a PIC16F73 because already available. The scheme is shown in Figure 3. I used a 18.432 MHz quartz because suitable for the exact generation of the UART baud rate. This component is easily found in the old PC serial cards.
Since microcontrollers don’t have a great memory, I could not use a large ram buffer that allows a high sampling rate. Then the achievable sampling frequency is limited by the maximum baud rate of the UART. The program, according also to the channels to be scanned, check if the required sample period is valid for data transmission.
Figure 4 shows the arrangement of the components of the PIC DAS controller. A 32-pin DIN connector connects this board with the DAS16. Note the double-dip switch that is used to set the 4 possible baud rates (on on: 9600, on off: 19200, off on: 57600, off off: 115200). An external push button is used to start the acquisition and a red LED lights up during the whole time of the acquisition.

This system, with the software provided, can acquire up to 16 analog channels at the maximum frequency of 1kHz, for one channel, at a baud rate of 115200 b/s. The time required for one scan of 16channels is about 0.4 milliseconds plus the time to transmit the data. The following table gives an idea of the possible sampling frequency limits.
channels
baud rate
Ts [ms]
Fs max. [Hz]
1
115200
1
1000.00
16
115200
10
100.00
1
9600
10
100.00
16
9600
103
9.71
With a baseline period of 1 ms, the maximum sampling period is 255 ms which corresponds to a minimum frequency of about 3.92 Hz. If you want to use lower frequencies, with simple changes (TMR0 = 76 instead of 238) you can use a basic period of 10 ms, as it was in the first version of the program.
As the project is not new but dates back to 2007, it is used standard serial interface RS232. Today you could use a TTL / USB serial adapter or a serial bluetooth module to connect to PCs, tablets or smartphones.

Figure 5 shows the connections between the boards.

The program
I modified and improved the program I had written in 2007 with a new version of the compiler and improving the interpretation of the command string. I had some problems because the memory limits of the PIC16F73, using about 92% of PIC flash memory and 96% of ram,  but I did not want to change the CPU with the newer ones.
All acquisition parameters, ie the initial and final channel of the scan, the full scale (+/- 5 or 10V) and the sampling frequency can be set by the computer by means of a command string. The acquisition start pressing the appropriate button or sending an ‘A’ by the terminal. The program checks whether the required sample period is compatible with the number of channels and the UART baud rate, in case of incompatibility a warning is printed on the terminal and a new corrected command string will be necessary.
The configuration string is of the form:
“$ci,cf,BPm,ns,fs*”
  Where:
ci = start channel (0..15);
cf = last channel of the scan (0..15);
BPm = Base Period multiplier (1..255), the Base Period = 1 [ms];
ns = Number of samples (1.. 65535);
fs = ADC full scale (5 or 10) bipolar.
The command string header is ‘$’ and the end is ‘*’, for example, the command string : “$0,5,50,2048,5*” is interpreted as a scan from channel 0 to channel 5 with a sampling period of 50ms, 2048 samples with a +/- 5V range.
If the parameters are okay, the system print the message 'Push Start Button or write A to start', otherwise one of the following messages will be printed:
Errors on configuration string !!
If we use a sample period too short  compared to the baud rate and the number of channels, the following message will printed:

Ts is incompatible with baud rate !!
Ts must be greater than xxxx [us]

Where xxxx = tscan+ttx is the minimum sampling period to be used, in microseconds.
In both cases a new correct string will be sent. In the case of the example above, the system respond to the command string with the message:

Initial Ch = 0, Final Ch = 5, +/- F.S. [V] = 5
Ts [ms] = 50, Samples = 2048
Push Start Button or write A to start

This information is useful for the program that will process the data, so it may be saved on the captured file. After pressing the button, or sending ‘a’, we can read the transmitted data:
DATA
  -720  -481  -708  -505  -730  -488
  -691  -464  -683  -490  -708  -488
……
The rows with the channel scans are preceded by the word 'DATA'. During acquisition the led is on and, at the end, the system is waiting for a new acquisition with the same parameters. If you want to change them, a reset button or turning off and turning on the power switch will restart the system.
The next lines, one for each scan, contain the data in a fixed format, six characters (including the sign) per channel, expressed in [mV].
On PC or tablet, you can use a terminal emulation program capable to save the received data to an ASCII file, I used RealTerm on Windows 7.
I compiled the new program  in mikroPascal PRO rev.6.6 for PIC (mikroElektronika, www.mikroe.com). The length of the code is greater than 2k bytes, so it can’t be compiled with the free version of the compiler and I provide also the hex file for the PIC programmer.