Using @execute to energize an external relay

SETUP:
Bibo 2 Printer with Laser
CuraEngine
Repetier-Host V2.1.2
Windows XP SP3

I've added an air pump for laser engraving with air assist.  I created R1on.bat that turns the pump on (using a USB relay) and R1off.bat to turn it off.  Here's a simple gcode file:

M107 S0
G90
G28 X0 Y0
@execute R1on.bat
G21
G1 F4000
G1  X-6.2249 Y5.3869
G4 P0
M106 S125
G4 P0
G1 F2000.000000
G1  X7.0628 Y5.3869
G1  X7.0628 Y-5.746
G1  X-6.2249 Y-5.746
G1  X-6.2249 Y5.3869
G4 P0
M107 S0
G1 F4000
@execute R1off.bat
G1 X142 Y93 F9000
M18

Here is R1on.bat:
MODE COM1: baud=9600 data=8
COPY "R1on.hex" COM1:

Here is R1off.bat:
MODE COM1: baud=9600 data=8
COPY "R1off.hex" COM1:


What I'm trying to do is home the laser, start the air pump, do all the laser paths, then turn off the pump after the laser has completed all the paths.

When I "print" this file,  the relay turns on right away (good).  However, as soon as the gcode executes Line 7 (G1  X-6.2249 Y5.3869), the relay turns off.  The @execute R1off.bat command runs before the laser movements are finished.  I've tried adding G4 S10, M400, M291, etc. just before the @execute R1off.bat command, but in all cases the R1off bat file runs before the laser has finished the path.

Can anyone help me?

Thanks!

-L


Comments

  • You have ping pong mode disabled so we send as many commands in advance. In addition firmware buffers moves as well so G1 moves get acknowledged.

    Solution is quite simple - before the off script add 40 times
    M400
    that should normally suffer to wait for all moves to finish regardless of command buffering.
  • Thanks for the reply.

    I did figure that there was a command buffer, so I loaded up the file with 18 dummy commands (I used G1 F6000) just before the script to turn off the relay.  It's not a very elegant solution, but it works.

    Thanks again!

    -L
Sign In or Register to comment.