
MCO 305 Design Guide
__ Functions and Examples __
MG.33.L4.02 – VLT
®
is a registered Danfoss trademark
23
Program Example: Touch Probe Positioning for Palletizer Application
/******** Touch probe positioning sample program for palletizer application example *********/
//
Inputs:
1
Go to position
//
2 Touch
probe
//
8 Clear
Error
// Outputs:
1 In
position
//
8 Error
/********************************* Interrupts ************************************/
ON ERROR GOSUB errhandle
// In case of error go to error handler routine, this must always be included
ON INT 2 GOSUB tp_handler
// Call touch probe handler on positive edge of input 2.
/******************************* Define flags ***********************************/
flag = 0
tp_active = 0
/***************************** Basic settings **********************************/
VEL 80
// Sets positioning velocity related to parameter 32-80 Maximum velocity.
ACC 100
// Sets positioning acceleration related to parameter 32-81 Shortest ramp.
DEC 100
// Sets positioning deceleration related to parameter 32-81 Shortest ramp.
/************************** Define application parameters ***************************/
LINKGPAR 1900 "Touch probe distance" 0 1073741823 0
/******************************* main loop **************************************/
MAIN:
IF (IN 1 == 1) AND (flag == 0) THEN
// Start movement once (ensured by flag) when input 1 is high.
OUT 1 0
// Reset "In position" output.
CVEL
80
// Set constant velocity.
CSTART
// Start with constant velocity.
tp_active = 0
// Reset "tp_active" to enable new touch probe positioning.
flag = 1
// Set "flag" to ensure that distance is only traveled once.
ELSE
MOTOR
STOP
// Stop if input is low.
flag = 0
// Reset "flag" to enable new start.
ENDIF
GOTO MAIN
/****************************** Sub programs start *******************************/
SUBMAINPROG
/****************************** Touch probe handler ******************************/
SUBPROG tp_handler
IF (tp_active == 0) THEN
POSR
(GET
1900)
// Go to touch probe target position
WAITAX
// Halt program execution until position is reached (This is necessary as
// NOWAIT ON is automatically set in a subroutine called by interrupt).
OUT 1 1
// Set "In position" output.
tp_active = 1
// Set "tp_active" to ensure that touch probe positioning is done only once
ENDIF
RETURN
/******************************** Error handler *********************************/
SUBPROG errhandle
err = 1
// Set error flag to remain in error handler until error is reset.
OUT 8 1
// Set error output.
WHILE err DO
// Remain in error handler until the reset is received.
IF IN 8 THEN
// Reset error when Input 8 is high.
ERRCLR
// Clear error.
err=0
// Reset error flag.
ENDIF
ENDWHILE
OUT 8 0
// Reset error output.
flag = 0
// Reset "flag" to enable new positioning.
RETURN
/*****************************************************************************/
ENDPROG
/******************************** End of program ********************************/
Содержание MCO 305
Страница 4: ......