Shooter Subsystem

The Shooter Subsystem will control the spinning wheel that shoots the Nerf ball. The design of this subsystem is similar to that of the Drive Subsystem except that there is only one motor involved.

The class which controls this motor is once again PWMMotor and you should use the following constructor:

You will, of course, need the pin numbers:

We will also need to control the speed of this motor so we will need to use the motor’s built in encoder. We will use the Encoder class to read these encoders with the type set to EncoderType.Quadrature. The constructor to use is:

And the pin numbers are:

Note that by setting the second pin number to -1 we are telling the encoder that we only care about the absolute speed and do not need to encode the direction. This is because we will only ever spin the shooter wheel in one direction.

After creating the instance for the Encoder, be sure to set that instance as the feedback device for the motor using the PWMMotor’s SetFeedbackDevice function, which PWMMotor inherits from SmartMotor.

Finally, create setPower and setSpeed functions to control the motor via power and speed. You can look back to the Drive Subsystem to refresh you memory of how to do that.

Now we are ready to tune the shooter. The technique for doing this is the same as for tuning the drive motors:

  1. You should create a Calibrate Shooter command and tie it to a button.
  2. Using this command, drive the shooter at full power (using setPower) and log the speed. This will tell you the maximum possible speed for the shooter. In my case I found the max speed to be about 1450.
  3. Since we will be running the shooter motor near full power, set the F term of the PID controller for the motor running at a speed of 1300 (using setSpeed).
  4. Next add a P term and increase it until you see the speed becoming unstable, and then back off a bit.
  5. Finally add an I term and increase it until you see the speed becoming unstable, and then back off a bit. Remember to set an appropriate IZone.
  6. Once you have it tuned for a speed of 1300, check the tuning at 1400 and 1200. Only change the P and I terms if there are significant problems at those speeds.

The following were the results of my calibration:

Now create a Spinup Command which will toggle the shooter motor on and off at a specific speed, and tie it to a button. Once you get the feeder working, you will be able to experiment with different speeds and use the speed you find works best. In my case I settled on 1400.

The Shooter wheel will now shoot balls that are fed into it, but we still need a way to do the feeding.

Next: Feeder Subsystem