Setting Multiple Ports high with one line of Addrequest | LabJack
 

Setting Multiple Ports high with one line of Addrequest

2 posts / 0 new
Last post
Lalit
29.lalit's picture
Setting Multiple Ports high with one line of Addrequest

Hi,

I would like to turn on multiple ports on Labjack U3 with just one request for certain duration and then turn them off after a certain delay.

I am able to turn them high but not turn them back low. The following is my code:

ljasm = NET.addAssembly('LJUDDotNet'); %Make the UD .NET assembly visible in MATLAB
ljudObj = LabJack.LabJackUD.LJUD;


[ljerror, ljhandle] = ljudObj.OpenLabJack(LabJack.LabJackUD.DEVICE.U3, LabJack.LabJackUD.CONNECTION.USB, '0', true, 0);
ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_DIGITAL_PORT,14,34, 6, 1);
ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_WAIT, 0, 2000000, 0, 0);
ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_DIGITAL_PORT,14,34,6,0);
ljudObj.GoOne(ljhandle);

ljudObj.Close();

The port I want to turn high are 15 and 19.

Can you explain where I am going wrong exactly or if there is another way to do it. Any help is appreciated.

Thanks

Lalit

LabJack Support
labjack support's picture
The following sets digital

The following sets digital channels 14 to 19 to low:

ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_DIGITAL_PORT,14,0,6,0);

So starting at digital channel 14 and for 6 channels (14 to 19), set them to b000000 (all low). Refer to here on digital I/O usage in the UD library:

https://labjack.com/support/datasheets/u3/high-level-driver/example-pseu...