Hi,
I'm working on an EtherCAT network, which may change in the future, and so am setting up my code to adapt to this. I'm using the "new PDO mapping name format" and the ability to set aliases on EtherCAT hardware to give consistent macro names, generated to ECATMap.pmh and .h.
Part of my network involves setting up amplifiers for motors. I want to pass through the appropriate ECAT addresses to set up for instance Motor[x].pDac or Motor[x].pAmpEnable, but using the macro names (rather that ECAT[0].IO[xxxx]) to protect from future mapping changes. However I have not been able to achieve this.
I have been using subprograms in a .pmc file, shown below. C1_Slot1_...is an example of the naming system I'm using, and is defined in ECATMap.pmh.
open subprog SetupMotors(void)
return;
// --------------------User Code Goes Here------------------------
sub: GetECATInfo(&FaultIO, &EnableIO, &DacIO)
switch (motorID)
{
case 1:
FaultIO = C1_Slot1_Inputs_EL1008_0002_6000_1_Input.a;
EnableIO = C1_Slot1_Inputs_EL1008_0002_6010_1_Input.a;
DacIO = C1_Slot1_Inputs_EL1008_0002_6020_1_Input.a;
break;
case 2:
FaultIO = C2_Slot1_Inputs_EL1008_0005_6000_1_Input.a;
EnableIO = C2_Slot1_Inputs_EL1008_0005_6010_1_Input.a;
DacIO = C2_Slot1_Inputs_EL1008_0005_6020_1_Input.a;
break;
}
return;
sub: SetupMotorEtherCAT(void)
local lFaultIO;
local lEnableIO;
local lDacIO;
callsub sub.GetECATInfo(&lFaultIO, &lEnableIO, &lDacIO)
Motor[motorID].pDac = lDacIO;
Motor[motorID].pAmpEnable = lEnableIO;
Motor[motorID].pAmpFault = lFaultIO;
return;
close
Is there a neat way to go about it? I have tried doing this in C, but also no luck. I need to do this for lots of settings and motors, without changing the structure of existing code, keeping this information passed through a second subprogram.
Thanks,
markr