Heres the VB I have in my RefAll button. My servos dont require that I cancel the Start Homing button right away, do yours require that? I am also doing it over ModBUS but you can do the same with ActivateSignal(OutPut*) etc
Hood
DoOemButton (240) 'De-Reference All axis
Sleep(10)
If GetOemLED (809) Then 'Check that Ref Z LED is RED
Do
Call SetModOutput (21,1) 'Activate ModOutPut 20
If GetInput(19) Then Exit Do 'Loop until ModInPut 18 is seen
Sleep (10)
Loop
End If
Call SetModOutPut (21,0) 'DeActivate ModOutPut 20
DoOemButton (1024) 'Set Z axis Home
If GetOemLED (807) Then
Do
Call SetModOutPut (20,1)
If GetInput(18) Then Exit Do
Sleep (10)
Loop
End If
Call SetModOutPut (20,0)
DoOemButton (1022)