The heater and cooler each have an independent PID, driving a chain of actuator classes, each with it's own feature they add to the actuator.
- A PWM actuator: converts the input to a pulse width modulated signal
- A time limited actuator: makes sure the time limits to protect the compressor are satisfied
- A mutex actuator: guards that 2 actuators that are part of the same mutex group cannot be active at the same time and when switching from one to the other, the minimum dead time is waited. The mutex group keeps a list of actuators that requested to go active and gives permission to the one with the highest priority. The priority is based on the PWM value.
It sounds complex, but it is nicely split into separate concerns. It will also allow us to re-use objects to set up complex scenario's later, when customers can create and link these objects themselves, like:
- An HLT heater and BK heater share the same power circuit and cannot be active at the same time. They can however quickly alternate and both run at 50%. This is a mutex dead time of 1ms.
- A fridge with 1 shared cooler and 2 beers with a heat belt could be set up with a mutex group containing all 3. Only the beer that needs it the most will be heated. Cooling will be shared by both beers.