Hi,
I think that you would have more success if you looked at the spindle API instructions.
You have changed the state of a signal (OSIG_SPINDLEFWD) which presumably is hooked to your spindle driver
and I would expect it to turn the spindle on. Does not 'spindle forward' imply that the spindle must also be turned on?
I suspect that Machs internal logic may be counteracting your intention.
May I suggest that you experiment with output signals 0 through 5; you can be assured that some internal logic is not
interfering with your desired sequence of operations. Secondly using those particular out siganals mean that the six LEDs
on the MachineDiagnostics tab display the signal current state.
It may well be that as a result of your experimentation you can shift the output signals to say #20-#22 say; leaving
#0-#5 free for 'playing with' later on. Or better still you may be able to unravel how Mach uses and interprets the
OSIG_SPINDLEFWD, OSIG_SPINDLEREV and OSIG_SINDLEON signals.
What you want is to set the spindle direction, a flag or variable, without also turning the spindle on. These APIs may help.
rc = mc.mcSpindleSetDirection(
number mInst,
number dir)
Description:
Set the desired spindle direction.
rc = mc.mcSpindleSetDirectionWait(
number mInst,
number dir)
Description:
Set the desired spindle direction and wait for the spindle to come to speed. The function will wait for up to 20 seconds before returning MERROR_TIMED_OUT.
The type of spindle wait is determined by the system configuration.
I confess that I don't know whether these will achieve the result you want. Does for instance setting the direction flag ALSO
cause the spindle to start? Some experimentation is in order.
No matter the result of the experimentation and whether a particular API works or not you need a logical set of steps.
I envisaged a logical structure something like this:
m3
1) if the spindle is stopped then turn it on CW.
2) if the spindle is on and in CW rotation....ignore m3
3) if the spindle is on and in CCW rotation......stop the spindle.....delay....start the spindle CW
m4
1) if the spindle is stopped then turn it on CCW.
2) if the spindle is on and in CCW rotation....ignore m4
3) if the spindle is on and in CW rotation......stop the spindle.....delay....start the spindle CCW
m5
1) if spindle is on....turn it off....delay before resuming operation
2) if spindle is stopped....ignore m5
If this looks reasonable to you THEN you can start looking at various APIs, macros, PMC scripts or whatever to enact
the desired scheme.
Also I couldn't find a good way to put a delay in, didn't want to use the wx, call..
Why not?
Craig