Hello all, thanks for looking at this post. This is my first electronics project, and I am looking for some input on why I am getting irregular, blank data (output is simply 0,0,0) from my ADXL313 boards from time to time.
The Story: I am currently working on building an accelerometer tool where an Arduino Uno collects data from three individual ADXL313 eval boards and sends that data to a host computer serially. For this prototype setup, the Arduino samples all three ADXL313 boards sequentially at 1000 Hz via SPI communication, then the Arduino does some calculations, and then it sends that data immediately to a serial COM port on the computer (I use puTTY to see the data). I use a timer counter interrupt to initiate the accelerometer sampling routine, so there are instances where the Arduino cannot send the desired data fast enough before the next interrupt is triggered, but that is a separate issue for later.
The Problem: My problem is that there are times where everything runs smoothly, where the data is displayed nicely on the terminal emulator, but then I will reprogram the Arduino with virtually identical code (only change what values are sent serially, no change in number of bytes sent) and I now get data which is extremely noisy because every second or third sample only displays "0,0,0" for x,y,z acceleration, which is clearly a bug and not normal. Sometimes, I only get a stream of zeros!
Has anyone seen this issue before and been able to pin point the root cause? It does not seem like it would be due to a faulty chip, since I am using three of them and they all experience the same symptoms.
The Details: Here is a summary of the ADXL313 parameters (each of the three programmed the same):
Any and all help is most appreciated! I can upload parts of my firmware code if you need more information from me to help figure out my issue. I have been stumped by this for a bit over two weeks now, but I will let you all know if I have progress on my own. Thanks.
Firstly, my sincere apologies for my delayed response. You were prompt with your comment, and I appreciate that.
Secondly, to answer your first question, no, I am not able to reliably restore normal operation when I go back to my "old" code. The only difference between the "new" and "old" firmware on the Arduino is the variable I pass to the "Serial.print()" command; the set up and algorithms are identical. Sometimes the data is normal, other times it is irregular as described above.
Admittedly, I have not revisited this issue since I posted this thread in January. I will review the blog you posted, which hopefully provides insight into my problem. Also, I will be replying to neilzhao below now.