# Turning an offset dc sinewave into a linear output

#### cmartinez

Joined Jan 17, 2007
7,379
I need to turn a 60 Hz sinewave that has an offset of 2.5V into a lineal signal depending on the sinewave's amplitude. The sinewave's maximum peak-to-peak is 4V. That is, it has an amplitude of 2V, its lowest point will be at 0.5V and its highest at 4.5V. What I want to do is convert the signal produced by an AC current transducer to a linear output.

If the sinewave has a 0V amplitude (that is, it's a fixed 2.5V signal) the circuit's output has to be 0V. If the sinewave has a 2V amplitude, the circuit's output needs to be 5V. Something like the following graphs:

Any advice as to what technique would be best to approach this problem, maintaining simplicity and minimizing the number of components?

Last edited:

#### cmartinez

Joined Jan 17, 2007
7,379

#### crutschow

Joined Mar 14, 2008
27,474
Why not just run the signal through a series capacitor (HPF) to remove DC offset and use a peak detector to generate a DC voltage?
You can amplify that with an op amp to give the desired output voltage.

How fast a response do you need to changes in current?

#### ebeowulf17

Joined Aug 12, 2014
3,282
Why not just run the signal through a series capacitor (HPF) to remove DC offset and use a peak detector to generate a DC voltage?
You can amplify that with an op amp to give the desired output voltage.

How fast a response do you need to changes in current?
Forget all the nonsense I originally wrote - I must've been hallucinating, because I completely misread the description the first time.

Wouldn't that leave only the DC offset and eliminate any trace of the AC amplitude? I believe the goal is to create a DC signal proportional to the AC amplitude of the input, ignoring DC offset.

Last edited:

#### cmartinez

Joined Jan 17, 2007
7,379
Why not just run the signal through a series capacitor (HPF) to remove DC offset and use a peak detector to generate a DC voltage?
You can amplify that with an op amp to give the desired output voltage.

How fast a response do you need to changes in current?
That's a very attractive idea, thanks. I need the signal to reach 0V, from its highest point of 5V, in 1/4 second. That is, if the highest allowable current is instantaneously removed, a response time of 1/4 second is desirable.

As you can see, I'd like the circuit's response to be relatively sluggish.

#### cmartinez

Joined Jan 17, 2007
7,379
Here's my first attempt at a sim:

I've (more or less) introduced the MLX91205 output parameters into V1, so as to more accurately represent the source. The circuit seems to be working fine, except maybe for a little ripple ... which can be tolerated, and maybe got rid of after feeding the output to a x3.3 OpAmp. Only thing bothering me is that the output takes a little too long for my taste to reach 0V after the source stops.

#### Attachments

• 1.3 KB Views: 0

#### MrChips

Joined Oct 2, 2009
23,962
Your time constant is C2 x R1.
With C2 = 0.47μF and R1 = 1MΩ, time constant = 0.47 s.
Try reducing C2 or R1 or both.

Edit: Of course, reducing the time constant will increase the ripple. You cannot have it both ways. In order to have low ripple and fast response you will have to go with a much more complicated design using peak detect and cross-over detection.

#### crutschow

Joined Mar 14, 2008
27,474
Is it no problem that inputs below about 0.5V peak are not seen at the output of your circuit due to the diode forward drop?

Joined Mar 10, 2018
4,057
Can always do a peak detector with a UP using its onboard
A/D to detect peaks and DAC to produce result. Something
like this -

Note can handle cycle to cycle generation of peak, not integrating
approach by typical analog peak detector. Latency is << analog
approach. And accuracy, because of onchip Vref, very good. If
these issues matter to you.

Note I forgot to G it up to meet the 0 - 5V requirement, thats also
trivial using one of the onboard R-R OpAmps.

Regards, Dana.

#### Danko

Joined Nov 22, 2017
1,105
I need to turn a 60 Hz sinewave that has an offset of 2.5V into a lineal signal depending on the sinewave's amplitude. The sinewave's maximum peak-to-peak is 4V. That is, it has an amplitude of 2V, its lowest point will be at 0.5V and its highest at 4.5V. What I want to do is convert the signal produced by an AC current transducer to a linear output.

#### cmartinez

Joined Jan 17, 2007
7,379
Thanks for the recommendation. There's also de AD536, which I've been using for this purpose on previous projects, but that chip and the one you've recommended are expensive components. That's one of the reasons I'm trying to find an alternative.

#### ebeowulf17

Joined Aug 12, 2014
3,282
Is it no problem that inputs below about 0.5V peak are not seen at the output of your circuit due to the diode forward drop?
I assume the solution would be to use something more like this?

#### crutschow

Joined Mar 14, 2008
27,474
Below is the LTspice simulation of a precision full-wave rectifier followed by a 2-pole Sallen-Key filter with gain.
This circuit uses a rail-rail opamp that operates from a single-supply, with the 2-pole filter providing good ripple suppression and relatively fast transient response.
The full-wave rectifier is less sensitive to any signal noise spikes as compared to a peak detector.

The output is shown for inputs of 1V and 2V peak.

#### Attachments

• 3.1 KB Views: 7
Last edited:

#### cmartinez

Joined Jan 17, 2007
7,379
Below is the LTspice simulation of a precision full-wave rectifier followed by a 2-pole Sallen-Key filter with gain.
This circuit uses a rail-rail opamp that operates from a single-supply, with the 2-pole filter providing good ripple suppression and relatively fast transient response.
The full-wave rectifier is less sensitive to any signal noise spikes as compared to a peak detector.

The output is shown for inputs of 1V and 2V peak.

View attachment 161429
That's impressive, Crutschow ... and your design's only using one chip! ... gonna start playing with it and be right back with my results. Many thanks!

#### cmartinez

Joined Jan 17, 2007
7,379
Here's my interaction with Crutschow's circuit. I've adjusted the caps and resistor values to what I have available at the moment, and it seems to be working fine. Also, I've specified a 5K and a 1nF output impedance and capacitance value for V2, just as the the MLX91205 output specs. I added an RC filter at the circuit's output, to smooth things a bit. And finally, I've set V2 to work as a 2.5V ±2.25V, also to imitate said chip's maximum range. Are there any critical component tolerances that I should be concerned about? Something tells me that R6 and R7 should have a tight tolerance.

#### Attachments

• 3.6 KB Views: 0

#### crutschow

Joined Mar 14, 2008
27,474
Are there any critical component tolerances that I should be concerned about? Something tells me that R6 and R7 should have a tight tolerance.
R6 and R7 determine the gain of U3.

The 5k and 1nF output load for the MLX91205 is a nominal load that it can drive.
You don't have to intentionally add that to the circuit.

#### cmartinez

Joined Jan 17, 2007
7,379
The 5k and 1nF output load for the MLX91205 is a nominal load that it can drive.
Thanks for pointing that out. Now I understand how to read datasheets a bit better.

#### cmartinez

Joined Jan 17, 2007
7,379
And considering all the previous observations, these latest values give (so far) the best results, with minimum output ripple. I also changed the 1N914 for a BAT54 diode to obtain a more symmetric rectified output from U1, and it seems to have worked.

#### Attachments

• 3.5 KB Views: 0
Last edited:

#### cmartinez

Joined Jan 17, 2007
7,379
I would use a precision rectifier and a peak detector. Subtract the 2.5V offset and then map 0-2VDC to 0-5VDC using a gain of 2.5

https://en.wikipedia.org/wiki/Precision_rectifier
http://sound.whsites.net/appnotes/an001.htm
And in the end, @Papabravo, it seems that the solution to the problem was exactly that ... I just didn't visualize that it could be done with a single chip ... sometimes a problem is much bigger in your head than it is in reality ... it's when things turn out to be the other way around when big trouble happens ...