#This E-Stop code I pasted into the printer.cfg file is getting errors when I hit SAVE & RESTART.

25 messages · Page 1 of 1 (latest)

sand mulch
#

I edited and trimmed the code down to this:

[gcode_button e-stop]

pin: rpi:gpio26

press_gcode:
{% do call_method("printer.emergency_stop") %}

release_gcode:
{% if event.elapsed_time > 1.0 %}
{% do call_method("machine.reboot") %}
{% endif %}

Resulting error:

Error loading template 'gcode_button e-stop:press_gcode':
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'do'.

queen spokeBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

granite stirrup
#

Just a guess, but try getting rid of the spaces in “gcode_button e-stop”

sand mulch
#

The docs show a space in there when you add an optional name (e-stop in my case), but I tried it anyway and got a new error. lol thanks though!

lament narwhal
sand mulch
#

The first few lines are fairly straightforward, but it's not evident to me how to integrate the rest. I will try though. Thanks.

viral bobcat
#

Isn't this supposed to be in moonraker.cfg and not printer.cfg?

keen bridge
viral bobcat
#

Ok, the snip helge posted had "# moonraker.conf" at the top of it, so I'm all turned around

sand mulch
#

Yes it does have moonraker.conf at the top, but when Helge gave me the code he said to put it in printer.cfg.

sand mulch
#

So should I put the code in moonraker.conf?

viral bobcat
#

Someone else got this working., might be worth some time to search some

sand mulch
#

When I searched I found some discussions about just interrupting the power, using M112, or using this code or something similar. I didn't find a final solution that somebody implemented and it just worked. Then Mikl said the E-Stop functionality is part of the Klipper configuration. Then Helge pasted in some code, and here I am.

viral bobcat
#

Check #v-core-4 message

#

That might not point to the message
Here,

#

I am using a latching e-stop button so I did only the reset function. Since I am going 3v3 to GPIO I had to use the ~ in front of the pin to enable the built in pull down resistor. Also it looks like pin format has to be gpiochip0/gpio22 in my case to work. Going to do some more testing but so far so good. Here is my current moonraker.conf file

[button estop]
type: gpio
pin: ~gpiochip0/gpio22
on_press:
  # Executes immediately after a press is detected
  {% do call_method("printer.emergency_stop") %}
sand mulch
#

My moonraker.conf has a bunch of IP addresses in it. Should the E-Stop code go above or below the IP stuff or does it matter?

viral bobcat
#

I don't know, but I'd put it after

sand mulch
#

This is my moonraker file.

#

Okay I'll try it.

lament narwhal
#

Try putting your code within a code block. Start and stop it with triple backtick (same button as tilde ~)

keen bridge
#

@sand mulch either you use the moonraker syntax and put it in moonraker.conf or you use the klipper syntax and put it in printer.cfg.

for klipper it would look like this in printer.cfg:

[gcode_button e-stop]
pin: rpi:gpio26
press_gcode:
    m112

If you want the long press stuff, you need to use moonraker.

sand mulch
#

The code below that I put in the moonraker.conf file is what I got working and I'm going to use unless I discover some weird side affects. I wired my E-Stop pushbutton to pull the input to ground when pressed, but that caused the E-Stop to occur when I released it (instead of when I pressed it), so I added the "!" inversion symbol to the pin definition. I also wired in a 4.7kOhm pullup resistor to 3v3 (versus using the software pullup). When I release the E-Stop, the last instruction apparently reboots the machine using "machine.reboot", but I still have to do a "FIRMWARE RESTART" in Mainsail after that. I'm still learning the difference between the two functions. Thanks to everybody!

this code runs in moonraker.conf

[button e-stop]
type: gpio
pin: !gpiochip0/gpio26
on_press:
{% do call_method("printer.emergency_stop") %}
on_release:
{% do call_method("machine.reboot") %}

sleek spruce
#

Reason you had to invert it is because most ESTOP buttons come with NC contacts that open with Press. Look at your ESTOP button and see if it has another set of contacts. On some ESTOPs the contacts have a clear cover so you can actually see them.