
tombrookYo!
Hi I'm trying to integrate gyro data to give angle of rotation but am having difficulty getting a high enough sample rate. For instance I've tried timing how long the following line takes to execute using the Diagnostics.StopwatchCode:
System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
timer.Start();
byte gyro_xvalh = ezb0.I2C.Read(gyro,0x1D); // read from x value register address msb
timer.Stop(); //
MessageBox.Show(string.Format("Elapsed time is: {0}", timer.ElapsedMilliseconds));
Its around 60ms which seems a long time, I'm running and compiling the test script from the c# script in ezbuilder. I could really do with a much faster read time as I want to get as accurate rotation angle as possible.
If anyone knows what the limiting factors are that are resulting in this delay that would be a great help.
Thanks
Tom
Code:
and now its taking about 1.4 secconds to read from 6 registers? Is ezB_Connect1 the wrong thing to be using each time? Is it reconnecting or something each time which is causing the delay?
Really stuck on this at the moment and need to make some headway so any help would be great.
I ask because usually a high query time is due to communication timeout by not being connected or the i2c device having a slow response.
Would it help if I put some of the code up in case I've missed something simple?
Thanks
Tom
gyro.zip
There is a new firmware coming out with some enhancements to the i2c protocol. It will be quite a bit faster. Also, there is a new bluetooth module that will be on the store shortly with a faster communication speed.
Both of those will help you greatly