Maker Pro
Maker Pro

Problem: converting a PWM signal voltage using an op-amp

I

Immo Birnbaum

Hi,

I've got a CPLD generating a 5V PWM signal which is used to drive an
analogue gauge. The first gauge I had had a range from 0 to 5V, so I
took a LM358 op-amp, connected V+ to 5V and V- to GND, set up a
voltage follower, connected the gauge to the output and everything
worked fine: when the effective voltage of the PWM signal was 0V, the
gauge was in the zero position, and when the effective voltage of the
signal was 5V, the gauge was at the upper end of the scale. So far, so
good, but the trouble started when I got another gauge to be driven by
the same signal. The new gauge has a range from 0 to 20V, so I want to
convert the 5V PWM signal to 20V. I tried the following: I connected
the LM358's V+ to 20V and V- to GND and set up a non-inverting
amplifier with a ratio of 4 (R2=3 kOhm, R1=1 kOhm). I used the 5V PWM
signal as the input. While the 5V signal coming out of the CPLD still
is a square wave, the output of the Op-Amp looks more like a triangle,
and the gauge, once hooked up to the output, somewhat works at the
upper and lower end of its scale, but goes wild in the middle.

Can anybody tell me what I did wrong and how I can amplify the 5V
signal to 20V while keeping it a square wave? Or is there an
alternative to using an op-amp?

Thanks in advance for any help,
regards,
Immo Birnbaum
 
A

Andrew Holme

Immo said:
Hi,

I've got a CPLD generating a 5V PWM signal which is used to drive an
analogue gauge. The first gauge I had had a range from 0 to 5V, so I
took a LM358 op-amp, connected V+ to 5V and V- to GND, set up a
voltage follower, connected the gauge to the output and everything
worked fine: when the effective voltage of the PWM signal was 0V, the
gauge was in the zero position, and when the effective voltage of the
signal was 5V, the gauge was at the upper end of the scale. So far, so
good, but the trouble started when I got another gauge to be driven by
the same signal. The new gauge has a range from 0 to 20V, so I want to
convert the 5V PWM signal to 20V. I tried the following: I connected
the LM358's V+ to 20V and V- to GND and set up a non-inverting
amplifier with a ratio of 4 (R2=3 kOhm, R1=1 kOhm). I used the 5V PWM
signal as the input. While the 5V signal coming out of the CPLD still
is a square wave, the output of the Op-Amp looks more like a triangle,
and the gauge, once hooked up to the output, somewhat works at the
upper and lower end of its scale, but goes wild in the middle.

Can anybody tell me what I did wrong and how I can amplify the 5V
signal to 20V while keeping it a square wave? Or is there an
alternative to using an op-amp?

Thanks in advance for any help,
regards,
Immo Birnbaum

You could try putting an RC low-pass filter between the CPLD output and the
op-amp non-inverting input, to convert the PWM into a DC voltage. At the
moment, you're relying on the guage to do the averaging, you're working the
op-amp rail-to-rail, more like a logic buffer than an analogue amplifier,
and it sounds like you could have a slew-rate problem.
 
Top