3
\$\begingroup\$

I'm using the ADC on an ATtiny24 to record a AC signal. The ADC has a range from 0-3.3V. I'm using a precision rectifier to get rid of the negative portion of the signal. I've attached a picture of the circuit I'm using for the rectifier. I'm using an LMC6484 as the op-amp with 3.3V to the V+ rail and 0 to the V- rail. I'm using 1N4004's as the diodes and 10k for the resistors.

My logger is able to graph the waveform of the rectifier very well. BUT the oscope shows that the output of the rectifier varies from -0.5 to 1V. But my micro shows a signal with the same waveform that goes from 0-1.5V! If I replace the precision rectifier with a simple diode/resistor combination, I get a waveform that varies from -0.X volts to Y volts (depending on the input through the function generator). The micro follows the shape of the waveform correctly but the voltage range is from 0.X to Y volts.

I always have a little bit of a negative signal even with the precision rectifier and when I graph the results through my logger, it appears that the largest negative value has been moved up to zero, so I seem to get a larger range than the input.

Is this a result of putting in negative voltages into my ADC? Does it take the negative voltages, set that as 'ground' with respect to other voltages?

I've input positive voltages into the logger through a power supply, and it reads those voltages perfectly! It follows the shape of the waveforms very well too. The only problem seems to be the range. I'm completely lost.

enter image description here enter image description here

\$\endgroup\$
  • 1
    \$\begingroup\$ The small negative voltage is probably from a diode drop. No, the A/D isn't going to convert negative values and then make the most negative the zero reference somehow, although a external circuit could do that. Show a schematic of your circuit. \$\endgroup\$ – Olin Lathrop Jun 1 '12 at 15:08
  • \$\begingroup\$ en.wikipedia.org/wiki/… \$\endgroup\$ – Nevermored Jun 1 '12 at 15:12
  • \$\begingroup\$ That is the circuit I'm using. It doesn't seem to matter WHAT circuit I use: a simple diode and resistor circuit results in the same problem. The shape of the waveform is very good but the output from the rectifier circuit seems to be moved up somehow. I wish I could attach pictures, I have one from an oscope and a graph from the resulting log. :( \$\endgroup\$ – Nevermored Jun 1 '12 at 15:15
  • \$\begingroup\$ Any chance you have the settings wrong on your oscope? \$\endgroup\$ – Kellenjb Jun 1 '12 at 15:25
  • 1
    \$\begingroup\$ Is the signal AC coupled? The op-amp's input impedance will change as it goes in and out of common-mode. \$\endgroup\$ – markrages Jun 1 '12 at 16:38
7
\$\begingroup\$

Your scope is set to AC coupling.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ +1 Sure. This must be it. Looks like I didn't read the question :). // @Nevermored, if the V- supply pin of your opamp is at the same voltage than its non-inverting input, you don't need the diodes. Just let the opamp clip the output. Even without diodes, the opamp is not able to produce negative voltages. So, it will still give you the positive portion of the signal. There is a speed penalty, but at 50 Hz, you won't notice anything at all. \$\endgroup\$ – Telaclavo Jun 1 '12 at 21:42
2
\$\begingroup\$

Last data for AC signal:

  • [0 to 50] Hz.
  • [-22 to +22] V.

If the AC signal can go down to 0 Hz, and you need to capture it, but with no special reason to rectify it in an analog way, you can do something like this:

Schematic

This way, you don't need diodes, or opamps. If you really need to rectify it, you can do it in the digital domain (by firmware).

The equation \$V_x=f(V_{in},R_1,R_2,R_3)\;\$ is:

\$V_x=\dfrac{R_3(3.3R_1+R_2V_{in})}{R_2R_3+R_1(R_2+R_3)}\$

Known data: \$V_{inMin}=-22\;V\$, \$V_{inMax}=22\;V\$, \$V_{xMin}=0\;V\$ and \$V_{xMax}=3.3\;V\$.
Equations: two.
Unknowns: \$R_1\$, \$R_2\$ and \$R_3\$.

You may freely choose one of the three unkowns, and the other two will be set by your known data and the two equations.

So, for instance, if you freely choose \$R_1\$, you may end up with:

R1= 3.3 k\$\Omega\$
R2= 495 \$\Omega\$
R3= 582 \$\Omega\$

With this, a [-22 to +22 V] Vin range will be mapped into a [0 to +3.3 V] Vx range.

\$\endgroup\$
  • \$\begingroup\$ I don't actually need all of the signal. I just need to see what kind of voltages the signal is producing. I don't know what I'm lowest frequency is since it is variable. It will go anywhere from 0-50Hz. Why do you suggest I not rectify the signal? \$\endgroup\$ – Nevermored Jun 1 '12 at 15:23
  • \$\begingroup\$ Well, if it can go down to 0 Hz, you cannot use a cap. I'll correct the circuit. \$\endgroup\$ – Telaclavo Jun 1 '12 at 15:25
  • \$\begingroup\$ Also, I don't know the max and min voltages of the AC signal. It is a variable, probably asymmetrical signal. \$\endgroup\$ – Nevermored Jun 1 '12 at 15:33
  • \$\begingroup\$ Seems I was writing my answer when you were editing yours, and our schematics were the same. I've deleted my answer. \$\endgroup\$ – stevenvh Jun 1 '12 at 15:45
  • \$\begingroup\$ @stevenvh Sorry. \$\endgroup\$ – Telaclavo Jun 1 '12 at 15:49
1
\$\begingroup\$

You can translate and scale with just three resistors. For a situation where maximum input > \$V_+\$ and minimum input < \$V_-\$ I found a dead easy way to calculate the scaling resistors.

Use a pull-up to \$+3.3V\$ and and a pull-down to \$GND\$. Then we have

enter image description here

(the +5V should be read as +3.3V)
We'll consider two situations: one with \$V_{IN}\$ = \$-22V\$ and one with \$V_{IN}\$ = \$+22V\$. We'll have a set of two equations, so we can choose 1 resistor value. Let's take \$10k\$ for \$R2\$.

First. \$V_{IN}\$ = \$-22V\$. The ADC should then be at \$0V\$. That means that there won't be any current through \$R3\$, since there's no voltage difference. Then \$R2\$ and \$R1\$ form a voltage divider with

\$ \dfrac{0V - (-22V)}{R2} = \dfrac{3.3V - 0V}{R1} \$

or

\$ R1 = \dfrac{3.3V}{22V} \cdot 10k\Omega = 1500\Omega \$

Found our first value.

Then the second situation. \$V_{IN}\$ = \$+22V\$. The ADC should then be at \$+3.3V\$. That means there won't be any current through \$R1\$, since there's no voltage difference. Then \$R2\$ and \$R3\$ form a voltage divider with

\$ \dfrac{22V - 3.3V}{R2} = \dfrac{3.3V - 0V}{R3} \$

or

\$ R3 = \dfrac{3.3V}{18.7V} \cdot 10k\Omega = 1765\Omega \$

Found our second value. So

\$R1\$ = 1500\$\Omega\$,
\$R2\$ = 10k\$\Omega\$,
\$R3\$ = 1765\$\Omega\$.

\$\endgroup\$
  • \$\begingroup\$ Nice schematic picture ;-) \$\endgroup\$ – Olin Lathrop Jun 1 '12 at 16:42
  • 1
    \$\begingroup\$ @Olin - Yeah, I've got this artist who makes them for me :-). \$\endgroup\$ – stevenvh Jun 1 '12 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.