I have a car seat motor that I am driving via PWM and am aiming to measure its position by counting the minor variations in voltage across a current sensing resistor attached to the low side of a FET as the motor rotates. At higher duties the Vpp is significantly less (30mV) than those at 25% duty (4.7V). I currently tap the signal for measuring by a microcontroller ADC at two different gain stages to handle this, but desire to make this all happen in one stage with a variable gain circuit so only 1 ADC is needed.

Before I go into what I've attempted I want to state my primary question. How do I dynamically adjust the gain of my waveform to output a signal at a constant Vpp when my input Vpp ranges from 30mV to 4.7V?

I use a TI LMV344 op amp with rails on 0V and 5V. The motors are 12V.

Currently the circuit flow is:

Sensing Resistor Output

Diode voltage clamp to remove DC bias

High gain, non-inverting LPF op amp. Filters out 20kHz PWM signal

Diode clamp to reduce bias. I now know that I can put a capacitor between the resistor an ground on the gain portion of the above LPF

Sallen-Key LPF to further reduce 20kHz PWM signal. Low gain. This is where I tap for low duty signals as any more gain causes the lowest of duties to cause the current signal to saturate the op amp.

Diode clamp to reduce DC bias.

Another Sallen-Key LPF identical to the above filter, no tap. I really wanted to filter out that noise.

The problem that I have run into is that at the highest duty, the Vpp output is low enough that its sometimes hard to make out pulses. At the cross-over duty, around 60%, the Vpp on the high duty side is saturating and the Vpp on the low duty side is too small.

My current attempt to solve this issue is to use the PWM signal used to drive the motor as a means of adjusting gain on a separate gain only amp. The gain is set to put the high duty signal at the desired Vpp. As the duty increases and inverted copy of the duty is filtered into an analog signal (represented by V3) and fed through a voltage follower connected to the inverting pin on the amp with the gain stage. But when I do this, the DC outputted in step 5 causes the signal to saturate at the op amp's upper rail when low duties are used. If I put a diode clamp between the signal from step 5 and the gain only amp, I can control the gain as I had hoped. When I put a capacitor between the gain resistor attached to ground and ground to reduce DC gain to unity and eliminate the need for the diode clamp, the gain is no longer controlled and the DC gain isn't unity. The diode clamp needs to be replaced since the various Vpp values need different offsets so they won't saturate.

Here's that last paragraph as a schematic. The op-amps are LMV344 op-amps, not LMV324 as the illustration suggests. The input signal has a Vpp from 30mV to 4.7V depending on the motor duty.

And here are two examples of the input signal. THe first is the current draw waveform at 100% duty and the second is the current draw at 25% duty.

How can I get a variable gain circuit, amplify signals with Vpp between 30mV and 4.7V to around 4.7V, while avoiding saturation due to input DC levels? Thank you in advance. This has consumed me for the past month.

\$\begingroup\$(1) Have you got any scope shots? (2) What in the motor causes these pulses? It seems a difficult choice of position tracking.\$\endgroup\$
– TransistorSep 1 '16 at 5:38

\$\begingroup\$Scope shots have been added. I believe that the pulses are from the commutator rotating and switching between brushes. Yes, this is a difficult way of tracking, but I have to stay with how this system's motors are currently tracked. I wish it used hall effect sensors.\$\endgroup\$
– user122407Sep 1 '16 at 13:21

\$\begingroup\$Those two scope shots imply to me that a simple fast comparator would work so, show a scope shot of where you believe the problem waveform occurs.\$\endgroup\$
– Andy akaSep 1 '16 at 17:35

\$\begingroup\$The signal that I care about is between 300 Hz and 500 Hz. The filter portion of the circuit has an +8db gain at 300 Hz, +6dB gain at 500Hz, and -50dB gain at 20kHz. It drops below unity gain around 815Hz. I don't believe that my filters are attenuating the part of the signal I need. Thanks.\$\endgroup\$
– user122407Sep 1 '16 at 14:53