Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

M-series digital input change detection

Hello,

I have 2 triggers for my counting application. One starts the whole
process, it is a long pulse whose length  changes each time, and the other is a

short pulse (300 ns) being used as a pause trigger to gate the counter in my M-series  board. Ideally, I want to
count only when both are high (AND). In fact I need to count with 2 different counters, and the gates will have different timings for each.

 

I was using a digital line 8 and change detection to look for the rising
edge and falling edge of the digital line, and read 2 samples. In my while loop, the counters would count when
the first sample was 256 (bit 8 high) and the pause trigger was high, and while loop would exit when the
2nd sample was 0.

I had 1 signal generator connected to produce both the pause trigger and
the starting trigger, and another for producing pulses synchronized to the first. Everything looks fine on
the oscilloscope, I can see the pulses and they are all stable with respect to each other.

But when I count using the counters, I often get an error saying that the
DAQmx tried to read too many samples and could not read anything. I also get 0 on the counter data. If I
run in highlighted mode, I get a number, but the number fluctuates each time I run it, which I don't think
should happen since the signal generators are producing constant number of pulses. I think this mode
basically does not work.

From the examples, I see that I can use change detection events to be the
arm start trigger. I changed my code to do that instead, and now I don't get an error, but the counter
reading is still 0. I also don't get a constant number each time.

How does one implement an AND function for 2 triggers in Labview and DAQmx?
I am attaching the first version of the code.


NI Software :  LabVIEW  version 8.5.1
NI Hardware :  Multifunction DAQ (and NI ELVIS) device PCI-6229
Driver Version :  1.13.0f4
OS :  Windows XP

0 Kudos
Message 1 of 3
(2,944 Views)

Sorry, can't look at code as my LV system is tied up and far away from my network connection.  Also, I'm pretty sure I don't have a clear picture in mind of what you're trying to do.  You've given a lot of details, but I don't think I've put it together yet.  That said, here are a couple quick thoughts:

 

  • There's no AND function available inside LV or DAQmx.  You'd need to use a logic chip circuit for that.
  • I'd be a little wary of counting on catching both edges of the 300 nsec pulse with change detection.  The specs for the 6229 put a 1 MHz limit on DI/DO.  (I'm not 100% sure that applies to change detection as well as "standard" clocks, but I'm inclined to think so until shown otherwise.)  
  • It isn't clear what's being counted, but it doesn't surprise me that you might get different results in highlight mode.  It sounds like some aspects of your code depend on software timing (loop termination on specific DI port value), which will be greatly affected by highlight mode.
  • Doesn't the 6229 only have an 8-bit wide port 0 available for hw-timed DIO?  If so then if you're looking at the MSB, it should be wired to bit 7 and you should look for a 8-bit unsigned value of 128.
  • You once described your 300 nsec pulse as a pause trigger for your counters.  Later you wanted to use the change detect event from its rising edge as an arm start trigger.  The change detect event is probably slightly delayed from the rising edge because it gets synced to the internal 80 MHz timebase.  The variable delay from syncing would account for at least some of the variation in count value.

 

-Kevin P

Message Edited by Kevin Price on 04-14-2010 11:41 AM
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 3
(2,941 Views)

I agree with Kevin on some of that, I’m still unclear on a lot of what you tried.  From what you originally asked, the simplest solution to count only when two lines are high is to use a hardware AND gate like Kevin Suggested. There is an AND function is LabVIEW but it is a software operation and I’m sure how you would incorporate that.

Matt
Applications Engineer
National Instruments
0 Kudos
Message 3 of 3
(2,912 Views)