MS Lee Posted December 9, 2014 Share 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. Link to comment Share on other sites More sharing options...
MS Lee Posted December 9, 2014 Author Share 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. Link to comment Share on other sites More sharing options...
Omron Forums Support Posted December 9, 2014 Share 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. Link to comment Share on other sites More sharing options...
Omron Forums Support Posted December 9, 2014 Share 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. Link to comment Share on other sites More sharing options...
MS Lee Posted December 11, 2014 Author Share Posted December 11, 2014 Thank you. It operate well. Link to comment Share on other sites More sharing options...
MS Lee Posted December 11, 2014 Author Share Posted December 11, 2014 Thank you. It operate well. Link to comment Share on other sites More sharing options...
shansen Posted February 9, 2015 Share 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 Link to comment Share on other sites More sharing options...
Recommended Posts