You are not logged in.

#1 2018-03-27 05:16:23

mungbean
Member
Registered: 2018-03-21
Posts: 12

Turning printer on and off

I have a Wanhao D7.  I was wanting to turn the printer off after a print. 
I have tested a few different methods.  The enable auto shutdown doesn't work for this.
I have successfully added a wifi relay to my FDM printer and via octoprint I can execute a python script that switches the relay state.
This can be executed via a button or after automatically a print finishes and temperature conditions are met.

Is their any way to execute a python script upon successful print finish? I was looking at a customized button for manual control and the print stop gcode/execute print stop options.

Here is an example of my script.  This turns on the printer via a wifi relay (ip address) and a relay for some 12v LED's
-----------------------------
#!/user/bin/env python
import requests
r = requests.get('http://192.168.1.100/api/relay/0?apikey=XYZ123&value=1')
print r.text

import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,GPIO.HIGH)
-----------------------------

Anyway someone think I could implement this into nanoDLP?

Offline

#2 2018-03-29 06:42:38

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,541

Re: Turning printer on and off

Execute field after print could run external python script.
You can find suitable fields both in setup edit and profile edit pages.

Even on gcode box you can call externals scripts/programs.

Offline

#3 2018-03-30 02:54:06

mungbean
Member
Registered: 2018-03-21
Posts: 12

Re: Turning printer on and off

Thanks for the reply.

Gave it a shot, works like a charm, can call upon script manually so far with customized buttons.  Was going to try adding to when print is finished.
I was looking at these options under hardware setup:

"Print Stop Gcode"

M107
G4 P30000
G90
G1 Z185 F300 P1
[[WaitForDoneMessage]]
M84
python /home/pi/printer/scripts/Shutdown.py

or

"Execute - Print Stop"

pushover.sh -p 1 -t "NanoDLP" "Printing stopped on Layer [[LayerNumber]] of [[TotalNumberOfLayers]]" python /home/pi/printer/scripts/Shutdown.py

Would either work/not work? and is one a better way to do it?

My Shutdown python script has a wait 5 minutes built into it to give everything time to position and cooldown.

Thanks

Offline

#4 2018-03-30 04:54:17

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,541

Re: Turning printer on and off

The first one would not work, you need to use appropriate keyword [[Exec ]] ...

They are almost same, no difference. But personally I would go with the first one as it could run async.

Offline

#5 2018-03-30 05:27:16

mungbean
Member
Registered: 2018-03-21
Posts: 12

Re: Turning printer on and off

Thanks for the fast reply.

So if I amended to this:

M107
G4 P30000
G90
G1 Z185 F300 P1
[[WaitForDoneMessage]]
M84
[[Exec python /home/pi/printer/scripts/Shutdown.py]]

Offline

#6 2018-03-30 12:39:35

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,541

Re: Turning printer on and off

Looks right.

Offline

Board footer

Powered by FluxBB