From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

ADXL345 connected to Arduino (SPI) to LabView

Hi,

I have an ADXL345 Accelerometer that is connected to my Arduino (Atmega 328) via SPI. And I want the data reading to be plotted to LabView but I do not know how to make it work. I am really not familiar with SPI communication.

I have already installed the Arduino Interface to LabView as well as the SPI add-ons to my LabView. But I really do not know the proper wiring.

Below is the link for the Arduino code that I used:

https://gist.github.com/e-Gizmo/7818304

The ADXL345 that I am using is below:

download.jpg

I want to plot the data coming from the adxl345 to LabView. This is for my undergraduated study. I hope someone can help me.

0 Kudos
Message 1 of 31
(10,011 Views)

Since LIFA is old and unsupported, I'd recommend that you upgrade to LINX (the LIFA replacement).  To be able to use that device with LINX, you'll either need to port the functions (from the library) to LINX using the LINX SPI VI's or create a LINX custom function that uses the existing library.

For wiring, I recommend that you search online.  You should find many resources for wiring SPI devices to your Arduino.

Alternatively, the ADXL345 is supported natively in LINX using the I2C protocol.  So, if you can use I2C instead, you won't need to do so much extra programming.

Another thing to notice is that the board you have shown there uses 3.3V logic while the Arduino is a 5V logic device.  Typically, if you use a 5V microcontroller with a 3.3V sensor, you could potentially damage the sensor.  You'll probably want to double check in the e-Gizmo documentation to see if it is 5V tolerant.

Message 2 of 31
(6,644 Views)

HI Nathan_B, first of all thank you for the response.

I am currently trying on the I2C protocol.

About the voltage, according to the hardware manual provided by e-gizmo, the power input of the ADXL345 is from 1.8V to 3.6V. The required voltage is +3.3V.

"This program uses a special software technique to allow direct and safe interfacing of a 3.3V

ADXL345 device (e-Gizmo ADXL345 breakout board) with the 5V logic interface of the gizDuino/Arduino I/O bus"

With that I think there shouldn't be a problem about the 3.3V and 5V difference. Right?

EDIT: Another question, is SDA equivalent to DI? and SDO equivalent to DO? Because in my ADXL345 I only have DI and DO. Thanks!

0 Kudos
Message 3 of 31
(6,644 Views)

Hey Nathan, I followed this by Salender (You also helped him). https://decibel.ni.com/content/thread/12287?start=15&tstart=0

But I couldn't make it work. My x,y,z reading are all zero and it does not change. I changed the baud rate to 9600. I followed the wiring of my adxl345 to arduino. However, my problem is really the SDA pin? I do not have that in my ADXL345.

My ADXL345 pin outs are these: CLK, DI, DO, CS, INT1, INT2, VDD, GND.

I used a breadboard so I can hook up CS and VDD to 3.3V (I am not using any resistor, my sensor has built-in resistors). Connected CLK to Analog 5. DI (since I do not have SDA) to Analog 4.

In Arduino, my board is Arduino Duemilanove or Diecimila, the processor is ATmega328.

img.png

0 Kudos
Message 4 of 31
(6,644 Views)

UPDATE: I made it work! Looks like I had an incomplete wiring on my first try.

img.png

I am just wondering on what range it is on right now. Because in my first code using SPI it was running on +/- 16g range.

Now, I will figure out the LabView part.

0 Kudos
Message 5 of 31
(6,644 Views)

Hey Nathan, I tried your library: https://decibel.ni.com/content/docs/DOC-28504

But it is for LIFA? What does it mean. I open the VI in the Examples folder.

From the Arduino item in LabView, I added the port, board type, baud rate, and connection type. Is that right thing to do?

Also, what should I choose for the Register?

img.png

0 Kudos
Message 6 of 31
(6,644 Views)

Hi,My name is barddya. And I have been following your progress so far.I also do buy  a lot of Arduino gadgets and I get them to somehow work with arduino script/programming and when I try to have them working in Labview , I encounter a lot of issues.There are not many people who do so , therefore there are not much help out there.My email is barddya@yahoo.com  please share your code and let's keep in contact. What we need is a Arduino to Labview converter expert gathered in one new group? what do you think? From: JersonJose <web.community@ni.com>

To: barddya <barddya@yahoo.com>

Sent: Tuesday, January 12, 2016 3:52 AM

Subject: - Re: ADXL345 connected to Arduino (SPI) to LabView

|

|

NI Community

|

Re: ADXL345 connected to Arduino (SPI) to LabView

created by JersonJose in LabVIEW Interface for Arduino - View the full discussionUPDATE: I made it work! Looks like I had an incomplete wiring on my first try.   https://decibel.ni.com/content/servlet/JiveServlet/downloadImage/2-126911-195655/450-253/img.png  I am just wondering on what range it is on right now. Because in my first code using SPI it was running on +/- 16g range. Now, I will figure out the LabView part. Reply to this message by replying to this email -or- go to the message on Community Start a new discussion in LabVIEW Interface for Arduino by email or at Community

0 Kudos
Message 7 of 31
(6,644 Views)

Hey barddya, the code that I am using is from Jeff Rowberg. I modify it a bit to fit my sensor. I changed the baud rate and removed the part of the codes that is for the LED because I am not using a LED. But before using the his code. I first copy/paste the library that he uses in the code which he also provides.

Just go to this site: https://github.com/jrowberg/i2cdevlib

Download the .zip file. Put the required libraries to MyDocuments > Arduino > Libraries.

I also followed this wiring diagram: adxl345_arduino_schematics.jpg

I hope that helps!

0 Kudos
Message 8 of 31
(6,644 Views)

Are you using LIFA or LINX?  Like I said before, LINX has native support for the ADXL345 using I2C (which it seems you have switch to using).

0 Kudos
Message 9 of 31
(6,644 Views)

Are LINX and LIFA just a LabView add-ons? or there is a physical hardware?

If it is just an add-on no I am not using either of the two. If there is a physical hardware involve (sorry really not familiar with the two) I also have none.

0 Kudos
Message 10 of 31
(6,644 Views)