Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronizing AI, DI and Counter i/p on two DAQ boards

I am facing some issues with synchronizing different tasks on two 'S' series boards. I would really appreciate if someone could help me solve those.

I am using two DAQ boards.
PCI 6154: Dev1 - Master (with hardware timed DIO)
PCI 6143: Dev2 - Slave

I would like to synchronize analog input, digital input and counter input on  these boards so that they share the same clock. I have been able to make a VI to synchronize AI from these 2 boards. I am facing some difficulty while synchronizing DI and counter i/p.
1.   When I try to read digital input on Dev1 is get an error 'Error -200077 occurred at Property Node DAQmx Timing (arg 1) in DAQmx Timing (Sample Clock).vi:3'
2.   I have to count edges from an encoder (@5MHz) on counter input. I get an error whie 'Error -200303 occurred at DAQmx Start Task.vi:3' while synchronizing this task. Can I have this task running at a different sampling frequency from AI and still share the same clock?
3.   How do I display the # counts?
4.   What would be an efficient way to write all the inputs (AI, DI, CI) to a text file?

Regards,
Dinesh


0 Kudos
Message 1 of 16
(4,765 Views)
Dinesh,

Thanks for posting to the NI forums.  Let me see if I can address some of your questions.

1. Timed DI
Unfortunately the 6154 and 6143 do not support hardware timed DIO.  In other words you cannot acquire digital signals using a hardware sample clock.  You can do some approximation of a steady acquisition rate if you set up some timing in software (by say creating a while loop that makes a read every iteration and attempts to keep the loop period constant) but this method is very susceptible to large jitter since it is controlled by a non-determinisitic software environment (Windows).

2. Error -200303 when attempting to use the counter
This error occurs when you explicitly need to specify an external sample clock source.  Are you wanting to have a sample clock for your counters?  How would you like the counter synchronized with AI?  You mentioned that you would like to use a different rate.  What rate would you like to buffer in counts from the counter?

3. Diplaying the # of Counts
I am not sure what you are asking here.  If I understand you can just use a numeric indicator to display the # of counts.  You may need to provide me with a better idea of what you would like to display and where.

4. Writing data to a file:
Once again I am not completely sure what you would like to do.  By efficiently do you mean executes quickly or easy to program?  The easiest way to write data to a text file is to use the Write to Spreadsheet File.VI.  This VI takes a two dimensional array of doubles(floating points) representing rows and columns of the spreadsheet and writes it to a tab deliminated text file.

Hopefully I was able to give some good pointers.  Let me know if you have additional questions or would like me to elaborate on any of the discussed topics.

Regards,
Neil S.
Applications Engineer
National Instruments
Message 2 of 16
(4,747 Views)
Thanks Neil. I really appreciate you giving me some useful pointers.
I am little confused about hardware timed DIO on PCI 6154. The board description on http://sine.ni.com/nips/cds/view/p/lang/en/nid/202913 says that the board is capable of synchronizing among AI, AO, DI and counter inputs. Doesn't this mean that they all share one clock? When I placed the order for this board I checked about this with one of NI's sales rep. and she did confirm with me on this. Can you please check and let me know if PCI 6154 can supply a hardware clock for synchronizing? If not then I'll have to buy a new board.

Dinesh



0 Kudos
Message 3 of 16
(4,737 Views)
Dinesh,

Thanks for pointing out the hardware timing on the DIO of the 6154.  You are correct this board does have hardware timed digital lines.  Most of our S Series boards do not and I must have missed that when I looked over the specs.  Using the 6154 to do the digital input you should be able to synchronize all of these different tasks.  There are several ways to synchronize a data acquisition between tasks.  You can share the sample clock by specifying the same sample clock for each task.  For example you can set the DI task to use the AI Sampel Clock from the the AI.  However, this means that the digital task will operate at the same rate as the Analog.  If you would like the digital task to operate at a different rate but still start at the same time you can use the AI Start Trigger from the analog task to trigger the DI acquisition.  I would take a look at the Multi-Function-Synch AI-Read Dig Chan.vi example.  It shows how to share the sample clock between the Analog Input and Digital input.

