Labjack UE9 initialization in DaqFactory


Recommended Posts

I am using DaqFactory to log data coming from two 16 channel Smart AtoD cards (devices 0 & 1) and a Labjack UE9 (device 2)

to initialize the Labjack I have put the following at the end of my startup sequence

openLabJack (LJ_dtUE9,LJ_ctEthernet,"192.168.0.209",2,&lngHandle);

and in Channels I have put

Channel Name LJ1

Device Labjack

D# 2

I/0 Type A to D

Ch# 2

When the sequence runs it gives D0050 Labjack Device#2 error: invalid handle

note I see the data channels fine in LJControl Panel

Should I have declared the handle as a variable somewhere

Nowhere in the samples does it seem to explain exactly what is the syntax to get DaqFactory to start acquiring data from the Labjack, can somebody explain in simple terms just how to get started.

Thanks Dave

Link to comment
Share on other sites

There is a Quick Start guide available on the LabJack website at:

http://www.labjack.com/files/DAQFactory%20...%20Tutorial.pdf

You should use the Device Configuration wizard to configure your LabJack.

This code that you wrote:

openLabJack (LJ_dtUE9,LJ_ctEthernet,"192.168.0.209",2,&lngHandle);

is in C, not DAQFactory script. There is no method for opening the labjack in DF script (unless you manually load the LabJackUD.dll file using the extern command, but this is rather advanced).

Link to comment
Share on other sites

  • 1 year later...

This code that you wrote:

openLabJack (LJ_dtUE9,LJ_ctEthernet,"192.168.0.209",2,&lngHandle);

is in C, not DAQFactory script. There is no method for opening the labjack in DF script (unless you manually load the LabJackUD.dll file using the extern command, but this is rather advanced).

It seems that this last statement is no longer true, but I am confused by the syntax. What should be entered for the "@D#" parameter? And the address for a USB device?

Link to comment
Share on other sites

DAQFactory uses @ instead of & to reference a variable. D# is essentially the same thing as the handle. You pass a reference to a variable to that function and if it succeeds (returns LJE_NOERROR), then that variable will hold a number. That number should be used wherever D# is required for all the other LJ functions (typically the first parameter).

We will be posting an update of DAQFactory Express (5.75) along with a 80 page or so getting started with DAQFactory and LabJack guide this weekend. This guide goes over all of this stuff in reasonable detail and I think will help you a lot. Visit www.daqexpress.com and check for the update on Monday. The getting started guide will be in the download. If you update you MUST also update the LabJack Universal Driver to the latest 2.77 release which LabJack should release this week.

Link to comment
Share on other sites

  • 3 weeks later...
  • 5 years later...

I have been using a LabJack UE9 for several years on a lot of projects. One thing that I haven't figured out is a set of startup code to initialize either the USB connection or the Eithernet connection. I usually end up screwing with the code to make a proceedure that works with usb so that it works on the eithernet. I have tried a Try catch() with OpenLabJack(..) in it to select either usb or eithernet. However there seems to be no error if I open the usb and the ethernet connection is connected. I have pasted by test code below. This kind of works.  Thanks for any info you can give.

Bob

 

 

?"Begining Start" + FormatDateTime(" @ %Y %m %d %H:%M:%S",SysTime())
 
try  //used because one of my computers has the drivers in a different file. This block works fine
   using("device.labjack.")
   include("C:\Program Files\LabJack\Drivers\labjackUD.h")
   ?"labjackUD.h from Program Files"
catch()
   using("device.labjack.")
   include("C:\Program Files (x86)\LabJack\Drivers\labjackUD.h")
   ?"labjackUD.h from Program Files (X86)"
endcatch
 
global address =0
global string strAddress
global LJDevNum =-1      // set to a invalid value
global string IOtype = "_"
?IOType
?"LJDevNum = " + LJDevNum
 
Try
   address = 0
   OpenLabJack(LJ_dtUE9,LJ_ctUSB,"1",0,@LJDevNum)
   IOType = "USB "+ LJDevNum
   ?"LJDevNum in Try USB = " + doubletostr(LJDevNum)
catch()
   ?"Error in USB"
endcatch
 
 
try
   eget(LJDevNum,LJ_ioGET_CONFIG,LJ_CHIP_ADDRESS,@address)
   ?address
   DoubleToStringAddress(address,@strAddress,"HexDot")
   ?strAddress
catch()
   ?"Error in eget USB"
 endcatch
 ?""
 delay(2.5)
 
 try
      address = 0
      OpenLabJack(LJ_dtUE9, LJ_ctETHERNET,"192.168.1.209", 0,@LJDevNum)
      IOType = "10BasedT " +"192.168.1.209"
      ?"LJDevNum in Try Ethernet = " + doubletostr(LJDevNum)
  catch()
      ?"Error on Eithernet"
   endcatch
      
try
   eget(LJDevNum,LJ_ioGET_CONFIG,LJ_CHIP_ADDRESS,@address)
   ?address
   DoubleToStringAddress(address,@strAddress,"HexDot")
   ?strAddress
catch()
   ?"Error in eget Ethernet" endcatch
endcatch
 
?"Labjack dev number = " + LJDevNum 
?""
Link to comment
Share on other sites

You'll have to ask the LabJack folks about this one.  I believe that if you do OpenLabJack under Ethernet and the address isn't found, you'll get a 0 (or maybe -1?) for the LJDevNum.  I'm guessing there is a similar response for trying to open a USB connection for a device that isn't there.  Most of the LabJack UD functionality is simply mapped to the low level LabJack UD driver so will work the same in DAQFactory.  

Link to comment
Share on other sites

Thanks! That will be my next step. Several years ago I wrote a visual basic program that figured out which I/O was active and then started streaming into a file using the LJ drivers. Unfortunately that version of Visual basic  is no longer current in my system and I didn't save a text file of the program only the Visual basic program which is tokenised ( I think) and not readable as such.

 

I have also figured out by reading the LJ UE9 manual and some of the posts on this site that it is not possible to "Close" labjack drivers like we do with file access. Thus we must exit DAQF to release the LJDevNum value.

 

 Actually I managed to get a script working in DAQF that will come up from a dead start with only one I/O active and connect. This program drives a SPI I/O to a Maxim 11213 Sigma Delta a/d and reads temperature with a resolution of 0.008 °C at 1 reading /second from an RTD(1KOHM@0°c) with a 100uamp kelvin connection. It is reading out 16 bits of a 24 bit sigma-delta conversion with the first noise bit  at bit 18. This was a design that I worked on as a contract engineer. I used a LabJack U3 and my own UE9 for testing the design. Most of the testing was done using Python script.

Link to comment
Share on other sites

Archived

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