External commands question. Run a gpio command after print job finished/idle for x amount of mins?

edited January 2018 in Questions & Answers
I've already created an extcommands.xml file and use it to power on/off my printer but I'd love to automate it to shut down after idle a certain amount of time.  In the extcommands.xml file i created a line      <execute name="idleoff" allowParams="false">/var/lib/Repetier-Server/idleoff.sh</execute> 

the idleoff.sh file runs the gpio write to send the pin low and it works as designed.  DO I just add and end script of @execute idleoff
??

Thanks
Dave

Comments

  • somehow yes.
    You need your own control logic that queries if printer is idle and after some time shuts down printer. You can do this as external software that uses server web api to query printer state or as a lua module inside, also that might get hard. You could attach it to a timer call and store state in a global state variable you define. For most option 1 will be easiest solution.
  • Ok with that said it may just be easiest to have it shut down right after the print job.  I suppose i don't need an idle timer, I just need it off after the job.  So just add that ending script and give it a go?

    Dave
  • Yes, but remember that the printer caches commands. So add 30 times
    G4 P1
    and then your shutdown script. YOu might want to wait maybe a bit longer if fans need to cool down extruders first. In that case add one more G4 at the beginning
    G4 Sseconds

  • Roger that, thanks for the amazing support.
    Dave
  • As an aside why couldn't I just do something like G4 S1 rather than 20 1ms dwells?
  • We compress commands and send 127 byte of commands to firmware. So when your external command runs the print would not be finished and could take a minute to finish. G4 waits for end of moves but is not enough to fill queue so we just send so much that we know then these dummy commands got send the print is really finished and it is safe to shutdown.
  • edited January 2018
    OK thanks.  I want to be clear where to add these commands.  In end gcode or in config | printer settings | scripts| end code?

    Dave
  • Where you want. Server does not know end code of slicers so it is just handled as normal commands and send. After that it sends the end code from the scripts.

    I personally would add it to the scripts end code so you can change it later without needing to upload new sliced gcodes. 
  • edited January 2018
    Does the script end code run AFTER the gcode or is it just injected into the end gcode?  So basically the exact same thing?  Because if it was after the gcod runs then I woudl not have to add the dwell commands 30 times would I?  Or is it still a buffer issue?  
    From what I see adding to scripts is a global script for that printer vs. a slicer by slicer gcode addtion right?

    Dave
  • Server will add script end gcode directly after the slicer script ends, no delay. So you still need to add the 30 G4.
    Difference is in deed is that that script is printer related and will run after EVERY print (except you abort it).
  • thanks, worked perfectly today.   This is a very user friendly program for someone who has only worked on it for 2 days.
    Dave
  • edited January 2018
    Following up on this.  I noticed that the gcode always puts the end code from the cure slicer start g-code rathe rthan my  config | printer settings | scripts | end code.  I even attempted to blank out the gcode.  Or was I mistaken in assuming that this would inject it into the gcode like it does from within the slicer end gcode tab?

    Dave
  • Cura slicer has it's own start/end gcode. The start/end gcode in host are added just like servers start/end gcode during print if host is the printing instance not the server.
  • Ahh so it depends where the print originates from?  What does the following do then?  
  • Can I ask one more question regarding the dwell G4 command?  I do have the G4 P1s (30 of them) in the end gcode and it does allow me to use @execute to shut off my printer.  My question is, I want it to wait longer so after those 30 G4 P1s I added a A4 S300 (Wait 5 minute) but it doesn't actually read that.  Do I need to put more of the 1ms dwells in first before it?  I guess i just don't grasp the buffer problem that is encountered here.
  • You put the 
    G4 S300
    before the fast G4 commands. Remember the last one do not get executed because you disable the printer.

    The copy server configs copies the printer dimension and shape to host.
  • edited January 2018
    I have the G4 S300 before the execute command.

    So end code looks like this
    G4 P1 (x30)
    G4 S300
    @execute printeroff

    Should it dwell 300 seconds after the 30 1ms dwells?


    Also that copy server config does not copy the scripts tab from server does it?  Or is that scripts tab in host different than printer settings | G codes | Event Dependent on Server?
  • I just said that you have ti put it BEFORE the 30 G4 to make it work, Please read my answers.
  • sorry i thought we needed the 30 1ms to fill the buffer first so the next commands would be run.  Is there somewhere I can read up and better understand why I need to put a bunch of random filler commands in just to make things work properly?

    Dave
  • I explained it already at the top:-) 
    Firmware buffers commands and therefor server does not know what is already executed. So we fill it with commands we do not care about to be sure the wanted commands were executed.
  • Sorry, I'm trying to understand this.  How many commands will fill a 127 byte buffer?   Why would the printer not run every command sent to it when it's in the buffer and then when done buffer the next set of commands, run them, etc. until no more commands are sent to be buffered?  It has to somehow know the commands have been run otherwise how could it flush the buffer and receive new data?  Sorry for the seemingly basic questions but it just is baffling me.

    Dave
  • It's not running all commands because you power off the printer before it has finished executing them. Otherwise they would execute of course.
Sign In or Register to comment.