Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use digital input to trigger analog input acquisition?

Hey everyone, I am pretty new to LabVIEW and I am having trouble designing a program for my engineering senior design project.  I am using a PCI 6024E card and LabVIEW 7. 
 
I am trying to use a digital input signal to trigger acquisition of a analog input.  Like everytime the digital input goes high I want to take a sample of the analog input (record the amplitude).  I can view the analog input signal which is just a series of spikes and I did this by using DAQ assistance and no triggering.
I need to somehow read the digital input and use that data to tell LabVIEW to sample the analog signal and store that value. 
 
If I can get that far, I then need to be able to create a loop that stores the samples of the analog signal into a file that goes from 1 to 64 and when it gets to 64 start a new column.
 
Do I need to put the digital input signal on a P0.X channel or a PFI channel, and how can I use that signal to tell LabVIEW to sample the analog signal.  Or if I can use the digital signal not to tell LabVIEW to sample the data but to always sample it and just store the data when the digital signal goes high.
 
As an overview I have a 64 channel photodiode array that yields the voltages of all 64 signals on one analog channel.  It also yields a digital trigger that goes high when the analog signal goes high and needs to be read.  I need to seperate the analog signal into 64 seperate signals corresponding to each photodiode using the digital trigger.
 
Sorry if this is long, but any help would be much appreciated.  Thanks!
0 Kudos
Message 1 of 19
(7,762 Views)

Hi!

Just configure your acquisition to take one sample, before calling the DAQmx Start.vi place the DAQmx Trigger VI, configure it for external trigger source and digital edge (rising/falling). One terminal of this VI is to set the pin for the external trigger signal. So, what happens is that if a trigger occure you acquire one sample.

But keep in mind, the analog input is not retriggerable, so if you want to do this continiously, you will need two counters (they are retriggerable). So i would suggest to search for a example, using the LabVIEW example finder (Help menu) with the keyword "retriggerable", so you will find a example for retriggerable I/O

Hope this helps, Christian

0 Kudos
Message 2 of 19
(7,751 Views)
Thanks for the help but it seems that I still could not get it to function properly.  I attached the VI file that I have been working with.  The top part sends the clock signal to our device so it will give us back an analog video signal into a0.  This signal is a series of spikes which I can see using another vi that I have but did not attach. 
 
I tried putting in the Start Trigger command after the read waveform and before start task.  I then had that go to a Start Retriggerable which I found in an example but am not sure exactly what it does.  I also tried getting the data into a table that would also be displayed in a waveform and saved into a spreadsheet file.  The data gets displayed in the table but it only uses one row and changes with time instead of adding a new row with another data point.  The waveform also does not work, the values on the x and y axis change but no waveform is displayed. 
 
Any more suggestions would be appreciated.  Thanks.
0 Kudos
Message 3 of 19
(7,727 Views)

Hi bawuer2,

The VI you posted is quite interessting!

I think, if you let the "retriggerable AI" VI as it is, without any changes your application will work fine! For example, you are wondering why there is only one value in the table after the acquisition....., it's because you are reading only one sample (see configuration of DAQmx Read.vi). The next thing is, where are the counter you have to use for retrigger AI in your VI. I can't find a counter task, however i found a DAQmx Create Task.vi which creates nothing?!

Attached you will find a VI which synchronizes AI, AO and makes it retriggerable with a counter, please have a look at and try to find out how to make a AI retriggerable. Then you can build up on it with a few little changes!

Christian

0 Kudos
Message 4 of 19
(7,721 Views)

Ok, I worked on it some more and what I have is attached.  I tried to enter the counter but it didn't seem to work.  Should the source of the counter and the source of the digital start trigger be the same?  It gives me the right graph and data table with no trigger so it seems that the trigger or counter is not working.

