OK, this works better in simulation on my laptop at least.
rpm = GetRPM() 'requested RPM
pulley = GetOEMDRO(56) 'current pulley
Select Case rpm
case 0 To 126
If pulley <> 1 then
DoOemButton (1001) 'feed-hold
Call SetOEMDRO(56,1) 'set the new pulley
if pulley = 2 then
Msgbox "Change Speed Dial To 700rpm"
else
Code "M05"
Msgbox "Change Back-Gear To Low Range And 700rpm"
end if
End If
Case 127 To 366
If pulley <> 2 Then
DoOemButton (1001) 'feed-hold
Call SetOEMDRO(56,2)
if pulley = 1 then
Msgbox "Change Speed Dial To 2200rpm"
else
Code "M05"
Msgbox "Change Back-Gear To Low Range And 2200rpm"
end if
End If
Case 367 To 1031
If pulley <> 3 Then
DoOemButton (1001) 'feed-hold
Call SetOEMDRO(56,3)
if pulley = 4 Then
Msgbox "Change Speed Dial To 700rpm"
else
Code "M05"
Msgbox "Change Back-Gear To High Range And 700rpm"
end if
End If
Case 1032 To 3000
If pulley <> 4 Then
DoOemButton (1001) 'feed-hold
Call SetOEMDRO(56,4)
if pulley = 3 Then
Msgbox "Change Speed Dial To 2200rpm"
else
Code "M05"
Msgbox "Change Back-Gear To High Range And 2200rpm"
end if
End If
Case 3001 To 99999
DoOemButton (1003) 'stop
Msgbox "Speed Requested Out Of Machine Range, Code Stopped"
End Select
SetSpinSpeed( rpm )
Now, is the msgbox function modal - does it suspend code until acknowledged as i would want to put an M03 after the message in some cases but this will only work if the message halts further code.
Also, something is upsetting the "Spindle Override" DRO for some reason - this makes a real mess of speeds as the code sets one speed but S/O changes it to something else !!
Any ideas of do i have to add a spindle override reset call as well??