" Internal error during connect: math domain error."

Basic Information:

Printer Model: Ender 3
MCU / Printerboard: BTT SKR Mini E3 -v- 3.0
Host / SBC Raspberry Pi 4B (2GB)
klippy.log
logs-20250401-141305.zip (6.9 KB)

Fill out above information and in all cases attach your klippy.log file (use zip to compress it, if too big). Pasting your printer.cfg is not needed
Be sure to check our “Knowledge Base” Category first. Most relevant items, e.g. error messages, are covered there

Describe your issue:

Can anyone help me understand where I’m going wrong here? Trying to configure “nitehawk-sb.cfg” post Stealthburner/Nitehawk toolhead hardware install. On startup, I get the following error: Option ‘z_offset’ in section ‘probe’ must be specified. Okay, opened up nitehawk-sb.cfg and added “z_offset:” with no parameters. Restarted machine, and got the following error: Unable to parse option ‘z_offset’ in section 'probe. Not unexpected. So again I opened up the config file, and added the value of 0.00 to the z_offset, and restarted. Now, this: Internal error during connect: math domain error.

I understand only in the vaguest terms what the error is; I’m at a total loss to understand why this failure would be associated with a parameter in “z_offset.” I tried entering both positive and negative integers, and all entries yield the same error message of math domain error.

Have not the slightest clue what to do with this. Looking at the ‘unhandled exceptions’ at the end of the klippy.log shows a number of errors in the ‘klippy.py’ file, which is way above my pay grade, and the last entry just states ‘math domain error.’ Not much to go on, for this relative newbie. Any ideas or pointers would be greatly appreciated!

Unsure, what you are tying to archive.

Regarding your klippy.log.

You might have a look at line 997 to 1015 of your klippy.log.

Thanks for the reply. Trying to get machine to start without errors. Replaced original print head with a Stealthburner, and used a nitehawk-sb toolhead (USB bus.) Downloaded LDO’s config file for the nitehawk, commented out things that weren’t relevant (like X & Y stops - - still using original OEM), and so far it’s been one error after another; been dealing with them one by one, then this “math domain error” pops up and I can’t get past it.

I did see those lines, but as I understand it, the errors appear to be in the klippy.py file, which I haven’t touched in any way. Likely I’m not understanding what it’s telling me, but that’s what I see when I read them. It would seem I’ve either omitted something it wants, or entered invalid values for something… or both. Anything I do from here would be shooting in the dark, without further input from more knowledgeable heads :wink:

I think it’s a syntax error.

Klipper quits after

[temperature_sensor hot_end]
sensor_type = PT1000
sensor_pin = nhk:gpio29
pullup_resistor = 2200
min_temp = 0
max_temp = 275

I guess you should declare your hot_end sensor in your [tmc2209 extruder] section like (don’t copy, your hardware is different)

[extruder]
step_pin = nhk:gpio23
dir_pin = nhk:gpio24
enable_pin = !nhk:gpio25
rotation_distance = 22.7562867
gear_ratio = 50:10
microsteps = 32
full_steps_per_rotation = 400
nozzle_diameter = 0.400
filament_diameter = 1.75
heater_pin = nhk:gpio9
sensor_type = Generic 3950
sensor_pin = nhk:gpio29
min_temp = -10
max_temp = 270
max_power = 1.0
min_extrude_temp = 170
pullup_resistor = 2200
control = pid
pid_kp = 22.315
pid_ki = 1.750
pid_kd = 71.131

Think I figured out Klipper’s issue with the PT1000 (as it is in my config file.) As soon as I changed both references to it from “PT1000” to “pt1000,” it stopped complaining about it and went on to the next error, which is still the “math domain error” in response to ANY value entered into “z_offset.” No “z_offset” results in a demand to have one in the “Probe” section; a bare “z_offset:” with no value entered returns a “can’t parse value” error, any entry of any kind in ‘z_offset’ results in the math domain error. Still have NO idea what to do with this.

Please attach a new klippy.log and the printer.cfg file.

Apologies, I lost track of which file is which; should be klippy.log, printer.cfg, nitehawk-sb.cfg. I VERY much appreciate your taking a look at this!

config-20241115-164147.zip (2.6 KB)
config-20250312-194600.zip (10.7 KB)
config-20250405-121538.zip (3.7 KB)

Based on the newest config you provided, try the following approach, assuming you are really connection a PT1000 to the nitehawk board:

Modify nitehawk-sb.cfg

