LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to start data collection through digital trigger OR user input

Solved!
Go to solution

Hello,

 

I have a vi with which I would like to collect data. It is set to start collecting when the start-trigger is sensed, which works perfectly, but I would also like to have the user be able to start the data collection process by pressing a button instead of applying the trigger. I'm at a loss on how to do this. I thought the event structure would work well; however the trigger has no boolean value with which I can associate it. If it did, I could then perform a logical comparison between the trigger and button to determine whether data collection ought to start.

 

So, how can I represent an activated trigger as a boolean? Or is there a better way to accomplish my goal?

 

I think I can make things clearer by expressing in linear programming what it is I'm trying to acheive:

 

if (trigger == true || button == true){

start data collection

}

 

I've attached my vi in case anyone feels it would be useful.

0 Kudos
Message 1 of 12
(3,267 Views)

Hello, curious

 

If this was my application, I would just start continuous scan, and then do a "software" trigger, rather than a hardware.  It would look something like this (in "plain text" code)

 

start acquisiton, but don't save all of it (either in memory or disk)

while (input < trigger and button isn't pressed)

    {acquire data and dump it in to a circular buffer, the size of which is your "prescan"}

dump your circular buffer in to file (memory) and start acquiring new data until stop condition

 

I hope this helps.

-M

0 Kudos
Message 2 of 12
(3,254 Views)

Hello, M

 

Thanks for your reply.

 

My system relies on the hardware digital trigger -- out of my control, I'm afraid. Is it possible to somehow synchronize a software trigger to my hardware trigger so that when the former is triggered, the latter is too -- then apply your method? I'm not sure if I'm making much sense here, but I still feel as if somehow generating a boolean from my hardware trigger may be an easier solution, at least from my beginner's perspective.

0 Kudos
Message 3 of 12
(3,235 Views)

Have you searched the LabVIEW Help file for "User event"? There's nothing that says that two different events can't result in the same action.

 

What do you mean by your "hardware trigger is activated"? There must be some kind of signal generated somewhere when that happens.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 4 of 12
(3,226 Views)

I am aware that different events can result in the same action; however I'm trying to find a way to represent the trigger as a boolean so that I can compare its occurence to the button's occurence.

 

What I mean when I say my "hardware trigger is activated" is the trigger is triggered. I understand there is a signal generated when my trigger is triggered, but I do not know how to represent this occurence as a boolean. I know that it is triggered because the signal appears on my chart, but I'm looking for a way to programmatically determine whether or not my trigger was triggered.

0 Kudos
Message 5 of 12
(3,199 Views)

Hey curious,

 

What DAQ hardware are you using? 

0 Kudos
Message 6 of 12
(3,178 Views)

Hi, hnesmith

 

I'm using the USB 6229 OEM.

0 Kudos
Message 7 of 12
(3,157 Views)

Hey,

 

I noticed that no one has commented on this post for the past 10 days. What is the status of your work? Do you still need assistance? Let me know.

 

Rob W

Applications Engineering

National Instruments

Rob W.
0 Kudos
Message 8 of 12
(3,095 Views)

Hi, Rob

 

I still haven't figured out a solution.

 

I have modified my approach by eliminating the option to start data collection via front panel button, and instead start collecting data when the program opens. The same issue remains, though: how can I collect data without writing to a file (so the user can use this time to zero out measurements) then, when a trigger is applied (by user), send the data to a file?

 

At this point I realized that a trigger may not be necessary, and that I could just read the state of the pin (PFI15) that the trigger is now physically connected to and link the result to a case structure. I discovered the niSync vi's and utilized the PFI Line State trigger property node thinking I could link it to the case structure, but I cannot assign any of the PFI lines as references for the property node. And even if I could, I am not entirely convinced this solution would work as documentation from NI indicates NI-Sync is compatible with devices I am not using (see: http://www.ni.com/download/ni-sync-3.4.1/4476/en/).

 

Attached is a simple vi demonstrating my attempts.

0 Kudos
Message 9 of 12
(3,045 Views)
Solution
Accepted by topic author curious_and_learning

Hi,

 

You are correct, USB 6229 is definitely not compatible with NI-Sync. However, you should be able to do this with the DAQmx driver functions.

 

If I understand correctly, you would like to generate a graph from your Analog Input, and have this write to file based on a triggered event. Using a PFI line won't work for this particular function, however you can create a Digital Input Task instead and route the wire to a D I/O line instead of a PFI line. You can then use that to write/not-write the Analog Input to file using a case structure depending on the state of the Digital Line. 

 

Hope this helps! Let me know if you have any other questions.

National Instruments
0 Kudos
Message 10 of 12
(3,014 Views)