Jump to content
OMRON Forums

Command Motor from user written servo using built-in servo routine


sbondhus
 Share

Recommended Posts

I have a project that currently uses a user-written servo routine for all kinematics and controls for a variety of motors and returns the user-calculated commanded voltage output from the servo routine to drive the motor. Two other motors are also assigned to this servo routine, though the intent and implementation (before my time on the project) for these two motors was to use the built-in Delta Tau servo routine (something like "return pshm->ServoCtrl(Mptr);"). The original coders of these routines used Mptr->DesPos and ->DesVel to attempt to command the motor to the desired position. This is similar to the method described in this previous post.

 

I have tried using our code as it stands, as well as writing my own simple project based on the post linked above, and neither of them worked as desired. When I tried the example project linked above, I was able to command motion, but the motion didn't seem to follow any of the desired constraints (e.g. .JogSpeed, .MaxSpeed, .MinPos, etc).

 

My question is this: If we want to continue commanding positions for this motor with the same routines we already have defined, but control it using the Delta Tau built-in PID controller, what is the most appropriate way to do that? The position we want to command to these motors is returned from function call in a separate user-written servo routine and stored in shared memory.

 

Pseudo-Code for what we want to do:

user_written_servo_routine_1(struct MotorData *Mptr)
{
  Read sensors from input controls
  store sensor values in shared memory
}

user_written_servo_routine_2(struct MotorData *Mptr)
{
  Update motor with desired position based on sensor readings obtained during user_written_servo_routine_1
  return pshm->ServoCtrl(Mptr); ?
}

 

or, instead of commanding via a returned value in a servo routine, could we...

 

user_written_servo_routine_2(struct MotorData *Mptr)
{
  Format string based on sensor readings obtained during user_written_servo_routine_1
  use Command(string) to issue jog command to desired motor
}

 

or, instead of using a servo routine to issue the command, read the desired position from shared memory and use a Motion Program to command the motor (I'm currently a little hesitant of this approach since we have no other Motion Programs in our project and none of our motors are currently assigned to specific coordinate systems, but if this is the correct approach I'm open to using it.

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

If you must poke values directly into a motor register servo cycle by servo cycle, you can use one of three registers:

 

Motor[x].Desired.Pos

Motor[x].MasterPos

Motor[x].CompDesPos

 

Power PMAC will automatically sum these three into the net Motor[x].DesPos and calculate Motor[x].DesVel from this.

 

Motor[x].Desired.Pos can be used if no trajectories are being calculated for the motor.

 

Motor[x].MasterPos can be used if no position following is active for the motor (Motor[x].MasterCtrl=0).

 

Motor[x].CompDesPos can be used if no cam table or compensation table targeting this register is active.

Link to comment
Share on other sites

I suggest you to use "Motor[x].MasterPos".

 

And there are reserved bits(bit2,3) in "Motor[x].MasterCtrl".

If you use reserved bit 3 then you can control using or not.

 

My code is like this.

 

double dPrevDesPos, dCurrDesPos, dDeltaPos;

double user_written_servo_routine_2(struct MotorData *Mptr)
{
   if (Mptr->MasterCtrl&0x08)
   {
       dCurrDesPos = *((double *)pushm+10);  // if use Sys.Ddata[10]
       dDeltaPos = dCurrDesPos - dPrevDesPos;
       Mptr->MasterPos += dDeltaPos;
       dPrevDesPos = dCurrDesPos;
   }
   else
   {
       dPrevDesPos = *((double *)pushm+10);
   } 

   return pshm->ServoCtrl(Mptr);
}

 

I don't know there would be other problems.

Please refer to my code.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...