Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

how to synchronize DIN on 16 or more lines with AI?

Solved!
Go to solution

I have been using correlated DIO to synchronize digital input (DIN) with analog input (AI) on M-series devices (e.g. the NI6225).    Correlated DIO is limited to Port0 (i.e. 8 lines).    I now need to work with 16 or more DIN lines so the correlated DIO technique will not work using a single NI device.

 

1) Is it possible to install a second DIN device that supports correlated DIO.   The idea would be to read DIN from Port0 on a NI6225 and Port0 on the second DIN device for a total of 16 DIN lines.   Is this a possibility?

 

2) After reading another post I have been able to use change detection on Port0 to read from the DIN lines on Port1 and Port2 (i.e. Port0 drives the change detection).  This is one half of the problem.  The second half of the problem is how can I obtain an accurate read of the total number of AI samples so as to be able to synchronize the onset of DIN with a single time point in the AI?   Is this possible to do?  In other words, can the hardware ‘latch’ an accurate AI sample count at the time change detection occurred?

 

Are there other techniques or methods that would let me synchronize DIN on 16 or more lines with AI? 

 

My application is written in C++ using VS2010 and runs in the Window environment (WinXP, Vista and Win7). Thanks,

 

Ian

 

0 Kudos
Message 1 of 11
(4,321 Views)

Hi Ian,

 

As far as synchronizing 16 lines of digital input, the best option I can recommend is a different card. X series cards have dedicated sample clocks for digital I/O tasks. The problem with two different devices is that you need to share a trigger somehow between the devices so that they would be synchronized. An option you could look into for this would be to use the RTSI bus cables for PCI cards. I have included the link to the product page for these cables. 

 

https://www.ni.com/en-us/support/model.rtsi-cable.html

 

If you want to synchronize the onset of the digital input based on a specific analog input sample then I would recommend setting up a counter task to count the AI sample clock and send a digital start trigger for the digital input task when the count reaches a known amount. 

 

Regards,

James D.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 11
(4,315 Views)

Hello James,

 

The NI6225 has 80 AI lines while the X series only have a maximum of 32 AI lines.  To obtain at least 64 AI lines requires getting two X series cards so either the NI6225 + timer card or the X series cards would require using RTSI.  I've worked with RTSI before and NI has done a good job at making the setup and configuration very easy. 

 

Your suggestion regarding a counter task to count the AI sample clock  sounds interesting.  I will describe my requirements and perhaps you might be able to confirm whether the counting the AI sample clock can be applied.  My application starts recording continuous AI for a user-defined period of time.  During an acquisition period, DI is received at times that is determined by external equipment - my application never knows when DI will be received.   The onset time of each DI would have to be set equal to the AI sample count at that point in time.  My question is as follows.  If I implement a DI change detection callback function, can this callback function query the AI sample count?  The key point is that the DI onset time must be accurately synchronized/correlated with a single AI sample count.

 

Ian

 

0 Kudos
Message 3 of 11
(4,312 Views)

Hi Ian,

 

If the application does not know when DI will be received, is there one DI channel that is controlled by external equipment and you want to synchronize the rest of the DI channels to that one channel as well as with the AI sample clock? Or will all the DI channels be taking in digital data at the same time?

 

If you have one channel that will be taking digital input at an unkown time then what you should do is trigger off that particular channel and share the tigger with all the other DI. Then you would just need to use the same sample clock as the AI task and the DI would be synchronized and correlated with a specific sample of AI (the sample being the closest one that occurs immediately after the trigger occurs from that DI channel).

 

If all the DI are controlled to go into the card at the same time, then you just need to have the digital input task sharing the AI sample clock. If you are using multiple boards with RTSI, however, you will still need to trigger off a channel andshare that trigger over the RTSI bus.  

 

As far as querying the sample count, I believe this post should help answer your question: http://forums.ni.com/t5/Multifunction-DAQ/Analog-read-sample-count-at-digital-input/m-p/1725288 

 

Regards,

 

James D.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 11
(4,304 Views)

Hello James,

 

When using 16 DI lines or more, it will not be a problem to dedicate one DI line/channel that can be controlled  by external equipment.  

 

I do not understand what you mean by "share the trigger with all the other DI".   Can you explain this in a more detail.   You then mention that the DIN could then be correlated with the AI.  Are you saying that this techinque/method would allow me to receive DI on all 3 ports (i.e. Port0, Port1 and Port2) of the NI6225?  If so then do you have any C/C++/NIDAQmx sample code that illustrates this technique?

 

Thanks,

 

Ian

0 Kudos
Message 5 of 11
(4,302 Views)

Hello James,

 

I was just rereading your message and realized I missed one of your points.  You wrote, "If all the DI are controlled to go into the card at the same time...".   Yes, each time DI is received at the same time.    The DI lines are used to represent a numerical value and this numerical value identifies the type or category of event that occurred on the external equipment. For example, my application has traditionally received DI on Port0 so that the total range of numerical events is 1 to 255.  I now need more than 255 events, hence the need to receive DI on 16 or more DI lines.

 

Ian

 

0 Kudos
Message 6 of 11
(4,301 Views)

Hi Ian,

 

It sounds like using a second card with RTSI cable connectors will be your best option. You can set up a trigger on a DI channel and have that trigger exported across the RTSI bus to have the DI on the second card synchronized with the first. Then if you use correlated DIO for both these cards by sharing the AI sample clock, you should be able to achieve what you have described. 

 

Regards,

 

James D.
Applications Engineer
National Instruments
0 Kudos
Message 7 of 11
(4,296 Views)

Hello James,

 

You wrote, "If you are using multiple boards with RTSI, however, you will still need to trigger off a channel and share that trigger over the RTSI bus".  How exactly does the first board 'trigger' the second board?  Can you provide sample C/C++ code that illustrates how this is done?

 

Thanks,

 

Ian

0 Kudos
Message 8 of 11
(4,292 Views)

Hi Ian,

 

Once you have set up the triggers and sample clock for the first board it is just a matter of including the DAQmxExportSignal function in your code. This function allows you to route a digital trigger along the RTSI bus so the second card can use the same signal as the source of its digital start trigger.

 

I've included the links to the C reference help for this function.

 

https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxexportsignal.html

 

https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/mxcprop/attributeclassexportsignal.html

 

Regards,

 

James D.
Applications Engineer
National Instruments
0 Kudos
Message 9 of 11
(4,285 Views)

Hello James,

 

I have been writing code to test correlated DIO from multiple devices.  I want to be able to determine how many DI lines a NI device supports with correlated DIO.   For example, the NI6225 supports only 8 lines while the 6229 supports 16 lines.  How do I use NIDAQmx to determine the number of DI lines a NI device supports with correlated DIO?  Let me know if I should post this question in a new thread.

 

Ian

0 Kudos
Message 10 of 11
(4,265 Views)