Jackpot board Vcarve spindle start stop issue (start OK won't stop)

I have set up a rotary 4th axis using the 6th driver on the Jackpot board.

I’m using Vcarve 9.5 I added rotary wrapping to the post processor, that part works fine. It substitutes A for X and applies factors to convert to cylindrical coordinates.
I want to control my DW660 trim router. I have a SSR wired to pin 27. I tried adding the text from the macros for start/stop on pin 27
Start works, but the stop does not
If I use the macro buttons it works. If I type in the M62 P1 and M63 P1 the spindle control (pin 27) starts and stops as expected.
BUT it doesn’t work when I use the pp and create a gcode file to cut a job.

+================================================
+                                                
+ Grbl - Vectric machine output configuration file   
+                                                
+================================================
+                                                
+ History                                        
+                                                  
+ Who      When       What                         
+ ======== ========== ===========================
+ EdwardP  28/11/2014 Written from GCode_mm.pp
+                     Added arc move support  
+ EdwardP  11/02/2015 Commented out arcs as these
+                     slow GRBL performance appear 
+                     interpolated anyway
+ EdwardP  18/06/2015 Explicitly set absolute mode (G90)
+ Mark     24/11/2015 Updated for interim 0.9 spec.
+                     Renaming to be machine specific.
+                     Removing M30 from Footer.
+ EdwardP  01/02/2018 Updated according to 1.1 spec
+                     Changed to 1.3 precision
+                     Spindle off (M5) in footer
+                     Added VTransfer Direct Output
+ EdwardP  07/12/2018 Added grbl laser 1.1 support. 
+                     - Power variable (0-1000 range)
+                     - Power on change only
+                     - [P] added to feedrate records
+                     - New laser record types:
+                       o JET_TOOL_ON
+                       o JET_TOOL_OFF 
+                       o JET_TOOL_POWER
+ MohamedM 13/12/2018 Move M3 and [S] from the header
+                     to a new SPINDLE_ON section which
+                     is not output in laser toolpaths
+                     or when the spindle speed is invalid (negative).
+ EdwardP 20/12/2018  Re-enabled arcs in response to 
+                     customer feedback ZD105327
+  MJC  11/DEC/2023   pasted ROTARY_WRAP_X
+ ======== ========== ===========================

POST_NAME = "1rev MJC rotary Grbl (mm) (*.gcode)"
 
FILE_EXTENSION = "gcode"
 
UNITS = "MM"

ROTARY_WRAP_X = "-A"

DIRECT_OUTPUT = "VTransfer"
 
+------------------------------------------------
+    Line terminating characters                 
+------------------------------------------------
 
LINE_ENDING = "[13][10]"
 
+------------------------------------------------
+    Block numbering                             
+------------------------------------------------
 
LINE_NUMBER_START     = 0
LINE_NUMBER_INCREMENT = 10
LINE_NUMBER_MAXIMUM = 999999
 
+================================================
+                                                
+    Formatting for variables                     
+                                                
+================================================
 
VAR LINE_NUMBER = [N|A|N|1.0]
VAR POWER = [P|C|S|1.0|10.0]
VAR SPINDLE_SPEED = [S|A|S|1.0]
VAR FEED_RATE = [F|C|F|1.1]
VAR X_POSITION = [X|C|X|1.3]
VAR Y_POSITION = [Y|C|Y|1.3]
VAR Z_POSITION = [Z|C|Z|1.3]
VAR ARC_CENTRE_I_INC_POSITION = [I|A|I|1.3]
VAR ARC_CENTRE_J_INC_POSITION = [J|A|J|1.3]
VAR X_HOME_POSITION = [XH|A|X|1.3]
VAR Y_HOME_POSITION = [YH|A|Y|1.3]
VAR Z_HOME_POSITION = [ZH|A|Z|1.3]
 
+================================================
+                                                
+    Block definitions for toolpath output       
+                                                
+================================================
 
+---------------------------------------------------
+  Commands output at the start of the file
+---------------------------------------------------
 
begin HEADER
 
+SKIP THE XH AND JUST SPECIFY G92  50MM ABOVE AXIS FOR ROTARY
"G21"
"G90"

 
+---------------------------------------------------
+  Command output after the header to switch spindle on
+---------------------------------------------------
 
begin SPINDLE_ON
"M62 P1"
"G92 X0"
"G92 A0"
"G92 Y0"
"G92 Z50"


+---------------------------------------------------
+  Commands output for rapid moves 
+---------------------------------------------------
 
begin RAPID_MOVE
 
"G0[X][Y][Z]"
 
 
+---------------------------------------------------
+  Commands output for the first feed rate move
+---------------------------------------------------
 
begin FIRST_FEED_MOVE
 
"G1[X][Y][Z][P][F]"
 
 
+---------------------------------------------------
+  Commands output for feed rate moves
+---------------------------------------------------
 
begin FEED_MOVE
 
"G1[X][Y][Z][P]"
 
 
+---------------------------------------------------
+  Commands output for the first clockwise arc move
+---------------------------------------------------

begin FIRST_CW_ARC_MOVE

"G2[X][Y][I][J][F][P]"
 
 
+---------------------------------------------------
+  Commands output for clockwise arc  move
+---------------------------------------------------
 
begin CW_ARC_MOVE
 
"G2[X][Y][I][J]"
 
 
+---------------------------------------------------
+  Commands output for the first counterclockwise arc move
+---------------------------------------------------
 
begin FIRST_CCW_ARC_MOVE
 
"G3[X][Y][I][J][F][P]"
 
 
+---------------------------------------------------
+  Commands output for counterclockwise arc  move
+---------------------------------------------------
 
begin CCW_ARC_MOVE
 
"G3[X][Y][I][J]"

+---------------------------------------------------
+  Commands output when the jet is turned on
+---------------------------------------------------

begin JET_TOOL_ON

"M4[P]"

+---------------------------------------------------
+  Commands output when the jet is turned off
+---------------------------------------------------

begin JET_TOOL_OFF

"M5"

+---------------------------------------------------
+  Commands output when the jet power is changed
+---------------------------------------------------

begin JET_TOOL_POWER
"[P]"
 
+---------------------------------------------------
+  Commands output at the end of the file
+---------------------------------------------------
+GO TO START Position

begin SPINDLE_OFF
"G0Z50"
"GOA0.0"
"GOY0.0"
"M63 P1"
"M2"

I also tried a version where " begin SPINDLE_OFF " was " begin FOOTER " same result

here is a truncated example of a gcode generated by Vcarve with this pp:

G21
G90
M62 P1
G92 X0
G92 A0
G92 Y0
G92 Z50
G0A-179.442Y-9.750Z46.001
G1Z38.058F127.0
G1A-180.000Y-9.351Z38.318F1016.0
G1Y-8.902Z38.590
G1A-178.815Y-9.750Z38.055
...
...
G1A178.578Y9.750Z38.030
G1A179.205Z38.032
G1A180.000Y9.181Z38.402
G1Y9.630Z38.116
G1A179.833Y9.750Z38.032
G0Z46.001
G0Z50
GOA0.0
GOY0.0
M63 P1
M2

the spindle will start as this file begins to run, but it doesn’t stop at the end.

Any ideas where to look? should I post this on the FluidNC discord?

thanks

My random guess is that M63 P1 is still in the planner when M2 kills everything. Adding a G4 P0 between them might clear the planner before reading the M2.

I couldn’t get G4 to work but your concept worked.

THANK YOU !!!

I moved the stop command before the A and Y moves

G1A179.833Y9.750Z38.032
G0Z46.001
G0Z50
M63 P1
G0A0.0
G0Y0.0
M2

So it kept the planner busy (?) anyway, it worked.
I”ll post my pp for Vectric GRBL both rotary and XYZ. in the my build section.