---SmartMotor尋找Index指令---

==============HOMING TO THE INDEX範例(class5)================
EIGN(W,0)
O=0
ADT=100 'Set maximum acceleration
VT=10000 'Set maximum velocity
MP 'Set to Mode Position
PRT=20 'Move off in case on index
G 'Start motion
TWAIT 'Wait for motion to complete
i=I(0) 'Clear index flag by read
Ai(0) 'Arm the index register
PRT=-4000 'Set 1 rev, specific to motor
'Start motion
WHILE Bi(0)==0 'Wait for index flag to be true(關鍵是這個)
LOOP 'Loop back to Wait
'Decelerate to stop
TWAIT 'Wait for motion to complete
PT=I(0) 'Set target position for Index
G 'Start motion
TWAIT 'Wait for motion to complete
O=0 'Declare current position home
END 'End program

==============HOMING TO THE INDEX範例(class5)================

C1 '找INDEX
MV
AT=1000
VT=32212
G
a=I(0) '讀取INDEX數值給a
WHILE a==I(0) '若INDEX沒有讀到新的數值舊維持空迴圈
LOOP
MP
AT=1000
VT=32212
P=I(0)
G
WAIT=1000
TWAIT
O=0
ZS
RETURN

==========================================================
I :Last recorded index position
==============HOMING TO THE INDEX範例(class4)================
C1 '找INDEX
MV
A=1000
V=32212
G
a=I '讀取INDEX數值給a
WHILE a==I '若INDEX沒有讀到新的數值舊維持空迴圈
LOOP
MP
A=1000
V=32212
P=I
G
WAIT=4069
TWAIT
O=0
ZS
RETURN