How do you set up the code for the ADXL345 SPI Accelerometer? I opened up the example under the example finder, but I don’t know where to put the code or what I need for read, range, etc.
The example is all you need. You connect the sensor, as shown on the Front Panel, and you hit the Run button to watch it work.
You’ll have to change the IP address on the Project Explorer to your team’s IP address.
How do I incorporate this into our team’s current code which features drive, camera, joystick, etc.?
In general, everything left of the loop in an example goes in Begin, and everything right of the loop goes in Finish. The contents of the loop (except for the delay) goes in Teleop, or wherever you need to read the value. Do not copy the Start/Stop Communication functions.
The Open function produces a Device Reference. You’ll need a way to make it available in other VIs; that’s what the RefNum Registry Set and Get functions are for. Follow the pattern you see with Joystick and Motor refnums in the code. The SPI Set/Get functions are in the WPI Robotics Library -> Communications subpalette.
Things will probably work best if you copy the contents of the ADXL345 SPI Driver folder from the example project into your team’s code, but I think you can get away with leaving them where they are as long as you don’t make any changes to them.
You might also look at Tutorial 7 - Integrating Examples into Robot Code. You can find this on the Tutorials tab of the LabVIEW Getting Started Window. If you already have LabVIEW code open, choose View>>Getting Started Window…
Now, how to debug why there’s nothing. No errors, no change in data. From two of the three boards we have (haven’t tried the third). Will I need to put a scope on the send and receive lines?
Have you updated LabVIEW recently? There was a bug with the SPI communication a few weeks back, and it was fixed with an update, then more recently, some other bugs were squashed wtih the latest update.
Specifically, there is were two updates for LabVIEW. Here’s the latest updated.
Next, if you haven’t, update the utilities and driver station as well. Those are available from the link above as well. To note, you MUST have the newest driver station software installed prior to competition.