Kneeling for the thesis of the college microcontroller

Intelligent multi-channel serial data acquisition/transmission module design

Guangzhou Opto-Electro-Mechanical Engineering Research Center line joint

Guangzhou Fangtong Bio-Technology Limited company Guan Qiang

Introduction

With the continuous development of electronic technology, the detection and control of various physical quantities can be realized. Microcomputer detection and control systems are not only used in aerospace, robotics, textile machinery, food processing and other industrial process control, but also has become a major part of a variety of daily household appliances. Among them, A/D (analog to digital conversion) equipment plays a very important role. Thus, a system will need more A/D equipment. Generally, it is realized by expanding one or more A/D acquisition cards. When the analog quantity is small or temperature, pressure and other slow-varying signal occasions, the use of bus-type A/D card is not the most appropriate and economical program. Here we introduce a AT89C2051 microcontroller as the core, using the TLC2543L 12-bit serial A/D converter sampling module, the module's sampling data from the microcontroller serial port level conversion to the host computer (PC) serial port COM1 or COM2, forming a serial data acquisition serial data transmission method.

Main Component Functions

AT89C2051 Microcontroller

AT89C2051 is a kind of 8-bit microcontroller with very high performance-price ratio introduced by ATMEL, and its instruction system is fully compatible with MCS-51 series. The pinout is shown in Figure 1.

TLC2543L Serial A/D Converter

TLC2543L adopts SPI serial interface bus, SPI serial interface bus is proposed by Motorola, which is a three-wire synchronous interface for synchronization signal, input signal and output signal. In addition the chip has a chip select line, the microcontroller selects the TLC2543L through the chip select line. where CLK is the synchronization clock pulse, CS is the chip select line, DIN is the data output of the microcontroller and the data input line of the TLC2543L, DOUT is the data input line of the microcontroller and the data output line of the TLC2543L. Figure 2 shows the timing diagram of the TLC2543L.The TLC2543L is full-duplex, i.e., data can be sent and received at the same time. If only writing data to the TLC2543L, the microcontroller can discard the data read in at the same time; conversely, if only reading data, it can write any data after the command byte. The data transfer is in bytes and is formatted with the high bit coming first.

The module uses TI's TLC2543L 12-bit serial A/D converter, using switched-capacitor successive approximation method to complete the A/D conversion process. Serial input structure, can greatly save the 51 series of microcontroller I / O resources, and affordable. Its features are:

(1) 11 analog input channels;

(2) Conversion time of 10 s;

(3) 12-bit resolution A/D converter;

(4) 3-channel built-in self-testing mode;

(5) Sampling rate of 66kbps;

(6) Linear error +1LSB (max) )

(7) End-of-conversion (EOC) output available;

(8) Unipolar and bipolar outputs available;

(9) Programmable MSB or LSB preamble;

(10) Programmable output data length. The pinout of the TLC2543L is shown in Figure 3. In Figure 3, AIN0 to AIN10 are analog inputs; AIN10 is the chip select; DIN is the serial data input; DOUT is the three-state serial output of the A/D conversion result; EOC is the end of conversion; CLK is the I/O clock; REF+ is the positive reference voltage terminal; REF- is the negative reference voltage terminal; VCC is the power supply; and GND is the ground.

Level converter MAX232C

MAX232C for RS-232 transceiver, simple and easy to use, a single +5V power supply, only a few external capacitors can be completed from the TTL level to the RS-232 level of the conversion, the pin arrangement shown in Figure 4.

Hardware Design

The hardware circuit is shown in Figure 5.

Microcontroller AT89C2051 is the core of the whole system, TLC2543L on the input analog signal acquisition, the conversion results are received by the microcontroller through P3.5 (9 pins), the AD chip's channel selection and the way the data is input through P3.4 (8 pins) into one of its internal 8-bit address and control registers, the data collected by the microcontroller through the serial port (3, 2) pins) are converted to RS232 level by MAX232C for transmission to the host computer.

Microcontroller software design

The microcontroller program mainly includes the system information of serial data acquisition/transmission module, the number of channels, the acquisition cycle and the definition of communication protocol, as well as the standard subroutines for data acquisition and transmission.

The channel selection and mode data of TLC2543L is 8-bit, and its function is as follows: D7, D6, D5 and D4 are used to select the channel which is required to be converted, channel 0 is selected when D7D6D5D4=0000, channel 1 is selected when D7D6D5D4=0001, and so on; D3 and D2 are used to select the length of the output data, and the program selects the length of the output data to be D3 and D2 are used to select the output data length, this program selects the output data length as 12 bits, i.e., D3D2=00 or D3D2=10; D1, D0 select the leading bit of the input data, and D1D0=00 selects the high leading bit.

