Wow, that was fast. And on a Saturday too!
> but some of it could be optimized.
Oh, no doubt.
My prime concern is that the code never fails is a way that does something undefined or dangerous. Uncommanded movements, movements faster than expected or in the wrong direction, etc.
And you are looking at the remnants of my first generation Lua coding. The lathe control panel was the first Lua I ever wrote, and my understanding of the language and how Mach works has gotten slightly better since then. I have some code for tool-length-probe on toolchange for mill in another thread - a project that got derailed by the lathe shenanigans.
> I think it could do with recoding to utilize the signal library to prevent it unnecessarily running functions every time a switch state is changed.
I'm listening. Where is this documented?
> A question regarding your pendant, does the 'Off' setting have it's own signal or are you saying it's considered off when there is no axis selected or speed selected?
For jog?
The jog section of the panel has 3 controls:
- an MPG handle
- an axis select switch, two positions, SPDT, with lines for each axis (X, Z)
- a rotary select switch, 4 positions, 3 lines, OFF (no lines connected) 0.001 (line 1 connected) 0.010 (line 2 connected) 0.100 (line 3 connected)
The reason why there is no "off line" is because I wanted JOG ENABLE to fail OFF if the panel was unplugged or a line broke
The "so what" there is that the function that handles turning on jogging must handle not just the line going ON (to turn jog active) but also OFF (to turn jog inactive). So the fact that Mach calls the function on state change is a feature here.
Axis select, in retrospect, could have been a single line - Z if OFF, X if ON, but at the time I was going for positive control - the axis was only selected if its select line was HIGH, so a broken or unplugged cable disabled jogging.
You should see the mill control - I've overloaded the MPG handle. There's not just an axis select switch, there's a handle function select switch: JOG - SPINDLE OVERRIDE - FEED OVERRIDE. In jog mode the handle jogs like the lathe. In SPINDLE mode the handle changes the spindle speed up or down, and in FEED mode the handle changes the feed speed up or down. And there are separate lights to indicate if the handle is active in JOG mode, or active in SPEED mode...
Anyway, thanks for the fixes - I'll try them tomorrow.