The title pretty much says it. We are trying to use three Gyros on our bot this year, but we understand that there are only two available hardware accumulators on the robot. Since this is getting down to the wire, has anyone already written some JAVA for this to just take the analog signal from the gyro? We tried for a good deal of time today with no avail.
make sure your gyro is plugged into an Analog Breakout.
Then, just use the gyro class in java and it should work.
assuming you are using the gryo that comes attached to the accelerometer.
That works great for the first two, but there are only two accumulators in the FPGA so you can only use two instances of the built in gyro class
The throw new Exception() of AnalogChannel.java line 229 states (if executed):
“Accumulators are only available on slot 1 on channels 1,2”
If you only need low performance from the third gyro you could try integrating the output yourself. Allocate a regular AnalogChannel, poll it regularly, and add the values up.
pseudocode:
thisSample = gyroAnalog.getValue
thisTimeStamp = Timer.getTimestamp
thisAmountTurned = ((thisSample + lastSample)/2) * (thisTimestamp - lastTimestamp) * (Kgyro)
currentHeading += thisAmountTurned
lastSample = thisSample
lastTimeStamp = thisTimeStamp
lather, rinse, repeat
I doubt you will get performance anywhere near the FPGA, but it is pretty quick to try.
If you’re running anything else on your robot, it might be worthwhile to run this on a separate thread. I’m not sure how nice Thread.Sleep() is on the robot, though.