Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

ni6602 synchronization

  I have made a program with LabVIEW 5.1 based on NI 6602, in which four counters were used.

  Counter 3 is used to generate pulses, which are directed to the gates of counter 0, 1 and 2. 

  The source terminals of counter 0,1 and 2 receive pulses, individually, to count how many pulses appear during the time interval of each gate pulse.

  The results are stored in a data file.

  In order to test its performance, only one signal of ramdom pulses is sent to counter 0,1 and 2.

  But I find that at the beginning the counts for the three counters are the same, but the following counts are totally different!

  What's wrong? And how to solve such a problem? Does it have something related with synchronization?

  Thank you very much!

0 Kudos
Message 1 of 4
(6,458 Views)

Can you post a screenshot of the code?   I kinda suspect the issue you see is tied to the code -- how things are configured, started, and read.  It is probably not purely about hardware sync of the signals.

 

A few tidbits of info that may help you troubleshoot:

1. It would generally be a good idea to start the 3 measuring counter tasks before starting the pulse train that acts as the gate (buffering) signal.  Then data(i) from each measuring tasks will be buffered at the same time.

2. Note that data(0) for each of the tasks may be essentially meaningless, merely representing the # of source edges that occur prior to the first gate edge.  Unless this is somehow important, just discard the first reading.  [Note: it is possible to configure an "arm start" trigger to make sure the 3 measuring tasks begin simultaneously, but it won't be necessary if you can live with discarding the 1st data value from each task.]

3. It'd be a good idea to explicitly read an equal # of samples from each task rather than leaving this input unwired.  When unwired, it'll read "all available" samples, so you may find extra data available in the later tasks you read from.  This could cause your data to *appear* out of sync if you don't handle such things carefully.  It's easier to just read the same quantity from each.

 

-Kevin P

 

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 4
(6,447 Views)
  So many thanks to Kevin P!
  My original program is divided into two vis. The first is used to generate gating pulses, and the second containing 3 counters count source pulses.
  If the first is started before the second, the data of the three counters are totally different.
  If the second is started before the first, the data of two counters among the three are the same all the time, but the third counter’s data may be delayed 1 second or so with respect to the other two, but after a while, perhaps several seconds, such a relation does not exist any more.
  The attachment is the pictures of the font panel and diagrams, is there anything not proper in it? Could you please give me some suggestions? And what does the backlog mean?
  Thank you very much!
Download All
0 Kudos
Message 3 of 4
(6,403 Views)

Quite a few of the key vi's I see (buffer, Gate, source, Read) are not NI's built-in calls so it's impossible to be certain what they do.  However, based on the symptoms you describe, I have a strong hunch that most of the issue (very possibly all of it) has to do with the "Read" calls.

 

You describe a symptom where 2 of the 3 counters' values start in sync with the 3rd being delayed a bit.  Then this situation changes over time.   That does not sound like a hardware-sync kind of problem.  That sounds like a software flaw in reading the acquisition buffers.

 

It is definitely correct to start the 3 source-counting tasks BEFORE starting the gate-generating task.  After that, you should make sure you read the SAME # of samples from each of the 3 counting tasks.   Unless explicitly programmed otherwise, by default this will always keep reading the earliest buffered data that hasn't already been read before.  HOWEVER, I've got a lurking suspicion that the custom "Read" function just might not do the default thing.  I notice that there's an output value which goes to a shift register to be used as an input value to the "Read" function on the next iteration.  This has the look of a NON-default way to read from the acquisition buffer where the shift register value is a cumulative index where the last buffer read left off, and where the next one should start.

 

In other words, it kinda looks like the "Read" function might be based on a non-default user-software-based management of the index into the acquisition buffer.  And if the user software doesn't manage the index properly, the data will appear out of sync.   The hardware would still be buffering data in sync, but the way the software reads and accumulates it doesn't maintain the order.

 

One simple thing to check just in case -- make sure all those shift register wires are connected to the appropriate input and output terminals of the "Read" functions.  All 3 look similar, so if only 2 of them maintain sync I wonder whether one of those wires is not actually connected to one of the "Read" output terminals.  Maybe the "Read" function icon just sits on top of the wire without being properly connected to it?

 

Finally, "backlog" usually would tell you how many samples are in the acquisition buffer that you haven't yet read.  You don't want to see that number keep growing and growing, and you should expect the backlog value for all 3 count tasks to be approximately equal each pass through the loop, though it may vary from one iteration to the next.

 

-Kevin P

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 4 of 4
(6,332 Views)