Close

Time to Configure Klipper

A project log for Not Just a Reflow Oven

Making a GCode controlled Toaster Oven with Klipper and Octoprint.

clearchrisclearchris 05/13/2020 at 23:060 Comments

This post assumes you have installed klipper and octoprint by following the instructions here:

https://github.com/KevinOConnor/klipper/blob/master/docs/Installation.md

It also assumes you have some familiarity with klipper already.  If you haven't used klipper before, this might not be the project to start on.

We will start with a basic configuration, with one heater configured.

For my host, I used a Raspberry Pi Zero W.  This is specifically recommended against, because it's too slow to feed commands to the MCU without stalling.  It works just fine on my oven, as my gcode scripts only feed a few commands per second.  I'm not running any steppers or extruders, so klipper is running at a slight fraction of normal speeds.  Octoprint runs a bit slowly, but it's adequate.

My MCU is an arduino uno clone with a protoshield.  The protoshield has a MAX6675 type-k thermocouple SPI chip and screw down connectors for the thermocouple.  The protoshield also controls the SSR, the 4 relay module and a buzzer.

First, let's set up the active buzzer.  This goes in the printer.cfg on the host.  I used pin ar6 on my arduino for the buzzer.

[output_pin buzzer_pin]
pin: ar6
pwm: false
hardware_pwm: false
value: 0
shutdown_value: 0

 After reloading klipper so it pulls the new config, you can go into the octoprint terminal and test out the buzzer.

SET_PIN PIN=buzzer_pin VALUE=1

 Set VALUE=0 to turn it off.

Now to set up the mechanical relays.  I used pin ar8 for the mechanical relay connected to the bottom halogen lamp.  Note the value and shutdown_value is set to 1.  These optoisolated modules are often set up to make on low signal and turn off on high.  This prevents the relays from making if the system reboots.  I used four similar sections, one for each mechanical relay.  You can test with the same command above, changing the PIN name and the VALUE.

[output_pin halogen_bottom]
pin: ar8
pwm: false
value: 1
shutdown_value: 1
hardware_pwm: false

 Next, I set up some macros to make setting up the mechanical relays easy and quick.

[gcode_macro setup_low_halogen]
gcode:
    TURN_OFF_HEATERS
    SET_PIN PIN=resistive_bottom VALUE=1
    SET_PIN PIN=resistive_top VALUE=1
    SET_PIN PIN=halogen_bottom VALUE=0
    SET_PIN PIN=halogen_top VALUE=1
    G4 P500

The gcode macro turns off all heaters (the SSR, more on that later) and set the unused heaters to 1.  The heater we intend to use is set to 0.  Then we stall for 0.5 seconds while the relays make or break.

Now to set up the SSR and thermocouple.

[heater_generic lowhalogen]
gcode_id: T0
heater_pin: ar5
sensor_type: MAX6675
sensor_pin: PB2
spi_software_sclk_pin: PB5
spi_software_mosi_pin: PB3
spi_software_miso_pin: PB4
spi_speed: 100000
control = pid
pid_ki = 1.269
pid_kp = 400
pid_kd = 60

I used an SPI type-k thermocouple converter chip, the MAX6675.  Klipper does not support software SPI, so you will have to use the hardware SPI pins on your MCU.  Many other sensor types are available, check the klipper docs.  Next, the SSR is set up on my arduino at pin ar5.  Technically, pin ar5 is hooked to a few resistors, an optocoupler and a JST jack to make removal easy.  Tutorials on how to do this are available online.

For each heater_generic you set up, you need to set up a "verify_heater" section.

#[verify_heater lowhalogen]
#max_error: 120
#check_gain_time:
#hysteresis: 5
#heating_gain: 2

 I have shown this, commented out, and with default values.  This is a safety feature of klipper, and if not set up, will send klipper into emergency stop mode.  Ovens don't heat as fast as 3d printer hotends do, and klipper, sensing that, will think something is wrong and will go into emergency shutdown mode.  Check the example-extras.cfg file in klipper for documentation on how to set it up properly.  My oven takes about 5 seconds to start seeing the temperature increase from room temp, yours will be different.

Finally, we change out the printer section of the printer.cfg file:

# The printer section controls high level printer settings.
[printer]
kinematics: none
#CHRIS:  the following are still required for noneKinematics
max_velocity: 500
max_accel: 3000
max_z_velocity: 25
max_z_accel: 30

This section tells klipper that there are no kinematics, so don't look for steppers, etc.

If everything is properly configured, and your thermal sensor is working, you can do a basic test by entering in commands in the terminal in octoprint.  Here's what I would use for my setup.

setup_low_halogen
SET_HEATER_TEMPERATURE HEATER=lowhalogen TARGET=50

That configures the relays, and sets the temperature target to 50C.  If anything unusual happens, you can turn off the heaters by using the following command.  If nothing unusual happens, congratulations, but you should still turn off the heaters and end the test:

TURN_OFF_HEATERS  

Discussions