Basic Information:
Printer Model: N/A
MCU / Printerboard: Custom STM32G0B1 board
Host / SBC: CM4
klippy.log / NA
In my functional test macro, I’m trying to read an adc_temperature
sensor.
On my board, there are three “temperature” sensors (two being actual temperature sensors and one being a voltage monitor circuit (PS_voltage
). I’ve defined them as:
[heater_generic heater0]
#gcode_id:
# The id to use when reporting the temperature in the M105 command.
# This parameter must be provided.
heater_pin: PD6 #$# HEATER0
#max_power:
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA0 #$# THERM0
#smooth_time:
control: pid
pid_Kp: 67.552
pid_Ki: 1.603
pid_Kd: 711.829
min_temp: 0
max_temp: 60
# See the "extruder" section for the definition of the above
# parameters.
[heater_generic heater1]
#gcode_id:
# The id to use when reporting the temperature in the M105 command.
# This parameter must be provided.
heater_pin: PB3 #$# HEATER1
#max_power:
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA1 #$# THERM1
#smooth_time:
control: pid
pid_Kp: 67.552
pid_Ki: 1.603
pid_Kd: 711.829
min_temp: 0
max_temp: 60
# See the "extruder" section for the definition of the above
# parameters.
[adc_temperature PS_voltage]
# PSU Voltage Value from Thermistor Value
# Assumuptions:
# 1. Power Supply Voltage from 0V to 70V
# 2. Thermistor ADC Pullup 4.7k
temperature1: 2
voltage1: 0.151
temperature2: 70
voltage2: 3.049
[temperature_sensor PS_voltage]
adc_voltage: 3.3
sensor_pin: PA2 #$# VINMON
sensor_type: PS_voltage
min_temp: 11 # For 12V Power Supply
max_temp: 26 # For 24V Power Supply
gcode_id: PS_voltage
To read them and display their values, I use the macro code:
RESPOND TYPE=command MSG="Test1: Heater0 Temperature: { printer["heater_generic heater0"].temperature }"
RESPOND TYPE=command MSG="Test1: Heater1 Temperature: { printer["heater_generic heater1"].temperature }"
RESPOND TYPE=command MSG="Test1: VINMON Voltage { printer["adc_temperature PS_voltage"].temperature }"
heater0
and heater1
return values without issue (and match what is shown on the Mainsail Dashboard) but the RESPOND
line for PS_voltage
causes the error:
I’ve looked through klipper/klippy/extras and it looks like the other temperature python objects have a get_status
method which is accessed by the macro processor whereas adc_temperature
does not.
I think all that’s needed to return the temperature value is to add the following get_status
method to klipper/klippy/extras/adc_temperature.py
in the PrinterADCtoTemperature
class:
def get_status(self, eventtime):
return {
'temperature': round(self.last_temp, 2),
}
Would this be correct?