Microcontroller Pulse Width Modulation to Analog DC Voltage

Click For Summary

Discussion Overview

The discussion revolves around methods to convert Pulse Width Modulation (PWM) signals from a microcontroller into a DC voltage suitable for driving a DC motor. Participants explore various filtering techniques, the use of operational amplifiers, and the implications of using PWM directly versus filtering it.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants suggest using a low pass filter to remove harmonics from the PWM signal, questioning whether active or passive filters yield better DC voltage.
  • One participant notes that the motor itself acts as a low pass filter, implying that only minimal additional filtering may be necessary.
  • There is a proposal to use two PWM signals to create a differential signal for controlling the motor, with a subsequent band pass filter to isolate the desired frequency.
  • Concerns are raised about the potential for noise backfeeding between PWM signals when using a differential amplifier, with suggestions for using diodes to mitigate this issue.
  • Another participant emphasizes that using PWM directly to control the motor can provide better linear control compared to filtering the signal.
  • Questions arise regarding the compatibility of PWM with PID controllers and encoders, with some affirming that it is commonly done in industrial applications.

Areas of Agreement / Disagreement

Participants express differing views on the necessity and effectiveness of filtering PWM signals versus using them directly. There is no consensus on the best approach, as multiple competing methods and opinions are presented.

Contextual Notes

Participants reference various technical concepts such as Laplace transforms, differential amplifiers, and the implications of motor control strategies, indicating a reliance on specific definitions and assumptions that may not be universally agreed upon.

Who May Find This Useful

This discussion may be useful for individuals interested in motor control systems, PWM signal processing, and the integration of microcontrollers in engineering applications.

SSGD
Messages
49
Reaction score
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
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   Reactions: cnh1995, jim hardy and SSGD
Thanks Tom. Have you ever heard of using a pair of PWMs to produce an a DC Voltage
 
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   Reactions: SSGD, berkeman and Tom.G
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.
 
(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   Reactions: SSGD
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
 
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.
 
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).
 

Similar threads

Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
6
Views
10K
  • · Replies 16 ·
Replies
16
Views
7K
  • · Replies 11 ·
Replies
11
Views
16K
Replies
2
Views
3K