Simpliq – ElmoMC SimplIQ Software Manual User Manual
Page 193
SimplIQ
Software Manual
Sensors, I/O and Events
MAN-SIMSW (Ver. 1.4)
12-8
The following user program performs the algorithm:
function [int status] = homing1(int TimeOut)
/*
Homing routine.
Input:
TimeOut: Timeout for failure
Output:
status=1 if o.k., otherwise a negative error code
Assumptions:
RLS,FLS,HOME already programmed by IL[1],IL[2],IL[3] commands
*/
int OldMi;
/* Go reverse until limit switch */
OldMi=MI;MI=MI|0x16; /* Prevent operational AUTO_RLS routine while in
homing process*/
/* Arm homing for
↑RLS, stop after homing, don't initialize counter*/
HM[3]=7;HM[4]=0;HM[5]=2;HM[1]=1;
/* Go to the reverse */
JV=-10000;BG;WaitArrive(2000);if(status<=0)goto LastLine; end
/* Go until home switch*/
HM[3]=1;HM[4]=2;HM[5]=2;HM[1]=1;
JV=-JV;BG;WaitHome(2000);if(status<=0)goto LastLine; end
/* Finallyset position by index */
HM[3]=3;HM[4]=0;HM[5]=0;HM[1]=1;
WaitHome(2000);if(status<=0)goto LastLine; end
status=1;/*Success return */
##LastLine
MI=OldMI; ** Restore AUTO_RLS routine status
return
Note that this function uses MI to prevent RLS and Home from activating the AUTO_RLS
and AUTO_HM routines, respectively. Another possible approach would be to use IL[N]
to change the functionality of the switch to GPI (general-purpose input) and then home
on the GPI. However, with the latter approach, the programmer must know which
connector pin is programmed as RLS.
The following auxiliary functions were used with the algorithm:
function [int status]=WaitArrive(int TimeOut)
/*
Wait until MS=0, or until too much time elapses
*/
int StartTime ;
status = -1;
StartTime = TM;
while (MS)
if ( tdif(handle) >= TimeOut) return ; end
end
status = 1 ;