LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

triggered output

Solved!
Go to solution

I want to detect peak from the analog input, and once there is a peak, output a pulse immediately. but it seems that the while loop obtains a certain number of sample one time, how can it output pulse immediately?

0 Kudos
Message 1 of 6
(2,000 Views)

Hi frogliang,

 

it seems that the while loop obtains a certain number of sample one time

Which while loop are you talking about?

Mind to share your VI?

 

how can it output pulse immediately?

How are you detecting "pulses"? How do you define a "pulse"?

Some DAQ devices allow to trigger DAQmx tasks based on AI signals: which DAQ hardware do you use?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,991 Views)

hi GerdW,

thank you!

I use the structure as the peak detector sample shows. I need to do some calculations base on the peak value and then trigger a voltage output pulse that is 1ms duration and 1.5V.

best regards

Liang

0 Kudos
Message 3 of 6
(1,984 Views)

and forgot to mention that the device I use is myDAQ. thank you!

0 Kudos
Message 4 of 6
(1,980 Views)
Solution
Accepted by topic author frogliang

Hi Liang,

 

you set that DAQmxRead to read 100 samples - and it will wait for those 100 samples.

When you want to react fast then you need to use a smaller amount of samples per DAQmxRead call…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(1,974 Views)
Solution
Accepted by topic author frogliang

Hi Liang,

 

As was already described by GerdW, the loop can only iterate (go to next loop iteration) once the elements inside have finished running - i.e. in your case, every 100/sample rate seconds.

 

If you read 1 Sample per iteration, it will be faster, but you may hit buffering issues if the loop cannot run fast enough to keep up with the acquisition (sample rate). If you don't connect a number of samples, it will read all available samples and return more or less immediately (but preventing buffer problems).

 

Note that you can also use Greater Than (with Element comparison mode) and Or Array Elements to detect if anything was higher than a threshold value. This won't tell you when the event occurred, but since it's already in the past, you probably don't care - you just want to find out as fast as possible. In the case of a single sample per iteration, you won't need the Or Array Elements either.

 

You'd have to test, but I'd guess that you might have a faster acquisition loop (once you have it set up) if you keep the DAQmx Write node in a separate loop and use something like a notifier to trigger the output. This might (but test - I don't know) make your input more responsive (because it won't be constantly writing the same low value to the output). It might also make your block diagram tidier, which in some cases is even worth a tiny bit of inefficiency if it is not faster. Your choice (but test!)


GCentral
0 Kudos
Message 6 of 6
(1,944 Views)