Where to insert code to issue G4 command after spindle start?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Where to insert code to issue G4 command after spindle start?
Hi Folks!
With great pleasure I was discovering all the improvements the PATH module has made recently. It is just awesome! Thanks to all the contributors - you rock!
I am using grbl_post and was wondering, how I could get it to insert an "G4 5" command to wait 5 seconds for the spindle to get up to speed, every time a "M3" Command was issued. Do I need to edit the post processor? I could not find any related code sections there. Any suggestions?
This would also be a good place to switch on coolant, etc.
Thanks, guys.
Sebastian
P.S. Adaptive tool paths are a dream come true! I am really excited.
With great pleasure I was discovering all the improvements the PATH module has made recently. It is just awesome! Thanks to all the contributors - you rock!
I am using grbl_post and was wondering, how I could get it to insert an "G4 5" command to wait 5 seconds for the spindle to get up to speed, every time a "M3" Command was issued. Do I need to edit the post processor? I could not find any related code sections there. Any suggestions?
This would also be a good place to switch on coolant, etc.
Thanks, guys.
Sebastian
P.S. Adaptive tool paths are a dream come true! I am really excited.
Re: Where to insert code to issue G4 command after spindle start?
yes I think a personalised post processor is the way to go here.
- roerich_64
- Veteran
- Posts: 1465
- Joined: Thu May 21, 2015 7:00 pm
- Location: Ostfriesland
Re: Where to insert code to issue G4 command after spindle start?
Those setting should be do in the global settings and there define the preamble and postamble
BR
Walter
BR
Walter
Die Liebe wird siegen, denn sie ist unzerstörbar
Re: Where to insert code to issue G4 command after spindle start?
It belongs neither in preamble nor postamble. This G4 command is to be issued after each toolchange. Pre- and postamble are executed only once.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Where to insert code to issue G4 command after spindle start?
Hi
hm, after a bit thinking about it. - It would be not a bad thing to have option buttons at the UI for switching coolant and spindle on and off (and pause, if needed) at each OP...
hm, after a bit thinking about it. - It would be not a bad thing to have option buttons at the UI for switching coolant and spindle on and off (and pause, if needed) at each OP...
Gruß Herbert
Re: Where to insert code to issue G4 command after spindle start?
Thank you guys for your answers, so far.
I agree with herbk. Just to have an option to insert custom g code before and after each op, to be defined in the setup sheet would give the most flixibility, I guess. This was the way I could set it up in Estlcam for instance.
So if i solve in the postprocessor, I was thinking, doing it similar to the way the toolchange is handled would be a working approach, right?
But I really think, having "hooks" before and after each op for custom code in the setup sheet could kill a lot of birds with one stone. Haven't looked at the source for ages, so I have no clue how hard this is to implement...
I agree with herbk. Just to have an option to insert custom g code before and after each op, to be defined in the setup sheet would give the most flixibility, I guess. This was the way I could set it up in Estlcam for instance.
So if i solve in the postprocessor, I was thinking, doing it similar to the way the toolchange is handled would be a working approach, right?
But I really think, having "hooks" before and after each op for custom code in the setup sheet could kill a lot of birds with one stone. Haven't looked at the source for ages, so I have no clue how hard this is to implement...
- sliptonic
- Veteran
- Posts: 3457
- Joined: Tue Oct 25, 2011 10:46 pm
- Location: Columbia, Missouri
- Contact:
Re: Where to insert code to issue G4 command after spindle start?
Take a look at the linuxcnc post. It has a pre_op and post_op global that does exactly this.
Re: Where to insert code to issue G4 command after spindle start?
Thanks for the hint! I tried this and ran into another problem.
I want to insert the G4 command right after the M3 command to wait for the spindle to get up to speed. This is not necessarily before or after every operation but just for the tool change operation. Including it in post_op would lead to adding G4s up unnecessarily. So using pre_ope and post_op does not really work. Any Ideas how I can intercept the spindle start command? It would work, of the spindle start commands would be issued by the pre_operation code, but they seem to be part of the operations itself. Any suggestion of how I can get hold of the spindle that command? Can I filter for it in the postprocessor?
Thank you once more.
I want to insert the G4 command right after the M3 command to wait for the spindle to get up to speed. This is not necessarily before or after every operation but just for the tool change operation. Including it in post_op would lead to adding G4s up unnecessarily. So using pre_ope and post_op does not really work. Any Ideas how I can intercept the spindle start command? It would work, of the spindle start commands would be issued by the pre_operation code, but they seem to be part of the operations itself. Any suggestion of how I can get hold of the spindle that command? Can I filter for it in the postprocessor?
Thank you once more.
- sliptonic
- Veteran
- Posts: 3457
- Joined: Tue Oct 25, 2011 10:46 pm
- Location: Columbia, Missouri
- Contact:
Re: Where to insert code to issue G4 command after spindle start?
There's this: https://github.com/FreeCAD/FreeCAD/blob ... ost.py#L96
If you want to insert a command AFTER a tool change, you could do something similar
If you want to insert a command AFTER a tool change, you could do something similar
Re: Where to insert code to issue G4 command after spindle start?
Hey guys!
While investigating the options for my problem here, I went down the rabbit hole and discovered another but related potential issue.
As far as I see, the Spindel start (M3 S0.000) is always initiated by a toolchange operation(M6). In my opinion this can be really problematic. Something like starting a spindle, laser, waterjet, etc. should always be done explicitly before an operation and not by a toolchange. Also keep in mind, that some machines ignore the spindle speed (S0.000) and switch on the spindle, as soon as they see the M3 command. So M3 S0.000 is really not the same as not starting the spindle at all. Not fun if the tool that happens to be in on the spindle is a drag knife for instance.
I would suggest, that the tool controller determines whether the spindle start command is issued or not. Maybe it can be a checkbox besides the spindle speed field. (Maybe If we could get hold hold of the M3/M4 command in the postprocessor (as operation), the postprocessor could eliminate the M3/M4 command if S is 0 so we would not need a checkbox in the tool controller. There we could also include the G4 command.)
Also I don't see, why a toolchange is an operation and starting the spindle is not. If it would be an operation, we could probably put some spindle specific code pre or post it in the postprocessor, just like it is done (pre) with the toolchange.
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?
P.S. I tried to catch the M3 / M4 commands in the postprocessor, just like it is done with M6, but had no luck. I think this is because M3/M4 is not an operation, right? Also I can not see any output / error messages from the post processor in the python console. How do you handle this?
Thanks again for your help
While investigating the options for my problem here, I went down the rabbit hole and discovered another but related potential issue.
As far as I see, the Spindel start (M3 S0.000) is always initiated by a toolchange operation(M6). In my opinion this can be really problematic. Something like starting a spindle, laser, waterjet, etc. should always be done explicitly before an operation and not by a toolchange. Also keep in mind, that some machines ignore the spindle speed (S0.000) and switch on the spindle, as soon as they see the M3 command. So M3 S0.000 is really not the same as not starting the spindle at all. Not fun if the tool that happens to be in on the spindle is a drag knife for instance.
I would suggest, that the tool controller determines whether the spindle start command is issued or not. Maybe it can be a checkbox besides the spindle speed field. (Maybe If we could get hold hold of the M3/M4 command in the postprocessor (as operation), the postprocessor could eliminate the M3/M4 command if S is 0 so we would not need a checkbox in the tool controller. There we could also include the G4 command.)
Also I don't see, why a toolchange is an operation and starting the spindle is not. If it would be an operation, we could probably put some spindle specific code pre or post it in the postprocessor, just like it is done (pre) with the toolchange.
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?
P.S. I tried to catch the M3 / M4 commands in the postprocessor, just like it is done with M6, but had no luck. I think this is because M3/M4 is not an operation, right? Also I can not see any output / error messages from the post processor in the python console. How do you handle this?
Thanks again for your help