I want to implement a digital controller C(z) on an Arduino Uno (transfer function in the z domain) in order to control a plant

G(s) = 3750/[(s+10)(s+30)(s+100)].

I have implemented G(s) with electronics (op-amps, capacitors and resistances). I want to realize C(z) on the Arduino Uno. The input to the Arduino is the error signal (reference − output of G) and the output of C(z) is the input of G(s). Finally, I will have a closed loop system with negative unit feedback. The reference input is a unit step signal (1 volt).

My problem is: how can I use PWM and filters in place of a DAC?


If you want to use PWM in place of a DAC, the normal thing to do is to use some kind of analog low-pass filter. However, many people skip the filter when the signal is meant for some system that inherently acts as a low-pass. Example: dimming an LED, where the human eye is the filter.

In your case, since your plant looks like a third order low-pass filter with cuts at 1.6, 4.8 and 16 Hz, you can probably skip the filter. If you output on pins 5 or 6, the PWM frequency will be around 980 Hz (exactly: fCPU/16384). At that frequency, your plant gain relative to DC will be

G(j2π × 980 Hz) / G(0) ≈ 1.3 × 10−7 j

Probably low enough to not be an issue.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.