Continue to Site

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.

  • 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.

R2R Digital to Analouge converter

Status
Not open for further replies.
oh ! So how does one choses resistance to generate sine wave ?

Hi,

Well to start with it might be impossible to use the binary output of the counter directly, but using say a 1 of 10 decoder you could use separate resistors for each step, counting from 0 to 9 and then back down to 0, then switch the sign of the output and repeat the entire count again.
To get the resistor values you have to think about what resistor value would give you sin(10 degrees) for the first step, sin(20 degrees) for the second step, etc., until you reach 90 degrees and then counting down will give you the second 90 degree part of the sine wave.
With a 1k output resistor for example and a 5v power supply, sin(10)=0.1736 so you can use this equation:
Vout=R1/(R1+R2)
0.1736=5*1000/(1000+R2)
Solving for R2 we get:
0.1736*(1000+R2)=5*1000
1736+0.1736*R2=5000
0.1736*R2=5000-1736
0.1736*R2=3264
R2=3264/0.1736
R2=18802 ohms
That would be the resistor for the 10 degree step, and you could work out the resistors for the other steps the same way.

This assumes open drain outputs just for this example. If you dont use open drain outputs (or analog switches to switch the resistors in and out) then you have to include the effects of all the other resistors in parallel to ground as well, which would lead to a different value resistor or no solution. This gets pretty hairy on the calculations for all the resistor values if the outputs go to ground when not selected. For example here are resistor values for a step every 18 degrees:
R1=4346.4413514837
R2=2285.05944547612
R3=1660.19286615875
R4=1412.24440361823
R5=1343.12424266248
R6=1k (always to ground never selected)
To get those values required solving a set of 5 equations in 5 unknowns.
The workings go like this:
For 0000, all the resistors are in parallel to ground.
For 0001, only R1 goes to +5v, the rest go to ground.
For 0002, only R2 goes to +5v, the rest to ground.
etc., up to R5 which causes the peak voltage output of 1.000 volts (this is when R5 goes to +5v and R1,R2,R3,R4, and R6 go to ground).
This would require a CMOS 1 of 10 decoder or something like that where the outputs go rail to rail. To compensate for non rail to rail we'd have to do a little more work.
The resistor values above do scale well however, so if R6 is increased 10 times (to 10k) then all the other resistors increase 10 times too,
so for example R5 would change to 13431 ohms.

Of course if you could make them all variable you would be able to adjust on the fly.
 
Last edited:
indeed very helpfull post. let me do some work before i post another query again !
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top