8-bit D / A Converter - Interface

Sometimes you have to proceed to time-measurements which must be more precise than the RCX is able to. In such cases you require digital counters. Of course the information needs to be transmitted to the RCX. This is not an evident task, since the RCX has only analog inputs. The LEGO Mindstorms community (have a look at the web-sites of Andreas Peter or the one of Philo ) has developped several serial interfaces.

We worked on the idea of converting the digital information to an analog signal. The first appearance of this device may be found at the Phase sound sensor's page. A real hybrid between serial and D/A-converting systems can be seen at the Infrared-ultrasonic beacon's pages.

The following device is an extended version of those prototypes. The main idea is to create a resistor-net which is a mathematical base to convert a binary 8-digit-number to a single resistor-value. This may be done by placing the resistors either in a serial or a parallel net. It is important that the different values of the net are multiples of 2i , otherwise you will not get an unambiguous result.

1. SERIAL NET

Note that open switch = 1; closed switch = 0;

r4 r3 r2 r1 R
8000 4000 2000 1000

Ohm

S4 = 0 S3 = 0 S2 = 0 S1 = 0 0
0 0 0 1 1000
0 0 1 0 2000
0 0 1 1 3000
0 1 0 0 4000
0 1 0 1 5000
0 1 1 0 6000
0 1 1 1 7000
1 0 0 0 8000
1 0 0 1 9000
1 0 1 0 10000
1 0 1 1 11000
1 1 0 0 12000
1 1 0 1 13000
1 1 1 0 14000
1 1 1 1 15000

2. PARALLEL NET

Note that this time closed switch = 1; open switch = 0;

Attention: because the inverse of ri is considered, the order of ri and Si must be changed. Note the decreasing R-values.

r1 r2 r3 r4 1/R R
1000 2000 4000 8000 Mho Ohm
S1 = 0 S2 = 0 S3 = 0 S4 = 0 0 #DIV/0!
0 0 0 1 0,000125 8000
0 0 1 0 0,00025 4000
0 0 1 1 0,000375 2666,66667
0 1 0 0 0,0005 2000
0 1 0 1 0,000625 1600
0 1 1 0 0,00075 1333,33333
0 1 1 1 0,000875 1142,85714
1 0 0 0 0,001 1000
1 0 0 1 0,001125 888,888889
1 0 1 0 0,00125 800
1 0 1 1 0,001375 727,272727
1 1 0 0 0,0015 666,666667
1 1 0 1 0,001625 615,384615
1 1 1 0 0,00175 571,428571
1 1 1 1 0,001875 533,333333

3. THE INTERFACE WITH A PARALLEL NET

Beside the low-cost-target we want to provide a galvanic separation, in order not to injure the RCX in any way. The easiest way is to use opto-couplers.

Note that the polarity has to be respected! +V to x1-1.

Because of the RCX-internal 10k pull-up resistor, the conversion to the raw-values follows the formula:

RAW = 1023 * R / (10000 + R)        have a look at the book Extreme Mindstorms, Mike Gasperi, USA, 2000

By transforming the formula you get the R-value back:

R = 10000 * RAW / ( 1023 - RAW)

We have R = f(X) = A / X, where X is the initial digital value

So we get back f -1(R)= A / R = X

In our case :

Note that there is a non-neglectable error due to part tolerance! The net has been chosen among standard resistor-values in order to provide as much as possible unambiguous RAW-values. Note that the 10-bit A/D-converter within the RCX gives 1024 different integer values. But the curve being hyperbolic, the function decreases at the rate of -1/x2. So the real function may be surjective for the higher x-values. Of course the result can be improved by changing the net as close as possible to multiples of 2i.


RetourMain Page