### Welcome to our site!

#### Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Status
Not open for further replies.

#### Oluvision

##### New Member
I am building a impedance meter. I need a Micro(X) that will be able to take two Analog Voltages as inputs, convert them to digital form divide them and give the output as Analog Number thru a DAC.
Thanks

I've seen many controllers with a ADC, but controllers with a DAC are rare... And they are mostly high-end (expensive) controllers.
I think it would be much cheaper to use a controller with only ADC (many pics have ADC) and use an external DAC

Silicon Labs has a line of super fast 8051s some of which have DtoAs. The C8051F020 is a good all around controller. It is more expensive than a PIC but it has everyting you could want built in and great AtoDs. Their Dev kits are also super easy to use.

Brent

You can use a simple R2R ladder DAC, if you have the spare output pins, or use PWM to generate an analogue voltage using just one pin.

I had that done once with a 16F84 and two serial ADC (TLC0831) and a serial DAC ( TLV5620CN) both from Texas Instrument. I was using the 16F84 because I had it readly available... a better option would be a PIC16F877 with its ADC and then use the above DAC.

Problems you might encounter. When using a 5V reference with a 8-bit ADC you have a steps of 0.019V. So 0.019V = 1 and 0.39V =2 and so on. Well say you have a 110 and a 6 as your two numbers. If you wanted to divided 110/6 that will give you 18.33 right.... but since only integer math can be done the result will be 18. So happens that a 113/6 or 112/6 or 111/6 or 109/6 or 108/6 will yield the same result. So for voltages of 2.05V to 2.14V (108 to 113) you will have the same result of 18 (in a 8-bit DAC would be 0.342). same would happen with say 195/15 will yield the same value for (196 to 209)/15. Or no change in output for 3.705V to 3.971V when dividing by 0.285V.

Good Luck

Ivancho

ivancho said:
Problems you might encounter. When using a 5V reference with a 8-bit ADC you have a steps of 0.019V. So 0.019V = 1 and 0.39V =2 and so on. Well say you have a 110 and a 6 as your two numbers. If you wanted to divided 110/6 that will give you 18.33 right.... but since only integer math can be done the result will be 18.

The answer to the maths is to scale it, you could use 16 bit maths, or even 24 or 32 bit. By scaling the input (to calculate 11,000/6) you get a result of 1833 - knowing full well the decimal point should be two digits in. You simply display the result placing the decimal point where it should be - integer maths, giving floating point results (very quickly and accurately).

You use a similar method programming a PC as well - it's far better to use integer maths where you can.

Nigel Goodwin said:
You use a similar method programming a PC as well - it's far better to use integer maths where you can.

depends, pc's x87 are faster in calculating complex floating point math then the main ALU is at integers
On a µC, ofcourse, FP should be avoided

Exo said:
Nigel Goodwin said:
You use a similar method programming a PC as well - it's far better to use integer maths where you can.

depends, pc's x87 are faster in calculating complex floating point math then the main ALU is at integers
On a µC, ofcourse, FP should be avoided

And on a PC as well - floating point tends to provide answers like 9.9978675646352377378 - when it should be 10. It's far easier, faster and more accurate, to scale the values and use integer arithmetic - particularly for financial calculations.

Why not consider an analog multiplier? Depending on the polarity of the signal, you might get away with a two-quadrant multiplier. At most you will then need an amp stage to scale the output.

The problem with scaling is that while it works well with displaying on LCD, etc it is not so good when sending it to a 8-bit DAC. You are still going to need to send a 0-255 number, and when you scale back down you are doomed again :evil:

If you were to use a 10-bit DAC then you will not have the perfect relation ship between the division result and what you need to output.

Ivancho

ivancho said:
The problem with scaling is that while it works well with displaying on LCD, etc it is not so good when sending it to a 8-bit DAC. You are still going to need to send a 0-255 number, and when you scale back down you are doomed again :evil:

If you were to use a 10-bit DAC then you will not have the perfect relation ship between the division result and what you need to output.

Ivancho

I'm sorry, I don't see the problem with scaling?.

If you are using the same hardware, scaling the calculations (instead of using floating point) will give a faster, more accurate, result. The resolution of any DAC converter is irrelevant to the calculations them selves. Obviously the final output has to be scaled to fit the hardware, but that applies however you do it.

This is the way I see it. 8)

Say I have a 8-bit ADC1 that gives me a value of 196 after conversion. And a second ADC2 that outputs a 15. You are to devide both of them and spit it out to a 8-bit DAC. So scaling is good to get rid of the floating point problem.

Lets scale 196* 100=19600. Now we use the unscaled version of ADC2 15. So now instead of having 196/15=13.06, we have 19600/15=1306

Now if you were to show this result on a LCD, the scaling would have helped. But if you are going to output the result to a parallel 8-bit DAC, what do you do? You can only convert numbers from 0-255, so what happens you still have to get rid of the decimal point. Going back to the problem that I mention in my past post. :?

You could then go to a 10-bit DAC so you have more resolution. (But that changes the problem if you only have 8-bit DAC on hand). Now with a 10 bit resolution DAC your 13.06 is equivalent to a 52 = (13.06*1024/255). The difference here is that a ADC conversion of 200/15=13.33 would yield an equivalent 10-bit number of (13.33*1024/255) = 53 for the DAC.

So the range of ADC conversions that might give you the same result when dividing has been reduced. But you still have 197/15 giving you the 10-bit equivalent of 52, the same as your 196/15 and 195/15. But these are only 3 numbers instead of the 15 numbers that would yield the same result if a 8-bit DAC was used. If you can live with that, then no problem.

I might not see how the scaling would help in this context, pehaps I am overlooking something? I know that it will help you work without using a float point, but at the time of outputing you will need to scale back and have the same problem.

Ivancho

I see what you mean, but it's not a problem with scaling, it's a hardware problem that that will occur however you do it. To overcome it, you would need a 16 bit resolution DAC.

However, I don't see it as much of a problem, using an 8 bit DAC gives you better than 0.5% accuracy, your inputs from the 8 bit ADC's are each the same accuracy as well. Do you really need to try and better that degree of accuracy? - particularly when these figures are only theoretical ones based on the resolution of the DAC and ADC's, and won't be that accurate in practice.

A quick extra thought! - you could use two 8 bit DAC's, and feed their outputs into an opamp mixer. By carefully setting the gains of the two channels (one 255 times that of the other) you could make a 16 bit resolution DAC.

However, as I mentioned before, the accuracy of the parts isn't going to be high enough to make it worth while.

Status
Not open for further replies. 