Quote:
Originally Posted by Ether
Please provide more detail how you are obtaining the period.
For example:
a) sensor is configured as a counter object, and the 40MHz FPGA is giving you an exact period via getPeriod() in WPILib,
or
b) you are counting wheel revs, and dividing that into your nominal thread period,
or,
c) you are counting wheel revs, and dividing that into your measured thread period,
or
d) something else? I ask because bang-bang does not like phase lag and/or jitter on your speed signal.
|
DISCLAIMER: I am not a Java programmer.
We are using a Banner photo sensor, I believe the model is Q12RB6LV, and a single piece of Retro tape in one section of our shooter wheel. The tape spans approximately a 50 deg arc. You can see it in the photo below near the bottom of the image.
I had our programmer work with the WPILib to figure out how to get the period of a pulsed signal. I believe the command he is using is getPeriod(), at least that rings a bell.
getPeriod() returns a value in seconds and has a resolution of 1ms. This limits the number of steps in RPM we can achieve to only 15, but that is more than enough for this game. The value we read is very consistent.
We usually target a period of .025 for our default shot, but will vary it with distance to as low as .010 as needed (10ms is basically full power all the time).
The psuedo code we use is:
Code:
if (getPeriod() <= .025)
{
MotorDrive = 0
}
else
{
MotorDrive = 1
}
wait (5ms)