The bottom part of the vi is where I try to read in the digital trigger that is provided to the card and I tried to use the digital waveform to enable the table that records the analog voltage when the digital waveform is high.  When I set it to single channel, multiple samples, waveform, I can get a waveform that seems to be what I want but I cant convert that into boolean that will enable the table when the signal is high and disable the table when the signal is low.  If I can do this it seems that I would be able to just continuouosly sample the analog signal but only record the values when the digital signal is high which would mean I wouldnt have to use any counters of digital start triggers.  Do you know how I can convert the output of the digital read to boolean somehow and use that to enable or diable the table?  Ive tried setting the digital read to single sample, boolean, but always seems to give a false value.

As I said I attached the vi again, the top is the clock, the middle is the analog input, and the bottom is the digital input we want to use to determine when to sample the analog input.  Thanks for all of your help.

0 Kudos
Message 5 of 19
(7,686 Views)
bawuer2,
 
Please use the LabVIEW Example Finder and search for "retriggerable", select the VI for retriggerable analog Input and use it first without any changes, and I'm sure it will work! Please play arround with this VI to see how it works, just use the debug mode for testing! Then you can build up on it, but don't change the VIs and there order, and also do not change the way of the error cluster wireing!
The example i posted before was a little bit to complex, because you don't need the digital I/O, this was only for example! You will need to retrigger the analog in, so you need a Task for an analog input and one for the counter (there are two counters in combination). The external trigger, to start the acquisition is the port of the counter task (e.g. PFI0)
 
 
Best Regards,
Christian
Message 6 of 19
(7,666 Views)
Ok I tried those examples and none of them seemed to work.  Maybe I had the connections hooked up wrong I dont know, but before I try the examples again I have one more question.  Don't these examples output a clock based on the input digital trigger?  Our digital input trigger will only be yielded when we have the clock continuously.  I think that the examples send the clock based on the input trigger but we need to have a continuous output clock to get a digital input trigger from our device.  Thanks for your help.
0 Kudos
Message 7 of 19
(7,644 Views)

Hi bawuer2,

First off all, NI call trigger as an event that will performed on a internal/external digital or analog edge, like to start a acquisition. You want to acquire a signal everytime a trigger occours, and this continiously. Now the problem is that the analog input is not retriggerable, which means you can perform an acquisition only one time with a start trigger. To make it retriggerable, you need two counters, which is demonstrated in the example you will find under the LabVIEW example finder.

If you also need to produce a output signal to your hardware to get a trigger from, you can do this with the digital I/O (bad thing with the 6024E, because there are static I/O which means that there always a interrupt occour if they change there states, so you can perform as a maximum frequency maybe 15kHz) or you use the analog output to generate this signal by creating an continous output with the desired frequency and the voltage level you need.

And this three components, you can synchronize with each other, like the VI i posted shows!

BR, Christian

0 Kudos
Message 8 of 19
(7,599 Views)
Ok, after beating my head against the wall for hours, here is the code that I have attached. 
 
A little backround first:  The top two lines provide signals to our device and both must be given to get data back from our device.  The third line takes a sample from the analog signal from the device everytime the trigger provided from the device goes high. 
 
On the front panel I set the sample clock source as PFI0.  I then click run continuously and have the vaules go into a table which is then saved into a file.  Is there a way I can have the first 64 amplitudes be stored in column 1 then the next 64 in column 2 and so on?  without using a counter? because we are using both counters to output our two digital signals to our device.  Thanks.
0 Kudos
Message 9 of 19
(7,585 Views)

Ok after yesterday here is my code attached.  I am still having two problems.  The first is that when I hit run, the values go into the data table on the front panel but it takes about 10 seconds to get .1 seconds of data into the table.  The indicator that I have to read the time after the analog read is really slow.  It seems that I am putting a lot of values into the buffer which I should but they are not getting read out fast enough.  I have it set to analog single channel single sample because I only want to read one value when the trigger goes high.  Is there a way I can continue reading out from the buffer after the program is stopped?  Or a way to read faster from the buffer?

The other problem I am having is that I want to have the amplitudes go into the table having the first 64 amplitudes going into the forst column, the next 64 into the second column, and so on continuosly.  If I dont include time data in the build table vi how can I manipulate the amplitudes coming out of the block to go into the column that I want?

Thanks for all of your help.

 

0 Kudos
Message 10 of 19
(7,572 Views)