LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Encoder Triggered Acquisition (Single Channel N Samples)

Solved!
Go to solution

Hello Internets,

 

I'm an inexperienced LabVIEW user, I'm trying to set up a system in which voltage samples are taken when triggered by a digital pulse.

 

I am sampling using a PCI-6250. I have an encoder set up that emits a digital pulse once per revolution. I would like to eventually take approximately 1000 samples in a very short space of time triggered by this once per rev pulse.

 

The problem I am currently having is that I seem to get much fewer readings than I would otherwise expect, the LabVIEW programme I am currently running also takes a long time to stop following my pressing the stop button.

 

The array also fills up in a way that is odd to me, perhaps someone could explain it?

 

Thank you, any help would be greatly appreciated! Smiley Happy

 

Download All
0 Kudos
Message 1 of 10
(3,618 Views)

Hi Relaxidermist,

 

Thanks for joining the community!

 

It would be a good idea for you to attach your VI, that way we can see it running and modify as needed.  However, it looks as though you are almost there.  You can configure your task to acquire a finite number of samples (1000) on the digital trigger - without any need for a For Loop.  The "DAQmx Read" will take (1/SampleFreq)*No.Samples to execute, so you will need to make sure you set a high enough timeout value.

 

You also mention that your program takes a long time to stop when you press the stop button, although I can't see one in your pictures Smiley Happy

 

Let us know if you have any questions!


Regards,

Peter D

0 Kudos
Message 2 of 10
(3,600 Views)
Solution
Accepted by topic author Relaxidermist

Hi Relaxidermist,

 

There are a couple of things in your current code that seem contrary to your objective:

"I would like to eventually take approximately 1000 samples in a very short space of time triggered by this once per rev pulse."

 

Assuming you want to read 1000 samples for each external trigger received and you have multiple triggers coming in, I would instead start with this example:

Finite Retriggerable Analog Input using Digital Trigger

 

 

I'll be the first to admit that it's not the most intuitive--on M Series (like your 6250) you have to use a counter output in order to achieve a truly re-triggerable acquisition.  You could re-arm the task in software but doing so takes time and is prone to missing trigger signals. 

 

 

If you were on an X Series (63xx devices), the code that you have is close but you would need to make the following changes:

 

1)  Use the on-board clock for your sample clock source instead of the external PPR signal.

 

2)  Make the task finite instead of continuous.

 

3)  Enable the Retriggerable property--this is not available on your M Series device (hence the workaround posted above).

 

 

Best Regards,

John Passiak
Message 3 of 10
(3,576 Views)

Hi, Thank you both for your quick responses.

 

John, just to clarify, when I input a digital pulse, should I expect to see n samples appear on the waveform graph at the frequency I've specified? I've managed to get something to this effect to occur when I wire a 5000 pulses per rev channel to the digital trigger soure and I use the 100 kHz timebase clock. I've left the counter for sample clock to counter 1 on dev1 (PCI 6220) because when I specify on dev2, I seem to be getting errors about paths being reserved for other processes.

 

Thanks,

 

Ingram

 

0 Kudos
Message 4 of 10
(3,546 Views)

Hi Ingram,

 

The code currently displays N samples on the graph every time a trigger occurs.  However, the loop and graph can only update so fast--you might need to read back more samples per iteration to keep up with your triggers.  I'm not sure how fast your trigger signal is occurring (in terms of Hz).

 

You won't be able to use a counter from another device unless the two are connected via RTSI cable (or in a PXI chassis).

 

 

Best Regards,

John Passiak
0 Kudos
Message 5 of 10
(3,540 Views)
Hi John, The two devices are connected with an RTSI cable. I was wondering how I would get the programme to deal with more samples per trigger. At the moment, I have a once per rev pulse wired to the trigger with 10 samples per trigger. I find that the system appears to struggle with recording the data. When I reduce the samples to 1 once per trigger I find that this no longer occurs. Is there a means to greatly increasing the number of samples I am able to take? I have replaced the waveform graph with an indexed table to make it easier to see how the data is being acquired. Cheers Ingram
0 Kudos
Message 6 of 10
(3,520 Views)

Hi Ingram,

 

What do you ultimately want to do with the data, and how fast is your trigger occurring (in terms of Hz)?  The bottleneck in your case is probably going to be the loop rate keeping up with the data if the trigger is occurring too quickly--you can mitigate this by readings more samples per loop.

 

To use the automatic routing available in DAQmx over RTSI, you have to make sure to configure the RTSI cable in MAX.

 


Best Regards,

John Passiak
0 Kudos
Message 7 of 10
(3,514 Views)

Hi John,

 

I'd like to just acquire the readings and store them for now and process them later.

 

The trigger is only coming in at around 3Hz, I'm rotating it manually, this is what has me somewhat confused. There appears to be significant lag between when I press stop and when the program actually stops.

 

Cheers,

 

Ingram

0 Kudos
Message 8 of 10
(3,507 Views)

Sorry John, my digital trigger is connected to the 80MHz clock and my AI sample clock is connected to the encoder pulse which is approximately 3Hz.

0 Kudos
Message 9 of 10
(3,503 Views)

Cheers John,

 

Managed to find a configuration that works,

 

Have a nice weekend

 

Ingram

0 Kudos
Message 10 of 10
(3,494 Views)