hey guys - this thread just showed up in the ‘new posts’ search for me - sorry I didnt get back sooner (we were at Pittsburg - made it to 2nd place [finalists])
couple things here - it doenst matter to you how fast the gyro chip samples and outputs its data, because it has an analog output and output filters, so the output changes smoothly from one update to the next - you cant ‘see’ the sample rate on the output unless your robot is oscillating back and forth faster than the gyro can undate (and trust me on this, our motors do not have any where NEAR the power required to make a 130 pound machine move back and forth at 40 or 100 Hz :^)
in fact, our bots have so much inertia, and we normally turn so slow that the difference between successive samples of the gyro will be fairly small - so it doesnt matter if you sample them at 38Hz (the loop frequency of the process_data_from_master_up function) or at 100Hz or more- if you sample it at 38Hz you are not going to ‘miss’ any data from the gyro.
The main difference between the old FIRST gyros and the AD chip is the degree/second rates - the old ones were +/-75° per second and the AD…150EB is +/-150° per second - that is the big thing you will have to change - when turning at the same rate the AD chip will put out a smaller signal, because you have to turn twice as fast to get a full scale output.
BTW - adding the signal to an accumulator IS integrating the signal - if you go through all the math, instead of degrees per second (the gyro output) you end up with degress * your sample rate
with the AD gyro turning at full scale for one second you will turn 150°. if you shift right the gyro output down to 8 bits, then If you sample it at 38Hz you will have 127*38 added to your accumulator - so 4572 represents a turn of 150°
divide it out and 1 degree is = 30.48 in the accumulator.
if you are sampling faster the conversion factor will be higher.
The other thing you have to be aware of is the zero point in the AD chips seems to be off more than they were with the old FIRST gyros - ours sits at 141 instead of 127 - I wrote a section of code to read the gyro when the bot is disabled, and average for 32 samples- this seems to be working but I also have gyroZero initalized to 141 incase this doesnt run for some reason - I put the gyroZero variable on the OI User byte so we can see it from the OI.
/* if disabled then average the gyro zero point*/
if (competition_mode==0)
{
gyroAccum=gyroAccum+gyroData; /*add data to accumulator*/
aveCount=aveCount+1;
if (aveCount==32) /* then done with this */
{
gyroZero=gyroAccum>>5; /*div by 32*/
gyroAccum=0; /*clear for next time*/
aveCount=0;
}
}
gyroAccum and aveCount are both initialized to zero on powerup.
ok - one last thing about fast and normal loop speeds - Innovation FIRST put the auton code in the user_routines_fast.c file, but I dont know why they did that - I think its misleading - from what I can see reading the default User_Autonomous_Code two things stand out:
-
auton spins internally on a while loop - once you get into this function you dont exit until auton ends - so only the code ‘in here’ gets run in auton mode
-
auton waits for statusflag.New_SPI_DATA before its body is executed - this is the 26.2mS (38 Hz) timing gate - so unless you add code outside that IF statement, its not going to run faster than 38Hz - so I dont know why people are thinking the auton code is running faster - unless you modify the default code, its not
in fact, we moved our auton code into the user_rountines.c file, so that I dont have to re-declare all the common variables as extern’s.
I think I missed something - let me post this and read the original questions again - if I did I will post again.