On the face of it, the logic is fairly simple - modify the the M03 instruction so that every "spindle start" command does this:
- If required spindle speed is >= 1000 rpm, select HIGH gear range
- Otherwise select LOW range.
Of course, it's not quite as simple as that. You can change the spindle set speed when the spindle is already rotating without needing to issue an M05 (spindle stop), so you (or the post processor) could quite easily select the correct range for the initial set speed, then ask for a speed that would require the other range. But in my case, almost every operation will be done in the high range which I will probably redefine as anything over perhaps 600rpm (currently I have simply reused the original threshold of 1000 rpm). I suspect the only time I will require the LOW range would be for tapping, rigid or otherwise.
This could also go horribly wrong without any difficulty, if you consider what might happen if you operated the wrong gear selection solenoid with the spindle already spinning, so some checking / waiting for things to happen may be sensible.
So my instructions will be tested using a std g code file initially. Like this. Yes, the spacings get all buggered up when you paste them into the Blogger editor:
;-------
;M3 macro - Spindle CW
;-------
etc
;
; (My stuff)
;
IF #4119 >= 1000 THEN GOTO 1000 ; HIGH range required...
GOTO 2000 ; ...otherwise LOW range required
N1000 ; HIGH range selection
IF #50002 THEN GOTO 5000 ; Engaged in HIGH correctly, so finished
M05 ; check spindle stopped!
G04 P3 ; spindle slow down - was in LOW
M94 /62 ; energise HIGH solenoid - OUTPUT #2
M03 ; START SPINDLE - CW
G04 P0.2 ; PAUSE to engage gears
M05 ; STOP SPINDLE
M95 /62 ; de-energise HIGH solenoid
GOTO 1000 ; recheck HIGH gears correctly engaged
N2000 ; LOW range selection
IF #50001 THEN GOTO 5000 ; Engaged in LOW correctly, so finished
M05 ; check spindle stopped!
G04 P1.5 ; spindle slow down - was in HIGH
M94 /61 ; energise LOW solenoid - OUTPUT #1
M03 ; START SPINDLE - CW
G04 P0.2 ; PAUSE to engage gears
M05 ; STOP SPINDLE
M95 /61 ; de-energise LOW solenoid
GOTO 2000 ; recheck LOW gears correctly engaged
N5000 ; In correct range and gears engaged now
M95 /62 ; check de-energise HIGH solenoid
M95 /61 ; check de-energise LOW solenoid
M03 ; spindle enable CW
Notes:
- Parameter #4119 is the demanded spindle speed.
- Parameter #50001 is the LOW range microswitch. It becomes TRUE when the LOW gear is fully meshed.
- Parameter #50002 is the HIGH range microswitch. It becomes TRUE when the HIGH gear is fully meshed.
- M95 /62 turns off output #2 (HIGH solenoid).
- M94 /62 turns on output #2 (HIGH solenoid).
- M95 /61 turns off output #1 (LOW solenoid).
- M94 /61 turns on output #1 (LOW solenoid).
And here's a test program, to check if it's doing what I imagined it would. It does very little apart from step the spindle between 1100 rpm (which requires HIGH range) and 800 rpm (which requires LOW range). If the modified M03 macro works as intended, the solenoids will do their stuff.
;------------------------------------------------------------------------------
; Filename: muzzer3.cnc
;
; Description: User Customizable Macro
; Notes: Murray 2 April 2018
;
; Gear selection macro
;------------------------------------------------------------------------------
IF #50010 ; Prevent lookahead from parsing past here
IF #4201 || #4202 THEN GOTO 100 ; Skip macro if graphing or searching
S1100 ; set 1100 rpm
M03 ; start spindle
G04 P2 ; run for 2 seconds
M05 ; stop spindle
G04 P1 ; pause to let spindle stop
S800 ; set 800 rpm
M03 ; start spindle
G04 P2 ; run for 2 seconds
M05 ; stop spindle
G04 P2 ; pause to let spindle stop
; (again)
S1100 ; 1100 rpm
M03 ; start
G04 P2 ; run
M05 ; stop
G04 P1 ; run down
S800 ; 800
M03 ; start
G04 P2 ; run
M05 ; stop
N100 ; end
NB: Note the test for gear engagement (IF #50002 THEN GOTO...), which is supposed to ensure the gears are positively engaged before exiting the conditional loops at lines N1000 and N2000. That didn't seem to work so well, judging by the gear grinding noises(!!). If parameters #50001 (LOW gear engaged signal from microswitch) and #50002 (ditto HIGH gear) tell us that the gears are engaged, no action is required. But if not, the spindle must have time to come to rest before the solenoid is activated - if it's just been running at high speed, it takes a while, particularly if it's been in low gear where there is a lot more momentum.
The answer is to ensure that there is a delay (G04 Px.x, where x.x is the time in seconds) between the M05 (stop spindle) and the solenoid moving.
Ideally the required delay times will be included in the M3 etc macros, rather than requiring an additional line of g code. I'll probably need to increase the decel rate on the VFD as a first action, then optimise the delay times - worst case will be running at max speed in LOW gear.
Seems to work reasonably well. However, I have still to 100% convince myself whether it is working correctly. I'll be taking a closer look over the next few days.....
Seems to work reasonably well. However, I have still to 100% convince myself whether it is working correctly. I'll be taking a closer look over the next few days.....
Took the cover off, so I could check the position of the rotary gear selector and the microswitches:
Also to come:
- Figure out how to accommodate M04 (CCW) operation (initially I have only tackled M03 (CW).
No comments:
Post a Comment