Plugin functions
You can start programming with the EYE+ plugin on RT ToolBox 3.
Important
The camera configuration and the hand-eye calibration must be done from the EYE+ Studio before programming any command. For further information, please refer to the Camera configuration wizard and Hand-eye calibration wizard.
The following 7 functions allow to create a simple and easy-to-integrate pick and place.
EYE_CONFIGURE
EYE_STOP
EYE_START_PRODUCTION
EYE_GET_PART
EYE_PREPARE_PART
EYE_RAW_COMMAND
EYE_CHECK_LAST_ERROR
Warning
Do not use the functions that start with EYE_INTERNAL_
. These functions are used internally
to manage the communication with your EYE+.
Warning
Do not use two functions that operate on the same communication line at the same time.
- Functions on communication line 1 (MClientNumber1):
EYE_START_PRODUCTION
EYE_GET_PART
EYE_PREAPRE_PART
EYE_RAW_COMMAND(“…”, 1)
- Functions on communication line 2 (MClientNumber2):
EYE_STOP
EYE_RAW_COMMAND(“…”, 2)
EYE_CONFIGURE( MClientNumber1, MClientNumber2 )
Parameters
MClientNumber1 - is the number you have written in Step 3: Configure the communication in parameter
MClient1
. The parameter must be an integer in the range of 1-8.MClientNumber2 - is the number you have written in Step 3: Configure the communication in parameter
MClient2
. The parameter must be an integer in the range of 1-8.
Description
This command must always be called at the beginning of your program to define the client configuration.
Note
Once you have chosen the MClientNumber1
and MClientNumber2
, consider that the associated communication
lines are reserved for the plugin.
Usage example
#include "EYEPLUSLIB"
' Configure the communication to reserve communication lines COM3 and COM4.
EYE_CONFIGURE( 3, 4 )
' ...
EYE_START_PRODUCTION( MRecipeID )
Parameters
MRecipeID - the recipe’s unique identifier. The parameter must be an integer between 1 and 65535.
Description
This command must be called to start EYE+ in production state using the right recipe.
Usage example
#include "EYEPLUSLIB"
' Configure the communication to reserve communication lines COM3 and COM4.
EYE_CONFIGURE( 3, 4 )
' Start EYE+ in production using the correct recipe identifier
EYE_START_PRODUCTION( 12345 )
MLastError = EYE_CHECK_LAST_ERROR
IF MLastError = 0 THEN
' EYE+ is in production state
ENDIF
EYE_STOP( CState )
Parameters
CState - one of EYE+ states. The parameter must be a string.
Description
This command is used to stop an EYE+ state. It must be called at the end of your program.
Usage example
#include "EYEPLUSLIB"
' Configure the communication to reserve communication lines COM3 and COM4.
EYE_CONFIGURE( 3, 4 )
' Start EYE+ in production using the correct recipe identifier
EYE_START_PRODUCTION( 12345 )
' ...
EYE_STOP("production")
MLastError = EYE_CHECK_LAST_ERROR
IF MLastError = 0 THEN
' EYE+ is not in production anymore
ENDIF
EYE_GET_PART
Return
The returned part is stored in the position variable PEYEPos.
When a part is found, only the (X
, Y
, C
) values are overwritten. You have to assign the other components
(Z
, A
, B
, L1
, L2
, Flag1
, Flag2
) yourself according to your robot setup.
Description
This command is used to request one part from EYE+. This is a blocking command, meaning it will keep going until it gets a response.
Warning
If you do not assign the other components, the position may not be reachable.
Usage example
#include "EYEPLUSLIB"
' Initialize components A and B of EYEPos
PEYEPos.A = 0
PEYEPos.B = Rad(180)
PEYEPos.Z = 20
' Move to home position
mov PHome
' Configure the communication to reserve communication lines COM3 and COM4.
EYE_CONFIGURE( 3, 4 )
' Start EYE+ in production using the correct recipe identifier
EYE_START_PRODUCTION( 12345 )
EYE_GET_PART()
MLastError = EYE_CHECK_LAST_ERROR()
IF MLastError = 0 THEN
' Move above the part regarding your current tool and robot base
mov PEYEPos - 50
' Move to the part
mvs PEYEPos
' Move above the part regarding your current tool and robot base
mvs PEYEPos - 50
' Move to home position
mov PHome
ENDIF
EYE_STOP("production")
EYE_PREPARE_PART
Description
This command is used to request one part from EYE+. This command is not a blocking command. The part coordinates can be retrieved later with the EYE_GET_PART command.
Usage example
#include "EYEPLUSLIB"
' Initialize components A and B of EYEPos
PEYEPos.A = 0
PEYEPos.B = Rad(180)
PEYEPos.Z = 20
' Move to home position
mov PHome
' Configure the communication to reserve communication lines COM3 and COM4.
EYE_CONFIGURE( 3, 4 )
' Start EYE+ in production using the correct recipe identifier
EYE_START_PRODUCTION( 12345 )
EYE_PREPARE_PART()
' Do something with your robot
' ...
EYE_GET_PART()
MLastError = EYE_CHECK_LAST_ERROR()
IF MLastError = 0 THEN
' Move above the part regarding your current tool and robot base
mov PEYEPos - 50
' Move on the part
mvs PEYEPos
' Move above the part
mvs PEYEPos
' Move to home position
mov PHome
ENDIF
EYE_STOP("production")
EYE_RAW_COMMAND( CCommand, MSocket )
Parameters
CCommand - is the raw command to send to EYE+. This parameter must be a string.
MSocket - is the socket number that will be used to send the command. The parameter must be an integer whose value is equal to 1 or 2 (respectively the first or second line you have chosen in EYE_CONFIGURE).
Return
The raw response of the command is returned as direct output. The output is a string.
Important
Don’t forget to assign the output of the function. If you don’t, you may get the error L3400 System
error (PROC stack overflow)
after a few iterations.
Description
This function is used to send raw commands to EYE+. Refer to chapter Commands to know what kind of commands can be sent.
Note
Due to the character length limitation in MELFA-BASIC VI, you cannot send or receive information longer than
127 characters. If it happens, you will get the error L3500 Illegal format input (INPUT)
.
Usage example
#include "EYEPLUSLIB"
' Configure the communication to reserve communication lines COM3 and COM4.
EYE_CONFIGURE( 3, 4 )
' Start EYE+ in production using the correct recipe identifier
CResponse = EYE_RAW_COMMAND( "start production 12345", 1)
MLastError = EYE_CHECK_LAST_ERROR()
IF MLastError = 0 and CResponse = "200" THEN
' EYE+ is in production
ENDIF
EYE_STOP("production")
EYE_CHECK_LAST_ERROR
Return
The last detected error is returned as direct output. The output is an integer.
Description
This function is used to check if an error has occurred.
If no error has occurred, the output is equal to 0.
If an EYE+ error has occurred, the output is equal to one of the error codes listed in Error codes (error type
4xx
or5xx
).If a plugin error has occurred, the output is one of the following errors displayed in section Plugin errors (error type
6xx
).
Once the error is returned as output from the function, the error is cleared internally (value set to 0).
Usage example
#include "EYEPLUSLIB"
' Configure the communication to reserve communication lines COM3 and COM4.
EYE_CONFIGURE( 3, 4 )
' Start EYE+ in production using the correct recipe identifier
EYE_START_PRODUCTION( 12345 )
MLastError = EYE_CHECK_LAST_ERROR()
IF MLastError = 0 THEN
' EYE+ is in production state
ENDIF