Damm uploaded the wrong file. This one is the one I use at the moment.
I have a double opto switch with a gap of 5mm. One output is INDEX and the other is OEMTRIG1.
Because the spindle needs to be very perfect aligned, I have used this dual opto switch.
So when both opto switch are triggered, the spindle is perfect aligned. The gap in the trigger ring is about 5,5mm.
I also tried below but did not help.
While ismoving
sleep 10
wend
About the speed.
When the spindle is stopped by the dynamic brake, it take some seconds before the spindle turn CCW to align spindle.
It looks like the command GetOEMDro(39) takes a while. When observe the spindle speed DRO, I notice that the DRO has a refresh delay compared to the real spindle speed.