Implementing PID control using mbed

02 Nov 2011

I was wondering is it possible to implement a PID controller using mbed.

The gains can be easily defined but what about the integrator and differential equations? Also there are different modes i.e. continuous and discrete.

Any ideas?

I found the link: http://mbed.org/cookbook/PID Thanks

02 Nov 2011

Hi

They can be defined with 'void setTunings (float Kc, float tauI, float tauD)'

How to get the values, depends on what your trying to control and how it behaves.

Manual and Auto mode had something to do with starting a PID control without a jump in output signal. You have to call the compute method periodically after setting the input values and after computation, set the outputs to the calulated output values.

I used it to control a heater & display coupled to a I2C thermocouple linearizer and it worked like charm.

27 Sep 2016

Can we modify it to work with pin 18 analog out ?

03 Oct 2016

Yeah you can, just change

PwmOut   co(p26); 

to

PwmOut   co(p18);

https://developer.mbed.org/users/aberk/code/PID_HelloWorld/file/c48bef0d5d3c/main.cpp

25 Sep 2019

I am trying to use an analog output, I only changed the line to PwmOut co(p18) but the voltage at the output is always 2.2V no matter the value I put as setpoint (defined in line 22 of attached code). Could you help me out please?