Page 1 of 1

Coupling Problem in PR24 feedback mechanism

PostPosted: Sat May 29, 2010 6:08 am
by macher
when i switch the power, i can see the angle and P, I,D values on the lcd and i can change them but when i push the run button, the motor does not respond properly, it seems like it is being overloaded because of the mechanism, since the cylinder showing the degree does not turn straightly although i have coupled it correctly, what should i do and what are the best values for this motor, how will i understand the right p, ı, d values

Re: Coupling Problem in PR24 feedback mechanism

PostPosted: Sat May 29, 2010 2:04 pm
by ober
If you have mounted the coupling correctly, the action of overshooting and slow are caused by the PID value in software. You need to play with the value of P, I and D in order to get the optimized result. This is an Trail and Error method.

Re: Coupling Problem in PR24 feedback mechanism

PostPosted: Tue Jun 01, 2010 3:55 am
by macher
is it normal for the motor to run when angle was zero but P value was set to a low value? I also couldn't screw the motor through that little holes so, i had to shave the holes of u-joint a little bit, does this effect the performance of the system? Also the motor does not stop and the the lcd display mixes on several values, does this mean the values are not useful? ı have no idea how will i find the best values by trial, i am not even sure if this system is working properly, i mean the motor turns the other side some occasions or never stops, i am desperately in need of help!

Re: Coupling Problem in PR24 feedback mechanism

PostPosted: Tue Jun 01, 2010 3:13 pm
by waiweng83
Try to replace the interrupt function with this one, see it works or not:

CODE: SELECT_ALL_CODE
//   Interrupt function
//==========================================================================
static void interrupt isr(void)
{
   signed int set_value = 0;
   signed int feedback_value = 0;
   signed long error_value = 0;
   static signed long pre_error = 0;
   static signed long integral = 0;
   signed long derivative = 0;
   signed long output = 0;
   static signed long pre_output = 0;
   signed int motor_direction = 0;
   
   
   unsigned char pwm_value=0;   

   if(TMR1IF == 1)                                             // If TMR1 register overflowed.
   {
      TMR1IF = 0;                                             // Clear TMR1 overflow flag.
      
      feedback_value = ai_read(1);                              // Get the feedback value.
      set_value = ai_read(0);                                    // Get the set value.
      
      error_value = set_value - feedback_value;                     // Calculate the error.
      
                if ((pre_output != 255) && (pre_output != -255))
                {
                    integral = integral + error_value;                           // Calculate integral.
                }
                derivative = error_value - pre_error;                        // Calculate derivative.
      
      output = (kp * error_value) + (ki * integral) + (kd * derivative);   // Calculate the output, pwm.
      
      if (output > 255) output = 255;                              // Limit the output to maximum 255.
      else if (output < -255) output = -255;
      
      if (output > 0)   motor_right((unsigned char)output);               // When output is positive, turn right.
      else if (output < 0) motor_left((unsigned char)(-output));         // When error is negative, turn left.
      else motor_stop();                                       // When ouput is 0, stop the motor.
      
      pre_error = error_value;                                 // Save as previous error.
                pre_output = output;                              // Save as previous output.
   }
}

Re: Coupling Problem in PR24 feedback mechanism

PostPosted: Wed Jun 02, 2010 3:51 pm
by macher
There is a beep noise comin i guess from the motor sometimes continuously, sometimes consecutive beeps, what does this noise refer to? for each position i guess there will different p,ı,d values, so how will i define them, firstly i have to increase the p value but until when and then i could see the effect of I by increasing it but how will i see the effect of D term? can you please help me how to define the most suitable PID values according to what since there are no parameters of the motor i can't find the transfer function and so the PID values?