Prev: how to get rid of array index
Next: table modification
From: Behnam Molavi on 3 Aug 2010 20:10 Hi everyone, I'm using Matlab R2008a with data acquisition toolbox (version 2.12) to read data from an NI USB 6009 DAQ system. Matlab is running in bootcamp on a MacMini. I have a problem with my code which essentially reads values from DAQ in a loop and performs some processing on it. Even though data acquisition works fine most of the time, it sometimes stops halfway through acquisition for apparently no reason and I get a timeout error running getdata. When this error occurs, get(ai) shows that the ai object is still running, but the number of samples acquired is less than what it should be and no more data comes in until I restart the object. This is what my code boils down to: x=daqfind; if ~isempty(x) stop(daqfind); delete(daqfind); end Board=daqhwinfo('nidaq'); BoardID=Board.InstalledBoardIds; ai=analoginput('nidaq',char(BoardID)); addchannel(ai,1); set(ai,'InputType','singleEnded') set(ai,'SampleRate',4000) set(ai,'SamplesPerTrigger',Inf); set(ai,'TimeOut',10); for l=1:60 start(ai); for k=1:100 [d,t]=getdata(ai,4000); end stop(ai); end delete(ai); clear ai; When the error happens, get(ai) output is as follows: BufferingConfig = [256 30] BufferingMode = Auto Channel = [1x1 aichannel] ChannelSkew = 2.08333e-005 ChannelSkewMode = Minimum ClockSource = Internal DataMissedFcn = @daqcallback EventLog = [1x2 struct] InitialTriggerTime = [2010 8 3 12 39 10.118] InputOverRangeFcn = [] InputType = SingleEnded LogFileName = logfile.daq Logging = On LoggingMode = Memory LogToDiskMode = Overwrite ManualTriggerHwOn = Start Name = nidaqmxDev1-AI Running = On RuntimeErrorFcn = @daqcallback SampleRate = 4000 SamplesAcquired = 356352 SamplesAcquiredFcn = [] SamplesAcquiredFcnCount = 1024 SamplesAvailable = 352 SamplesPerTrigger = Inf StartFcn = [] StopFcn = [] Tag = Timeout = 10 TimerFcn = [] TimerPeriod = 0.1 TriggerChannel = [1x0 aichannel] TriggerCondition = None TriggerConditionValue = 0 TriggerDelay = 0 TriggerDelayUnits = Seconds TriggerFcn = [] TriggerRepeat = 0 TriggersExecuted = 1 TriggerType = Immediate Type = Analog Input UserData = [] NIDAQMX specific properties: ExternalSampleClockSource = PFI2 ExternalScanClockSource = PFI7 HwDigitalTriggerSource = PFI0 Could this be because of using Windows on a mac? Thank you for your help, Behnam Molavi
|
Pages: 1 Prev: how to get rid of array index Next: table modification |