loading

This is a basic tutorial on how to connect the a ADLX345 Accelerometer IC (found on the PmodACL) to labVIEW. The goal here is to setup a simple project that will read values from the accelerometer and calibrate the inputs so they display correctly.

Step 1: Materials

Materials

1.chipKIT Max32

2.Breadboard

3.PmodACL (this should come with some spare header pins, and connection cables)

4. Optional: Platform to Fasten the circuit to ( i.e cardboard, plexiglass, wood ect)

5. Optional: Your preferred type of fasteners (i.e zip ties, tape, hotglue ect)

Check out step 5 to see how I fastened my circuit.

Software Requirements

1.LabVIEW installed

2.LabVIEW addon LINX installed

If you don’t have labVIEW and LINX installed check out this instructable.

Material Alternatives

This project is desgined around using a chipKIT Max32, and PmodACL. However you can substitute the following.

In place of the Max32: Any chipKIT, Arduino, or myRIO device that has an I2C port and is supported in the LINX Firmware Wizard.

In place of the PmodACL: Any board that has an ADLX345 Accelerometer IC which can be talked to via I2C should work.

NOTE: This instructable doesn't go over how to setup the circuit for these alternative devices.

Step 2: Circuit Setup

I included an image of how the circuit setup. The setup is pretty straight forward but here are a few key things to know.

The Pins 20 and 21 on the chipKIT are SDA and SCL I2C pins for the Max32. I determined this information by referring to page 9 of the Max32’s refrence manual.

I wired the pins of the PmodACL according to its reference manual. If you are unfamiliar with Pmods, here is a generic diagram of the pin out used for the connectors.

Pullup resistors are required on the I2C data bus. I use two 10K ohm resistors.

Side Note: Whenever I cant decipher a resistor color code I use WolframAlpah. Just type “resistor color code” and all the color stripes you see.

Heres an example: http://www.wolframalpha.com/input/?i=resistor+color+code+brown+black+orange+gold

Step 3: Code

The code in labVIEW is pretty straight forward. I attached an image of the code as well as the actual VI. The LINX addon for labVIEW has a few block functions designed to communicate with the ADXL345 chip via I2C. All you have to do is string the blocks together and grab the values they output.

Once you have the circuit setup and have downloaded the code try running it. Be sure that you setup your Max32 in the LINX firmware Wizard, prior to hitting the run button. If you don’t know how to setup a device in the LINX firmware Wizard go here.

After hit the stop button and the code is done running if you get this error, just hit continue. The error shouldn't really effect anything.

If you want to learn more about how the ADXL345 functions were designed in labVIEW double click on one of them and hit CTRL+E to open its block diagram. Some of these block diagrams use hexadecimal values to communicate with the ADXL345. To find out what these values do, refer to the ADXL345’s reference manual.

Step 4: Calibrating the Output

By default the ADXL345 isn't 100% accurate. Sitting on your desk theoretically it should display a value of 1 on the Z axis and values of 0 on the other axes. This is assuming the PmodACL is oriented as it was shown in the Circuit Diagram. You may have noticed that in reality the Z axis is not quite 1 and the X and Y axes are not quite zero. This is because the ADXL345 isn't perfect and needs to be calibrated. This can either be done by writing to hardware registers contained on the chip, or it can be done by simplay adding the calibration values in labVIEW.

To calibrate the accelerometer properly place it so it wont move at all. Using the Calibration controls on the VI front panel add or subtract small values until you get as close as you can to X = 0, Y = 0, Z = 1. Thats all there is to it, now your accelerometer should be reading accurate values!

Step 5: Optional[ Physically Securing Your Circuit ]

To test the project, you need to be able move, shake or rotate the PmodACL. You should be able to safely do this if the Pmod is attached to the cable it came with. However, if you want something a bit more practical, you should consider securing the entire system. This will allow you to move your whole circuit as one unit and prevent it from falling apart during testing.

I'll leave it up to you to figure out exactly how you want to go about securing things. I happened to have a good sized piece of plexiglass laying around, so I decided to mount the breadboard and chipKIT to it. The breadboard came with an adhesive strip so I was able to stick it directly on. To secure the Max32 I measured and drilled a few holes in the plexiglass. Then I snaked some zip ties through the Max32's screw holes. I like zip ties because they provide a secure but temporary constraint.

You may have noticed in my pictures that I placed the PmodACL upside down on the breadboard. This was my quick and dirty solution for securing the Pmod itself. I placed the Pmod so its J2 pins physically secure it to the breadboard. On the Pmod Jumper 2 just provides two extra hookups to the I2C bus, as depicted here. Placing the PmodACL upside down doesn’t hurt anything because I carefully oriented it so none of the jumper pins are shorting. You may want to figure out a better method for securing the Pmod than I did.

About This Instructable

10,151views

19favorites

License:

More by dacook13:Analog Discovery PWM and Digital IO Control though LabVIEW Controlling the Analog Discovery™ Waveform Generator in LabVIEW Manipulating Accelerometer Data In LabVIEW 
Add instructable to: