LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

error 200284-DAQmx Analog trigger

Hi,

 

I am trying to start data acquisition (e.g. input channels ai6 to ai10) and save it to a file based on an analog input voltage signal change (acquire whenever ai6 >2 Volts) that will work as a trigger.

 

I also found an example that is pretty similar to this (attached). The trigger source in my case is the first analog input channel. Following the attached example, I am always getting the error code 200284 after running the vi. Basically it gives the error after the specified timeout.

I am using PCI-6289, but the problem is I cannot use any PFI lines for the voltage trigger and have to use ai channels only for trigger.

 

Can't figure out what is wrong. 

 

Any help is highly appreciated. 

 

Thanks,

Roy

Download All
0 Kudos
Message 1 of 4
(2,668 Views)

Well, your problem is due to the fact that you only have one AI clock, so all of your AI channels need to be contained in a single task.  This precludes your using an AI channel as a trigger source for an AI operation.  Can't be done.  That's why it's telling you that your trigger configuration is invalid.  It IS invalid.

 

So, you need a different approach.  If what you want to do is write data to a file when ai6 > 2V, you don't need a trigger...you need a case structure.

 

(You also need a different architecture, by the way...you don't want your file write in the same loop as your acquisition because the time it takes to write data to a file can goof up your acquisition timing.  Look into a producer-consumer architecture, much better for what you want to do.)

 

Take a look:

 

Write if greater than 2V.png

Does that give you any ideas?  🙂

0 Kudos
Message 2 of 4
(2,645 Views)

Hi DianeS,

 

Thanks for your response. Well, this logic definitely makes sense, however, does it also mean that when I use an analog voltage as my trigger for data acquisition through ai channels (and saving it in a file) I always have to use an APFI or PFI channels (as per the examples) as they have different clock source?

 

One more thing if you could please clarify, if I want to write data file only for a finite amount of time (say for 3s) as soon as the ai6>2V for the first time, do I just change the sampling mode to "Finite Samples" and change the number of samples to 3000 and that would work (attached block diagram)? 

 

Please point out any dumb mistake, I am new to labview API, have worked with DAQ assistants only!  

 

Thanks again..

Roy

 

0 Kudos
Message 3 of 4
(2,631 Views)

Yes, you must use a digital channel as your trigger source because it has a different clock.  Remember, something has to activate your trigger!  For instance, let's say you want to use PFI0 as your trigger...when PFI0 goes high, start collecting data.

 

How do you plan to control when PFI0 goes high?

 

It can be an external trigger.  It can be another, digital, DAQmx task, where the DO line is hard-wired to PFI0.  But something has to cause PFI0 to go high, in order to trigger your task.

 

Since you can only have a single AI task, since there's only one AI clock, you have no way of ever generating a trigger.  You won't start acquiring until you receive a specific signal on an AI channel, but you won't receive that signal until you start acquiring.  See why it's a no-go?

 

So you want to acquire for 3 seconds after getting a signal on ai6 that's >2V.  So let's think this through, ok?

 

If we set our task to finite samples, and we set our number of samples to 3000, what will happen?

 

We'll acquire 3000 samples.  Right?  Right!  If our acquisition rate is set to 1kHz, it will take 3 seconds to acquire those samples.

 

While we are acquiring those 3000 samples, we may (or may not!) see ai6 go over 2V.  Let's say we see ai6 read >2V after 2 seconds -- that is, our second loop iteration.  Since we've set our # of samples to acquire at 3000, we've already acquired 2000 samples (assuming a 1kHz sample rate).  That leaves us 1000 samples until our task expects to terminate (after which, you'll get an error).  That's not 3 seconds worth of data, is it?

 

What if ai6 never goes >2V within our 3000 sample window?  Now you haven't collected anything, and your task will throw an error if you try to collect beyond 3000 samples.

 

So no, setting our samples to finite and specifying the collection of 3000 samples isn't going to work, is it?  Clearly not.  That's 3 seconds' worth of data, all right, but it may not be the right 3 seconds' worth of data.  Since you don't know when ai6 will be >2V, you need to continuously acquire samples.

 

Do you suppose we could do something with keeping track of time?  Specifically, the time at which >2V was detected?  Compared to the current time?  And take action based on that?  The logic for your case structure will become slightly more complex.

 

Do you know about shift registers?  I'm not trying to be insulting, you said you were new and I'm not 100% sure of how new you are.  🙂 

 

You seriously do need to take your Write to File out of your DAQ loop...please look into producer-consumers, or you'll be right back on this forum asking us about buffer overflow errors.  🙂  Also, beware of the Write to Measurement File Express VI...you don't have a file path wired in the code you showed, so it's going to pop up a dialog box every time it's called, asking for a file path.

 

If you really want to learn LabVIEW, you will get rid of all Express VIs in your code.  At the very least, you need to understand exactly what they do and how they work.  Writing code that you don't understand is only going to cause problems later

0 Kudos
Message 4 of 4
(2,624 Views)