Categories

How to read several infrared sensors using one MCU pin

Posted on Sunday, January 22nd, 2012 in how-to, Interface, robotics, sensors, techniques by the machinegeek


Oscar has written an article describing a technique he’s used for reading multiple analog sensors with one MCU ADC pin. He was designing a line-following robot and wanted to read several infrared sensors without having to dedicate an analog read pin for each. His solution uses “a Schmitt trigger inverter whose output has resistors connected in a series of different values attached to a common point. From this point the voltage value is measured, which will be different depending on the active sensor, being able to know the position of the robot.”

You can find the complete explanation of Oscar’s project on his website. Note that this is a multi-lingual post.

Via the contact form.

This entry was posted on Sunday, January 22nd, 2012 at 7:09 am and is filed under how-to, Interface, robotics, sensors, techniques. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

5 Responses to “How to read several infrared sensors using one MCU pin”

  1. rsdio says:

    With binary weighting, this could almost correlate each input pin with a bit in the A/D result, although it would probably require 10-bit A/D and some smart quantization.

  2. mike says:

    if all you want is a binary value then why not attach these 8 sensors to a 74HC165N or similar and then read the incoming byte? 00010000 will mean sensor 4 crossed the line.

    • rsdio says:

      A/D needs only 1 pin, the 74HC165N needs at least 2 for clock and data. In that respect, this idea can prove useful.

      However, if you read the entire web site he suggests using the ADC0831 and in that case you’re absolutely right, Mike. There’s no point in using this hack when you’re adding an external chip that requires a couple of pins to interface. It makes way more sense to add a parallel input shift register instead of dealing with fuzzy resistor values.

  3. Colin says:

    From his website, roughly translated:

    Having to use I2C (2 pin) or SPI (4 pin) and we are losing the advantage of handling a single pin, in addition to communications that these buses have to send and receive commands and data, so you get the status of sensors is not so straightforward. However, the I2C is a good option for when you have an analog pin as it would be fast enough to not take a PID control and would use only 2 pins.

  4. mike says:

    That’s true.

    I guess I’ve been looking at i2c chip data sheets so much lately, I can’t imagine anything without that bus in use.

Leave a Reply to Colin

Click here to cancel reply.

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • Joe Desbonnet: Ya, I can recommend the low melting point solder. I used brand 'ChipQuik' and it's amazingly easy to use.
  • Jerome: I need a new BusPirate for the Fablab ;) Many thanks!
  • Max: Seems like an unexpectedly violent way to remove the chip indeed. A hot air station should of course do the job just fine, but in...
  • jose: Part removal described here is pure butchery, the cheapest hot air station will do a fast and clean job removing the QFP, heat air to...
  • Cody: Yes please