Problem with converting PWM to DC voltage

Thread Starter

vietle3110

Joined Nov 17, 2016
2
Hi guys. I'm currently studying in electrical engineering program; however, my knowledge about circuits is kinda limited and I know this question is asked over and over again but, please, understand that I have found a lot of similar topics, none of them satisfied me completely. So, I'm working on an analog PID controller for DC motor speed control (why analog you may ask, I have done a digital one. Atm, I kinda want to try analog and compare them). My DC motor is attached with a optical encoder so it's quite tricky, the idea is to connect this encoder with my arduino board (interrupt pin) and have the arduino putting out PWM signal (this is convenient for me because I also want to send actual speed data to PC). The first thing I found is adafruit MCP4725 but it's not available in my place; hence, I looked for other solutions. I am now considering using an active low-pass filter at the PWM output but not quite sure how to calculate parameters (my motor speed is roughly 100 rounds per secs, my optical has 44 ppr so it is approx. 4kHz). I want the DC output to be in 0-5VDC, however, in some places, they said that if i put a 5 Vpp into opamp, I will only get 3.6V maximum at the output.
Can you guys confirm my idea is valid and help me calculate parameters?
If my idea is not okay, I can use some common packaged DAC, can you guys provide me some example with these DAC?
Thanks
 

MrChips

Joined Oct 2, 2009
34,823
What you want is an integrator.
A PWM signal at 4kHz is a period of 250μs. Hence you want to integrate the signal over a time frame of the order of 250μs.
What is the time constant of an RC low-pass filter?
 

AnalogKid

Joined Aug 1, 2013
12,142
The advice abot opamp output voltage swing is correct. Older designs can get to withing about 1 or 2 volts of the positive rail. Newer designs have an output characteristic called "rail-to-rail". This indicates that the output can swing very near the positive and negative power pins. Not that usually the output can't source or sink very much current when operating so close to the rails.

ak
 

Thread Starter

vietle3110

Joined Nov 17, 2016
2
Thank you for replying.
@MrChips: I think I will put my PWM at much higher frequency rather than 4kHz, cause it will make my filter easier to design, right? (i'm assuming integrator and active low-pass filter is the same thing). From some calculation, seems like at 16k, cut off frequency will be 7.5 Hz, so I will have to choose time constant to suit with this (will this ensure my ripple at +-5%?). Another note, I'm putting the DC voltage output into a comparator, so do I need to concern about current?
@AnalogKid: can you recommend any IC of this types?
Thanks
 
Top