MS Lee Posted December 9, 2014 Posted December 9, 2014 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.
MS Lee Posted December 9, 2014 Author Posted December 9, 2014 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.
Omron Forums Support Posted December 9, 2014 Posted December 9, 2014 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.
Omron Forums Support Posted December 9, 2014 Posted December 9, 2014 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.
shansen Posted February 9, 2015 Posted February 9, 2015 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
Recommended Posts