Hello Guest it is April 12, 2021, 08:43:10 PM

Author Topic: Custom M11/M10 code headers and footers  (Read 374 times)

0 Members and 1 Guest are viewing this topic.

Custom M11/M10 code headers and footers
« on: December 26, 2020, 06:22:41 PM »
So I have added a laser to my CNC frame. I am having a hard time finding a suitable post-processor for Fusion 360. I have discovered the use of the inkscape Lasertools extension to create g-code.

however the headers and footers are not quire right

So in my research I have written a header and footer to turn the laser on with the M11 and off with the M10 commands that I can add manually to my laser code.

If you would please take a look at what I've written to see if this will do what I want it to which is to

Turn on the Spindle  at 0% power (spindle is mapped to laser output in mach 3)
Move to the origin of the program with the laser off
Turn on the laser at 50% power with a feed rate of 3000

full g-code program inserted here

turn off the laser set laser power to 0
Turn off the spindle
Stop program and rewind

So here are the code blocks I've written
;
M3 S0
G01 X0 Y0 F3000.0
M10P3 S0
(go to start of first cut)
M11P3 S50 F3000

add g-code here

;(Footer)
M10P3 S0
M5
G21
G90
G0 X0 Y0
M30


Will this accomplish what I'm looking to do?

Offline Tweakie.CNC

*
  • *
  •  8,691 8,691
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Custom M11/M10 code headers and footers
« Reply #1 on: December 27, 2020, 01:51:47 AM »
It may do but it is not perfect.

Your M10P3 and M11P3 commands will only come into effect when followed by an axis (any axis) movement.

So…

Your header may fail if the first Gcode movements are G00 positioning moves. (The laser will turn on before it gets to the G01 moves).

Your footer may fail if the Gcode ends at the X0, Y0 position. (the laser will stay on because there is no actual axis movement to X0, Y0 as it is already there).

Tweakie.
KEEP SAFE !
Re: Custom M11/M10 code headers and footers
« Reply #2 on: December 27, 2020, 04:26:30 AM »
Ok I understand that. How do I work around that? I have read about setting up a phantom axis to get the laser to turn off. Would it work to turn it on also?
Re: Custom M11/M10 code headers and footers
« Reply #3 on: December 27, 2020, 04:50:08 AM »
So would moving the G0 immediately after the M10 command keep it from turning on too soon and turn it off when the program is over  as shown below?

;
M3 S0
G01 X0 Y0 F1000
M10P3 S0
G01 X0 Y0
M11P3 S50 F3000

add g-code here

;(Footer)
M10P3 S0
G0 X0 Y0
M5
G21
G90
M30

Or would I need to set up the phantom axis?

Or would calling M10 with a short axis movement to simply back up like 1mm at the end of the program work?


Will this accomplish what I'm looking to do?
[/quote]
« Last Edit: December 27, 2020, 04:52:56 AM by WhiteRoom Skis »

Offline Tweakie.CNC

*
  • *
  •  8,691 8,691
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Custom M11/M10 code headers and footers
« Reply #4 on: December 27, 2020, 06:34:56 AM »
This is perhaps not easy to understand but look at it one line at a time…

M3 S0
G01 X0 Y0 F1000
M10P3 S0
G01 X0 Y0
M11P3 S50 F3000

The line G01 X0 Y0 F1000 will move the X and Y axes to zero (if they are not there already).
The line M10P3 S0 will do nothing.
The line G01 X0 Y0 will do nothing – the axes are already at X0 Y0 so the M10P3 will not be acted upon. Remember…
Your M10P3 and M11P3 commands will only come into effect when followed by an axis (any axis) movement and no movement occurred.
The line M11P3 S50 F3000 will mean the laser will be turned on at the next (actual) axis movement and what if that is a G01 positional move ?

Ideally, you need to modify your Fusion360 Post Processor so that it creates Gcode where your laser is turned on by M11P3 prior to every feed-rate move (G01, G02, G03, etc.) and turned off with M10P3 prior to every rapid move (G00). Adding a header and a footer to existing Gcode may work in some cases but I doubt it will be of any use in the long term.

