EtherCAT Operation Example EtherCAT Programming Guide
3-4 March, 2017
3
(2) Initialize interface card
Figure 3.1.2.3
Press the Initial key to execute the following program:
for(i=0; i< gESCExistCards; i++)
{
RetCode = _ECAT_Master_Get_CardSeq(i, &CardNo);
/* Get the card No. of the PC interface Card i. This card No. is the dip switch value.
EtherCAT card number in RTX version is 16. */
RetCode = _ECAT_Master_Initial(CardNo);
/* Start to initialize the interface card. */
if(RetCode != 0)
{
strMsg.Format("_ECAT_Master_Initial, RetCode = %d", RetCode);
MessageBox(strMsg);
}
}
RetCode = _ECAT_Master_Check_Initial_Done(gESCCardNo, &InitialDone);
/* Get the Initial status. */
// Display the Initial Status:
// InitialDone = 1: Display “Pre Initial”
// InitialDone = 0: Display “Initial Done”
// InitialDone = 99: Display “Initial Error”
(3) Set the information of the connected modules
Figure 3.1.2.5
Press the Find Slave key to execute the following program:
RetCode = _ECAT_Master_Get_SlaveNum(gESCCardNo, &SlaveNum);
// Get the number of the connected modules.
When the above program completes, the number of the found Slave devices will be
displayed in Slave Num field.