Where to insert code to issue G4 command after spindle start?

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
pauluzs
Posts: 27
Joined: Wed Feb 27, 2019 7:48 pm
Location: Netherlands

Re: Where to insert code to issue G4 command after spindle start?

Post by pauluzs »

Hi Guy's

I'm looking into the same problem as above, for laser/plasma/waterjet workflow, spindle start is also a part of it.

For this there should be a spindle start at the beginning of each pierce/cut and a spindle end at the end of cut/leadout and a spindle stop at the end of each cut. If possible there would be a difference in m3 and m4 ie cut with THC/AUTOFOCUS or without.

Based on these spindle commands the simulation viewprovider:CutTool ShapeColor should be set different for M3/M4 and M5 and depth of cut would change from top of stock to trough-all. There seem to be some code for color setting on a probe cycle. only haven't looked into that.

For S parameter in m3/4 commands THC voltage or cutting power could be set.

Been trying to do this in post without the wanted results as for now. A Dress up which inserts these commands or just custom G-code blocks might be a solution.
herbk
Veteran
Posts: 2657
Joined: Mon Nov 03, 2014 3:45 pm
Location: Windsbach, Bavarya (Germany)

Re: Where to insert code to issue G4 command after spindle start?

Post by herbk »

sebste wrote: Tue Mar 05, 2019 9:40 am In any case, starting the spindle should happen right before the operation that needs it and not after the operation of changing a tool.
What do you guys think?
For lasers und watercutters it is a need, but mills don't work like that, at least not the mills i know...
If there is no toolchange between OPs, the wasted time for waiting to speed up the spindle again counts more as a little wasted energie, needed for a running spindle at G0 moves.

If i need different speeds with the same tool, i create more then one TC with the same tool, but different speeds. Path don't put in a M3/M4 order between OPs with different TCs (but it should in my mind).
Gruß Herbert
pauluzs
Posts: 27
Joined: Wed Feb 27, 2019 7:48 pm
Location: Netherlands

Re: Where to insert code to issue G4 command after spindle start?

Post by pauluzs »

Agree it's a waste of time on milling op's still necessary on other processes

That's why i suggested a Dressup for this, so it's optional to insert/apply to a path
For milling it would be just a append a M3/4 and a G4 Tsec Command at the desired point ie. toolchange or start of cut etc.
where G0>G1>G1/G2/G3 (rapid,movedown,move)
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: Where to insert code to issue G4 command after spindle start?

Post by mlampert »

pauluzs wrote: Tue Mar 05, 2019 9:09 pm Hi Guy's

I'm looking into the same problem as above, for laser/plasma/waterjet workflow, spindle start is also a part of it.

For this there should be a spindle start at the beginning of each pierce/cut and a spindle end at the end of cut/leadout and a spindle stop at the end of each cut. If possible there would be a difference in m3 and m4 ie cut with THC/AUTOFOCUS or without.

Based on these spindle commands the simulation viewprovider:CutTool ShapeColor should be set different for M3/M4 and M5 and depth of cut would change from top of stock to trough-all. There seem to be some code for color setting on a probe cycle. only haven't looked into that.

For S parameter in m3/4 commands THC voltage or cutting power could be set.

Been trying to do this in post without the wanted results as for now. A Dress up which inserts these commands or just custom G-code blocks might be a solution.
A dressup is for machine independent path manipulations. All of this belongs into a post processor, not the TC or a dressup.
pauluzs
Posts: 27
Joined: Wed Feb 27, 2019 7:48 pm
Location: Netherlands

Re: Where to insert code to issue G4 command after spindle start?

Post by pauluzs »

mlampert wrote: Wed Mar 06, 2019 12:27 am A dressup is for machine independent path manipulations. All of this belongs into a post processor, not the TC or a dressup.
Clear, still fairly new to Freecad. Only where does simulation fit in? According to the wiki its job>path>verify>simulate>post should i do a other simulate after postprocessing to see M3/M4/M5's? Or should it be job>path>verify>post>simulate?
sebste
Posts: 25
Joined: Tue Sep 01, 2015 9:23 am

Re: Where to insert code to issue G4 command after spindle start?

Post by sebste »

A dressup is for machine independent path manipulations. All of this belongs into a post processor, not the TC or a dressup.
That is exactely what I think, Martin! So I suggest there should be a way to handle M3/M4 in the postprocessor.
I somehow failed to make myself clear. I think we mix up some things here.
My point is,
A) that M3/M4 should never be initiated at the end of a toolchange (what is the proper spindle speed for a dial indicator a touch probe? Or a drag knife?) but rather at the beginning of the operation that requires a running spindle. (Btw, I did not mean to say that an operation should stop the spindle at its end either. Therefore there is actually no time is wasted.)

B) Starting the spindle or changing the spindle speed should not require a toolchange, since this is in fact is a waste of time. (My machine goes to the tool change position and touches the tool length sensor during every toolchange. It also requires operator intervention) I think there are a lot of good reasons why M3/M4 and M6 are seperate commands in g-code.

