Nyame hi, thanks, I see you did post the diagram in another post as well. I really don't like the way they are doing this. Your results are correct in that your ratios are correct. Let's look at what's going on here.in the first case in your table, you only have the 40K resistor in circuit. This is actually 47K you say. Now the feedback resistor across the opamp (you have shown 450 ohms) is probably 470 ohms? So the gain of this circuit would be -(470/47000) = 0,01. if this is the case then since your output was -0.083 mV your battery voltage would be 8.3 volts.Now lets take the case of your second line. The gain of the circuit would be -(470/22000) = 0.1236. Multiply this by your battery voltage of 8.3 and this gives us 177.3 mV - within half a percent of your measured 178 mV. (I'd guess you were using 1% resistors?)You can do the same calculations for the other cases and your results should be accurate. So how would I teach this better?Well for starters this is a digital to analog converter. Each switch will have a "weighting" showing how much it will affect the output. And each resistor should be an exact multiple of the feedback resistor - 100x, 200x, etc. You can do this easily. Make your feedback resistor 400 ohms exactly. You can do this easily with a 390 ohm and a 10 ohm resistor in series. Then make your switch resistors multiples of this as follows
40K - 39K + 1K in series. Weighting = 1
20K - 2 x 10K resistors in series Weighting = 2
10K - one 10K resistor Weighting = 4
5K - 2 x 10K resistors in parallel Weighting = 8
How do we get the Weightings? Well the 40K resistor will let one "unit" of current through. The 20K resistor is half of that so will let through twice as much current - 2 "units", the 10K will let through 4 times as much and the 5 k will let through 8 times as much current.So we can now calculate the gain of the circuit very precisely. we jsut add up the weigntings of the resistors that are switched in and multiply it by 0.01 (because our 400 ohm feedback resistor is 0.01 of the 40K resistor. So our table will now look as follows:
The weighting is a very important concept with Digital to analog converters (DACs) because it lets you calculate your output very easily. As above it will be - (sum of weightings) x 0.01 x input voltage (in this case the battery voltage).You were asked to ignore the sign of the voltage (they will be negative) so I have too.if your weighting is 1, then your output will be 1 x 0,1 x 9V = 90 mVin your third row the weighting is 4, so output - 4 x 0.1 x 9V = 360 mVin your 4th row you have weightings of 8 and 2, the sum of these is 10, sooutput = (8+2) x 0.01 x 9V = 900 mv
Another improvement I would make would be to make the input a precise voltage - say 5 volts which you could get from a 7805 or 78L05 voltage regulator IC. The your results would be more predictable because they would not depend on a battery voltage which might not be exactly 9V - in your table your outputs would then be 50, 100, 200 and 500 mV. In real life DACs a voltage reference is used like this to ensure that the output is very precise.Let me know if all this is clear or if you need more explanation.Cheers // David