Sie sind auf Seite 1von 1

A/D Converter for Robots

Tilo Gockel
operating sequence
1 2 3 4 5 6 7 8 8 1 2 3 4 5 6 7
The TLC549CP analogue to digital con- Don’t Care
I/O
verter (A/D) from Texas Instruments is a CLOCK
Access Access Sample
tconv
good choice for applications in the field of tsu(CS)
Cycle B Sample
Cycle B (see Note A)
Cycle C Cycle C
tsu(CS)
robotics (especially those using 8051-com-
patible microcontrollers). These particular CS

converters are readily available, low-cost twH(CS)


Hi-Z State
and easy to use. DATA A7 A6 A5 A4 A3 A2 A1 A0
Hi-Z State
B7 B6 B5 B4 B3 B2 B1 B0
OUT
A quick look at the TLC549data sheet A7 B7
indicates the timing waveforms for the I/ MSB
Previous Conversion Data A
LSB MSB
Conversion Data B
MSB LSB MSB
O Clock, DATA OUT and CS signals (Fig- (see Note B) ten
ten
ure 1). A circuit to test the converter was
NOTES: A. The conversion cycle, which requires 36 internal system clock periods (17 µs maximum), is initiated with the eighth I/O clock pulse
quickly constructed using a variable resis- trailing edge after CS goes low for the channel whose address exists in memory at the time.
tor as a potential divider. Figure 2 shows B. The most significant bit (A7) is automatically placed on the DATA OUT bus after CS is brought low. The remaining seven bits (A6–A0)
are clocked out on the first seven I/O clock falling edges. B7–B0 follows in the same manner.
the simple interface between a TLC549CP
and a 8051-compatible microcontroller.
A short function which reads the serial
data from the TLC549 and returns the +5VDC
value addat is given below. Tests with an µC51
AT89S8252 Controller-Board (the Elektor
Electronics December 2005 Flash Micro
Board) indicated that the _wait() can be
1 8
omitted because the controller runs slowly REF+ VCC

enough not to need it (faster processors TLC549


7
may require it but it has been ‘commented I/O CLOCK Px.x

out’ in this listing). The actual function DATA OUT


6
A7 A6 A5 A4 A3 A2 A1 A0 Px.x
2
written in C is: ANALOG 5
Px.x
10k
unsigned char ReadADC1() { 3 4
REF- GND
unsigned char count;
unsigned char addat = 0;
P1_B2 = 0; // clk 070134 - 12
P3_B0 = 0; // Chip Select
P3_B0 = 1; //
//_wait(); // > 20 usek (50kHz)
P3_B0 = 0; P1_B2 = 0;
} measure the amount of light falling onto
for(count = 0; count
return addat; two Light Dependant Resistors (LDR). This
< 8; count++){
addat = addat << 1; } application will require two of the inter-
if (P1_B3 == 1) ++addat; face connections shown in Figure 2. Con-
P1_B2 = 1; As an example two TLC549 A/D convert- nect the LDR either in place of the variable
//_wait(); ers can be wired to a microcontroller to resistor or in parallel to it.
(070134-I)

 elektor electronics - 7-8/2007

Das könnte Ihnen auch gefallen