Need some help with VB script for my lathe turret macro. What I currently have is:
If GetSelectedTool = 1 Then
ActivateSignal(OutPut7)
Sleep 500
Code "G53 G0 A0"
While IsMoving()
Wend
DeActivateSignal(OutPut7)
End If
Output 7 activates a solenoid valve to raise and lower the turret. I also have a switch for turret up/down which I'd like to integrate into the macro. Hood suggested the following code a while back, but I haven't had time to really play with it:
If GetSelectedTool = 1 Then
Do
ActivateSignal(OutPut7)
If IsActive(Input1) Then Exit Do
Loop
Code "G53 G0 A0"
While IsMoving()
Wend
DeActivateSignal(OutPut7)
End If
Input 1 is a switch, active when the turret is up. The above example keeps the turret from rotating until it is up. I'd also like to add a line to ensure that the turret is back down before exiting the macro (I.E. input 1 is off). I'm sure that's pretty easy?
If possible, I'd also like to add something to either feed hold or e-stop the machine in the event that the turret fails to raise or lower, and maybe even display something in the message box if that happens. "Turret Error, E Stop" or something like that.
Can anyone get me pointed in the right direction?
I've looked through the VB reference doc, but I'm not too well versed on that kind of programming.
Thanks!
Kevin