Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

PCIe-6259 triggered AI

I need to measure an analog signal when I receive a trigger which comes randomly. The board I am using is a PCIe-6259. This board does not have traditional DAQ driver, only DAQmx with wich I am not very familiar yet. To test if I am doing the programming right I made a small VI that generates a waveform on AO0 and measures it on AI0 when the PFI1 line goes high. I am using a BNC-2110 box and connected the AO0 to AI0 and port 0 line 3 to PFI1. To change the the PFI1 line I am using the read button on the front panel of my VI that switchies port 0 line 3 (which is connected to PFI1 on the BNC-2110) to high then back to low one second later (I need this to be able to see the signal on an oscilloscope). I can confirm that I am genrating the signal on AO0 and that I am switching the DIO line. Somehow it never reads even once. When I stop the program I get error 200284, I attached a screen shot of it with the test VI. Can somebody tell me what I am doing wrong? Any help would be appreciated.

George
Download All
Message 1 of 3
(2,884 Views)
Hello George,

I believe I know what is going on, but how we approach this depends on some specifics I am unclear on.  Are you trying to just take one point on the rising edge of your digital line (your trigger)?  If this is the case, then I would recommend using your digital line as your sample clock.  What this would do is instead of using a trigger (and then read only one point),  you could simplify it by just doing continuous samples and specify the digital line as your source.  Then the read (in the loop) needs to have the samples to read as -1 (which means read whatever is available) so that you do not wait for a sample to be read. The example (Help»Find Examples) called Cont Acq&Graph Voltage-Int Clk.vi (located under Hardware Input and Output»NI-DAQmx»Analog Measurements»Voltage) shows the programming for this.

If you want to acquire multiple points after your trigger, then you need to use the digital signal as a trigger (like you are) and use an internal sample clock.   The example (same place) called Acq&Graph Voltage-Int Clk-Dig Start&Ref.vi shows how to do this.  You can ignore the second triggering VI since this sets up the reference trigger (which i believe you are not using for this application).  Looking at your program, this appears to be the method you want.  The only problem I see with the program is that the polymorphic instance of the DAQmx Read vi is not set to Analog»Single Channel»Multiple Samples. 



This means that the program is trying to use software timing to read one sample instead of reading out of the buffer for your Finite Samples, which could be causing your error.

Other than that, your program looks good.  Your code is very easy to follow and is laid out exactly as I would have programmed it.  Please post back if you have any more issues (or if my explnation is confusing).

Also, your post was awesome;  you provided exactly the right information (setup, application, hardware, error, simple program).  I find it hard to believe that this is your first post, Thank you!


Message Edited by Neal M on 12-19-2007 12:26 PM
Neal M.
Applications Engineering       National Instruments        www.ni.com/support
0 Kudos
Message 2 of 3
(2,854 Views)

Hi George,

Neal makes some great points about your code. After getting more information from you, I've been able to determine some good ways as to accomplish what you are attempting (acquire a single sample every time the PFI line is asserted over varying amounts of time). First off, let's configure your hardware before heading into the while loop by using a "DAQmx Control Task." This will set the hardware settings until the task is cleared and not be continually programmed by a start VI (which now simply tells the board to start), which can be inefficient. Inside your while loop, we'll call the "Start Task," "Read," and also "Stop" functions. Since your trigger will be coming in at any time (10m seconds all the way up to 5 minutes), we should set the timeout to -1. This will read one value right when you assert the PFI line with your ion beam and continue to do so while the program runs. The downside to this is that when you click the stop button, TWO more triggers must come in before the program exits the while loop. This is because of the timeout blocking execution of anything else. I've attached this VI (test5good.vi) for you to view.

One way to get around this is to set the timeout value to be small, let the "Read" VI timeout, programmatically discard that specific error code, and allow the loop to run again. You should still catch your triggers. See the picture below:


One way to avoid the 'blocking' nature of reading finite sample(s) is to set your timing VI to “continuously sample”. This will allow you to press the stop button at any time during execution. Because DAQ boards require at least 2 samples before sending the samples to memory, we will have to fill this buffer with 2 samples every time you send a start trigger and then discard the 2nd sample. To do this is a little tricky but the attached vi (test5better.vi) accomplishes the task. In a nutshell, I set up my M-series card's counter to generate 2 pulses whenever a trigger is received. This is linked to the analog task's timing clock (sample clock) so your DAQmx Read VI (set to 1 ch, N samples) will sample twice. Then, using a case statement, we discard the second sample if data is available.

I Neal and I's advise has helped you and again, thanks for using the National Instruments Forums!


-Patrick Barrett | Applications Engineering | National Instruments



Message Edited by Patrick_Ba on 12-20-2007 05:21 PM
PBear
NI RF
Download All
0 Kudos
Message 3 of 3
(2,835 Views)