PWM to Voltage Improvement

Hi, I am new to Arduino.I have one question about converting PWM to voltage. In our project?we use Arduino with LabVIEW to finish PID control. We input time duty to arduino through labview and output voltage. Since the project is about laser stabilization, we need accuracy of output voltage. Arduino's PWM is 8-bit, this is fine. Probably we would try Maple Board with 12-bit PWM next. Currently, we are using basic Simple RC circuit to convert PWM to DC. I want to know how could I improve this except changing resistor and capacitor combination? Thank you for help.

Improve this by using a higher order low pass filter than just a simple RC first order filter.

And set the cut off frequency as 20 Hz, right?

Set it at what ever rate you want to change the voltage at.

You need to look at the requirements for laser stability over time. If you understand the math in your PID algorithm you can figure out the time relationships. There can be big differences in the response time needed for a heat treat oven, balancing a Segway, or leveling a Quadcopter.

Once you know that a simple 3 pole active filter with one operational amplifier is probably all you need. LOts of info here: Dale's Homemade Robots - Lowpass and Highpass Filter Calculator

The arduino can act as a very accurate 12 bit and even 24 bit DAC if you want it to but you need to be prepared to wait for it to settle.

See here

Personally I wouldn't use PWM, but would use an MCP4822 (or similar) 12-bit voltage DAC.

The MCP4822 is a dual channel 12-bit DAC with internal voltage reference. This device offers high accuracy and low power consumption, and is available in various packages. Communication with the device is accomplished via a simple serial interface using SPI protocols. The MCP4822 device is a part of the MCP4802/MCP4812/MCP4822 product family, which are dual channel 8-bit/10-bit/12-bit DACs with internal voltage reference (VREF). These devices provide very high accuracy and low noise performance, and are suitable for consumer and industrial applications, such as set point control, offset adjustment and sensor calibration applications. The low power consumption and small package options make these devices very attractive for many portable and battery-powered applications. If only a single output is needed then the MCP4801/4811/4821 single channel product family can be used.

I use them as an adjustable Vref for ADCs. They're very handy, and very accurate. You can set them to almost anything between 0 and 4095mV.

Remember that the filter cutoff component mustn't be a part of the response time of the PID algorithm or it will decidedly skew the PID response.

Doc

Docedison:
Remember that the filter cutoff component mustn't be a part of the response time of the PID algorithm or it will decidedly skew the PID response.

Doc

Yeah, you are right. Could you explain this further?

What he means is that the filters cut off has to be way lower than the PID filter response. So the the PWM keeps looking like DC.