Grove - 3-axis Accelerometer freezes

Hello,

I’ve recently bought a Grove - 3-axis Accelerometer, based on MMA7660 chip. I’ve connected it to my Arduino, 10 centimeters wires to breadboard, then another 10 from breadboard to Arduino. I’m using the code provided on wiki page for the product, and I can successfully read the data from all 3 axis. However, at some unspecified time serial output freezes, and it seems like the whole Arduino freezes completely, and the only way to unfreeze it is to reset it.

What could be the problem? Wire length? Default Wire library? I2C clock speed is too high?

Thank you.

I am having the same issues. I my case I read samples OK in a very short test, but it was only when I tried a fast loop to see haw many times a second I could read the sensor (thinking about trying real time motion tracking - 120 samples per second) that I experienced the freezes. My tight loops have completed 20,000 reads before lockup, but have also locked up at 9,000 reads. This is using Arduino GUI 1.0 release and the updated wire libraries that it comes with.

Looking around the web produces a LOT of issues that seem to be related to the Arduino wire library. Seems like it has bugs, and also “blocks” ie waits forever in some situations for a response. This is a big issue for the people with helicoptors as this causes expensive crash!

I have only just run into this issue and started looking, so don’t have any solution yet. Things I can see are:
a lot of issues with the Arduino Wire lib
apparently the additon of I2C (and maybe other functions) to the Wire lib has made it large and unwieldy and buggy
many requests & suggestions to modify the wire lib
3rd party I2C libs
I2C libs that are assembly - ie you have to do all your code in assembly…

This is as far as I have got and was checking back here for more ideas when I found your post. I’ll post any updates as I (hoepfully) progress.

I decided to start from the simplest part: replacing Wire library to something else. The first third-party library I’ve tried was found here: http://dsscircuits.com/articles/arduino-i2c-master-library.html

Code changes were insignificant, example sketch was enough to understand, how’s library working.

And that was enough! I can now run measurements with any sampling rate, and I didn’t notice any freezing or something like that. All you need is to put default Wire library into trash can and find something more acceptable.

that is good news.

… except I cannot access it from my location :frowning:

Is that library also hosted on an SVN or somehwere else?

I put the library to Dropbox, you can find it at http://dl.dropbox.com/u/614850/I2C.zip
The guy who wrote it is Wayne Truchsess