Microcontroller Pulse Width Modulation to Analog DC Voltage

In summary, this method uses two PWM signals to control a dc motor. Each PWM signal is passed thru a differential amplifier to get a differential signal. The differential signal is then passed thru a band pass filter to only allow the 0th frequency to pass. The filtered differential signal is now a function of +/- Vmax and the duty cycles of the two PWM. By changing the relationship between the duty cycles of the two PWM signals, you can run the dc motor forward and reverse.
  • #1
SSGD
49
4
What are some effective ways to convert a Pulse Width Modulation from a Microcontroller to a DC Voltage as a function of Pulse Width?

1. Use a low pass filter to remove the unwanted harmonics and leave only the 0th term of the Fourier Series. What produces a better DC Voltage an Active or a Passive Filter.

2... Any other methods.

Background.

I want to use a Microcontroller and the duty cycle of the PWM to generate an output voltage that is a function of duty cycle and then use an OP-AMP to increase the voltage to operating range of the DC Motor.

Example before OP-AMP Gain

@ 0% Duty DC Voltage = 0V
@50% Duty DC Voltage = 2.5V
@100% Duty DC Voltage = 5V
 
Engineering news on Phys.org
  • #2
The motor itself is a pretty good low pass filter so at the most you would need a single pole RC for additional filtering either before or as part of the op-amp driver. This is of course assuming that the pulse repetition rate is sufficiently above the motor mechanical resonance, typically easy to do.
 
  • Like
Likes cnh1995, jim hardy and SSGD
  • #3
Thanks Tom. Have you ever heard of using a pair of PWMs to produce an a DC Voltage
 
  • #4
SSGD said:
What are some effective ways to convert a Pulse Width Modulation from a Microcontroller to a DC Voltage as a function of Pulse Width?

1. Use a low pass filter to remove the unwanted harmonics and leave only the 0th term of the Fourier Series. What produces a better DC Voltage an Active or a Passive Filter.

2... Any other methods.

Background.

I want to use a Microcontroller and the duty cycle of the PWM to generate an output voltage that is a function of duty cycle and then use an OP-AMP to increase the voltage to operating range of the DC Motor.

Example before OP-AMP Gain

@ 0% Duty DC Voltage = 0V
@50% Duty DC Voltage = 2.5V
@100% Duty DC Voltage = 5V

Driving the motor with a pwm signal will result in linear control (moving the signal from 10% to 20% duty cycle will result in a 100% power increase). The same in NOT true of voltage (changing the voltage from 1 V to 2 V. Controlling the motor directly with a PWM signal is preferred.

In fact many analog motor controllers will change the analog control signal to PWM to drive the motor itself. If it is a voltage range problem, just provide a power amplifier to boost the voltage of the pwm signal.
 
  • Like
Likes SSGD, berkeman and Tom.G
  • #5
Okay. I have never use PWM. Can you still use it with a PID controller and an encoder? That is my reason for wanting to filter the PWM to DC Voltage and pass it to a controller then the motor.
 
  • #6
(Thought I posted the first half of this yesterday but it showed up as still being edited today. So here it is.)

SSGD said:
Thanks Tom. Have you ever heard of using a pair of PWMs to produce an a DC Voltage
No, can't say as I have. What did you have in mind?

BTW, if you are after a linear duty cycle vs speed, as @donpacino pointed out just use PWM directly to the motor without low pass filtering. It works much better

SSGD said:
Can you still use it with a PID controller and an encoder?
Yes, it's done all the time in Industrial control. There are probably a few quirks to watch out for, but they tend to be hidden in the 'black box' processing of the drives. One thing that comes to mind is minimum motor movement per pulse versus the control deadband. Get it wrong and it is guaranteed to hunt.
 
  • Like
Likes SSGD
  • #7
Got it. Thanks for the tips. I need to draw up the controller and solve the Laplace transform with the PWM as an input and see if it all makes sense. I needed to ask about the PWM b/c I don't have much exp. with it. And I didn't know if it was common to filter it or use it as is. Thanks
 
  • #8
Well I know this is an old post. But I did come up with a way to directly control a dc motor with two pwm signals without the use of a bridge.

1. Setup two PWM signals with the same period and amplitude of Vmax
2. Pass both signals thru a differential amplifier to get a differential signal
3. Pass the differential signal thru a band pass filter and only allow the 0th frequency to pass
4. Filtered Differential signal is now a function of +/- Vmax and the duty cycles of the two PWM.
5. You can now run the dc motor forward and reverse by changing the relationship between the to duty cycles.

4. Might be a waste of power but if we keep the current and voltage small and then use an amplifier with a large gain after 5 that should minimize the power loss of the filter and still provide the needed voltage to run the motor.
 
  • #9
SSGD said:
2. Pass both signals thru a differential amplifier to get a differential signal
Yea, that works. If the diff-amp has differential outputs and the motor is connected across them, you are using the output stages as the bridge. If it's single ended output, realize that the dual power supplies to the diff-amp and the totem-pole diff-amp output comprise a half bridge.
 
  • #10
Sweet. I will have look up some of the details of totem pole and half bridge, but I think I understand what you are saying.
 
  • #11
One question... Can the differential amplifier back feed noise from either PWM signal into the other. I wouldn't want current feedback into the controller/computer. If so would a diode help with this or would it create other issues.
 
  • #12
SSGD said:
Can the differential amplifier back feed noise from either PWM signal into the other.
Not if everything is working properly. It's sort of like asking 'Can my car crash me into that tree beside the road?' Well, if you steer toward the tree, yes; or if a front wheel falls off, maybe.

SSGD said:
If so would a diode help with this or would it create other issues.
That would probably overly complicate the design, although that couldn't be determined without a complete design review (which I'll leave to others if you feel you need it).
 

1. What is Microcontroller Pulse Width Modulation (PWM)?

Microcontroller Pulse Width Modulation (PWM) is a technique used to digitally control the amount of power delivered to a device. It involves rapidly switching a digital signal on and off to create an analog-like output.

2. How does PWM produce an analog DC voltage?

PWM works by varying the duty cycle (the ratio of on time to off time) of the digital signal. By adjusting the duty cycle, the average voltage output can be altered, creating an analog-like output that can be used to control devices such as motors, lights, and speakers.

3. What are the advantages of using PWM over traditional analog voltage control?

PWM offers several advantages over traditional analog voltage control. It allows for precise control of output voltage, reduces wasted energy, and can easily be integrated into digital control systems. It also allows for more complex control of devices, such as varying the speed of a motor or the brightness of a light.

4. How is PWM implemented in microcontrollers?

Microcontrollers have built-in hardware modules specifically designed for PWM control. These modules have registers that can be programmed to adjust the duty cycle and frequency of the digital signal. The microcontroller can then use this signal to control external devices.

5. What are some common applications of PWM in microcontrollers?

PWM is commonly used in microcontrollers for controlling motors, generating audio signals, and controlling the brightness of LEDs. It is also used in power supplies to regulate the output voltage and in communication systems to encode digital information into analog signals.

Similar threads

  • Electrical Engineering
Replies
1
Views
2K
Replies
8
Views
2K
  • Electrical Engineering
Replies
2
Views
2K
  • Electrical Engineering
Replies
2
Views
2K
  • Electrical Engineering
Replies
1
Views
4K
Replies
6
Views
9K
  • Electrical Engineering
Replies
2
Views
2K
  • Electrical Engineering
Replies
16
Views
7K
Replies
2
Views
2K
Back
Top