01-10-2011 11:59 AM
Hello,
I have a problem using DAQmx functions (PCI-6250). I have two signals (analog channels), where ai0 are changing pulses (signal to analyse) and ai1 is keyphasor - pulse/revolution. I need to trigger the value of keyphasor and acquire exactly 2 revolutions from rising edge to rising edge.
I'm not sure which functions can I use (implementation is in Matlab using nicaiu.dll). I'm trying following, but triggering doesn't work for me. Please, can you help me?
Thanks
Jindrich
... loadlibrary('nicaiu.dll'...
DAQmx_Val_Volts= 10348; % measure volts
DAQmx_Val_Rising = 10280; % Rising
DAQmx_Val_FiniteSamps = 10178; % Finite Samples
taskh1=uint32([]);
[a,b,taskh1] = calllib('nicaiu','DAQmxCreateTask','master',taskh1);
taskchans1=['Dev1/ai0:ai1'];
[a,b,c,d] = calllib('nicaiu','DAQmxCreateAIVoltageChan',taskh1,taskchans1,'',-1,-10,10,DAQmx_Val_Volts,'');
nsample = 100000;
[a,b]=calllib('nicaiu','DAQmxCfgSampClkTiming',taskh1,'',10000,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,nsample);
[a,b]=calllib('nicaiu','DAQmxCfgAnlgEdgeStartTrig',taskh1,'/Dev1/ai1',DAQmx_Val_Rising,3.0);
[a]=calllib('nicaiu','DAQmxStartTask',taskh1);
DAQmx_Val_GroupByScanNumber = 1;
readarray1=ones(numofchans,nsample);
readarray1_ptr=libpointer('doublePtr',readarray1);
sampread=0;
sampread_ptr=libpointer('int32Ptr',sampread);
empty=[];
empty_ptr=libpointer('uint32Ptr',empty);
arraylength= nsample*numofchans; % more like "buffersize",
[a,readarray1,sampread,empty]=calllib('nicaiu','DAQmxReadAnalogF64',taskh1,-1,-1,DAQmx_Val_GroupByScanNumber,readarray1_ptr,arraylength,sampread_ptr,empty_ptr);
[a] = calllib('nicaiu','DAQmxStopTask',taskh1);
[a] = calllib('nicaiu','DAQmxClearTask',taskh1);
data = get(readarray1_ptr,'Value')';
01-11-2011 04:45 AM
Ahoj Jindra,
Now i'm not sure what exactly you try to accomplish - if you really need to start acquisition on rising edge of your signal, and acquire data until next pulse, then even though M series boards doesn't support Start and Stop trigger directly, I think there is possibility.
You need to implement Finite Sample Acquisition with Start and Reference trigger. As far as i remember, it has to be Finite, because Reference trigger is not supported for continuous measurement. However, when you use reference trigger, you create circular buffer. If you set Read Relative to Current Read Possition, then you can actually keep reading the data out from buffer as board is actually sampling. When reference trigger comes, you read just certain amount of posttriggered samples and you finish task.
Though I can't give you code straight for Matlab, there is couple of document which could be very helpful for you:
Can a Pretriggered Acquisition be Continuous?
Tips and Techniques in Data Acquisition Triggering - NI-DAQmx
Cou can find even some examples for C - they should be pretty much what you need, as you need to call the same functions in Matlab:
I hope it might help you.
Regards,
Martin Stefik