Hi Labjack and forum users
I'm using a U3-HV and I would like to use WAIT commands between series of instructions to the LJTick_DAC in order to precisely time changes in analogue outputs. However, if I try to use the LJ_ioPUT_WAIT command on the port that my LJTick-DAC is using (namely, FIO4), it does not work - it simply skips to the last value that I instructed. Is there any different way i should be using the WAIT function? Here is some example code:
values = [1 2]
port = 4
%Set DACA to first value
Error = ljud_AddRequest(ljHandle, LJ_ioTDAC_COMMUNICATION, LJ_chTDAC_UPDATE_DACA, values(1), 0, 0);
Error_Message(Error)
%Wait for 1 second
Error = ljud_AddRequest(ljHandle,LJ_ioPUT_WAIT,port,1000000,0,0);
Error_Message(Error)
%Set DACA to second value
Error = ljud_AddRequest(ljHandle, LJ_ioTDAC_COMMUNICATION, LJ_chTDAC_UPDATE_DACA, values(2), 0, 0);
Error_Message(Error)
% execute
Error = ljud_GoOne(ljHandle);
Error_Message(Error)
Many thanks
Chris
Note that the WAIT does not act on a channel. Channel is ignored. Rather the WAIT simply tells the U3 to do nothing for that amount of time:
https://labjack.com/support/datasheets/u3/high-level-driver/example-pseu...
The WAIT iotype is useful when you combine a bunch of actions in a single low-level feedback packet:
https://labjack.com/support/datasheets/u3/low-level-function-reference/f...
AddRequest(ljHandle, LJ_ioPUT_DIGITAL_BIT, 3, 1, 0, 0);
AddRequest(ljHandle, LJ_ioPUT_WAIT, 0, 1024, 0, 0);
AddRequest(ljHandle, LJ_ioPUT_DIGITAL_BIT, 3, 0, 0, 0);
GoOne(ljHandle);
... you would get a 1024 us pulse on FIO3. Looking at Section 5.2.5, though, you can see that setting the LJTDAC is not an iotype supported by the low-level feedback function. Rather I2C communication is used to control the LJTDAC and that is a separate function:
https://labjack.com/support/datasheets/u3/low-level-function-reference/i2c
So if the UD driver is capable it would break your request list into 3 packets: send a packet to set the LJTDAC, send a packet to wait 1 s, and then send a packet to set the LJTDAC. The fact that you are not seeing that happen tells me the UD driver does not support that. I will mark this for a UD expert here to comment on that.
Regardless, to make it work you could just do 3 separate AddRequest-GoOne, or 3 eGet/ePut calls. And really there is little point to use the U3 wait function when you have multiple low-level packets, but instead might as well just use a software delay.
Note that the T-series devices have a better way of controlling LJTDACs, and that can be done with the wait function available on them.
The way the UD driver groups commands, LJ_ioPUT_WAIT will not work in your request list in the order you specified. TDAC commands will run first, then the Feedback commands which LJ_ioPUT_WAIT is. So basically your requests are sent in this order in 3 command packets:
//TDAC requests
ljud_AddRequest(ljHandle, LJ_ioTDAC_COMMUNICATION, LJ_chTDAC_UPDATE_DACA, values(1), 0, 0);
ljud_AddRequest(ljHandle, LJ_ioTDAC_COMMUNICATION, LJ_chTDAC_UPDATE_DACA, values(2), 0, 0);
//Feedback requests
ljud_AddRequest(ljHandle,LJ_ioPUT_WAIT,port,1000000,0,0);
As pointed out in our previous post, to do what you want will require 3 command packets. To have your request order your need 3 AddRequest-GoOne, or 3 eGet/ePut calls.