I2C - Sensirion SDP610 pressure sensor on Labjack T-7


Recommended Posts

We are trying to get a Sensirion SDP610 differential pressure sensor to communicate with a Lajack T-7 via DAQFactory Pro 16.1 build 2242.
The DAQFactory sequence script is attached.
Trying to send a test array (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) in the script to the T-7, a scope shows no signal on the data line to the sensor.
The T-7 is working fine otherwise. It seems to be a problem with line 14 of the script:


Any insight into why this is not working would be greatly appreciated.

Thanks in advance..................Norbert


Link to comment
Share on other sites

At present, the eWriteNameArray and eReadNameArray functions are not supported in DAQFactory.  You have two choices:

1) we can look to add them for you, but you'd have to wait

2) you can use the extern() function, which you obviously have some experience with, to load those two functions from the LabJackM DLL directly.  There is no real reason this should not work, even though the LabJackM DLL is already loaded by DAQFactory.  You would, of course, be accessing these two functions through the import from extern(), but could still use all the other DAQFactory LabJack functionality.

Link to comment
Share on other sites

  • 2 weeks later...

Attached is a test .ctl file trying to send commands to the T-7 from DF using the extern() function as you suggest.
The error message returned is:

Invalid argument specified.: Init_I2C_T7_extern Line 6 -
Uncaught error in sequence Init_I2C_T7_extern

An additional question: is it possible to use the T7 via the extern() function and simultaneously use the DF integrated functionality,
such as channels, etc.?


test I2C b.ctl

Link to comment
Share on other sites

That's because "INT" is not a valid data type for the prototype.  See 15.1.3.  The reason is that Int, technically has different meanings depending on the compiler and operating system. For example, on 16 bit computers, its a 16 bit integer, but on 32 bit computers its a 32 bit integer.  Who knows what it will mean as we move towards 64 bit OS's.  For that reason, we force you to specify what type of integer and not just use the ambiguous "int".  Most likely you want to use "long" instead of "int".

Link to comment
Share on other sites

  • 2 weeks later...

If I replace INT with LONG in line 6, DAQFactory crashes.

Do you have any code examples of DF using the Labjack.LJM.dll to communicate with an I2C device?

In the attached ctl file, see sequence Init_I2C_T7_extern

I tried to add a sequence "DLLFunctions" to list the DLL functions, as per the UD example in your documentation.
When I try to delete the sequence and save the .ctl, it won't delete the sequence, or allow me to rename it.

test I2C c.ctl

Link to comment
Share on other sites

I don't have any examples, but LabJack might.

The prototype for eWriteName in the LabJackM header is:

LJM_ERROR_RETURN LJM_eWriteName(int Handle, const char * Name, double Value);

The extern should be something like:

extern("C:\DAQFactory\LabJackM.dll","LONG LJM_eWriteName(LONG, string, DOUBLE)","LJM_eWriteName","stdcall")

Note that I wouldn't name the functions LJM_eWriteName in DAQFactory (the 3rd parameter of extern) since this will collide with the internal function of the same name if you use the using() function as many LabJack samples do.

 The prototype for eWriteNameArray in the LabJackM header is:

LJM_ERROR_RETURN LJM_eReadNameArray(int Handle, const char * Name,  int NumValues, double * aValues, int * ErrorAddress);

This in turn should be something like below, assuming you are going to read 16 values.  For the 3rd parameter you should always pass 16 or under as that is the size of the array that DAQFactory is going to pass.

extern("C:\DAQFactory\LabJackM.dll","LONG LJM_eReadNameArray(LONG, string, long, DOUBLE[16], long[16])","LJM_eReadNameArray","stdcall")

Finally, you really need to either use the functions you bring in using extern() or the built in LabJackM device, but not both.  The problem is that the DAQFactory driver takes care of handles for you so all you do is specify the ID for each call.  This will cause conflicts with handles you may open using LJM_OpenS() that you brought in using extern.

We need to do an overhaul of the DAQFactory LJM driver very soon, especially to improve streaming, and will look to bring more of the LabJack functions into DAQFactory.

Link to comment
Share on other sites

  • 3 weeks later...

After consulting with Labjack, we plan to use Lua script on the T7 to communicate with the sensor, and have it write data to Modbus user ram. We would like to use DF to read the data out of T7 user ram. What is the best way to do this? Do we need to set up a new channel?


Link to comment
Share on other sites

 You'll need a new LabJackM channel, select Special for the I/O type, then in the Quick Note / Special / OPC column put the name of the LabJack channel (for example AIN0) that corresponds to the location you want.  Sorry to pass you back, but you'd have to ask LabJack what the name would be to read data out of T7 ram.

BTW: if you are reading multiple channels and want to utilize the Duplicate feature, you can use # in the quick note and DAQFactory will substitute the channel number specified for the #.  So, you could put AIN#, and then specify which AIN you want in the channel number column.  This is for the LabJackM driver only.

Link to comment
Share on other sites

Digital data lines on the Labjack T-7 are DIO(0-22)
The clock and data line to the I2C sensors would be 2 channels, DIO0 and DIO1
However, you use an onboard T7 lua script to read the data from the channel and put it into a Modbus register. It is too difficult for us to do directly through Daqfactory due to the complications of having no direct support for the LJM eWriteNameArray and eReadNameArray functions, as you mention in the second post, above.
There are dedicated Labjack modbus user registers (user ram), and I want the data in there, not the raw I2C traffic.
Then, I want to read the data out of the Modbus registers with DAQFactory.

Link to comment
Share on other sites

Yes, I understand, and presumably those same registers are available through one of the special channel names that the LabJackM uses and thus you could use the DAQFactory LabJackM driver with the Special I/O type to specify that name..  LabJack would know what they are called.

Link to comment
Share on other sites

You want to use the "USER_RAM" registers.  They are documented on scripting section of the T7 datasheet about half way down the page.  Below the register descriptions is a short lua script example that reads from the USER_RAM0_F32 register (address 46000) and writes to the USER_RAM1_F32 register (address 46002).  

I highly recommend checking out the I2C_Utility script that we have for Lua (currently only posted to github, and released with the latest beta installer on our website):

The script (with no modifications) will search for any available slave addresses where the SDA line is DIO12 (EIO4) and SCL line is DIO13 (EIO5), look at line #92 to re-configure this.  We have several I2C examples that use the I2C utility that you can look at for examples: https://github.com/labjack/I2C-AppNotes/tree/master/LJM_Library.  All of the .lua examples should read data from the designated sensor and post some data to user ram registers.  The IO-Expander example uses a few registers as "input" registers.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.