Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Help integrate hardware trigger in a while loop

Hi NI Community,

 

I created an example code to trigger on rise and fall edge on the PFI0 channel and calculate the pulse width of IO0 bit flips. However, I'm having a hard time trying to put this in to a while loop.

 

Here is what I'm trying to do. I'm measuring bit flip of a device and the device output is constant low (0V). Randomly, there will be a bit flip. That means that it could happen at any time during the test.

 

The test is set up so that channel IO0 is tied with PFI0 and that can work as a hardware trigger and capturing data.

 

The problems I'm having:

1. The way I set this up, it looks like the Acquire VI times out when it nothing is triggered. This could be fixed by increasing the timeout of the acquire VI. However, I'm not sure how this will work in a while loop.

2. I want to put this in to a while loop so that this can run more than once. But I have not figured out how to do that. Please help!

3. How do I append the 2 waveforms into 1 plot so it shows the rising edge and falling edge of the waveform?

 

Thank you for your help!

0 Kudos
Message 1 of 4
(1,039 Views)

Hi NI LabVIEW Community,

 

I created an example code to trigger on rise and fall edge on the PFI0 channel and calculate the pulse width of IO0 bit flips. However, I'm having a hard time trying to put this in to a while loop.

 

Here is what I'm trying to do. I'm measuring bit flip of a device and the device output is constant low (0V). Randomly, there will be a bit flip. That means that it could happen at any time during the test.

 

The test is set up so that channel IO0 is tied with PFI0 and that can work as a hardware trigger and capturing data.

 

The problems I'm having:

1. The way I set this up, it looks like the Acquire VI times out when it nothing is triggered. This could be fixed by increasing the timeout of the acquire VI. However, I'm not sure how this will work in a while loop.

2. I want to put this in to a while loop so that this can run more than once. But I have not figured out how to do that. Please help!

3. How do I append the 2 waveforms into 1 plot so it shows the rising edge and falling edge of the waveform?

 

Thank you for your help!

0 Kudos
Message 2 of 4
(1,071 Views)

A few general tips b/c I've mainly used DAQmx devices and am not very familiar with the HS-DIO line of products.  Of particular note is that I don't see that you're calling the equivalent of DAQmx's "Start Task" and "Stop Task", though I don't know if such explicit starts and stops are needed with the HS-DIO driver.

 

1. I would set a fairly short timeout and then generally ignore timeout errors because they'd be *expected*.   Just keep trying again.   Note: watch out for the possibility of a corner case where you get both a timeout error and also *part* of your data.

 

2. Under DAQmx, I'd start the acquisition before the loop, makes calls (which might time out) to DAQmx Read inside the loop, and stop the acquisition after the loop.  I'm not certain of the right way to approach this under HS-DIO.

 

3. I wouldn't trust your method for measuring bit timing where you're subtracting the T0 fields from 2 distinct triggered acquisitions.   I'd want to measure timing based on the HS-DIO device and it's high-speed internal sample clock.

   I suspect there's more than one way to approach this, but I don't know the HS-DIO driver well enough to offer specific advice.   With DAQmx, I'd aim to trigger on the rising edge (including a few pretrigger samples) and retrieve data in a loop until I saw the bit toggle back low. 

 

 

-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 3 of 4
(1,001 Views)

Crossposted from the Digital I/O forum, where followups probably belong as the key issues relate to triggering and acquisition of a digital signal.   If you have specific experience with HS-DIO devices, follow the link and help give a better response than my generic one.

 

 

-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 4 of 4
(1,000 Views)