I wanted to make a volt meter for the NXT, but it needs a good reference voltage to get accurate results. I currently have an LDO regulator connected to the PICAXE to measure the reference voltage, so that will work.
Instead of only measuring voltages between 0 and reference, I want to be able to measure up to at least 24v, safely. I concluded that I should use a resistor voltage divider. If I use a 1k pulldown, and a 10k pullup to the probe, I should be able to safely measure up to about 50v (based on 4.5v reference). I should get resolution of about 50 / 1023, or about 0.05v, which is certainly good enough.
Here is pseudo code to convert the RAW ADC value into the voltage:
Volts = Reference volts / max ADC value * RAW ADC value * ((PULLUP + PULLDOWN) / PULLDOWN)
Or with the actual values I am using (based on a 10-bit ADC, with a 1k pulldown, and a 10k pullup):
Volts = Reference volts / 1023 * RAW ADC value * ((10000 + 1000) / 1000)
Which can be condensed into:
Volts = Reference volts * RAW ADC value / 93
Here is the schematic for the 20X2 with LDO and voltage divider:
I don’t have a zener diode, but the circuit should have one. It should be 5v, and be in parallel with R3. Because I don’t have one to protect the 20X2 from over-voltage I used a 4k7 resistor (R5) as potentially a little protection.
R3 and R4 values can be changed for different voltage ranges (and precisions). I happened to have 1k and 10k 1% resistors, so that’s why I chose to use those values.