Jump to content
OMRON Forums

Recommended Posts

Posted

I wrote "user_pid_ctrl".

For example,

double user_pid_ctrl(struct MotorData *Mptr)

{

test_buf = (int *)(pushm) + 1000 + Mtr_Index;

}

 

I need current motor number in user pid.

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Posted

I wrote "user_pid_ctrl".

For example,

double user_pid_ctrl(struct MotorData *Mptr)

{

test_buf = (int *)(pushm) + 1000 + Mtr_Index;

}

 

I need current motor number in user pid.

Posted

Hi,

 

You can use this formula, for example:

#define Mtr0Base 0xBE2B8800
unsigned int *mtrnum = (unsigned int*)pushm + 2;
*mtrnum = ((unsigned int)Mptr - Mtr0Base)/2440;

 

Then the motor number will be in *mtrnum.

 

In general, the base address of each motor is 2440 * (MotorNumber) + Mtr0Base, where Mtr0Base is 0xBE2B8800.

Posted

Hi,

 

You can use this formula, for example:

#define Mtr0Base 0xBE2B8800
unsigned int *mtrnum = (unsigned int*)pushm + 2;
*mtrnum = ((unsigned int)Mptr - Mtr0Base)/2440;

 

Then the motor number will be in *mtrnum.

 

In general, the base address of each motor is 2440 * (MotorNumber) + Mtr0Base, where Mtr0Base is 0xBE2B8800.

  • 1 month later...
Posted

For anyone who uses this method, it seems that the base motor address and the size of each motor has changed in later firmware versions. Here is a corrected version that should work on any firmware:

 


unsigned int motor = (unsigned int)Mptr;
unsigned int mbase = (unsigned int)&pshm->Motor[0];
unsigned int msize = (unsigned int)&pshm->Motor[1] - mbase;

unsigned int mnum = (motor - mbase) / msize; // motor number

Guest
This topic is now closed to further replies.

×
×
  • Create New...