I have been working on a M6.script file for working a lathe turret via a spare axis and standard output pins (in this case the Y-axis since I dont need it for my lathe) and I would like to provide for fixed tools. In order to move from turret to fixed tools and back again I need to store the current turret position however I have found the variables are not stored between uses of the script. I would like to know how or if I can store a value ether while the machine is on, or preferably until removed.
I currently plan to use an unused offset in one of the tools for now to store a whole number, and if this does not work I will force a move to T1 before setting to requested T# of fixed tool
Turret movements are G91/incremental to allow movement in both directions via the shortest path and infinite rotation of the turret.
To help with number of tools if this script is used by others:
Y-axis: 1 unit = 1 turret revolution, 1 move = 1 / number of positions set in script
Tools above the set variable will be treated as fixed and reference the tool table only for X and Z offsets with no movement.
T0 has been used as a position setting procedure for the turret, requesting T0 will force a stop if needed and the next tool change after T0 sets the current turret tool with no movement. Although I noticed T0 cannot be defined in the tool table I added a check to make sure it wasn't in the there and request it be removed if found. Message boxes keep you informed if what is going on when using T0
I have been trying to note lines as I go including some of the existing code I kept for others to use.
The turret design I intend to use self locates when locked although the script could be given the option to use single direction ratchet and reverse tool turret with an on/off variable in the script if some one thought it was worthwhile adding. All I need is 1 pin to be on and a delay time before and after the movement. I am not sure whether to write it that way or just reference the settings choice, this may allow a more complex procedure, but increases the technicality of adapting machine settings for other folks setups since the ATC settings are geared towards Mill and just looks like a spread sheet so some of us.
I searched a lot for some of this info and came up dry so I am planning to upload when I finish the file.
Parameter names that start with '_' (underscore) are global and will not be reset.
If you put it in "Parameters.txt" file then it will be remembered even between software restart.
I have attached a working copy of the lathe turret script for PlanetCNC TNG with all notes left in, if anyone has time and a spare axis to play with please test it to death and let me know if you break it (the code...). Keep in mind the units/min for axis speed will be RPM if the setup is followed. My changer axis is set to 10 units/min vs 2000mm/min for Z for example.
There are more features to add but the work so far:
- Assign turret to any axis.
- Any number of turret positions.
- Follows standard pin activation/deactivation and delay process in ATC settings.
- Retracts X then Z by default when moving to tool change position.
- 2 (or 3) modes of rotation, 2-way, one way, other way.
- 2-way rotation takes shortest path.
- Infinite rotation in any direction.
- Optional over rotate and reverse for ratchet turrets.
- Optional additional reverse in ratchet mode to assist locking.
- Turret position setting procedure: Change to T0, next tool change sets tool with no turret movement.
- T#'s above turret positions are treated as fixed and turret location is stored when used.
- If setup is followed turret position will be remembered after shutdowns and resets.
Let me know if it works for you! I hope this script will help for self built turrets or stepper converted and cannibalised 2nd hand projects.
Features I would still like to add:
- For long tool avoid set additional tool length as Z tool change offset in tool table
- Largest Z tool change offset will be added to Z retract when passing tool on turret change
- Attempt to avoid long tools or minimise Z retract with alternate turret rotation
- Automatic tool measuring - Please set all offsets in tool table in advance currently
- Support for second turret..?
Anyone else got any ideas? I should be able to boil down the code quite a bit once its done. I have also started a Fusion360 turning post processor to work with PlanetCNC and "T# M6" tool changes, it turns, tool changes and threads correctly. I have started from the HAAS turning post since I am familiar with their flavor of code and I would like to add some of their M-codes to PlanetCNC like auto tailstock and part catcher.
Can I define an array of strings in a script and assign them to a variable? "X", "Y", "Z", "..." etc. I see ARCHR and ARRAY in the Gcode guide but I can't find an example to know if I am interpreting their usage correctly.
Thanks, I will get that altered later. I did however try a clean install of the script today and picked up a heap if errors (I never could spell) so I've attached a v0.2, altered the install readme and included the work in progress Fusion 360 turning post that worked well for me.