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.
- High gain, non-inverting LPF op-amp. Higher duty signals are tapped here.
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.
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.