Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generating Normal to a Contour
I need to generate a normal angle to a contour. I am looking at using Motor[0] with a user written servo. The Motor[0] position will then be used by a came table for other functions.

double user_pid_ctrl(struct MotorData *Mptr)
double normalangle;
if (abs(Motor[XMOTOR].DesVel)>0 || abs(Motor[YMOTOR].DesVel)>0)
{ normalangle=atan2d(Motor[XMOTOR].DesVel,Motor[YMOTOR].DesVel); }
else { normalangle = 200; }// not a valid angle use for table suppression.
return 0;

Would it be appropriate to write the angle directly to Motor[0].pos, or should it go through an encoder table entry, or perhaps some other register?
This should be OK to do. In Script, the write is blocked if the "motor" is enabled, but this routine is in C so you don't even need to worry about that. Of course, the motor must be activated for your value to get copied into Motor[0].ActPos, and not closed-loop if you then want the value to be copied into Motor[0].DesPos.

Forum Jump:

Users browsing this thread: 1 Guest(s)