processing +/- 5V sensor input

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jbaylor
 
Posts: 4
Joined: Tue Dec 28, 2010 5:15 pm

processing +/- 5V sensor input

Post by jbaylor »

Hello,

I have absolutely loved playing around with the Arduino, which was introduced to my by your site. I have a couple of Uno's, your prototype shield and wave shield and have learned a lot from the tutorials. Thanks! These inspired quite a lot of creative play with my 7 year old son and me. I have degrees in mechanical and aero/astro engineering and have written software professionally, but my electronics knowledge is limited to an EE's first class in circuit analysis and my own casual hacking. Electronics is still a bit of magic, but this is making it more clear.

My son and I are working on our third robot, a pumpkin which will drive up to doors, says "trick or treat" and then "thank you, happy Halloween". We have most of it working, but ran into a road block that seems like it ought to be easy, but I cannot get through it. We have a salvaged receiver board which we are using for our PumkinBot's motion control. The trouble is that its output is +/-5 volts, but the Arduino's analog pins take 0-5 volts. My son thought to use two analog pins and diodes so that we could read the negative voltage in one pin and the positive in the other. This works nice on a bread board with LEDs, but translating this to the Arduino is beyond us. Could anyone give us a hint at what we could do next in our experimenting? If someone has a solution already, would you point me to the schematic?

BTW, we are powering the receiver board with the Arduino so we are less likely to over load any pins.

Thanks in advance for any advice!
Jeff

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: processing +/- 5V sensor input

Post by adafruit_support_rick »

Sounds like you want to build half a diode bridge to rectify the negative going pulses into positive-going pulses (you could make this out of LEDs for some additional blinking lights). There is no "translation" to arduino. You simply use the hardware to rectify the negative-going pulses to positive-going pulses. Use one digital input for the positive pulses, and another digital input for the rectified negative-going pulses.

User avatar
jbaylor
 
Posts: 4
Joined: Tue Dec 28, 2010 5:15 pm

Re: processing +/- 5V sensor input

Post by jbaylor »

Thanks! I did not think to use four diodes in combination like that. Very nice.

'Translation' was a poor choice of words. I meant to say that I could not take what we thought we had working on a breadboard to light up LEDs depending on the sign of the voltage to work with our Arduino.

As I got the notification of your reply, I was writing a followup post to ask if a voltage divider would work. Two equal resistors in series connecting the input voltage (-5 to +5) to the Arduino's 5V pin. Then connect an analog pin between the resistors. Would that work as well? I found a reply to a similar forum post I had previously missed which suggesting something like this, but with a much more succinct description ("Use a 1:1 resistor divider."). My expansion of this is filtered through my ignorance, so I might have misunderstood what the answer meant.

Thanks,
Jeff

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: processing +/- 5V sensor input

Post by adafruit_support_rick »

I think what the resistor divider solution is looking at is the difference between +5 and -5. If you think of the -5V signal as being equivalent to ground, then the +5V signal is equivalent to +10V. If you put in a 1:1 resistor divider, then you'll see -5V as 0V, 0V as +5V.

Essentially, what it's doing is remapping -5V to GND, and GND to +5V. The voltage difference in both cases is 5V.

The diode solution does the same thing. It remaps -5V to GND, and GND to +5V by simply swapping the leads The diodes are there to prevent the real +5V signals from entering the swapped leads.

To do what you want, you would essentially split the diode bridge in half. Use two diodes to pass +5 and GND to one digital input while blocking -5V. Use the other two diodes to pass GND and -5V to another digital input while blocking +5V signals.

Use the first two pictures in the wikipedia page as a guide. You basically want one of each. Where the diodes are grayed out, you simply don't use any components or connections, and so you only need two diodes for each.

User avatar
jbaylor
 
Posts: 4
Joined: Tue Dec 28, 2010 5:15 pm

Re: processing +/- 5V sensor input

Post by jbaylor »

Thanks! I got the diode bridge set up as you suggested and it works great! It took me awhile because I forgot the pull down resistors, but all works well now. I had a very excited 7 year old jumping up and down watching the serial monitor while toggling his the remote control. That was the last technical challenge for our project. We are putting it on perf board tonight.

I sure appreciate your help.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: processing +/- 5V sensor input

Post by adafruit_support_rick »

You're welcome. Glad to hear you got it working! :D

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”