Spinner Speed Control

Now that we have the drive motors controllable by speed, we need to do the same for the spinner motors.  In order to make consistent shots, we need to be able to spin the wheels at a consistent speed.

Let’s start by adding the encoders you will need to your SpinnerSubsystem class.  Note, however, that the encoders attached to the spinner motors are controlled by the IREncoder class.  I would like you to take a crack at modifying your SpinnerSubsystem class to include these encoders.  Note that the left encoder is attached to port 1 and the right encoder is attached to port 0.  When you are done, you can compare your result to the solution below.

.

.

.

.

.

Once you have added the encoders, your SpinnerSubsystem.java file should look something like:

Now create a new test command (let’s call it SpinnerSpeedTestCommand). This time, we really only care about controlling the spinners when they are spinning at about maximum power.  So set up your test so that it runs the motors at full power and logs the speed vs time.  I would like you to take a crack at implementing this new class.  When you are finished, you can compare your solution to the one below.

.

.

.

.

.

You SpinnerSpeedTestCommand.java file should look something like:

Finally we will want change the OI class so that button 12 now runs our new command SpinnerSpeedTestCommand.  After you have made the change, compare you result to the solution below:

.

.

.

.

.

Your OI.java file should now look like:

Now run your program, get the logged data, and graph it.  Your result should look something like.  Note that in this case, since we know that we get one count for each rotation, the units for the speed are simply rotations/sec.

SpinnerSpeedGraph1

As we can see from the graph, the maximum speed of the spinner motors is around 90 rotations/sec (or about 5400 rpm).  In this case, however, we are not going to want to try and run the motors at full power.  It is more important that we can hit a consistent target speed than running at max speed.  If we try and shoot for the max, we will not be able to control the speed as well since the PIDController can never increase the power beyond full power.  So to be a little conservative, lets set our max speed to 75 rotations/sec.

Now you need to add the MotorSpeedController class to your SpinnerSubsystem, and set it up to control the motor by speed instead of power.  When you set up the P, I, D, and F parameters for the MotorSpeedController constructor, you will want to start with only an F term.  Since the max speed possible is about 90, a good first guess would be 1/90 or about 0.01.  Also, let’s not set a Scale Factor, instead choosing to set the speed in rotations/sec, rather than from 0 to 1.0. After you have made your changes, you can compare your result to the one below.

.

.

.

.

.

Your SpinnerSubsystem.java file should now look like:

If you run the program and graph the logged data you should see something like:

SpinnerSpeedGraph2

Here we can see that the right motor is slightly weaker than the left, but both are close enough to our target of 75 rps that we can now set the rest of the terms.  You should try and see if you can come up with values for the P and I terms, as well as the SetIRange value that works best.  Once you have your best numbers, scroll down and see what our best set was.

.

.

.

.

.

We chose a value of 0.02 for P0.0025 for I, and 10 for the SetIRange.  The following was our result:

SpinnerSpeedGraph3

How does yours compare?

Next: Vision

Pierre Pierre, who replica handbag 185cm tall, gucci replica handbags the "Diamond King" in his hermes replica handbags . He has been selected as one of the handbag replica most beautiful 50 people in the "People" magazine. It is also known as replica handbags most elegant and quiet in the world. Unforgettable prince.