Subject
- Posted on
March 9, 2007, 5:16 pm
The venerable ADC0831 is only a couple bucks, but it is only 8-bit. A
decent 10- or 12-bit version shouldn't be that much more. These basic
chips use simple serial to keep things cheap.
You can also do it with an input capture timer, a resistor, and a
capacitor. It's not as accurate, but it works for simple tasks. Another
way is to use a 555. There are a number of ways to implement this.
Search the Web and you'll find examples. This is basically how the PC
gameport works. Here is just one page of many that discusses it:
http://english.cxem.net/comp/comp184.php
Take a look at the following PDF on the Parallax site for some ideas:
http://www.parallax.com/dl/docs/books/edu/baad.pdf
They provide the book with an A2D kit they sell. The kit is intended for
the BASIC Stamp, but the concepts are the same.
-- Gordon
Re: reading analog signals on a MCU with only digital I/O
Thanks, that's a good start. I see there's also an ADC0834, which is
still 8-bit but offers 4 channels, for $9. That's not too bad.
Sounds like the voltage-to-frequency converter idea I had shortly after
my first post. I'm currently reading over the data sheet for the LM231,
which is under $5. The thing I like about this approach is that it
should be dead-simple to use from the ARMexpress, which has a PULSIN
function for measuring an input pulse width. That should make getting a
value from it a one-liner.
(The same technique would work directly with the TSL230 Light to
Frequency converter too, if one had need for such a thing.)
But I haven't yet worked through whether this would actually be faster
than a serial interface.
Hey thanks, that's very neat! It's just at my level. :)
So the BASIC Stamp doesn't have analog inputs either? That surprises
me. But if so, it puts the ARMexpress in good company, and means I
should find lots of other people who have already solved this problem.
Thanks,
- Joe
Re: reading analog signals on a MCU with only digital I/O
Since the ARMexpress is something of a BASIC Stamp "compatible" device
you may want to read up on the documentation for the chip before
spending much more time on this. I think you'll find that like the BASIC
Stamp it supports an RCTIME statement that does exactly what the BASIC
Stamp does with the resistor/capacitor (hence "RC") measurement.
There's not a lot of accuracy with this approach, but it's not bad for
many tasks. For most anything else there are plenty of ADC chips out
there. This is a well-travelled road.
-- Gordon
Re: reading analog signals on a MCU with only digital I/O
Seemed like it must be. I did indeed see RCTIME in the documentation,
but it didn't sound relevant. It says "Measure the time which pin
remains at *level*, returning the value to variable." It sounds the
same as PULSIN, except that it applies when the pin is already at the
specified level (low or high), whereas PULSIN waits for the next
transition to that level before starting its measurement.
But both RCTIME and PULSIN seem to measure the time at which a digital
input remains in a given state. How does that help me with analog
sensors?
An attempt to answer this very question myself (adding RCTIME to my
search terms) did turn up these, which look helpful:
<http://www.emesystems.com/BS2index.htm>
<http://www.emesystems.com/BS2rct.htm>
I think I see now -- this doesn't have its own resistor/capacitor
circuit inside the chip; instead you set up your own R/C circuit in such
a way that you can pull the pin low (discharging the capacitor?), and
then let it charge up again in a way that the charging time depends on
the voltage or resistance you're trying to measure. The RCTIME function
will then return how long this took to cross a threshold indicating a
digital "high" state. Clever!
I'll have to play with this a bit, but it sounds like a promising
approach when minimizing the component count is desired. Thanks again!
Best,
- Joe
Site Timeline
- » Speech & Other Delays
- — Next thread in » General Robotics Forum
-

- » Re: reading analog signals on a MCU with only digital I/O
- — Previous thread in » General Robotics Forum
-

- » evoMUSART 2013: First CFP (with correct dates)
- — Newest thread in » General Robotics Forum
-

- » Heat pump refrigerant change to R-22 substitute
- — The site's Newest Thread. Posted in » General Metalworking
-

- » DCC sound question
- — The site's Last Updated Thread. Posted in » Model Railroad Forum
-