The data read by the TLC2543L at each I/O cycle is the result of the last conversion, and the current conversion is serially shifted out in the next I/O cycle. The first reading may read an inaccurate conversion result due to internal adjustments and should be discarded.

The data acquisition program is as follows:

sbit DATAIN=P1^1;

sbit CLOCK=P1^0;

sbit DATAOUT=P1^2;

sbit CS=P1^3;

bit datain_a_bit0()< /p>

{ bit m=0;

DATAOUT=1;

m=DATAOUT;

DATAIN=0;

Nop();

CLOCK=1;

Nop();

CLOCK=0;

Return(m);

}

bit datain_a_bit1()

{ bit m=0;

DATAOUT=1;

m=DATAOUT;

DATAIN=1;

Nop();

CLOCK=1;

Nop();

CLOCK=0;

Return(m);

}

The microcontroller is programmed to generate the serial clock and send and receive the data bits in a time sequence to complete the writing of the channel mode/channel data and the reading of the conversion result with the following program:

unsigned int Tlc2543L(unsigned char ch)

{unsigned char i,chch=0;<br>unsigned int xdata xxx=0;<br>unsigned int xdata y=0;< br>CS=0;<br>Chch=ch<<4;<br>Y=chch;<br>Y<<=8;<br>I=0;<br>While(I<12)<br>{if(( y&0x8000)==0)<br>{if(datain_a_bit0()==0) xxx&=0xfffe;<br>else xxx|=0x0001;<br>if(I!=11) xxx<<=1;<. br>}

else

{if(datain_a_bit1()==0) xxx&=0xfffe;<br>else xxx|=0x0001;<br>if(I!=11) xxx<<=1;<br& gt;}

y<<=1;

I+=1;

}

CS=1;

Return(xxx);

}

Serial data transmission module includes the serial port initialization subroutine and the data transmission subroutine, and each subroutine is as follows. Which data transfer using query mode, can also be easily changed to interrupt mode.

Void rs232init()

{TMOD=0x20;<br>TH1=0xfd;<br>TR1=1;<br>SCON=0x50;<br>}

void receandtran()

{unsigned char da;<br>while(!RI)<br>RI=0;<br>Da=SBUF;<br>SBUF==da;<br>While(!TI);<br>TI=0 ;<br>}

The C language program used for receiving data from the upper computer includes an initialization subroutine and a reception subroutine. The subroutines are as follows:

void cominit(void)

{

outportb(0x3fb,0x80);

outportb(0x3f8,0x18); / with the microcontroller baud rate consistent with the 9600bps*/

outportb(0x3f9,0x00);

outportb(0x3fb,0x03); /8 data bits, 1 stop bit, no parity*/

outportb(0x3fc,0x03); /*Modem control register setting, make the DTR and RTS outputs active*/

outportb(0x3f9,0x00); /*Set Interrupt Allow Register, disable all interrupts*/

}

void data_rece(void) /*Query way to receive data subroutine*/

{

while(!kbhit())

{

while(! (inportb(0x3fd)&0x01));/* wait if receive register is empty*/

printf("%x ",inportb(0x3f8)); /* read the result and display it*/

}

getch();

}

Intelligent Serial Acquisition/Transmission Module in PCR Instrument

In the circuit design of PCR instrument, because there are a lot of signals that need to be detected, including the temperature detection of the hot cover, the temperature detection of the heat sink, the temperature detection inside the chamber, the temperature detection of the airflow, the detection of the light signal and so on, in order to simplify the circuit, to save the cost, to reduce the volume, in the selection of the A/D converter circuit, the choice of SPI bus In order to simplify the circuit, save cost and reduce the size, the SPI bus was chosen for the A/D converter circuit, which has up to 11 analog signal inputs to fully meet the needs of the PCR instrument circuit design, and a chip can complete the function of detecting multiple signals and save the resources of the microcontroller, and the hardware schematic is shown in Fig. 6.

Conclusion

The intelligent serial data module described in this paper can be used directly in any microcomputer control and detection systems to replace the original analog-to-digital conversion design. After the practical test, the module has low power consumption, high sampling accuracy, good reliability, easy interface, and has high practical value. The software and hardware of this intelligent module have been successfully applied in the design and practice of the life science instrument "Thermocycler", which is easy to use, simple and feasible, cost-saving, and able to meet most of the data sampling applications. Source: www.lw3721.com