Use of the PID-controller node

Hi - this might be a dumb question, but here goes…

I want to use the PID-controller node ( for temperature control in a biological micro reactor (…and I’m not convinced that I know how to use it properly.

I have 3D printed vessels that are heated by a fan-driven PTC heater (12V, 100W), switched on-off under arduino control, using a MOSFET. I’m using DS18b20 temperature sensors for feedback. All is good electrically/thermally - but I am keen to optimise speed and accuracy of the temperature control. So far, I have been mainly using a simple “bang-bang” software controller, using the target temperature(s) as threshold. I have also hooked up the output of the PID-controller to the MOSFET switch for the heater, and attempted to tune the controller - but I have a few questions, that I’m hoping that a proper engineer can help with!

I’m not sure of the proper use of the values from PID-controller output pin - when the heater device has just on-off states. As I understand it, the controller output will produce a numerical output that decreases to zero as the target is approached. Is there any more information about the range of values or code examples? I have used a standard digital output port, and also piped the PID-controller output through a pwm-node. Am I throwing away useful information by doing this? i.e. effectively clipping the values and reverting to something closer to a simple on-off switch around the set threshold?

I also have some doubts about using an Arduino PWM pin to drive the PTC heater? The normal ~500Hz switching frequency doesn’t seem sensible for a relatively slow responding air heated system (~1 Hz seems more likely, to avoid electrical issues, heating MOSFETs, etc.). I’ve seen (non-XOD) instances online where software is used to convert a PID output to generate a more slowly switching output - say, over 5 secs, instead of 2 ms.

Does anyone have any examples or advice to share? Any help would be much appreciated!

(I’ve attached a view of one of the patches used - the Arduino is hooked up to a 4D Systems touchscreen that is used for input and display)

bw, Jim.

Which Arduino are you using? you can change the pwm frequency in a roundabout way depending on which arduino you have.

if its a mega 2560 you can change the frequency by injecting abit of code.

  1. click on Deploy> show code for arduino
  2. in the code find “Void Setup”
  3. paste “TCCR2B = TCCR2B & B11111000 | B00000001; // last 3 digits determine PWM Freq” the link below will tell you what last 3 digits will get you for a PWM frequency
  4. open arduino IDE and upload, you’ll need to use a scope to verify pwm frequency has changed.

Unfortunately doing it this way will not allow you to run the XOD Debug feature.

Hi - thanks for the tip - could be useful for other things too…

I’m using a Totemduino - an UNO R3 compatible with a few tweaks for hardware control and prototyping - integrated into a custom prototyping device ( An indistinguishable UNO clone, as far as I can tell.

Totem info at:

I’m starting play around with parameters for the PID controller, setting different target temperatures from 30ºC to 95ºC, and watching the output of the pid-controller node. At the moment, these feed directly into the pwm-load node - and look like they will only trigger pwm output between the values of 0 and 1. Even when the temperature controller is surfing around the setpoint, and a few degrees away from the target temperature, the pid-controller output can be over 1 or less than 0…so I might as well be using on-off control of the heater. I guess that’s not unusual for a PID controller, so maybe I shouild just live with this.

…just wondering if I’m missing something. Finer control of the heater would be useful.

Things are about to get more complicated, as I have connected intake and exhaust fans for cooling, and these need to be controlled too (for thermal cycling - very useful in molecular biology).

Thanks again for the help. J.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.