Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Crashing Matlab with streaming on U3

  • Please log in to reply
1 reply to this topic

#1 odo53

  • Members
  • 2 posts

Posted 03 December 2013 - 10:25 AM

I have tried to modify the sample file U3_simplestream.m for my application.  I want to turn on DAC0 with a 5V output to power a sensor (takes just a few mAmps).  After executing the command "ljudObj.OpenLabJack(..." I execute the following:


ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_DAC, 0, 5, 0, 0);


It works, my sensor powers on and I can see the data is being collected when the loop executes:  disp(['First scan = ' num2str(adblData(1)) ', ' num2str(adblData(2))])


At the end of my scan I want to turn off the DAC0 output.  I use:


      ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_DAC, 0, 0, 0, 0);


I have tried this before executing the STOP_STREAM command, after the STOP_STREAM command but still in the TRY block, and after the TRY block.  In all instances Matlab crashes and I have to reboot the computer to get it to run again.


Am I doing something wrong with the command to set DAC0 to 0 volt output?


Unrelated follow up question:  my data is collected in a .Net Structure.Double[].  I know knothing about .Net.  Is there some way to cast that into a Matlab variable?  I am resorting to brute force by looping through each data point and putting it into a Matlab array that I can work with.

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 03 December 2013 - 03:48 PM

I tried the PUT_DAC calls before and after streaming with no crashing but seeing as you are basing your code on the example, remove the "ljudObj.Close()" call and see if that helps. Current versions of the UD driver have issues with the Close call after streaming has started and in most cases the call is unnecessary. If that doesn't help, tell us what version of MATLAB you are running and whether it is the 32 or 64-bit version.


As for converting the .NET array to a MATLAB one, these two ways will work:


matlabArray = dotnetArray.double


matlabArray = double(dotnetArray)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users