Tweakie.
KEEP SAFE !
Re: Custom M11/M10 code headers and footers
« Reply #5 on: December 27, 2020, 08:24:48 AM »
Ok thnak you for your help. I see the issue. The code generated by the Inkscape laser tools plugin definitely adds the appropriate m11 m10 calls in the body of the code, but it does not necessarily add the right info in the header and footer. I'll be generating most of my laser code with this instead of fusion. I failed to,explain that well in the original post.

It is really just the header and footer than I need to figure out for this to run well.

I guess I'll just have to do som trial and error. Amy chance you can point me to an example of some code than has the correct m3 call follows by the correct sequences for m10/11 to fat rat and stop the laser the right way? Or should I try to program the phantom c axis?

Offline Tweakie.CNC

*
  • *
  •  8,691 8,691
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Custom M11/M10 code headers and footers
« Reply #6 on: December 27, 2020, 10:23:00 AM »
The Gcode file   Trispokedovetiles(laser).tap   contained in the .zip file here;
https://www.machsupport.com/forum/index.php?topic=18345.0  is a typical example of the M11/M10 switching. Output#1 is being used, there are no S commands or M3/M5 but it should give you the idea of how the laser is switched at the start and end of the code.
Also, the file   Star Trek.tap   (which does contain the S and M3/M5 commands) is typical for Mach4 laser switching where M62 is used in place of M11 and M63 is used in place of M10.

Hope this helps,

Tweakie.
KEEP SAFE !
Re: Custom M11/M10 code headers and footers
« Reply #7 on: December 27, 2020, 10:49:17 AM »
Tweakie, can you take a look at the file I have attached specifically if this will start/stop the laser commands properly? You can probably ignore the bulk of the code except to look at the rapid moves that would start stop to code in the middle of the file.

This was generated with the LaserTools extension in Ink Scape https://github.com/ChrisWag91/Inkscape-Lasertools-Plugin

I'm sure you are familiar with this extension with your vast laser knowledge But I figured I would attach them so you can see what I am working with.
Re: Custom M11/M10 code headers and footers
« Reply #8 on: December 27, 2020, 06:17:30 PM »
I found this on the Warp9 website in the laser PWM control documentation for the ESS.

(Start of GCode)

M3 (Enable the PWM output)
S50 (Set the PWM for the laser to 50%, assuming max of 100)
G0 X1 Y1 (Move to start)

M11P1 (This will activate the PWM output, synchronized to start with the next motion command)
G0 X10 (This is the line that will be burned from X1 to X10)

S20  (Lower the PWM  for the laser to 20%)
G0 Y10 (The line will be burned from X10 Y0  to X10 Y10)

S100 (Raise the PWM for the laser to 100%)
G0 X5 (The line will be burned from X10 Y10 to X5 Y10)

M10P1 (This will deactivate the PWM output, synchronized with the start of the next motion command)
G0 X0 Y0 (Moves to the next position)

(Do more things as desired)

M5 S0 (Shuts off the PWM)
M30 (Rewind)
(End of GCode)
 

I also think I had some issues with how my mach profile was set up. This guide indicates active low for the motor outputs and output signals. I changed this in my set up and will test again tomorrow.

____________________________________________________________________________________________________________________

would this piece of code work for headers and footers?

; WhiteRoom Skis Laser custom code

;
G90
G21
M3
S0

;
G0 X1 Y1 F3000.0
M11P3
G01 *********x Yyyy F3000.0 (*********x Yyyy indicates a G1 move defined in the code)
M11P3 F3000.0
S50

add inscape LaserTools g-code here (assuming the plugin generates appropriate code)

M10P3
S0
G0 *********x Yyyy
M11P3
S50

Add more LaserTools g-code (assuming the plugin generates appropriate code)

;(Footer)
M10P3 S0
G1 ********* Yyy
M5 S0
G0 X0 Y0
M30

« Last Edit: December 27, 2020, 06:33:25 PM by WhiteRoom Skis »

Offline Tweakie.CNC

*
  • *
  •  8,691 8,691
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Custom M11/M10 code headers and footers
« Reply #9 on: December 28, 2020, 01:07:40 AM »
Your Gcode file looks OK (there are many unnecessary commands in the code but that does not matter, they will not slow the code execution or cause any problems).

Not certain about the headers and footers, I would need to see them in the context of the Gcode file.

Why do you need headers and footers ?

Tweakie.
KEEP SAFE !