Download RSI-ECAT-Master User`s manual

Transcript
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Access process to a slave from here
// Search slave
stSlave.dwSize
stSlave.dwVenderID
stSlave.dwProductCode
stSlave.dwInstance
=
=
=
=
sizeof(stSlave);
131;
50;
0;
In searching for a slave,
①VenderID, ②ProductCode ③instance number are required.
Here, require to detect the slave with the slave of “VenderID
= 131 and ProductCode = 50 and instance no = 0 (First
Detected)”. When searching two or more same slaves, slave
information returns in the order in which the instance
number is found by carrying out an increment.
woStatus = EhFindSlave(hAPI, &stSlave);
if( 0 != woStatus ) {
printf("EhFindSlave() failed. Status = %04xH\n", woStatus);
return ;
Possible to block until cyclic process
}
occurs by setting the
time(*) as WAIT_FOREVER.
(the time(*) means one of waiting for API which returns response
every cyclic process of EtherCAT Master)
// Process of operation
while(1) {
// Waiting for cyclic process
woStatus = EhWaitForCyclic(hAPI, WAIT_FOREVER);
if( 0 != woStatus ) {
break; // End because cyclic process is interrupted
}
// Conversion request ON / OFF per each loop
if( 0 != EhReadbackByte(hAPI, stSlave.dwViosOutBaseOffset, &woStatus) ) {
EhWriteByte(hAPI, stSlave.dwViosOutBaseOffset, 0x00);
} else {
EhWriteByte(hAPI, stSlave.dwViosOutBaseOffset, 0xFF);
}
}
The input and output to PI are performed by API which performs VIOS access.
0 and 0xFF are reversed and outputted based on the last output value.
printf("program end.");
}
In order to build this sample code, the following project settings are needed..
①
Add $(RSIECAT)\include as an additional path of the header file.
②
Add $(RSIECAT)\lib as the path of the additional library.
③
Add EhApi.lib as additional library.
-53/63-