Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Questions on B-Robot PID code
06-14-2016, 06:46 AM
Post: #1
Questions on B-Robot PID code
Hi, I hope someone that's familiar with the B-Robot PID code can help me out.

Question#1

Code:
// Estimated_Speed = angular_velocity_of_stepper_motors(combined) - angular_velocity_of_robot(angle measured by IMU)
1   actual_robot_speed_Old = actual_robot_speed;
2   actual_robot_speed = (speed_M1 + speed_M2) / 2; // Positive: forward

3   int16_t angular_velocity = (angle_adjusted - angle_adjusted_Old) * 90.0; // 90 is an empirical extracted factor to adjust for real units
4   int16_t estimated_speed = -actual_robot_speed_Old - angular_velocity;     // We use robot_speed(t-1) or (t-2) to compensate the delay

In the third line, why is the angular_velocity not = (angle_adjusted - angle_adjusted_Old)/ looptime but multiplied by 90 instead?

Question#2

Code:
// PI controller implementation (Proportional, integral). DT is in miliseconds
    float speedPIControl(float DT, float input, float setPoint,  float Kp, float Ki)
    {
1      float error;
2      float output;

3     error = setPoint - input;
4     PID_errorSum += constrain(error, -ITERM_MAX_ERROR, ITERM_MAX_ERROR);
5     PID_errorSum = constrain(PID_errorSum, -ITERM_MAX, ITERM_MAX);

6     //Serial.println(PID_errorSum);

7     output = Kp * error + Ki * PID_errorSum * DT * 0.001; // DT is in miliseconds...
8     return (output);
    }

From what I have read, the inputs to the PI controller are: (1)Velocity setpoint and (2)Estimated velocity, and the output should be the desired tilt angle for the robot to maintain its balance.

Looking at line 7 of the code snippet, I cannot understand why the return value would turn out to be the desire tilt angle. Can someone help me out here?

Thank you.
Find all posts by this user
Quote this message in a reply
06-14-2016, 07:46 PM
Post: #2
RE: Questions on B-Robot PID code
any experts on this forum able to help? pls...
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)