Let's Make Robots!

How to use two analogue devices with only one analoque input?

For now it's theory, it's for a future evolution of a future project (yeah i know that's two "future")
Ok actually i'll need 3 analogue inputs (one SRF05 ultrasonic rangefinder and one 2-axis accelerometer), but the 18x picaxe chip has only two. So basically, i need to find a way to share one of the inputs. As i won't need to read the all inputs at the same time, maybe it's doable.

So two ideas came to my mind, each one with its pros and cons.

First idea : a SPDT relay.

With that, two solutions :

  • Connect it to the V+ of each sensor to switch them on and off (so when the srf05 is on, the accelerometer is off and vice versa).
  • Connect it to the analogue input so i can choose which device use the input.

The first of the two solutions has the advantage to use less power since only one device is on at a given moment.

Pros :

  • Use only one output af the chip to control the relay.

Cons :

  • A relay takes some space (compared to a small component).
  • They're a bit expensive (not that much i know but still)
  • Looks like most relays use 12v. The less i found was 5V (and it was pretty hard to find), but i feed my chip with 4.8V so i don't know if it'd work.

Second idea : transistors switches (as explained here)

Again two solutions :

  • Switch on/off the devices.
  • Decide which one use the input.

Pros :
    Transistors are cheap, i already have plenty of them.
    They're small.

Cons :
    Because they don't act like SPDT switches, i'll need two, so it'll use two outputs of the chip. (Which actually is not really a big deal).

Ok i hope you understood, they're just ideas, i'm not very good at electronic so maybe i'm completely wrong... that's why i submit that to you! Feel free to tell what you think about that, or if you have other ideas, or maybe if you already have solved that problem a long time ago!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

"So Analog? the SRF05 is a digital device and not Analog, its signal is a digital pulse whose width is proportional to the distance to the echo"

Well... that changes everything! I don't know why, i was sure that it was analogue... maybe because the result is not 0/1... but it's true that we don't use a readadc but a pulsin... At least i know more now, thanks for the clarification!

Hello TotoroYamada,

 Forgot to mention, probably obvious anyway, If you mux the PIN's you will need a little code for the Accelerometers, after the switch you need to wait for the start of frame

The SRF05 can be controlled with one or two pins, it is covered in the datasheet.

why not just use a multichannel adc? adc0834?