LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I sync the digital waveform to read on the timing set on counter output?

Hi,
 
I would like to run the digital input read in sync with the counter output frequency. The digital waveform is supposed to represent the address data for the respective voltage channels. But I can only set the digital read to be 'on demand'. In this mode, the address data does not seem to be in sync with the counter frequency. How do I make them run synchronously, reading the correct address data (digital input) when the counter output pulses? I have attached the vi and the result for your reference. The digital input should read from 00000 to 10111 in 24 pulses. I'm using labview 7.1 on DAQ PCI 6143.
 
Thanks in advance!
 
Regards,
Dick
0 Kudos
Message 1 of 7
(3,426 Views)

Greetings Dick,

The NI PCI-6143 only supports On Demand DIO acquisitions.  To perform simultaneous sampling on this card, the NI PCI-6143 generates two sample clocks for each digital acquisition.  Refer to this KB for more information.  Basically, the ADC must use two sample clocks to grab each DIO point.  The actual data that is returned is always the correct DIO data because the extra samples are discarded internally...this is handled by NI-DAQmx.  The additional sample clocks do not affect single task timing (again it is handled internally by the device's driver), but when you synchronize this task with others, additional considerations must be taken.

To synchronize your DIO and Counter tasks, you will need to perform the Counter task on every other sample clock to sync up with the DIO task.

Hope that helps,

Nicholas B, National Instruments

0 Kudos
Message 2 of 7
(3,397 Views)
Thanks for your reply!
 


@Nicholas_B wrote:

To synchronize your DIO and Counter tasks, you will need to perform the Counter task on every other sample clock to sync up with the DIO task.


How do I actually synchronize the both of them together? Is there an example that shows this function? My labview version is 7.1.

Thank you very much!

0 Kudos
Message 3 of 7
(3,383 Views)

Hi Dick,

If you open the NI Example Finder by choosing Help >> Find Examples... you can perform a search for the VI entitled "Multi-Function-Synch AI-Read Dig Chan.vi"   Even though this VI does not exactly perform the functions your application requires, it showcases how to perform synchronization between two tasks.  The key is that the ai/SampleClock is sent from the AI task to the DI task, so that they share a clock and thus perform actions simultaneously on the same rising (or falling) edge. 

Now, to incorporate the nuance of the PCI-6143 noted in my previous post, you will need to perform your Counter task on every other sample clock pulse.  One way to do this would be to share the sample clock but specify different rates for each task.  For example use 10Hz for the DIO task but 5Hz for the Counter task (you might have to test frequency combinations that are almost a 2:1 ratio to incorporate any additional clock ticks).  Another possible solution would be to discard every other data point acquired by the counter task.  You can use the iteration terminal of the while loop to monitor odd and even iterations, and only capture data from the counter on even iterations, while you DIO task captures data on every iteration. 

Let me know if you have any other questions...

Nicholas B, National Instruments

0 Kudos
Message 4 of 7
(3,377 Views)
Hi Nicholas,
 
Thanks for your advice.
 
But I seemed to have a problem with placing a sample clock on the digital input line. LV only allows on-demand option to be selected. How can I overcome this?
 
I attached the error message & a test program I just ran.
 
Thanks again for your help!
 
Regards,
Dick
Download All
0 Kudos
Message 5 of 7
(3,363 Views)
Hi Dick,
 
I've taken a look at your VI...and there are a couple things I noticed.  First, since we are forced to perform the Digital Input on demand and the Counter task performs continuously, we will only be able to start them at the same time.  Due to the nature of on demand measurements, we cannot know ahead of time when the measurements will come in.  We only know after they are received, which will make it very difficult, if possible at all, to ensure that the counter measurements are taken at the same time.  We can use a property node to monitor when data is available from the Digital Input task and trigger the counter off of this value, but this will introduce a small processing/computational delay between the two.  This delay could very well be small enough to consider the two measurements synchronized.  You can give that a try to see what your data looks like. Another thing to note is that since the counter task uses implicit timing, we cannot specify a sample clock for that task either.  Without a sample clock for either task, the synchronization can be performed by using a single trigger to begin each task.  There are several examples in the NI Example Finder that illustrate the use of shared triggering. 
 
Regards,
 
Nicholas B, National Instruments
0 Kudos
Message 6 of 7
(3,351 Views)

Hi Nicholas,

Thanks for your time and advice. I will look at the trigger samples.

Thanks again!

Regards,

Dick

0 Kudos
Message 7 of 7
(3,342 Views)