Want to travel faster ? Here's how!

Update:

Original post:

Hi fellas :smiley:

I know we aren’t many to use Fusion for generating Gcode for our CNC’s.
Nonetheless, I enjoy using it and have no plan on paying any soft for my not-so-frequent use of the machine.
But, as you might know, the main limitation on the free version of Fusion is the travel speed; said speed won’t exceed work speed, whatever you try.

So I dig a bit in the gcode world, and with the help of my dev brother, we came up with a Regex command to change that.
It’s not straight forward, but it’s much simpler and faster than anything I could’ve hoped for.

DISCLAIMER :: USE AT YOUR OWN RISK, I’M NOT RESPONSIBLE FOR ANY ERROR OR BREAKAGE OF YOUR MACHINE

If you know nothing about gcode, I STRONGLY ADVISE AGAINST USING THIS METHOD.
It’s mandatory to understand what you’re seeing in a gcode, and be able to know if it’s going in the right direction.
You also need VSC installed on your computer to use; notepad++ won’t do the trick.

So, how does it work ?

1- Generate your .gcode, as usual
2- Open VSC
3- Open your .gcode file in VSC
4- Ctrl + H, and Alt + R (or just select “Use Regular Expression” on the right of the box; if disabled, it won’t work)
Capture d’écran 2023-06-20 165726

5- Copy - paste the magic formula in the “Find” section
6- In the “Replace” section, you’ll enter the second formula, followed by the desired value in mm/min
7- Slam enter for every result given, until it gets back to the top and replaced all values. You can keep slamming enter to go over a second time and verify it did the job.
8- Magic’s done, your movement will now be fast as … you want.

If you’ve come this far, and everything seems clear to you, and you’re ready to give it a go, and you’re fully aware of what you’re doing, AND ONLY IF EVERYTHING IS CLEAR, here is the magic :

(G\d{1,2} (X0 Y0 Z0|Z5 F\d{2,4})\n)(([;M].*\n)*)(G\d [XYZ]-?\d{1,4}\.?\d{0,3} ?[XYZ]?-?\d{0,4}.?\d{0,3} ?[XYZ]?-?\d{0,4}.?\d{0,3} F)\d{2,4}

And the replace part, where XXXX is the desired speed in mm/min

$1$3$5XXXX

Good to know : it works because the Regex will find instruction movements where Z=5, hence movement above the surface, and change the F value afterwards to move faster ABOVE the top of the stock.
I used Z=5, because I set my retract / clearance / feed height at 5mm above my stock.
If you use any other value, it won’t work !
You still can modify the Regex at your will, and adapt depending on the value you’re using :slight_smile:

I hope this will help someone, some day.
And if not … at least, it helps me, and satisfies me greatly :grin:

7 Likes

Thanks!

Have you checked the search modes? Would be strange if n++ wouldn’t work. And if it does you could create an auto search & replace script to make life easier:)

1 Like

For sure. Using a regex from a post in the Internet (especially months from now) is really risky. The risk isn’t that your router will be hacked, but it may make a mistake and change the XYZ coordinates of a movement and you would get undesired cuts in your project.

I thought the flyfisher post processor detected these Z clearance moves and adjusted the speeds accordingly. Are you using that post processor?

scotty_physics

2 Likes

I thought the flyfisher post processor detected these Z clearance moves and adjusted the speeds accordingly. Are you using that post processor?

This is the section in the FlyFisher postprocessor that maps Fusion 360 G1 commands to G0:

image

2 Likes

Omg no no no. Not advisable.

Ok, with that out of the way, let’s see how this works.

G\d{1,2} looks for a one- or two-digit g-code command, G0, G1, G00, G01, or also G02, G03. This also matches G28, or G4, G92, etc. Then look for either “X0 Y0 Z0” (with no feedrate) or “Z5 F\d{2,4}” meaning Z5 F#### with two or three or four digits, and newline.

So this will match for example
G01 Z5 F123
G92 X0 Y0 Z0
G1 X0 Y0 Z0
G92 Z5 F1000 (generally shouldn’t occur, shouldn’t specify feedrate with G92)

But it won’t match
G1 X25 Y35 F123
G01 Z10 F300 (only works for Z=5)
G1X0Y0Z0 (requires space separation)
G92 X10 Y10
G92 Z5 (doesn’t match without feedrate)
G04
G28
G21

This serves as the “trigger” that marks the start of the high-speed section.

I’m not sure why you are triggering on X0 Y0 Z0. It seems like you might drag across the top of your workpiece at high speed, or if you do G92 X0 Y0 Z0 and then raise to safe height, then that raising motion is going to go at crazy speed.

Then the second part (([;M].*\n)*) is zero or one or more lines that start with semicolon or start with M.
This would match
; a comment
M3
M117 LCD message

But it would not match

T1 ; change tools
  ; a comment with preceding spaces
  M119 ; M-code with preceding spaces
G38.2 X0

If there are comments e.g. between parts, they are preserved, and M commands are preserved.

