We use an ADC very frequently. Input range of an ADC is normally 0 to +5V. Atmega AVRs contain typically many 10bit ADC channels (6 for atmega8 to atmega328 and 8 channels for atmega8535). The designer faces a problem when (s)he has to sense an ac signal.
The ac signal must be processed before connecting to the ADC channel, such that its shape is retained but magnitude lies in the range 0 to 5V. The following circuit is useful to shift the level of the ac signal as desired.
- When the input is -2.5V, we need the output as zero, so that any voltage greater than -2.5 will be above the value 0V and is eligible for connection with the ADC input.
- Select the value of resistors R1 & R2 such that, the potential divider between Vin and +5V will produce 0 Volts at the non-inverting terminal.
- In the above case, it is: R1 = 10k and R2 = 20k
- We can change the resistor values to suit the voltage added to the non-inverting terminal.
Also notice the following facts:
- Op-amp is LM324. One of the 4 op-amps is used here.
- LM324 is single supply rail op-amp. No need to use +Ve and -Ve supply.
- Considering the saturation voltage equals 85% of Vcc for this op-amp, we use 6.2V for the op-amp power supply. This makes it possible to accomodate full range of wave shape at the output.
- The op-amp is also improving the output impedance of the signal source.