Jump to content
OMRON Forums

Pass through pointer to ECAT address


markr
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

I've just made this as a test project, the calling program is simply a one line plc.

open plc 1

call SetupMotors.SetupMotorEtherCAT();

disable plc 1
close

 

The error message is

"C:...\setup motors.pmc(33,1) : Error : ( error #31) invalid data : Motor[P8196].pDac = L2"

Line 33 is Motor[motorID].pDac = lDacIO;

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...