Serial Sequence Data


Recommended Posts


I'm looking to send a serial data on one or more IO to simulate microcontrollers outputs.

I have take a look on the DAQFactory help, but I dont understand how to do.

Someone can show me a little sequence like this:

Output1: 0 0 5 0 5 5 0

Output2: 5 0 5 0 5 0 5

The two signals must to be syncro


Philippe Rapin

Link to comment
Share on other sites

Are you talking about setting LabJack outputs like this, or stuff out the serial port? I'm going to guess labjack outputs. My next question then is which LabJack, as its done differently with the U12 from the UE9/U3. I'll assume the UE9/U3. In this case you use the AddRequest / GoOne format similar to what is in the LabJack documentation. I'm going to assume you are using two DACs since you have 5 in your list. I'm also going to assume you are using DAQFactory 5.70+ and that you have the include() to pull in the labjackud.h file and a using("device.labjack") as well. I'm assuming LabJack ID of 1, and DACs properly enabled. It'd be something like this (no error handling shown):

private array1 = {0,0,5,0,5,5,0}
private array2 = {5,0,5,0,5,0,5}
private count = 0
while (count < numrows(array1))
	AddRequest(1, LJ_ioPUT_DAC, 0, array1[count])
	AddRequest(1, LJ_ioPUT_DAC, 1, array2[count])
	delay(0.1)   // wait 0.1 seconds and move on

It wouldn't be that much different if you were using digital's. You'd just replace all the 5's with 1's and the LJ_ioPUT_DAC with LJ_ioPUT_DIGITAL_BIT.

Now to explain the rest of my assumptions:

I'm also going to assume you are using DAQFactory 5.70+:

DAQFactory 5.70 has an updated LabJack driver for the U3/UE9's and some other features that allow you to write code like I did above that looks almost identical to the psuedo-code in the LabJack manual, as well as C code in the LabJack examples. You can download an update for Express by going to

...that you have the include() to pull in the labjackud.h file and a using("device.labjack") as well.

Part of the 5.70 improvements is the include and using functions. Include() takes a path to a C header file (.h) such as the LabJackUD.h file and makes read-only variables out of all the constants found inside. For example, this makes the variable LJ_ioPUT_DAC equal 20. You only have to do this once, so you'd usually put it in an Auto-Start sequence like this:

include("c:\program files\labjack\drivers\labjackud.h")

using() is used to take member functions and bring them into the global namespace. Normally, to access LabJack specific functions, you'd have to do Device.LabJack.AddRequest(..). This is because DAQFactory supports a wide variety of devices and functions and this is required to keep them from colliding. However, if you are only using the LabJack, you can usually bring those functions into the global namespace, meaning you wouldn't have to type Device.LabJack. in front of every function call. Again, this function should go in an Auto-Start sequence as it only needs to be called once and would look like this:


I'm assuming LabJack ID of 1, and DACs properly enabled.

The AddRequest / GoOne functions need to know which LabJack you are working with and I just assumed you are using ID #1. If you went into Device Configuration, for example to setup an Ethernet connection, then this is actually the Device # you specified there and not the ID. With 5.7+, if you don't go into Device Configuration, DAQFactory assumes that unknown Device #'s in these function calls, and in channels, are actually LabJack ID's to devices connected over USB. For Ethernet you have to go through Device Configuration to assign the IP address to a particular Device #.

As for the DAC enabling, different LabJack's have different default capabilities, and depending on which device you have, the DAC's may be disabled by default. Use LJ_ioPUT_DAC_ENABLE to enable the DAC. You can do it in a single line in an auto-start sequence using ePut:

ePut(1, LJ_ioPUT_DAC_ENABLE,0,1)
ePut(1, LJ_ioPUT_DAC_ENABLE,1,1)

Those lines will enable DAC's 0 and 1.

... (no error handling shown):

You may want to implement error handling. To do this, you'd have to add GetResult() calls after the GoOne to get the result (success / error code) for each of the two commands. Then you could do something on it. It'd be something like (assuming you declared err and junk above as a privates):

	err = GetResult(1, LJ_ioPUT_DAC, 0, @junk)
	if (err != LJE_NOERROR)
		// error occured!
	err = GetResult(1, LJ_ioPUT_DAC, 1, @junk)
	if (err != LJE_NOERROR)
		// error occured!

Link to comment
Share on other sites

I wrote a nice reply and then my laptop bluescreened. Never install memory to the full capacity of the laptop and then expect a secondary video card in a docking station to not conflict :) Now what to do with an extra memory chip....

Anyhow, before I delve into it, at what speed do you want it to go through these values? The U12 is somewhat limited on speed, especially if you are doing anything else with it. You may be better off upgrading to a U3. They are not expensive and are much faster (among other things).

You can upgrade DAQFactory Express to 5.7+ by going to

Link to comment
Share on other sites


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