[extruder]
step_pin: nhk:gpio23
dir_pin: nhk:gpio24
enable_pin: !nhk:gpio25
heater_pin: nhk:gpio9
sensor_pin: nhk:gpio29
pullup_resistor: 2200
sensor_type: PT1000             # <------------------------

Delete from nitehawk-sb.cfg

[thermistor pt1000]
temperature1: 0.0
resistance1: 1000.0
temperature2: 100.0
resistance2: 1385.1
temperature3: 200.0
resistance3: 1758.6

[temperature_sensor hot_end]
sensor_type: pt1000
sensor_pin: nhk:gpio29
pullup_resistor: 4700
min_temp: 0
max_temp: 275

Delete from printer.cfg

[tmc2209 extruder]
uart_pin: PC11
tx_pin: PC10
uart_address: 3
#  Following line: original value 0.650; changed for Galileo 2 6/19/24
run_current: 0.6  			
stealthchop_threshold: 999999

[heater_fan heatbreak_cooling_fan]
pin: PC7
# (FAN_1 on card.)

As a general remark: Since the nitehawk board seems to have only a pullup of 2k2, I’m not sure that directly connecting a PT1000 will work properly.

If it does not work, provide both your final config files AND the corresponding klippy.log.

Made the suggested changes; saved & restarted. Now the first error that shows is "Unknown temperature sensor ‘PT1000’ Changed to ‘pt1000’ in the event it matters (seemed to when I made that change in my initial config file)… error persists.

Have read in several places that if using a pt1000, ideally, it needs a 1K 1% pullup resistor. If I can make Klipper happy, I was planning to replace the 2.2K (R19) with a 1k 1% 0204 SMD resistor. Does that seem accurate to you, or more like nonsense? In either case, that’s obviously down the road apiece AFTER it’s running.

Attaching requested config files & log from startup made with these changes in place.
klippy(1).log (91.5 KB)
nhk-config-20250406-142706.zip (3.6 KB)
config-20241115-164147.zip (2.6 KB)

Klipper started to complain about the PT1000 as you put into the [extruder] section.

As for Configuration reference - Klipper documentation

sensor_type: PT1000
sensor_pin:
#   Analog input pin connected to the sensor. This parameter must be
#   provided.
#pullup_resistor: 4700
#   The resistance (in ohms) of the pullup attached to the sensor. The
#   default is 4700 ohms.

Have you tried with PT1000 at all points where you use it?

So far, it doesn’t seem to matter whether I put it in the “extruder” section of printer.cfg, or delete the “extruder” section from printer.cfg and just use the one in the nitehawk-sb.cfg file. It doesn’t like “PT1000” in either location. If I “define” the PT1000 in the nitehawk-sb.cfg, (temp1/resistance1, 2, and 3) and leave it as “PT1000,” it still doesn’t like it. If I then change from upper case to lower case (pt1000) it stopped haranguing me and moved on to the math domain error, which so far nothing has affected, other than as I described above. As I understand it, it could be in both locations, and as the last file read, the nitehawk-sb.cfg entry will override the one in printer.cfg, so technically it shouldn’t matter… though likely it does and I just don’t know how.

You did not follow the above instructions.

  • Remove the [temperature_sensor hot_end]
  • In the [extruder] section in the included nitehawk config set the sensor type to PT1000

For any new issue, please follow the above instructions and provide only one klipyy.log file and one set of configuration files. I prefer not to guess which files to examine.

My apologies for the multiple files - - I didn’t realize one of them contained both config files. I’ll make it a habit to look at them before uploading them.

BINGO! Got it in one!! Well, two… but that was entirely my fault. I appreciate your help, and patience with a newbie.

1 Like

How did you fix it? Others may stumble into the same problem.

Oh… followed (correctly and completely, the second time…) Sineos’ instructions listed above: Modify nitehawk-sb.cfg,… delete from nitehawk-sb.cfg… and last, delete from printer.cfg. All the error ‘redscreens’ went away and it was ‘bluescreen’ for a few minutes, then errored (amber) with can’t connect. With all the cut/copy/paste and deleting, I took a piece of the [mcu] section out and didn’t notice. Wasn’t hard to spot, just ‘had a moment’ when reconfiguring thermistor and stepper driver entries caused a ‘can’t communicate’ error. Quickly noticed the truncated [mcu] section and checked a backup file… yep, “baud:” and "restart_method: " were missing. No wonder… Fires right up now, homes all axes, good to go! Thanks again, Sineos!

2 Likes