The same method could be used with the counter.  However, the counter only has a 2 sample FIFO on the 6154 or 6143 and cannot be buffered at very high speeds.  It can count pulses at a very high speed but it can not transfer the data from the onboard register to computer memory (this is done at each pulse of the sample clock).

I would also recommend taking a look at the following Developer Zone document:
http://zone.ni.com/devzone/conceptd.nsf/webmain/6dc991028566309886256f990080a720
The document is focused toward M-Series boards but many of the concepts are exactly the same for the S-Series boards. 

Hopefully I have been helpful in getting you started with your application.  Let me know how it goes.

Regards,

Neil S.

0 Kudos
Message 4 of 16
(4,725 Views)
Hi Neil,
I have a similar situation here. I am trying to count edges on counter 0 and produce PWModulated signal on counter 1. I am unable to do them both simulataneously. Here are the different options I tried and the relevant errors that I am getting

Picture 1 and Picture 2
1. Error 200303 occured at DAQmx start Task. vi ;
External sample clock source must be specified for this applicaiton.

2. Error 200300 occured at DAQmx start tast.vi:22
Invalid timing type for this channel.

Please suggest. I am using PCI 6221 only.
Thanks


Please suggest.
Thanks
0 Kudos
Message 5 of 16
(4,556 Views)
UBAP,

Thanks for posting to the NI Forums.  Typically both the PWM and edge counting tasks will use implicit timing.  There are examples of both applications and to get the two to work together would be a matter of copying the contents of one example into the other.  An example of continuous edge counting is shipped with the DAQmx driver.  This example can be located by going to Help >> Find Examples, clicking the Browse tab, and navigating to Hardware Input and Output >> DAQmx >> Counter Measurements >> Count Digital Events.  There is also an example of a PWM generator available on our website:

http://zone.ni.com/devzone/cda/epd/p/id/4812#0requirements

I would highly recommend taking a look at these two examples and incorporating them into your final program.   In addition I noticed that in two of the figures above you used the ai/SampleClock but I don't see an Analog Input task in your code.  Are there parts of your code that you do not show?  Let me know if you have any additional questions.

Regards,

Neil S.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 16
(4,524 Views)
Thanks Neil !!
I have the following tasks.
  • TASK 1. Acquire an analog signal.
  • TASK 2. Measure the rotational speed of an encoder. [by measuring the frequency of the train of pulses from an encoder. I used a simple transparent glass with a couple of dark lines on it. And i am using a transmissive photomicrosensor]. I am using "counter 0" for this task.
  • TASK 3. Produce a PWMoulated signal. I am using "Counter 1" for this.
So, yes I have an analog signal also...
Thanks again, for offering the help...I would surely post If I have furhter questions.

UBAP

0 Kudos
Message 7 of 16
(4,497 Views)
and here is the figure with different tasks. I used the example: "meaure Digital frequency-Low Freq1 ctr.vi"
 

Message Edited by UBAP on 03-02-2007 08:54 AM

0 Kudos
Message 8 of 16
(4,497 Views)
UBAP,

Once again, thanks for posting to the NI Forums.  It is unclear from your previous posts if you are still experiencing difficulties in getting you application up and running.  I wanted to follow up and make sure we were able to answer your questions.  Let me know if you are still getting errors or not being able to get the application to function properly.

Regards,

Neil S.
Applications Engineer
National Instruments
0 Kudos
Message 9 of 16
(4,467 Views)
Dear Neil,
Thanks for the concern. Yes, I am encountering another problem.


Here is my code to measure the frequency of the train of continuous pulses.



I sometimes (at speeds more than certain limit]) get garbage values or the message "Data was overwritten before it could be read by the system.
If data transfer mechanism is Interrupts, try using DMA, Otherwise divide the input signal before taking the measurement"


I first ran the motor with, so that I get four pulses per revolution and then changed my hardware so that I get only two pulses per revolution. [I am running a small 12 Volt DC motor at speeds around 2 rpm to 15rpm]
I tried giving various values for "Timeout" and the "milliseconds to wait". But the problem seemed to remain. Any suggestions to avoid the garbage values/the error message?

Thanks


0 Kudos
Message 10 of 16
(4,459 Views)