Introduction: Taking Negative Analog Input in Arduino or Any Other Micro-controller.

Taking a negative input into Arduino is necessary sometimes. However Arduino takes only positive voltages at its pins. The method elucidated below takes both negative and positive values and sends them to Arduino along with the sign information. The idea is to take both the original input and an inverted one and select one of them using a multiplexer. So we can get the positive input as it is and the negative input in an inverted form. The sign can be determined using the output of a comparator which is subjected to the same input as the differential amplifiers.

Step 1: Differential Amplifier

The circuit uses two differential amplifiers. The circuit for both is exactly same. but the input given is opposite.

(V1-V2 to one and V2-V1 to other). I have used LM358 op-amps to make differential amplifier part. So we now have two imputs one an inverted one and the original one. How to choose between them is given in the net step.

Step 2: Comparator Circuit

Comparator is used to determine the sign of the input (negative or positive). A comparator can be made using a simple op-amp. Just give positive feedback(i.e. connect the output terminal to non-inverting terminal of op-amp) using a high resistor. I have used 1Mohm 1K or 220 ohm shoud do the job too. Give two inputs (V1 and V2) to the comparator. V2 to non inverting terminal and V1 to inverting terminal. The comparator gives output zero if the V2-V1<0 and Vcc if V2-V1>0. The output of the comparator is also used as an input of the multiplexer(CD4053).

Step 3: Multiplexer

Now we have three wires :an actual input, its inverted counterpart and sign of the input. These three can be directly connected to the controller and the correct input can be selected in code (digitalRead() the sign input) or if conserving a pin is of importance CD4053 mux can be used. Its connection to the rest of the circuit are as follows.

pin11 (select line of A) ------------------------- Sign / comparator output

pin12 (X0)------------------------------ V1-V2/output of first op-amp.

pin13(X1)--------------------------------V2-V1/output of second op-amp.

pin14(X)---------------------------------input of the micro-controller/ADC.

Step 4: Negative Supply and Edits to the Design.

In the above design I have set the gain of differential amplifiers to around 0.22 because I required a larger range. This value can be changed by altering the resistors in the differential amplifier.

One problem that might cause trouble to some is power supply to the op-amp. Op-amps generally require +Vcc and -Vcc to work properly. Here however a large negative output is not required from the op-amp so even +Vcc and 0 would work unless one has to measure voltages less than 0.5V (in this case the op-amp saturates). However, even if you require to measure small voltages a regulated -Vcc is not required even a small (and unregulated) negative voltage would do the job. A circuit for this can be found here: Build your own negative supply.

If a regulated negative supply is required then this can be done using 7905 regulator.

Comments

author
DIY Hacks and How Tos made it! (author)2017-07-02

Great tutorial. Very well explained.

About This Instructable

166views

8favorites

License:

More by HarshC17:Taking Negative Analog Input in Arduino or Any Other Micro-controller.
Add instructable to: