I have made a controller for an heat exchanger. The controller monitors the output temperature and opens or closes a valve if it's too hot or too cold. This regulation is gross but for my scope of application is ok.

I am more concerned by the fact that this type of regulation causes the actuator to open and close continuously and the system reaches an equilibrium only after a few hours of operation.

Unfortunally the actuator takes only two commands: open and close. When I have voltage on PIN1 the actuator opens the valve, whe I have voltage on PIN2 the actuator closes the valve. When there is no voltage on both pins, the actuator is stopped in that position.

Now I'm using python to control two relays that are wired to PIN1 and PIN2. So one relay is for open command and the other is for close command.

Is it possible to implement a software PID controller for an actuator like this?

  • \$\begingroup\$ How often does the application read temperature and send valve commands? \$\endgroup\$
    – JYelton
    Aug 12, 2021 at 15:21
  • \$\begingroup\$ 30 seconds, but it's not a specific need. The actuator needs 60 seconds to fully open or close \$\endgroup\$ Aug 12, 2021 at 15:25
  • \$\begingroup\$ I don't have a qualified answer, but if you can measure the change in temperature over 30 seconds you might be able to approximate when the temperature reaches the target and open/close the valve slightly ahead of time. That wouldn't be full PID but you could implement just the proportional component to reduce overshoot. \$\endgroup\$
    – JYelton
    Aug 12, 2021 at 15:28
  • \$\begingroup\$ @LucaScalvi so it can't be operating continuously then if it takes a minute to change state? \$\endgroup\$
    – Andy aka
    Aug 12, 2021 at 15:28
  • \$\begingroup\$ I will take a guess and say you are cycling the heat source. Why not throttle it down so it has less flow, that should dampen the temperature swing. \$\endgroup\$
    – Gil
    Aug 12, 2021 at 15:52

1 Answer 1


You can implement a PID there. In order to tune it you will need some time, maybe days (because its so slow -60 seconds to open/close the valve-).

I would like more information (what are you heating? what is the ambient temperature etc)

Start with a PWM regulation of the heater. Since it takes 60 seconds to open/close I think keeping it on from 0 minutes = 0% on to 20 minutes= 100% on- is good? you will figure this out. Your temperature target is lets say 25oC since I guess you heat a room?. And lets say its pretty cold (19oC).

Start with a really large Kp value, so it will heat up the room until it reaches 25oC, and probably overshoot to 30 (lets say). then try reduce the kp value until it heats from 19oC to 24oC, and you are done with kp.

Then go with Ki. Start from a really low Ki value. Ki will keep the temperature at 25oC once Kp reaches there (since Kp will be 0 when it reaches the target).

Finally, if you are overshooting, use Kd.

  • \$\begingroup\$ This system is used to heat apartments, not only my room or my apartment, so I do not control ambient temperature but the temperature of the hot water generated from the heat exchanger that flows inside radiators. An heat exchanger is very quick to heat up water, maybe too much fast, this is why I have pendulations \$\endgroup\$ Aug 12, 2021 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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