Depending on what you want to do, you are not limited to TTL/CMOS.
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.
You can use the so called "bitstream" Analog to digital conversion technique.
All you need is two resistors and a cap to make an 8-bit ADC.
The technique is basically PWM in reverse.
Right Terry, and what's more, you are NOT limited to reading 5 volts. With proper resistor ratio selection the input can be any voltage you want, although for safety I would probably not go beyond 48 volts.
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.
http://www.sxlist.com/techref/ubicom/lib/io/a2d.htm has a number of methods·and some links to other parts of the site were the front end·(conditioning the·signal for greater range or sensitivity) is discussed.
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!