Serial Port A/D-converter
Original design Copyright Tomi Engdahl 1996 Description revised by Tomi Engdahl 2001
This circuit is a simple 8-bit analogue to digital converter circuit which is connects to PC serial port. The circuit is based on TLC548 A/D-converter chip (might be hard to get nowadays, Texas Instruments makes this IC), which is an A/D-converter with serial output. The output of the TLC548 is not directly suitable for standard serial data reception, so this circuit uses serial port handshaking lines in a nonstandard way which enables the communication between computer and converter chip to be implemented with as few components as possible. The circuit takes all the power it needs from PC serial port.
General introdution to serial port interfacing
A generally asked question is "Can I Connect a Serial A/D to My Computer's Serial Port?". The answer to this question is yes, but there are simpler ways to interface to a computer. To begin with, the computer's RS-232 port uses higher voltage levels that are incompatible with most ADC's TTL/CMOS logic.
Another problem is that the computer's RS-232 serial port is asynchronous, which places a few more requirements on the communication, including some additional handshaking control lines. Also, with the RS-232 serial port, you must set both ends of the link to the same baud rate. The A/D converter's serial port is synchronous; thus, its handshaking requirements are minimal and it only requires one wire for clock and one or two wires for data.
If you are truly determined, you can bit-bang using the RS-232 port's handshake lines. This circuit uses this control method. The voltage conversion of signals from RS-232 port to IC input pins is done using a combination of series resistors and the internal input protection diodes in the IC. The output of this A/D was able to directly output signals which seemed to be detected by RS-232 port (the output of the chip does not meet RS-232 specifications, but in practice still worked with the PC serial ports tested).
Technical data of the circuit
Maximum sample rate: 40 000 samples/second (maximum rate of TLC548 chip)
Input voltage range: 0-5 V
Accuracy of A/D converter chip: 8 databits (+-0.5 LSB)
Computer interface: PC serial port
Interface protocol: Proprietary syncronous serial interface (uses PC serial port as general purpose I/O port)
The TLC548 IC datasheet is available at http://www-s.ti.com/sc/psheets/slas067/slas067.pdf.
Circuit diagram
The picture below is tha circuit diagram of the circuit. The pin numbers of the connector are pin numbers of 25-pin serial port connector. All diodes are IN4148 or similar. All resistors connected to IC are 30 kOhm and their function is to protect the IC inputs with the diodes against overvoltage. The 1 kOhm resistor, one diode, 5.1V zener-diode, 10uF and 100nF capacitors make the power supply which takes circuit power from serial port Data Terminal Ready -pin.
Circuit diagram of the serial port A/D converter. This picture is available separately in GIF format.
Component list
- 3 pices of 30 kohm resistor
- 7 pieces of 1N4148 diode
- 1 kohm resistor
- 5.1 V zener diode
- 10 uF 15V electrolytic capacitor
- 100 nF capacitor
- TLC548 A/D converter IC (may be hard to get)
- 25 pin female D connector
Control signals
The following signal diagram tells that signals are needed for controlling the TLC548 A/D conversion chip. The chip needs chip selected (CS) and i/o clock signal (CLK) to operate. The chip gives the conversion results from data output pins (Dout). Those signals are simple and easy to understand and can be easily generated using simple software routine.
Signal diagram of TLC548 chip. This picture is available separately in GIF format.
This type of signaling is quite common in many A/D converters with serial outputs. There are differences in different type of A/D converters, but you can easily use the ideas used in this circuit for interfacing other types of A/D converters to your PC.
Software
Here is a simple program for testing and operating A/D converter circuit. The program is written using Turbo Pascal version 4.0 and can be compiled with never versions also. This program needs to know the address of your PC's COM-port and you have to set it to the source code before running it. If you have very fast computer, you might have to add some delay after if I/O access.
Program serial_adc; Uses Crt; Const combase=$2f8; { I/O address of the COM port you are using } MCR=combase+4; LCR=combase+3; MSR=combase+6; Procedure Initialize_converter; Begin Port[MCR]:=3; { make DTR line to supply power and set CS input of chip to 1 } Port[LCR]:=0; { set clock line of the chip to 0 } End; Function Read_value:byte; Var value:byte; count:byte; Begin value:=0; Port[MCR]:=1; { set CS down } For count:=0 to 7 Do Begin { do the bit value eading 7 times } value:=value SHL 1; { value=2*value } Port[LCR]:=64; { clock line up } If (port[MSR] and $10)=$10 Then Inc(value); { read the input data and update value } Port[LCR]:=0; { clock line down } End; Port[MCR]:=3; { set CS up again } Read_value:=value; { return the value } End; Begin Initialize_converter; { call initialization routine } Repeat Writeln(Read_value); { call reading routine and print the value } Until KeyPressed; { repeat until any key is pressed } End.
Frequently asked questions and answers
How the out of the ADC is converted to -10V and +10V for RS232 ?
I don't convert them to those voltges. Normal PC serial port will not need the full voltage range to operate. I just put the TTL level output from the ADC chip and this will worj for PC RS-232 ports when wires are short.
Don't you need start and stop bits like in normal RS-232 data?
I don't use standard RS-232 protocols. The circuit does not use normal data transmission or reception of RS-232 serial data. All the data transfer is carried though CTS input on bit by bit basis controlled by the output signals from TD and RTS lines.
Other information sources
Ian Harries has designed quite similar circuit for parallel port using TLC549 chip, which is quite similar to TLC548. The circuit is available at http://www.doc.ic.ac.uk/~ih/doc/adc_dac/tlc549/ and you can find some documentation of TLC549 chip there also.
Tomi Engdahl <[email protected]>