FeedForward Feedback controller for flywheel velocity on SPIN UP

Hi vex community, my name is Héctor Alonso, i am the programmer of the team ITESM1. And i want to show you what kind of controller i used to control the flywheel velocity.

We used the V5 vex rotation plugged in the flywheel shaft to measure the current velocity of the flywheel.

The native input of the rotation sensor using pros is in centidegrees per second. But, we wanted to transform the units to one that would be more useful for use and more practice to us , so we transform to RPM (Revolutions per minute).

At the first iteration of making the controller for the flywheel we used a feedback controller such a P controller.

float target_Rpm = 2000; 
float kp = 3.1; 

while (1) {
float current = Rotation.get_velocity(); 
float error = target_Rpm - current; 

float proportional  = error * kp ; 

Flywheel move (proportional)
}

We used a PID controller for our flywheel and worked just well, however we found that tunning this kind of controller was difficult and hard for us, so we had to use another controller.

In the next image is a chart of the controller, plotting the current and target velocity .
[image]

PURE FEEDFORWARD CONTROLLER

A feedforward controller is a type of control system that is used to control a process or system by predicting its output based on a known input or set of inputs. In a feedforward control system, the input to the system is known and the output is predicted based on a mathematical model or algorithm. The output prediction is then used to adjust the system’s input to achieve a desired output.

So we know what is the feedforward control, but what mathematical model i need to use?

Well, the system that we’re interested in controlling is the permanent-magnet DC motor.

These motors have a number of convenient properties that make them particularly easy to control, and ideal for FRC tasks. In particular, they obey a particular relationship between applied voltage, rotor velocity, and rotor acceleration known as a “voltage balance equation”.

image

FTC. (s.f.). Introduction to DC Motor Feedforward. obtained from Introduction to DC Motor Feedforward — FIRST Robotics Competition documentation

For more information about this controller and what represent every variable i recommend to see the nexts links:

Using the voltage balance equation and using as an output we get the feedforward controller. We can get the feedforward controller for our flywheel.

To tune the feedforward controller we can follow the next steps:

  1. Ks, start adding some portion of voltage to your system (flywheel motors), tha portion of voltage that makes that your system start to move would be the value of Ks. For example, using pros you could add 1000 mv to your motors ( Flywheel.move_voltage(1000)). If the flywheel doesnt move you should add more voltage, then if you put 2000 mv and the flywheel start to move that is the correct value for Ks.

  2. Kv, For this variable i recommend to use excel or another tools to plotting and have visual representation of the current and target velocity (You can run your pros terminal in an Excel sheet using the next command, “pros terminal > [name of the archieve].csv” ). Start to picking a low value and run your function. You would to increase this variable until your current velocity star to aproach to some target velocity overt the time.

  3. Ka, Once that we tunned the Ka and Kv, is time to tune Ka. We need to increase to variable until the target and measured velocities match decently.

image

image

This is a raw example of using this controller.

int Ks = 1; 
int Kv=1; 
int ka=1; 
int target_RPM = 2000; 
prev_d_dot = 0; 

while(1){
 d_dot = Rotation_get_velocity(); 
 accel  = d_dot-prev_d_dot; 
 prev_d_dot = d_dot; 
 
 V = Ks* sgn(d_dot) + Kv*d_dot + Ka*accel; 

Flywheel.move_voltage(V); 

pros::delay(10) ;
}

The feedfoward controller is pretty accurate to aproach to a target, however, the response in this case was slow so, if we wanted to use the feedforward controller in a match wouldnt be worty. So we need to do the next step.

FEEDFORWARD FEEDBACK CONTROLLER

This controller combine the previous controller that we used.

This controller is more robust, quick and accurate.

The first step is to set up a feeforward controller, then we can add a feedback controller such a P controller.

We should tune the feeforward first, once that the feeforward is tunned we can tune the feedback controller in this case for a P controller, we can increase the Kp constant until the current velocity reach the target.

Notice, that once that we add the feedforward part, adding the Proportinal part is more easy and more quick to tune.

You can increase Kp to have more quick response of your controller.

int Ks = 1; 
int Kv=1; 
int ka=1; 
int kp=1; 

int target_RPM = 2000; 
float prev_d_dot = 0; 

while(1){
 float d_dot = Rotation_get_velocity(); 
 float accel  = d_dot-prev_d_dot; 
 float prev_d_dot = d_dot; 
 
 float error = target_RPM - d_dot; 
 float proportional = error * kp; 

 float V = Ks* sgn(d_dot) + Kv*d_dot + Ka*accel; 
 
//The output is the sum of feedback controller (P ) and the feedforward controller (V) 
 float output= proportinal + V

 Flywheel.move_voltage(output); 

pros::delay(10) ;
}

For our controller we use a PID controller for the feedback controller and we have an incredible results. In the next chart we can see how the system reach the target velocity. Each disturbance in the velocity is because the robot just throw a disc. So the velocity of the flywheel decrease and start to inject more voltage to reach the target again.

The time of recuperation for our system was 1 second with 500 miliseconds.

With this controller we were able to perform a very consistent autonomous routine.

This is the link of our autonomous routine: Right side auto VEX U SPIN UP - YouTube

Some observations: Is neccesary to make more deep investigation about tunning the velocity controllers. Having a more accurate value of the constants would result in a better controller.

I think that exist some potentional use for this feeforward controller outside of a flywheel control.

I am pretty sure that exist some alternatives more consistent or more easy to get the same results or even better that the results that we got. But i wanted to post our solution that we found. In our automous routine the robot just failed in average of one disc every 3 matches.

I hope that this topic was interesting for you and helpful.

16 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.