4.3 Example Pseudocode
hecking
The initial step is to open the LabJac t the driver uses for further
interaction. The DeviceType for the
LJ_dtU3
There is only one valid ConnectionTy
LJ_ctUSB
ollowing is example pseudocode to open a U3 over USB:
LabJack U3 over USB.
andle);
on e the address parameter is a
string in th
The ampersan
of that varia le
function, th ion
expects a poin
In general, a fu
parameter g
cannot be mod
that can be h
passing th
4.3.2 Con g
One of the mo
analog. The fo
A L
ANALOG_ENABLE_BIT
LJ_ioPUT_A L
LJ_ioGET_ANAL
When a req e cify
e starting bit number, and the x1 parameter is used to spe
ollowing are some pseudocode examples:
/Configure FIO3 as an analog input.
ePut (lngHandle, LJ_ioPUT_ANALOG_ENABLE_BIT, 3, 1, 0);
//Configure FIO3 as digital I/O.
ePut (lngHandle, LJ_ioPUT_ANALOG_ENABLE_BIT, 3, 0, 0);
//Configure FIO0-FIO2 and EIO0-EIO7 as analog, all others as digital. That
//means a starting channel of 0, a value of b1111111100000111 (=d65287), and
The following pseudocode examples are simplified for clarity, and in particular no error c
shown. The language used for the pseudocode is C.
is
4.3.1 Open
k and get a handle tha
U3 is:
pe for the U3:
F
//Open the first found
ck (
OpenLabJa LJ_dtU3, LJ_ctUSB, "1", TRUE, &lngH
The reas for the quotes around the address (“1”), is becaus
e OpenLabJack function.
d (&) in front of lngHandle is a C notation that means we are passing the address
, rather than the value of that variable. In the definitio
b n of the OpenLabJack
e handle parameter is defined with an asterisk (*) in front, meaning that the funct
ter, i.e. an address.
nction parameter is passed as a p
ointer (address) rather than a value, when the
mi ht need to output something. The parameter value passed to a function in C
ified in the function, but the parameter can be an address that points to a value
anged. Pointers are also used when passing arrays, as rather
c than actually
e array, an address to the first element in the array is passed.
fi uration
st important operations on the U3 is configuring the flexible I/O as digital or
llowing 4 IOTypes are used for that:
LJ_ioPUT_
LJ_ioGET_
NA OG_ENABLE_BIT
NA OG_ENABLE_PORT //x1 is number of bits.
OG_ENABLE_PORT //x1 is number of bits.
u st is done with one of the port IOTypes, the Channel parameter is used to spe
cify the number of applicable bits.
th
F
/
62