The Feeder Subsystem is also fairly simple. Once again, you have a single motor. The feeder has an issue where is sometimes jams so you need to write code to deal with this fact. The basic idea is that you use the encoder to detect the jam (i.e. when the speed drops to zero or near zero) and reverse the direction for a short time and then start shooting again.
In addition to the feeder motor there is a beam break sensor which can be used to count the number of ball shot. The class to use for this is DigitalCounter and it count two counts each time a ball passes through.
You will need the following pin numbers for the PWMMotor, Encoder, and DigitalCounter.
1 2 3 4 5 6 |
private static final int k_PWMPin = Device.M3_1_PWM; private static final int k_DIRPin = Device.M3_1_DIR; private static final int k_encInt = Device.Q3_INT; private static final int k_encDir = Device.Q3_DIR; private static final int k_ballCounter = Device.IO_1; private static final int k_I2CAddr = 5; |
You should create a FeederCommand which can shoot a specified number of balls. You should pass in the desired ball count in the constructor and if that count is set to zero, have it shoot an infinite number of balls. This mode can be used when manually shooting. Later when you are shooting autonomously, you can specify the count. You may also want to include a parameter which specifies whether or not to reset the counter at the beginning of the command. This will come in handy when you complete the Final Challenge at the end of the tutorial.