OK, I have a new problem. When I MDI m3s100 it goes through its gear change beautifully, and starts the spindle and runs at 100rpm. I then MDI m5 the spindle stops, I then MDI m3s1000 and the gear changes and the spindle spins to 1000rpm... so far so good, OK now the strange part. I then MDI m5 to stop the spindle then put m3s100 again, the gear changes to low gear like it should but it runs the spindle at max RPM. When I look at the "Spindle Speed" windows it shows 900 in the S ov and 100 in S, 900% Override. It seems to me that either the GetRPM() isn't working properly for me or I have another problem I'm not aware of. Here is a copy of my SpinSpeed macro and M3 macro.
Spinspeed:
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
M3:
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
If anyone can see a problem in my code please let me know.
Thanks,
Aero