For some reason (being mainly my own stupidity) we never tried to use an accelerometer before kickoff for practice. As it turns out it’s a vital part of what we’re planning to do (No bonus points if you guess - it’s too obvious!), so it certainly doesn’t help that nothing I try to do works.
We’re using a cRIO-FRC2. We have the digital sidecar connected to the digital module on slot 2, and we connected the ADXL345 accelerometer to the sidecar exactly as shown in the examples. We have tried both examples (I2C and SPI) several times, and neither worked. We’ve also tried two different accelerometers, both reacting the same.
We’ve checked, double-checked, triple-checked, and then checked a bunch more times - everything is connected correctly. I am completely baffled as to why it’s not working.
When we run the I2C example, it spits up an error, immediately stopping the VI. I’m afraid I can’t copy-paste it at this moment, but generally (from memory): it expected something like “Address 58” (not 100% sure about the number) but instead received “The sensor did not respond” (or something to that effect). The error text then goes on about the error code being undefined, and the rest of that annoyingly long message. Error code was was -44xxx (xxx being your best guess!)
I tried to go deeper and see the source of the error. I’ve found the oddest thing - a devref entering a Read VI was probed error-free, but when probing the input when going inside the read VI, it has the error in it.
The SPI example, on the other hand, DOES run, but returns 0 for all axis’s at all times. I made sure that earth’s gravity was in fact turned on, and even tried moving the sensor myself - it did not output anything. We’ve given this one less attempts though.
I am not a very experienced programmer but I’m skilled enough so you don’t have to dumb down your replies for me.
Side question: Is either protocol better than the other for the accelerometer? For what reason?
What is “slot”? If you’re trying to specify a digital module, don’t refer to it by its cRIO slot number. The first installed module (in slot 2) is module 1.
Every time we try to read the ADXL345, we get this output:
[frcrun] [cRIO] Digital module 2 is not present.
That’s a pretty specific error message. Do you indeed have a second digital module installed?
I was looking through SensorBase, and this javadoc on SensorBase.checkDigitalModule() looked interesting: Module numbers are 1 or 2 (they are no longer real cRIO slots).
I’m not sure how to deal with this, and any help would be greatly appreciated.
I know what it means, so I can’t be sure it’s as self-explanatory as it looks, but you deal with it by addressing the digital module as either number 1 or number 2, depending on whether it’s the first module (in slot 2) or the second (in slot 4 of a 4-slot or slot 6 of an 8-slot cRIO).
After spending nearly all day trying different things, I am forced to reach the conclusion that the ADXL345 drivers used in the examples are simply wrong. It doesn’t work, nor does it show any signs of working. I’ve tried with two cRIOs (one 8-slot and one 4-slot), made absolutely sure EVERYTHING is connected as it should. This makes no sense. I give up.
If anyone gets the ADXL345 working using either protocol in LabView, please show me your code.
So now I have to go look around for an analog accelerometer…