Regarding non milling machines, lasers, waterjets, plasma, etc.: some CAM packages have an option to issue M3/M5 commands before and after every G1/G2 move. But I guess that could be easily done in the postprocessor (where it belongs IMO) if spindle control would be independent from toolchange.

From my perspective it is not so much a question if I can get it to work for me, but what is the most flexible, clean and safe way to handle spindle control in path.
Clear, still fairly new to Freecad. Only where does simulation fit in? According to the wiki its job>path>verify>simulate>post should i do a other simulate after postprocessing to see M3/M4/M5's? Or should it be job>path>verify>post>simulate?
I think 2d cutting with plasma, laser, waterjet or knifes are so different in nature from milling, that it would be hard to cover them in the same simulation.

Sorry, got a little sidetracked from the original topic. Should this be a seperate thread?
sebste
Posts: 25
Joined: Tue Sep 01, 2015 9:23 am

Re: Where to insert code to issue G4 command after spindle start?

Post by sebste »

Okay, so I investigated this a bit further.

Since Feeds and speeds are determined by the tool controller, it makes sense, that the tool controller issues the spindle start command.
I have had some success changing the postprocessor in a way, that it includes the G4 Command after spindle startup and that it supresses M3/M4 if S is 0.

So far so good. The issue that is left, is that there is no way to determine if the tool controller should actually issue an M6 command. This is the case if I want to change the actual tool, but not if i just want to change the tool controller in order to change feeds & speeds but not the tool on the collet.

So from my point of view a good solution would be to add a checkbox to the tool controller to for output of the M6 command. This way, we can change the tool controller without actually doing a tool change (including tool length probing, etc)
In the same go we could add a command for M7 M8 M9 (coolant) to the TC.

The control of Lasers, Waterjets, Plasmacutters, etc. can relatively easily be done in the post processor by filtering for G1/G2... commands and adding the respecting M commands there, then.

What do you think?
pauluzs
Posts: 27
Joined: Wed Feb 27, 2019 7:48 pm
Location: Netherlands

Re: Where to insert code to issue G4 command after spindle start?

Post by pauluzs »

I think 2d cutting with plasma, laser, waterjet or knifes are so different in nature from milling, that it would be hard to cover them in the same simulation.

Sorry, got a little sidetracked from the original topic. Should this be a seperate thread?
It has one.

Al tough ie Plasma, water jet can cut beveled edges , cone shapes and copes on pipe etc., this would compare most with a slotting operation.
Making it a 4 or 5 axis operation with a pivoting head or a rotating axis
Besides that , also got a 6 axis robot for cutting, but as being new to freecad i would like to get my feet wet on some a bit more simple and less dangerous first.

My believe is the spindle commands (or at least some in cut in material dialect) should be issued before posting. So they can show up in the simulator, it should be Up to your postprocessor to leave them in or not.

So even Probe,s and dragknive's(which is a shearing operation) should have a spindle direction with a speed of +0(M3) or -0(M4) the post can act different if tools are found with 0 spindle speed.
sebste
Posts: 25
Joined: Tue Sep 01, 2015 9:23 am

Re: Where to insert code to issue G4 command after spindle start?

Post by sebste »

So even Probe,s and dragknive's(which is a shearing operation) should have a spindle direction with a speed of +0(M3) or -0(M4) the post can act different if tools are found with 0 spindle speed.
You have a point there. I changed my postprocessor in a way that it can filter out M3/M4 with zero spindle speed or leave them in.

In fact I could achieve most of what I need in the postprocessor. I will post my code here, once I have cleaned it up a bit.
I have also stored the last used tool number in a variable and filtered out toolchanges if the next tool is the same as before.

I have discovered a different issue, though. Apparently toolchanges / tool controller operations are only issued if the new operation requires a different tool number - that is basically what we want but leads to another problem I can not catch in the postprocesso: If I change to a new tool controller with the same tool (for different feeds and speeds), there is no TC operation issued, therefore the feedrates are changed to the F of the new tool controller, but the spindle speed/direction is not changed, since there is no M3/M4 S command issued.
This would indicate, that the spindle commands should better be issued by the operation and not by the tool controller, but still be based on the tool controller for the operation.

So in my opinion the key point here remains that the spindle should start / change speed with the beginning of the operation and not with the end of a tool change.
pauluzs
Posts: 27
Joined: Wed Feb 27, 2019 7:48 pm
Location: Netherlands

Re: Where to insert code to issue G4 command after spindle start?

Post by pauluzs »

Correct, that's why i suggested a dressup earlier, to catch these moments of starting and ending of a cut. Which technically ain't the correct procedure either.
So in my opinion the key point here remains that the spindle should start / change speed with the beginning of the operation and not with the end of a tool change.

To add just a bit more to this loophole, how about handling adaptive spindle speeds during the cut based in DOC?
Example Starting a slotting OP trough-all in 10mm S500 at 90 degrees and ending it on 45 (14,14MM) S800.
Would like to set my cutting power(spindle speed) according to DOC

Not really inserting that G4 Anymore, still related to issuing the spindle commands at start/end OP, that's also what you simulate from.
Post Reply