Preliminary alpha release with PWM
Pre-releaseWarning: untested, unstable, use at your own risk
This is a preliminary release of BrewPi with PWM actuators. I am releasing this now, because I am going on vacation in 3 days, but it sill might be usefull for some of you guys who want to control mashing or sous vide cooking. This has not been tested enough. It will have bugs. Keep an eye on it.
This is not the multi-PID PWM release I have been working on, this is just a quick fix to use PWM with BrewPi.
A quick hack to help you guys out now, until the proper firmware is out.
For fermentation control, please use release 0.2.11
How does it differ from 0.2.11?
A lot has changed compared to 0.2.11 in this release. The biggest change is that PWM is used for the actuators.
The actuators are still tied to the fridge temperature. I have only tested this release by controlling sous vide cooking in fridge constant mode.
PWM actuators
This release has pulse width modulated outputs (the ability to turn on a heater for x %), instead of full on.
The PWM duty is given by a PI controller and based on the Fridge temperature (proportional + integral). The settings for the proportional and integral gain can be changed in advanced settings. There is no auto tuning. You will have to tune manually.
In the device manager, if you check 'read values' you can see the PWM value (0-255). The proportional part is easily calculated (Kp * temperature error) and the remainder is the integral part. That can help you with tuning. Overshoot can result from too high Ki or too high Kp. I have set some defaults, but you'll have to tweak them for your setup.
Software PWM
The PWM outputs are updated irregularly, but the ON/OFF times that result are tracked and adjusted to maintain the correct average duty. Due this this, sometime a pulse will be skipped for low PWM values.
It should be possible to use PWM with OneWire actuators (on our SSR breakout board), but I have not tested this recently.
Compressor safety
The fridge output is also driven with PWM in this release. However, underneath the PWM driver is a class that protects the compressor with a minimum ON and minimum OFF time. Defaults are 2 minutes minimum ON time, 3 minutes minimum OFF time.
These are honored regardless of PWM. The PWM driver will compensate in the next cycle if it was ON or OFF longer than it wanted due to the minimum times. I have not tested this release in a fridge and I don't recommend using it for fermentation (your own risk). You might damage your fridge or ruin your beer.
PWM period
The PWM period is configurable, but I recommend leaving the defaults. These are 4 seconds for the heater, 10 minutes for the cooler.
Stripped Parts
In this release, peak detection has been removed. The integrator anti-windup has also been altered. This release does no auto-tuning at all. The waiting states (waiting to cool, waiting to heat) have also been removed.
Web interface compatibility
For the web interface, check out the feature/pwm-actuators
branch.
You can do this with our update script.
Run the update script with --ask to be presented with a choice which branch to check out:
sudo ~/brewpi-tools/updater.py --ask
When given this choice, choose the feature/pwm-actuators
branch:
Available branches on the remote 'origin' for /var/www:
[0] develop
[1] feature/pwm-actuators
[2] master
[3] Skip updating this repository
Enter the number of the branch you wish to update [master]: 1
Programming your Photon/Core
I have updated flashDfu.py to download releases by tag.
flashDfu.py (in the script/utils directory) will download the firmware for you. Do not use the web interface. Stop the BrewPi script. Then put your Photon/Core in DFU mode by holding the mode/setup button while you plug in the USB cable. After 5 seconds, it will start blinking yellow to indicate it is in DFU mode.
On the BrewPi Spark V1, the mode button is under the hole closest to the Dutch flag.
You can get the PWM actuators release by running:
sudo python /home/brewpi/utils/flashDfu.py --tag 0.3.0a
If you have a Photon running an up to date system image, you can automatically reboot it in DFU mode:
sudo python /home/brewpi/utils/flashDfu.py --tag 0.3.0a --autodfu
flashDfu.py will download the firmware for you and flashes it to your core/photon. Then it resets the EEPROM, a necessary step. If it does not say it has reset the EEPROM (after opening the serial port), but it has updated your device, do this manually by running:
echo -ne 'E\n' > /dev/ttyACM0
(assuming your device is /dev/tty/ACM0, check with ls/dev/ttyA*)