|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
Using a Gyro on any port (How to code that)?
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.
|
|
#2
|
|||
|
|||
|
Re: Using a Gyro on any port (How to code that)?
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. |
|
#3
|
|||
|
|||
|
Re: Using a Gyro on any port (How to code that)?
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
|
|
#4
|
|||
|
|||
|
Re: Using a Gyro on any port (How to code that)?
The throw new Exception() of AnalogChannel.java line 229 states (if executed):
"Accumulators are only available on slot 1 on channels 1,2" |
|
#5
|
|||
|
|||
|
Re: Using a Gyro on any port (How to code that)?
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.
Code:
pseudocode: thisSample = gyroAnalog.getValue thisTimeStamp = Timer.getTimestamp thisAmountTurned = ((thisSample + lastSample)/2) * (thisTimestamp - lastTimestamp) * (Kgyro) currentHeading += thisAmountTurned lastSample = thisSample lastTimeStamp = thisTimeStamp lather, rinse, repeat |
|
#6
|
|||
|
|||
|
Re: Using a Gyro on any port (How to code that)?
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|