We’re having great fun here digging into the examples with the Zumo. But an example that worked the other day is now having problems. When I load the RotationResist example and turn it on, the LCD stays stuck in “Gyro Cal”.
I found where this code is (TurnSensor.cpp) and gyro cal loops 1024 times, reads the gyro each time, then computes the average. I added a few lines to see the loop iteration: it stays stuck a zero! Seems clear that something’s wrong with the gyro chip.
Any ideas for getting this to work? Thanks,
// Calibrate the gyro.
int32_t total = 0;
for (uint16_t i = 0; i < 1024; i++)
lcd.gotoXY(0,1); // CRW added
lcd.print(i); // CRW added
// Wait for new data to be available, then read it.
while(!gyro.readReg(L3G::STATUS_REG) & 0x08);
// Add the Z axis reading to the total.
total += gyro.g.z;
I would like to verify that you are using this library on a Zumo 32U4 robot and not one of our Zumo for Arduino robots. That library is written for the the Zumo 32U4 robot.
Could you try powering everything off for 5 minutes and trying again? It is possible that the gyro chip is stuck in some indeterminate state and cycling the power could reset it.
Sorry for the late reply. I must have forgot to check “notify when a reply is posted”.
I believe I am using the right library - got it from: pololu.com/file/0J743/a-star-1.4.0.zip.
I’ve had the robot off for several days now, and I just pulled the batteries to be sure. Still nothing beyond “gyro cal”.
Can you tell me what hardware you are using? I linked to two different sets of hardware in my first post. The software libraries required for those two sets of hardware will be different.
Sorry - it’s the Zumo 32U4, not Zumo for Arduino.
When it got stuck (before you made the “Gyro Cal” print modification),were you using an example sketch without any modifications? I noticed a similar problem with my Zumo robot here when I wrote some new code that did not have the Wire.begin(); statement in it. The statement is in Line 44 of the TurnSensor.cpp file in the RotationResist sketch (which you included code from in your original post). Is that statement still present?
Have you tried any of the other example sketches to see if they work? The “FaceUphill” example would be good to test, because it only uses the accelerometer, which is on the same I2C bus as the gyro, but is a separate chip. The "InertialSensors " example should use both sensors and if there is a hardware problem, I would expect it not to work.
Have you made any hardware modifications to your Zumo 32U4? The SCL and SDA pins used by the I2C bus the accelerometer and gyro are connected to are exposed in several different locations on the board. You can see these locations in the diagrams in the “Expansion areas” section of the Zumo 32U4 user’s guide. If you post pictures of the soldering you have done on your robot, I can look to see if anything looks like it could be shorted. One of the places those pins are exposed is at the header for the front IR board.
Thanks for the many suggestions.
I have not made any hardware modifications. I have run many of the examples at least once and they worked. For instance, FaceUphill, RotationResist, Encoders, SumoProximitySensors… All worked. It’s only after some time passed and I tried RotationResist again that it no longer worked.
Anyway, looks like it’s working now. I just now swapped the front sensor array with a second Zumo 32U4 that worked fine, and now they both work fine. I swapped them back and they still work fine . I don’t know if plugging the sensors in off by one on the pins would cause this, but that should be rather noticeably off-center, so I find it hard to believe it was plugged wrong. All the same, your suggestion about I2C on the front IR board prompted me to try the swap. Looks like they’re up and running again, no worse for wear.
Thanks for all the help,