From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Using an External Digital Trigger to Read Digital Input Once

Hello,

 

I am using the NI USB X Series (specifically the NI USB-6343) and programming in Visual studio 2010 with C# .NET . What I have been trying to do is use an external Digital trigger on Port 1 (PFI0) and reading the input from Port 0. When there is a rising edge on the digital trigger line (PFI0) I want that trigger a read from the input port (port 0) just once next I want it to be retriggerable so it is ready for the next trigger again without the user needing to do anything (like press a button to start looking for the trigger again).

 

I tried creating my task, and using the configure trigger function on the same task, but my code doesn't seem to wait for a trigger it just reads the input data from port 0 regardless of whether there was a trigger or not.

 

Have I misunderstood how the trigger works? What am I missing?

 

Thank you and I appreciate the help.

0 Kudos
Message 1 of 7
(3,096 Views)

Hi,

Have you tried including the triggering in the task in NI-MAX? This would be a good initial test to be sure that you are able to get a simple trigger case working.

 

If you have LabVIEW, try using the  "Voltage - Finite Input" example. This should be a good starting point for building your C# code.

 

Also, have you verified your trigger signal with a loop back test?

 

Matthew C

NI | AE

 

0 Kudos
Message 2 of 7
(2,991 Views)

Hello Matthew,

 

I have tried using MAX and configured a task to read Port 0, however I want to only read 1 sample when there is a trigger. The only option in which I can configure a trigger is: 1 sample (Hardware Timed) acquisition mode. However, when I run the program from MAX I get

 

Error -200077 occurred at DAQ Assistant

 

Possible Reasons:

Requested value is not a supported value for this property

 

Property: SampQuant.SampMode

You have requested: Hardware Timed Single Point

You can Select: Finite Samples, Continuous Samples

 

The only other 1 sample read is "on demand" which does not have the option to use a start trigger.

I wanted to try the N samples option, however it requires a minimum of 2 samples to work.

 

Is there any other way around this?

 

Thanks,

Mulan

0 Kudos
Message 3 of 7
(2,984 Views)

Hi Mulan,

USB devices like the USB 6343 are not able to use hardware timed single point sampling because the data transfer is non-deterministic. 

 

Which devices can use Hardware-Timed Simple Point Sampling

 

Also, you're correct that on-demand sampling will not work with a trigger.

Without changing your hardware, you're remaining option would be to use finite sampling with 2 samples and then either store or throw away the extra sample. 

 

Matthew C

NI | AE

 

0 Kudos
Message 4 of 7
(2,971 Views)

Have you considered configuring the task to use the PFI0 signal as an external sample clock?  It sounds to me like that's the kind of behavior you're after -- each active edge on PFI0 would cause one sample to be A/D converted instantly and stored in a buffer for later retrieval.

 

I only program LabVIEW though, so I'm no help on the C#.NET syntax.  I also don't think MAX allows you to configure an external signal as a sample clock.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 7
(2,955 Views)

Hi Kevin,

 

That does sound like what I am looking for, however you mentioned one sample will be read on each active edge. Do you mean both rising and falling edge, because I am looking to collect a sample on the falling edge. Is is possible to read data on the falling edge of a signal or only a rising edge?

 

Sincerely,

Mulan

0 Kudos
Message 6 of 7
(2,951 Views)

DAQmx Timing.vi lets you configure which edge is the "active" edge for sampling.  There's an input terminal you can right-click and create a constant (or control) to define which edge to use.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 7 of 7
(2,946 Views)