Hello all, I have this INFO in another post that is mixed with other questions, so I decided to start a fresh thread with just one question. I have set-up my M3 macro along with my SpindleSpeed macro to get my spindle and gear changer working. A little history, I have VFD and automatic gear changer for high gear and low gear that uses two OUTPUTS, I also have two INPUTS that come on when the gear is in high or low position. So this means I have two pulleys, pulley 1 = 0-900 RPM and pulley 2= 901-5000 RPM. I'm still trying to get the RPM tuned in, but that is something I'm sure I can get tuned. I had to put all my gear change code in the SpindleSpeed macro, along with changing the pulleys. I will post the two macros at the end of this post.
Everything is working great except one part. I MDI M03S100, the macros run and change to low gear, and spin the spindle to 100RPM. I then MDI M05 and the spindle stops. I then MDI M03S1000 and the macros run and change to high gear, and spin the spindle to 1000RPM. I MDI m05 and the spindle stops. Now comes the problem, I then MDI M03S100 again and the macros run, they change the gear to low, but instead of running the spindle at 100RPM it runs the spindle at full speed(10v). Since the macros set the pulley to #1 it runs the spindle at 900RPM instead of 100RPM. I then MDI M05 and the spindle stops. I then MDI M03S1000 and the spindle runs at full speed(10v), which in pulley #2 makes the spindle run at 5000RPM instead of 1000RPM. I can MDI M05 and the spindle turns off but, I have to shut Mach3 down and restart it to get it not to run at the max speed.
I'm think that some DRO isn't being updated. I added a DRO to my screen to monitor, OEMDRO#817, and when I run through the above sequence I can see that the spindle speed I set is being set in OEMDRO 817.
If anyone has any idea why this might be happening please let me know.
Thanks,
Aero
M3 Macro:
SpinS = GetRPM()
If SpinS < 901 Then
Call LowGearON
End If
If SpinS > 900 Then
Call HighGearON
End If
Sub LowGearON
While IsActive(OEMTRIG2) = False
Sleep(10)
Wend
If IsActive(OEMTRIG2) Then
Sleep(5000)
Message "Spindle On"
DeActivateSignal(OUTPUT2)'Spin Reverse
ActivateSignal(OUTPUT1)'Spin Forward
DoSpinCW()
End If
End Sub
Sub HighGearON
While IsActive(OEMTRIG1) = False
Sleep(10)
Wend
If IsActive(OEMTRIG1) Then
Sleep(5000)
Message "Spindle On"
DeActivateSignal(OUTPUT2)'Spin Reverse
ActivateSignal(OUTPUT1)'Spin Forward
DoSpinCW()
End If
End Sub
SpindleSpeed Macro:
Spin = GetRPM()
If Spin < 901 Then
SetPulley(1)
Call LowGear
End If
If Spin > 900 Then
SetPulley(2)
Call HighGear
End If
Sub LowGear
DeActivateSignal(OUTPUT7)'HG=7 LG=8
ActivateSignal(OUTPUT8)'Low Gear
While IsActive(OEMTRIG2) = False'HG=1 LG=2
Sleep(10)
Wend
If IsActive(OEMTRIG2) Then
Message "Low gear input is active"
End If
Call SpinON
End Sub
Sub HighGear
DeActivateSignal(OUTPUT8)'HG=7 LG=8
ActivateSignal(OUTPUT7)'Low Gear
While IsActive(OEMTRIG1) = False'HG=1 LG=2
Sleep(10)
Wend
If IsActive(OEMTRIG1) Then
Message "High gear input is active"
End If
Call SpinON
End Sub
Sub SpinON
Sleep(5000)
rpm = GetRPM()
SetSpinSpeed( rpm )
End Sub
M5 Macro:
DoSpinStop()
DeactivateSignal(OUTPUT7)'High Gear OUTPUT
DeactivateSignal(OUTPUT8)'Low Gear OUTPUT
DeactivateSignal(OUTPUT1)'Spin CW OUTPUT
DeactivateSignal(OUTPUT2)'Spin CCW OUTPUT