Ok, so I wanted to make an ohm meter with the readadc command. I have some code, but it returns values that aren't expected. Here is my code:
It's entirely possible that my calculations are completely wrong; I probably need another person to look at my code. Thanks in advance.
PS my circuit goes like so:
symbol adcpin = 4
symbol adcval = b1
symbol voltoadc = b2
symbol voltognd = b3
symbol diff = b4
symbol ohms = b5
'********** Voltoadc calculations not yet working
ReadLoop:
readadc adcpin, adcval 'Read incoming voltage
voltoadc = adcval / 5666 / 100 'Convert it from a value between 0 and 255 to a value between 0 and 5
voltognd = 46/10 - voltoadc 'Figure out the voltage going to ground
diff = 10000 / voltognd 'Figure out the ratios
ohms = voltoadc * diff 'Ohms
'sertxd (#ohms," ohms",cr,lf) 'Transmit ohm value
sertxd ("ADC Value ",#adcval,cr,lf)
sertxd ("Volts to ADC pin ",#voltoadc,cr,lf)
sertxd ("Volts to ground ", #voltognd,cr,lf)
sertxd ("Ratio difference ",#diff,cr,lf)
sertxd ("Ohm value ",#ohms,cr,lf)
sertxd (cr,lf)
pause 4000
goto ReadLoop
It's entirely possible that my calculations are completely wrong; I probably need another person to look at my code. Thanks in advance.
PS my circuit goes like so:
+4.5v
|
|
[] Unknown resistor
|
--------------ADC Pin
|
[] 10k resistor
|
|
GND
Last edited: