From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

AI start and stop trigger

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')';

 

0 Kudos
Message 1 of 2
(2,775 Views)

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:

NI-DAQmx: Continuous Analog Input with Both Start and Reference (Stop) Triggers - LabVIEW - CVI - AN...

 

 

I hope it might help you.

 

Regards,

Martin Stefik

Certified-LabVIEW-Developer_rgb.jpg

0 Kudos
Message 2 of 2
(2,752 Views)