Tuning the P, I, and D values is an art. Please consult Google.
Things to try:
Use an RC low-pass circuit between the output pin and the input pin. One or many stages of RC filter.
Try setting the analogWrite() to a 50 Hz frequency and the pulse width of 1ms for a zero value and 2ms for a 1 value. Connect this output to a servo and use an accelerometer as the input. Mount the accelerometer on the servo arm and have some fun tilting it back and forth. (my parts are on order).
Setup a temperature sensor and a solid state switch supplying current to a heating element to control an oven temperature.
How to make input, output and setpoint appear to the user in Engineering units?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Continued:
Add a method to do one iteration of PID control
And finally some code to test it all.
For a simple test on an Espruino board I connected pin A4 to Pin A1.
Some console output:
Tuning the P, I, and D values is an art. Please consult Google.
Things to try:
How to make input, output and setpoint appear to the user in Engineering units?
2 Attachments