I would like to have a parameter say #<_maxrpm> that I can use in G96 statements, like
G96 D#<_maxrpm> S150
My lathe has a six speed manually operated gearbox. #<_maxrpm> needs to have its value set after which gear is used.
Right now I use a set of M101 - M106 command to manually set up the scaling for the speed. This works fine, except that I keep forgetting to enter the right M-code when I change gears. I can live with that. Here is an example for M104.
Code:
#!/bin/bash
R=0.8846
MAXRPM=1770
halcmd setp scale.0.gain $R
halcmd setp scale.1.gain $(echo "scale=5;1.0 / $R"| bc -q)
exit 0
What I want is to have access to the MAXRPM value in a global parameter #<_maxrpm>.
When I enter a high max rpm in the G96 command, say
G96 D2000 S150
and the gearbox is in fourth gear and the spindle will only do 1770 rpm. The program stops here.
So I want to set the rpm in D to the max possible for the specific gear in use.
G96 D#<_maxrpm> S150
would work for any gear.
Is there a way to define a global parameter from M-code? Or even better from hal,
then I can use the auto-detection of gear.