I'm working on a project where I need an output voltage proportional to the input, but I know I cannot use a negative input. What is the best way I can "shift" my input voltage from -2.5V to 2.5V to 0-5V?
The device I'm using to get that input voltage has a gain built into it, meaning I could make the input range be -25V to 25V... would it be better (in terms of staying proportional) to use this function, and use a voltage divider?
Also, what is the best way to protect the Arduino, in case I end up with an input outside of that -5V range? I'd like to bring my input as close to 0-5V as possible, but the device (it records EMG signals / muscle activity) is somewhat sensitive and can bounce outside of our range (of -2.5 to 2.5V) if it bumps into something. Would a 0V Zener diode and 5V Zener diode be enough? (I'm not too sure how these things work - I was told to look into them, but I was wondering if you guys knew a better way or if that's the best)
Use two 10K resistors from +5 to Gnd, the junction sits at 2.5V, use that as input to the ADC.
Take the EMG signal thru a 1uF cap to the 2.5V junction.
Play around with cap value, resistor value, if results aren't as expected.
Or, use a summing op amp, and add 2.5V DC offset to it.
A summing amplifier would probably be more precise than the resistor method. But, if you are "smart", you should be able to "calibrate-out" any errors or small offsets in software...
A 2-input summing amplifier is an op-amp and 3 resistors. But a single-stage summing amplifier inverts the signal, so you need a 2nd op-amp (or a dual op-amp) and 2 more resistors for another inverter-stage. And the op-amp, will need plus and minus power supplies to handle the inverted & shifted/biased voltage, and to make sure that you can go all the way down to zero-volts.
It would be a good idea to adjust your resistor network (or the gain of the amplifier) to allow for a slightly larger voltage range than you need (maybe +/- 3V or so). I don't know about the Arduino ADC, but typically, if you try to use the full-range of an ADC, you can get anomilies near the limits (0V & 5V). For example, if you have a -10mV input-offset error, you won't read zero 'till you input +10mV. Or, if your 5V supply is actually 4.9V, you might not read accurately above 4.9V.
Also, what is the best way to protect the Arduino, in case I end up with an input outside of that -5V range? I'd like to bring my input as close to 0-5V as possible,
A regular diode wired "backwards" to +5V, so that any input voltage above 5V* will "turn-on" the diode, "shorting" the "extra" voltage to the 5V supply. Another diode wired "backwards" the other way to ground will "short" any negative voltage to ground. (You need some resistance in series, so that these "shorts" don't draw excess current from whatever's connected to the input.)
*It actually takes 0.5 to 0.7V to turn-on a silicon diode, so with the diodes you can get from -0.7V to +5.7V into the Arduino. But, that's safe.