RoastLogger's Arduino Controller includes a PID. The PID can be used to control the heater in your roaster (via a TC4C, TC4, RL-HT-CTRL or Arduino). When the PID is off the action tables control the roasters heater and fan. If the PID is turned on via the menu then all action tables are used as before except that, after the beans are loaded, the action table settings for heater power will be ignored and the PID will be in control of the heater power.
Those wishing to control using the action tables (without PID control) should ensure that the PID is turned off. The top level PID menu will state "PID (on)" or "PID (off)".
The PID can be set to use bean temperature, environment temperature or RoR on bean temperature as the control variable. Two entirely separate methods are provided to control the PID by adjusting it's settings further during a roast. See Notes on using the PID setpoint table and Notes on using the action table PID commands for details.
The PID is based on the work of Brett Beauregard. In particular the excellent blog series by Brett Improving the beginners PID(http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/) and his Arduino PID. For a general overview of PID control, the tuning parameters and manual tuning see the Wikipedia article on PID control.
- If the PID is turned off everything works as in previous versions of the RoastLogger. That is the action tables control as before.
- To use the PID it must be turned on before loading the
beans. The PID can not be turned on or off whilst a roast is in
progress, that is between loading beans and ejecting beans.
- If the PID is turned on then, after the beans are loaded, the PID controls the heater and any heater setting in the action tables is ignored. The action tables control everything before the beans are loaded and the fan after the beans are loaded.
- Whilst the PID is in control of the heater the "Auto heater" check box can be unchecked to break the connection between the PID and the heater slider to provide manual control of the heater. Checking again allows the PID to regain control.
- Whilst the PID is in control of the heater the "Auto setpoint"
checkbox can be unchecked to break the connection between the PID
settings table or action table PID commands and the setpoint slider to provide manual control of the
- User can select to use BT, ET or RoR on BT as the control variable. This must be done before the roast is started.
- You must set the Initial settings for PID control before using the PID (menu PID | Change PID settings).
Before first use of the PID the initial settings to be applied at the start of any PID controlled roasts must be set. These settings are saved and restored between sessions. Open the Change PID settings dialog by selecting the Arduino Controller PID menu > Change PID settings option:
1. Set the control variable as in 1. in the dialog. If you are unsure it is recommended that you use environment temperature for the control variable.
Important notes on using RoR on T1 as the control variable:
- Please note that using RoR on T1 as the control variable is experimental and untested and should be used with care.
- When using RoR on T1 as the control variable the required RoR setpoints should be entered as the required setting x 10 i.e. for an RoR of 3.3 enter 33 in the tables or setpoint slider.
2. Set the initial PID control variables as in 2. in the above dialog. These settings will be applied at the start of any PID controlled roast.
3. For simple PID control of the maximum ET this is all that is necessary to control the roast. If you wish to change the PID parameters during the roast then it is necessary to set the method to be used to further control the PID settings during the roast as in 3. in the above dialog. See Choosing the method to control the PID below.
To provide optimum PID control it is suggested that you ensure that menu option 'Set sliders granularity to 1%' is selected in the Arduino Controller 'Options' menu.
Two entirely separate methods are provided to control the PID by adjusting it's settings further during a roast:
1. PID setpoints can be adjusted based on elapsed time since roast start (Load Beans). A PID setpoint table is provided on the PID tab which allows setpoints and setpoint ramps to be set in up to 30 segments (rows). Each segment runs for the set number of seconds. When a segment is entered any setting in the "Setpoint" column is immediately applied and the adjacent checkbox checked to show that the segment is now active. If the "Ramp to" column has a setting then the setpoint is ramped in a straight line from the previous setting to achieve the "Ramp to" setting by the end of the segment.
2. PID setpoints and tuning parameters can be adjusted based on T1 temperature before FCs and on time after FCs. This is facilitated by new PID commands that have been added to the action tables (Action at T1 and Action at secs. after FC). These commands can be entered in the heater column of the tables. When the PID is turned off these new commands are ignored and only normal heater percentage values (0..100) will be actioned. When this option is selected and the PID is on the new commands will be actioned at the appropriate temperature or time after FCs.
PID setpoints and setpoint ramps can be adjusted during the roast via the setpoint table included on the Arduino Controller PID tab. Controlling the PID via the setpoint tables provides the ability to adjust settings based on elapsed time.
You can experiment with the setpoint table without conducting a real roast. You do not need to connect your device (RL-HT-CTRL/Arduino/TC4/TC4C) to the roaster or power up the roaster. Just open RoastLogger and the Arduino Controller set the PID how you want it and enter some values in the setpoint table. When you are ready to run a test go to the "Log tab" and click "Load Beans" to start the test “roast" and the PID will then start. You will see the setpoint slider move at the relevant number of elapsed seconds. Once you are finished click "eject beans" and the "test roast" and the PID will stop. I suggest you try the following:
If you set:
You will see the setpoint step to 100 as soon as it starts and hold this for 5 seconds then it will step to 150. It will then stay at 150 as it has no more instruction.
If you set:
It will start at 100 and hold it for 5 seconds then the setpoint will ramp up from the previous setting (100 in this case) to 150 over 50 seconds. If a setpoint or ramp-to cell is left blank then it performs no action. If it has a value it is applied.
You can also apply both the setpoint and ramp to one segment, i.e.:
This will start at 100 then, after 5 seconds, will change to 120, then ramp up to 220 over the next 50 seconds.
PID settings (setpoints, setpoint ramps and PID tuning parameters) can be adjusted during the roast via the main action tables (Action at T1 and Action at secs. after FC). Controlling the PID via the action tables provides the ability to adjust settings based on bean temperature before first crack and elapsed time after first crack.
The new PID setting commands allow a great deal of flexibility and can be entered into the heater column of the action tables. If the PID is turned off then any PID commands are ignored and any heater settings are applied. If the PID is turned on then any heater settings are ignored and, if the "Use PID commands in action tables" is selected, then any PID commands are applied.
The PID commands are:
|P0 .. P9||Apply all the PID settings in the associated row of the PID settings table. This is a new table on the PID settings dialog.|
|S0 .. S600||Apply the new setpoint (integer 0..600)|
|R0 .. R100||Apply a ramp to the current setpoint (integer 0 .. 100) in degrees per minute (ramp applied each second until a new ramp or any new setpoint is set)|
The following is an example of using the commands:
These are not meant to represent a real roast and are just an example of the different commands. At a bean temperature of 150 the PID setpoint will be changed to 200 and the fan setting to 30%. At a BT of 160 a ramp will be applied to the current setpoint (200) at a rate of 10 degrees per minute applied each second. At a BT of 180 all the settings in line P0 of the PID settings table will be applied. At 40 seconds after first crack start the setpoint will be set to 210.
The PID settings table allows all the PID settings (setpoint, ramp and tuning parameters) to be changed in one command. In the above example we used P0 which is the first line in the table:
In this example only one line of settings (P0) is entered. You can enter settings on any and all lines. Settings are saved and restored between sessions. Any blank cells in the PID settings table have no action. In this example the setpoint will change to 209 and the tuning parameters will change to the values shown. Any change in setpoint will cancel any ramp previously set.
Controlling the PID via the action tables has the significant advantage that actions occur at specific bean temperatures rather than elapsed time. This can produce better control of a roast. The disadvantage of this approach is that you have to keep the setpoint high enough or ramping up during the roast. If you fail to do this then any further actions you want to be triggered at higher bean temperature may never be triggered as the bean temperature may not go high enough to reach the set temperature. For example it is not possible to set a fixed setpoint for bean drying as, once the temperature settles to the setpoint it will never trigger actions at a higher temperature. After first crack start the action at seconds after FC table is active so settings can then be based on seconds after first crack.
The following notes are intended to help people set up the RoastLogger PID to provide simple control of a Hottop roaster via an HTRI board (TC4C+HTC, TC4+HTShield or RL-HT-CTRL). The RoastLogger PID is not limited to Hottop roasters or HTRI boards and it is hoped the notes may also be helpful for RoastLogger users with different roasters controlled by other hardware interfaces.
This simple control relies on adjusting the mass of beans to achieve the desired ramp and, therefore, time to first crack start. The PID is used to set a maximum environment temperature. By adjusting the maximum environment temperature setting you can extend or reduce the time from first crack start to the end of the roast.
The following chart shows the comparison between a Hottop roast controlled by the action tables with the PID off (shown as the template in pastel colours) and a roast controlled by the PID (shown as the current roast bold colours). Both of these roasts are without any human intervention except to mark the roast stages by pressing the roast stage button. The left chart title indicates the PID settings used:
The details of the settings required to achieve this result are as follows:
1. PID settings to be applied once, these will be preserved between sessions and restored each start of the RoastLogger:
In the Arduino Controller select menu option PID > Change PID settings, this will open the PID settings dialog (shown above).
1.1. Set the control variable to "Environment Temperature (T2)"
1.2. Set the initial setpoint to your chosen value (see "Determining the optimum setpoint for your roaster" below).
1.3. Set the initial PID tuning parameters depending on whether you are working in Celsius or Fahrenheit:
Celsius: Kp = 20, Ki = 0.04, Kd = 0
Fahrenheit: Kp = 10, Ki = 0.02, Kd = 0
Fahrenheit: Kp = 10, Ki = 0.02, Kd = 0
The parameters shown above were the actual values used in testing in Celsius and Fahrenheit and work well. Please note that all the tuning parameters are temperature scale dependent. For example, to convert a Ki Fahrenheit scale value of 0.02 to Celsius scale, multiply it by 9/5 which gives approximately 0.04.
The above settings are all that are required for this simple PID control of a roast. As the initial settings will be applied throughout the roast with no changes needed you can choose either "Use the setpoint table on the PID tab" or "Use PID commands in the action tables..". You should ensure, however, that you have not added any other PID settings that would change the settings during the roast. That is, if you have chosen "Use the setpoint table on the PID tab" then ensure the settings table is empty and, if you have chosen "Use PID commands in the action tables.." then ensure you have not entered any PID commands in the heater column of the action tables.
You are of course free to change the PID settings during the roast if you wish. Please see Choosing the method to control the PID for information on this.
1.4. Close the PID settings dialog.
1.5. When the PID is on, the action tables still control the heater and fan before the roast is started (before load beans) and control the fan throughout the roast. Any actions table settings to adjust the heater after the roast is started are ignored as the PID is in control of the heater. The default action table settings should be suitable in most cases. If you wish to have different settings for PID roasts then save a copy of these settings and load them when required.
2. Settings to be applied for each roast session you wish to use the PID:
1. Ensure the PID is turned on by selecting the PID menu option "Use PID for this session" or "Start in PID mode" if you wish to always us the PID.
3. Check your chosen action table settings or setpoint table settings are loaded and start the roast.
Different thermocouple installations will read different temperatures so you will need to do a few test roasts to determine the best value for your installation.
If the setpoint is set too high the ET will level off at too high a setting which will cause the roast to progress too fast from first crack start to second crack start. If the setpoint is set too low the ET will be too low resulting in too long a duration between FCs and SCs.
On my Hottops I find that a settings between 208 and 210 Celsius (406 and 410 Fahrenheit) work well. This equates to about 22 C (40 F) above the bean temperature at first crack start.