tombrookYo!
United Kingdom
Asked
— Edited
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.Stopwatch
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 ARC. 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
I've tried running it through VisualStudio by changing the code to
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.
Are you connected to the EZ-B when you run the code?
Yeah thats with it connected, the test program so far is just a basic form with the pre made connect button out of the toolbox from the ezb.dll file and then a click button to run the code.
Are you receiving correct data also?
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.
Yeah the data seems to be ok, I used a similar method for getting a heading using a compass with tilt compensation combined with an accelerometer (all on the same RM-G146 module) but it wasn't time critical so I didnt look at the communication speed then. Would it help if I put some of the code up in case I've missed something simple? Thanks Tom
You can zip up your project and upload it as an attached file
Thanks, really appreciate you taking the time to look at it. gyro.zip
Any ideas? I've tried adding some pull up resistors but that didnt seem to make any difference? The wire to the device is reasonably long but its what came with the sensor (aprox 30cm). I've tired 1k and 4k7 but not 10k yet as I need to pick some up tomorrow.
Ok I've just got an MMA7455 to check that its not an issue with my i2c device. A read from the x data register using the tutorial example is still taking 50ms so I guess thats as fast as I can expect? Whats the reason for this duration as I know using Arduino's etc you can get much faster readings in order to use gyro data properly?
On an Arduino, you program the microcontroller directly. With EZ-Robot, your computer speaks to the microcontroller over a wireless communication protocol - which introduces a delay.
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