A non-match on the second part is not a problem, it just means that the speedup won’t occur. It won’t drop the gcode from the output, so that’s good.

The third part parses what is inferred to be a rapid at Z=5, and chops off the feedrate so that it can be replaced with the XXXX in $1$3$5XXX.

A couple observations:

  • It will work with G0 and G1 but not with G00 and G01. I assume the post processor is not generating G00 or G01 or it wouldn’t work, but it could be made to work with G0?[01] while not also tripping over other two-digit g-code commands.
  • The only other thing I see is a couple occurrences of . where \. was probably intended. I’m not sure if this has an effect.

Overall, this is clever. And terrible.

4 Likes

Well, it is regex… Would it be better or worse as a sed script?

1 Like

Almost identical, with a lot more potential for harm :slight_smile:

Holy Molly, i wasn’t expecting such reactions ! Well … kind of, I was propared to it, and hesitated quite a bit before posting. Should’ve hesitated a bit more ! :slight_smile:

So, in order :

Olivier, in fact I have no idea; my brother told me so, it’s his work, so I trust his words.
But if you find a way, feel free to share and I’ll correct my post accordingly.

Jeff, I’m indeed using the flyfisher pp, but not very familiar with it and had no idea it could do such thing. I heard about Fusion limitations, and thought no more …
I will take a better look !

K Cummins nobody’s changing any laws … Just bending them a bit ! Isn’t that the magic of open source ? :face_with_hand_over_mouth:

Robert, I definitly lack knowledge in this pp; could you elaborate on how to use it ? Or share a link that explains it to dummies ?

Jamie, I totally agree ! Hence my multiple warnings.
But a good written Regex line, in the hand of good peoples, will work just fine imo.

Regarding the Z=5, I’m planning to change it and make it more inclusive, to avoid such issues.

Regarding the lack of space seprartion in the line, never saw that; can marlin even manage it ?

Regarding the G92, I never had such generated Gcode ! I could modify it if needed, eventually, but at this point I don’t know if it’s needed ?
As for the other observations you made regarding the structure, it all came along differents gcode i made, the lack of results, and the tweaks I had to make in order for the formula to work properly. I could argue, give parts of Gcode to explain why, if you need ?

Regarding the G00 and G01, this could easily be solved, if needed ?

As stated earlier, I’m a bit of a noob in Regex, and beginner in milling …
So, yeah, it’s terrible, but it helps me be terrible faster :slight_smile:

In the end, I don’t know if I should keep this topic alive, or keep my dumb idea for myself ?
I anyone find it too harmful, I’ll gladly put it down !

And if anyone wants me to improve / work on the regex, on wathever issue they encounter, I’d gladly do it. As far as my abilities and knowledge goes :sweat_smile:

scotty-startrek

You will find the documentation for the FlyFisher post processor here. Typically, rapids are a small portion of my jobs, so I don’t turn on these features, so have little direct experience.

Based on the documentation. When defining a toolpath in Fusion 360, one section is the heights tab. In the heights tab, are various heights like clearance height, retract height, feed height, etc.

The default settings in the postprocessor for mapping the Z1 to Z0 is “Retract:15.” With this setting, if you turn on “Map: G1s → G0s Rapid,” Then any G1 movements made at the Retract height will be converted to G0 commands and move at whatever rapid speed you have defined. According to the documentation, the “15” indicates the height used if a Retract height is not defined. I’m not sure under what conditions a Retract height might not be defined. Perhaps there are specific toolpaths without a heights tab.

1 Like

For clarification, you have read my comments before, right? For the record (and for anyone else who may not know), 99.82% of my posts are to be read with either an imperial buttload (look it up, it’s a real unit of measure) of salt, or with tongue planted firmly in cheek. Especially if they include an image of any sort. Unless it’s part of actual documentation, any image I post is some post-modern, pop-cultural, gen-x/boomer dada-ism.

3 Likes

Soumds suspect. I heard that 88.64% of all statistics are made up on the spot.

4 Likes

So You're Telling Me There's A Chance Gif Imgur

Hello everyone !
Dumbass trying to brake the law of physcis here :smiley:

And after digging / testing a bit … I have to tip my hat off to @robertbu for the spot-on advice.
It’s exactly what I was trying to achieve.

Just … Simpler. Way simpler. And safer, also.
So … Just don’t use my Regex abomination, and use the post processor correctly instead ! :sweat_smile:

Maybe I should ask for Ryan to close this topic and edit the first post ?
I don’t know, it looks silly now …

Anyway, thanks everyone for the help and feedbacks !
Works like a charm now ! Again, thanks @robertbu :grin:

3 Likes

I edited the first post for you. It was a “clever” hack anyway. I don’t want to delete it.

2 Likes

@robertbu as always thanks for the great support on the post processor.

While I’m the author of the pp I don’t get a chance to use it very much now a days. The pp has all sorts of features, but most are disabled by default. I encourage all users to refer to the GitHub documentation and do some experimentation.

5 Likes