# How to map PID output to actuator control?

I'm building a control system for the heating of a house. A sensor reads the temperature inside and is then used as the input in the PID control. The temperature is then controlled by a servo which opens and closes a shunt were water runs to the radiators. I understand all the inner workings of the PID library for Arduino and PID in general, but the thing I don't understand is what I'm exactly supposed to do with the output signal I receive. In what way should the output signal correspond to how open or closed the shunt is?

I understand I can simply map the output signal to the servo signal, but is this the correct way? And with what angle coefficient should I map it with, cause that is basically set with the P parameter, isn't it? Is there some standard way to map the output signal to the actuator "signal", so that that tuning parameters are somewhat "standard".

Hope someone understands anything of what I tried to explain :)

• For a radiator TBH is easier to understand, implement, configure and fine tune. – jippie May 7 '14 at 17:57
• What are the limits of your actuator range? I don't use 'standard' tuning parameters, with a map(), I use the P term as a conversion of input error units directly into actuator units. For example P=20 could mean 20 degrees of valve-turning per degreeF of error. Or P=20000 could mean 20000 milliseconds of on-time during a 3600 second heating cycle. – Dave X Jan 22 '16 at 2:46

I don't think you would need to use a PID library (or any control loop for that matter) to control a radiator. You could use a simple threshold code, like this:

Pseudocode:

``````Check temperature
If radiator is off and temperature > (ideal temp - threshold)
If radiator is on and temperature > (ideal temp + threshold)
``````

If you can't find some actual info regarding applying PID to a water-based radiator system, then I'd suggest the following principles.

First, I assume that the output of the PID algorithm appears as an An Arduino PWM output at some rate. This could be a fast rate, like in the hundreds of Hz (if the load is DC), or fractions of Hz, or even 10 sec or more cycle time.

Next, I assume that the PID algorithm is likely designed to expect that a linear change in output has a linear effect on the heating output. That is to say, as though it's controlling an electric heater, where, for example, 25% ON-time produces 25% of full heat output.

If these are true, then you need to determine how that relates to what you can control on your shunt valve.

Is it acceptable for the valve to be turned full on/off on a proportion-of-10-seconds basis? Probably not.

Can the valve be set to an intermittent position if fed with a 10 Hz or 100 Hz PWM signal, perhaps so.

If the latter, then a further question is how does the PWM range of values correspond to actual angle of the valve, and more to the point, how does it correspond to flow rate, and ultimately to heat delivery. Perhaps a 33% PWM signal is required to deliver 25% of the full-range heat, for example.

(At a guess, I'd assume that heat delivery is proportional to flow, but as I think you anticipate, flow is not proportional to valve angle.)

You might just mock up your system, program the Arduino to output particular PWM values to the valve, and measure the resulting flow, and if possible, heat delivery. Then, interpose in the PID library the inverse function, perhaps as a lookup table.

So when the PID library wants to command 25%, that number gets looked up in the table, which (continuing my example) translates it to a 33% PWM signal, and your program sends that value to the PWM output.

Hope that provides some ideas.