Digital Actuator PID Control

Can anyone point to the area of the GitHub Repo where the integration of the digital actuator is controlled from the PID? I am trying to get a better understanding of exactly what is going on here. How the estimated overshoot is calculated and adjusted, interactions between air temp and beer temp etc.

Thanks,

PID hpp: brewblox-firmware/Pid.hpp at develop · BrewBlox/brewblox-firmware · GitHub
PID cpp: brewblox-firmware/Pid.cpp at develop · BrewBlox/brewblox-firmware · GitHub

PWM hpp: brewblox-firmware/ActuatorPwm.hpp at develop · BrewBlox/brewblox-firmware · GitHub
PWM cpp: brewblox-firmware/ActuatorPwm.cpp at develop · BrewBlox/brewblox-firmware · GitHub

I suspect that the source code by itself is less than helpful.

If required, a basic explanation of PID control can be found at PID for Dummies - Control Solutions

In our case, the PID does not directly control the digital actuator: It controls an analog actuator, typically a PWM. The PID output can be pretty much whatever, but the effective range for a PWM is 0-100.
The PWM controls the digital actuator.

The old BrewPi software used to have a setting for estimated overshoot. This was made obsolete by improvements to the generic PID calculation. Overshoot correction is fully handled by the Td/derivative part.

The old BrewPi software also used to have a separate PID for air temp and beer temp. The beer temp PID used air temp as a black box heater / cooler by adjusting the air temp setpoint.
The air temp PID would use the heater/cooler to bring the air temp to the temperature desired by the beer temp PID.
With the new software, we found that this approach is no longer required. A PID can accurately adjust beer temp by using the heater / cooler directly.

There are setups where this indirect approach is still useful (eg. HERMS HLT), so it is still supported. Documentation can be found at Brewblox control chains | Brewblox

Thanks, I have a basic understanding of PID (in an analog application), I’m trying to understand how to take the 0-100% PID output and control a bang bang device like the fridge. Again Thanks, now I’ve got some reading to do.

0-100 (or any other range like 0-255) to digital is universally accomplished with PWM. This is a common enough term that google yields multiple tutorials and explanations.

Yes but the part I’m the most concerned about is controlling the fridge compressor (on/off not pwm). PWM works great for the heating element, not so much for a compressor, or did I mis-read your response?

PWM is what converts 0-100 to on/off. In brewblox, both heating and cooling is on/off, so PWM is used for both.

I’m looking through the code now, maybe it will become obvious to me, however; in general when I think of Pulse width modulation, I think of turning something on and off multiple times a second. This would clearly be very bad for a refrigerator. Or am I missing something? I’m still going through the code.

When using a fridge, we apply the same logic, but with a much longer period - it doesn’t switch multiple times per second, but a few times per hour.

We use Constraints to force the digital actuator to have minimum on and off times.

I’m looking to drive a proportional valve which uses a 0-5v signal, and have run into the same sort of issues with fast switching. I’ve only done some preliminary tests with the PID:kp=1 and mock setting workaround.

Ultimately I’m trying use my volume sensors as an input for a “kettle_filling PID” which then drives the proportional valve. The min_on and min_off constraints appear to me to not be very useful for this case, unless it would be min_on for like 1s with some long duty cycle.

This is on a spark 4 since there’s currently some differences.

Any input on optimizing the settings for a proportional valve control chain would be appreciated.

Also, what is the max duty cycle period?

Are you driving the valve directly, or is this behind a PWM->voltage converter?

4,294,967,295 milliseconds, or 49 days and change.

Yes driving directly, similar to the pump. Last time I tried it kept opening fully at 5v and closing at zero voltage. I’m looking to do output% as a 0-5v “steady” signal, I guess this is a different issue in that respect.

Edit: will look into the PWM->voltage converter.

1 Like