% =================================================================== %> @brief Turn LED ON %> %> % =================================================================== function ledON(obj) if obj.silentMode == 0 && obj.vHandle == 1 obj.rawWrite(obj.ledIsON); in = obj.rawRead(obj.inp,10); end end
Do I need to read the response using the Exodriver
Posted 11 February 2011 - 07:52 AM
Posted 11 February 2011 - 10:57 AM
Posted 01 August 2012 - 02:43 AM
You do need to read the responses. Communications are done through a command/response structure, unless you are using stream mode. I believe on the UE9, U3, and U6 if you perform two consecutive writes without reading the responses the device will reset itself.
I have a new function which I want to send asynchronously, in this case a digital TTL high of variable length.
line = 1; %FIO1 time1 = 100; % 16e-3 * 100 = 1.6s time2 = 100; % 64e-3 * 100 = 0.0064s cmd=zeros(16,1); cmd(2) = 248; %command byte for feedback command (f8 in hex) cmd(3) = (length(cmd)-6)/2; cmd(8) = 11; %BitStateWrite: IOType=11 cmd(9) = line+128; %add 128 as bit 7 sets value high cmd(10) = 6; %IOType for waitshort is 5, waitlong is 6 cmd(11) = time1; %time to wait in unit multiples cmd(12) = 5; %IOType for waitshort is 5, waitlong is 6 cmd(13) = time2; %time to wait in unit multiples cmd(14) = 11; %BitStateWrite: IOType=11 cmd(15) = line; %bit to set low obj.command = obj.checksum(cmd,'extended'); obj.outp = obj.rawWrite(obj.command); obj.inp = obj.rawRead(zeros(1,10),10);
If I have to read the response (obj.rawRead calls LJUSB_Read directly) then Matlab blocks for the length of the TTL (1.6064 second TTL and Matlab hangs for that time). If I comment out the obj.rawRead then Matlab returns directly. If I keep doing this without reading I don't notice a reset (tested on a U6, is the reset very fast?), but perhaps over time things get worse?
What would happen if I use the new LJUSB_WriteTO commands with a small timeout, does a timed out read handle differently? I suspect it won't because what is blocking is the previous obj.rawWrite command and until the WaitShort and WaitLong feedback commands complete the LabJack will not respond to the obj.rawRead...
Is there a way to not let the LabJack reset itself (not that I notice it) and handle unread responses gracefully?
Posted 01 August 2012 - 02:22 PM
Posted 02 August 2012 - 03:59 AM
The reset is fast, and is a soft reset (no re-enumeration). It will mainly clear buffers on the U6, and you will probably not notice it.
So for asynchronous mode I will basically not read and let the reset occur -- have you timed how long the reset takes, and does it occur on the next write i.e.
or after some defined timeout with no read
write 1 ...deltatT... (reset)
Posted 06 August 2012 - 11:52 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users