Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Accelerometer I2C and Labjack U3 HV


  • Please log in to reply
13 replies to this topic

#1 EE Designer

EE Designer
  • Members
  • 11 posts

Posted 29 August 2012 - 01:17 PM

Hi, I have a labjack U3-HV and i need to read and store the data from an accelerometer via i2C to a text file. I have looked at a few application notes on how to connect the sensor to the Labjack U3. What i would like to know is can i use any of the application software like the LJLogUD, LJStreamUD, or the DaqFactory to read and store the data to a file ? I know from experience that the DaqFactory can read and store the data to a file from an analog input. Unfortunately, i don't have Labview or Matlab or VB software. BR, Vu

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 29 August 2012 - 02:09 PM

No, you cannot use LJStreamUD or LJLogUD to read from an I2C slave. You need to make calls to our UD driver to do the I2C communication. You can do that in any programming language, or even DAQFactory. Here are some links to get started:

http://labjack.com/s...rs-guide/4.3.11

http://labjack.com/s...t/app-notes/i2c

http://labjack.com/s...ture-sensor-i2c

http://labjack.com/s...agnetometer-i2c

https://forums.labja...?showtopic=5717

#3 EE Designer

EE Designer
  • Members
  • 11 posts

Posted 29 August 2012 - 02:32 PM

Hi, Thanks for your quick reply. BR,

#4 EE Designer

EE Designer
  • Members
  • 11 posts

Posted 31 August 2012 - 10:03 AM

Hi, I've looked at a few I2C and Daqfactory examples. One thing i notice is that there is no Register mapping/address defines anywhere in the script. for example, in C/C++ you have #define xyz_reg1 0x32 and so forth. Does this mean scripting in Daqfactory doesn't required the use of #define ? What scripting language is the Daqfactory using ? Because in my application, i need to set up registers for the accelerometer to a certain value on power up

#5 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 31 August 2012 - 02:57 PM

Hi,
I've looked at a few I2C and Daqfactory examples. One thing i notice is that there is no Register mapping/address defines anywhere in the script. for example, in C/C++ you have #define xyz_reg1 0x32 and so forth. Does this mean scripting in Daqfactory doesn't required the use of #define ? What scripting language is the Daqfactory using ? Because in my application, i need to set up registers for the accelerometer to a certain value on power up


DAQFactory uses it's own scripting language. I believe you can create variables with certain values which would act the same as #defines. For the I2C specific things there are various properties that the driver keeps track of:

LJ_chI2C_ADDRESS_BYTE
LJ_chI2C_SCL_PIN_NUM
LJ_chI2C_SDA_PIN_NUM
LJ_chI2C_OPTIONS
LJ_chI2C_SPEED_ADJUST

Which can be set with LJ_ioPUT_CONFIG to control various I2C properties (such as the address byte).

In DAQFactory you can do:

global xyz_reg1 = 0x32

which gives similar results to C/C++ #defines.

#6 EE Designer

EE Designer
  • Members
  • 11 posts

Posted 05 September 2012 - 01:28 PM

Hi support.

Attached file is my 1st attempt to read acceleration to the LIS331HH via I2C using the DaqFactory scripting language . I have a few questions i would like to ask.

1. I'm using the DaqFactory free version "Express", how do i execute the script and how can i track the variables ?
2. Could anyone provide me some guidelines on how to debug the script (If any) ?

Datasheet.
http://www.sparkfun....er/LIS331HH.pdf


Many Thanks

EE_Designer

Attached Files



#7 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 05 September 2012 - 02:40 PM

From the hardware perspective of LabJack, the best way to debug I2C communication is with a logic analyzer or oscilloscope. Start with a very simple read of some single known register, and see if the signal on the scope looks right.

From the software side, I would post on AzeoTech's forum for ideas on debugging scripts:

http://www.azeotech.com/board/


If you have any experience programming, I would suggest you consider using a normal programming language rather than so much script in DAQFactory. For example, there are free C++ environments available for Windows such as Dev-C:

http://labjack.com/support/ud/examples

#8 EE Designer

EE Designer
  • Members
  • 11 posts

Posted 06 September 2012 - 10:23 AM

So, I begin with a really basic read that i borrowed from the eGet.ctl on a register with a default value of 0x07 then probed the SCL and SDA lines on the oscilloscope but i didn't see any clock or data signals activity. The SCL line is connected to FIO7 and the SDA line is connected to FI06. Could anyone give me some hints.

#9 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 06 September 2012 - 11:51 AM

I suggest you add to your sequence a couple ePut(LJ_ioPUT_DIGITAL_BIT) commands to toggle some other digital output. That way you can confirm that the sequence has run by putting your scope on that line. Are you checking for errors after every Go, GoOne, ePut, or eGet? Do you have the error/alert window displayed so can see errors if they happen? To test whether you are seeing errors, do something that you know will cause an error like trying to toggle digital output #100 which is not valid number.

#10 EE Designer

EE Designer
  • Members
  • 11 posts

Posted 06 September 2012 - 12:24 PM

So, finally i see activities on the bus but not retrieving the correct values

#11 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 06 September 2012 - 12:26 PM

So if you can see bus activity, then the next thing to do is analyze the I2C waveform and see if it looks correct.

#12 EE Designer

EE Designer
  • Members
  • 11 posts

Posted 06 September 2012 - 01:21 PM

So if you can see bus activity, then the next thing to do is analyze the I2C waveform and see if it looks correct.

According to the datasheet page 18, the last paragraph stated that i need to issue a repeated start (SR) after issue a slave address plus a sub address. How can i accomplish this ?

#13 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 06 September 2012 - 03:27 PM

The LabJack will do this automatically when writing and reading in a single I2C operation. You can control whether it stop and starts or restarts using the options byte.

#14 EE Designer

EE Designer
  • Members
  • 11 posts

Posted 06 September 2012 - 03:47 PM

Support, Thanks for your help. I will tackle this at later day.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users