Skip to content

Compile

Compile Time Options

I built the software using PlatformIO. This allows the required libraries to be defined in the configuration file (platformio.ini) and downloaded automatically from the PlatformIO repository. Also, compile time options can be set in that same .ini file, avoiding the need to modify the source files (in most cases) in order to adapt the code to your particular hardware (such as if you choose different GPIOs for the required connections.)

The following constants can be modified or added to the build_flags entry in platformio.ini:

Constant Description Default
CLK_PIN GPIO attached to CLK pin of rotary encoder. GPIO_NUM_27
DT_PIN GPIO attached to DT pin of rotary encoder. GPIO_NUM_33
BUTTON_PIN GPIO attached to button of rotary encoder. GPIO_NUM_32
FAN_POWER_PIN GPIO that controls power to the fan. GPIO_NUM_25
FAN_PWM_PIN GPIO that controls fan speed when powered on. GPIO_NUM_26
HEATER_PWM_PIN GPIO that controls power to the heating element. GPIO_NUM_2
MAX_CS_PIN GPIO connected to chip select line of thermocouple interface module. GPIO_NUM_13
MAX_SO_PIN GPIO connected to data line of thermocouple interface module. GPIO_NUM_21
MAX_CLK_PIN GPIO connected to clock line of thermocouple interface module. GPIO_NUM_19

The following constants are associated with Bodmer's TFT_eSPI library. Please refer to the documentation for that library if you want to change these settings.

    -D USER_SETUP_LOADED=1
    -D ILI9341_DRIVER=1
    -D TFT_CS=5
    -D TFT_DC=16
    -D TFT_RST=17
    -D LOAD_GLCD=1
    -D LOAD_FONT2=1
    -D SPI_FREQUENCY=27000000
    -D TOUCH_CS=-1

Builds

The project supports a number of different build configurations that I used for development and testing. The builds are configured using the following constants in the build_flags entry:

Constant Description
CTRL_SIMULATION Simulates the temperature control elements (the heater block and cooling fan).
ENCODER_SIMULATION Simulates input from the rotary encoder using the keyboard. In which case the following can be used in the terminal:

R = Rotate encoder one click clockwise.
L = Rotate encoder one click counterclockwise.
Add an 'F' to either to make it a fast rotation.

B = Press the rotary encoder button.
BL = Long Press the rotary encoder button.
THERMOCOUPLE_SIMULATION Simulates the measured temperature of the hotplate. In order to provide a little realism, the change in temperature is based on the amount of heating or cooling currently being applied and the current hotplate temperature (the hotter the temperature, the more difficult it is to raise the temperature another degree).
TIME_ACCELERATION A multiplier indicating how many simulated seconds pass each actual second. This allows quicker testing of the code associated with the wraparound of the temperature vs time graph after 330 seconds. It does, however, leave gaps in the graph.
VIEW_SIMULATION Outputs screen update information to the terminal instead of to the TFT display.

Using these constants, a number of predefined builds are available (represented by the [env] entries in the platformio.ini file).

Env Description
release Normal build for functioning hotplate.
thermocouple_simulation Simulates the temperature measurement only. Useful for testing the almost complete circuit on the benchtop (but, for example, using a lightbulb instead of the actual heating element) since you don't need to have the hotplate actually heat up.
thermal_simulation For testing of rotary encoder input with Handler logic. Thermal control (heater and fan) and temperature measurement are simulated.
ctrl_simulation Useful for testing all display formatting on the TFT display (with no time acceleration). Encoder input, thermal control and temperature readings are all simulated.
fast_simulation Same as ctrl_simulation but "time passes" at 4 times normal speed. Useful for testing wraparound of the temperature graph on the TFT display without any other hardware hooked up.
full_simulation Useful for testing the Handler logic in isolation (without any of the actual hardware).

If you run one of these builds, it is identified during startup by a message in the terminal output (for versions that don't support the TFT display) and also on the Welcome screen for versions that do support the TFT display.

Temperature Adjustment

The program includes an optional temperature adjustment feature if you find that the measured temperature from the thermocouple differs greatly from the setpoint temperature. I ran a test where I set the temperature using the Manual Control feature of the software, measured the actual temperature at the surface of the hotplate using a multimeter and compared the two. In the end, I found that if I waited for a minute to let the temperature settle, the two values were close enough that the offset was not concerning. But I left the feature in place in case it would be of use for anyone.

The adjustment function uses an equation of the form:

Ta = P2 x Tm2 + P1 x Tm + P0

  • Ta is the adjusted temperature
  • Tm is the measured temperature
  • P0, P1, P2 are the "adjustment" parameters

There is a spreadsheet (Temperature Adjustment.ods - in LibreOffice Calc format) in the repository to help you determine the appropriate values for the 3 parameters. Enter the setpoint and measured values at a few temperatures and the best fit line (and its paramters) will be displayed.

To activate this feature, edit platformio.ini, uncomment the following lines and enter the values you determined. Note that all three values must be defined to activate the feature.

  ; -D TEMP_CORRECTION_P0=3.26
  ; -D TEMP_CORRECTION_P1=0.8823
  ; -D TEMP_CORRECTION_P2=-0.000885