Voltage Reading
John Whitfield
Posts: 42
Does anyone know of a good method for taking a voltage measurement with the SX, or are you limited to TTL/CMOS voltages?
Comments
The sx has an analog comparitor on ports RB.1 & RB.2.
If you are not familiar with a comparitor, a typical use is to set one pin at a known fixed voltage and feed the unknown voltage to the other pin.
Depening on the value of the unknown voltage being greater than or less than the fixed voltage, the SX will return a logic 1 or 0. An ouput pin, RB.0 can also be linked to the result of the voltage comparison.
All you need is two resistors and a cap to make an 8-bit ADC.
The technique is basically PWM in reverse.
http://www.sxlist.com/techref/ubicom/lib/io/adc_vp.htm
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"It's not getting what you want, it's wanting what you've got."
·
To measure 0 to 5 volts I would use 100K input resistor, and a 100K feedback resistor.
For 0 to 24 volts I would change the input resistor to (24-2.5)*(2.5/100,000)=860,000 ohms
For 0 to 48 volts the input resistor would become (48-2.5)*(2.5/100,000)=1,820,000 ohms
For an 8 bit conversion, the scale will be linear from 0 to FF in all cases, where FF represents the count at full scale.
Cheers,
Peter (pjv)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!