Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Duplex implementation in SW for NI 9402

I'm pretty new with NI toolset, but I have a following question:

 

I need to use NI 9402 on cDAQ-9171 chassis to implement SPI bus in my SW. So I need to be able read and write data simultaniously from MOSI and MISO mapped lines.

My understanding that I have two create separate virtual channels for MISO line and another channel for MOSI, CLK, CS lines and use these channels from the different tasks. Now the question here is: how I can do this simultaniously?

 

Thanks in advance!

Dmitry

0 Kudos
Message 1 of 6
(5,788 Views)

Dimash7,

 

Since you’re new to LabVIEW, I think it would be helpful for you to walk through some examples on synchronization with digital I/O. You should have some examples in Help>>Find Examples...>>Hardware Input and Output that you can browse through or you can search ni.com for some KnowledgeBase articles or community examples on the website. I found one that should be helpful to you.

https://decibel.ni.com/content/docs/DOC-11700

Blake C.
Applications Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 2 of 6
(5,764 Views)

Thanks for respond!

 I have another question now: I'm trying to adopt an SynchAI example for my purposes. My idea is setup trigger for every EdgeRaise on line0 (CLK) and get a callback call where I read a status of line1. But this code throws a following message when trying to execute line 9:

 

There is a code I'm trying to test:

 

1 DAQmxErrChk (DAQmxCreateTask("",&AItaskHandle));
2 DAQmxErrChk (DAQmxCreateDIChan(AItaskHandle,"cDAQ3Mod1/port0/line0","",DAQmx_Val_ChanForAllLines));
3 DAQmxErrChk (DAQmxCfgSampClkTiming(AItaskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
4 DAQmxErrChk (GetTerminalNameWithDevPrefix(AItaskHandle,"port0/line1/StartTrigger",trigName));

5 DAQmxErrChk (DAQmxCreateTask("",&AOtaskHandle));
6 DAQmxErrChk (DAQmxCreateDOChan(AOtaskHandle,"cDAQ3Mod1/port0/line1","",DAQmx_Val_ChanForAllLines));
7 DAQmxErrChk (DAQmxCfgSampClkTiming(AOtaskHandle,"",5000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
8 DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(AOtaskHandle,trigName,DAQmx_Val_Rising));

 

9 DAQmxErrChk (DAQmxWriteDigitalU8(AOtaskHandle, 1000, 0, 10.0, DAQmx_Val_GroupByChannel, WrArray, & writtenSamplesNum, NULL));

 

10 DAQmxErrChk (DAQmxStartTask(AOtaskHandle));
11 DAQmxErrChk (DAQmxStartTask(AItaskHandle));

 

This is a message I'm getting:

 

DAQmx Error: Source terminal to be routed could not be found on the device.

Make sure the terminal name is valid for the specified device. Refer to Measurem
ent & Automation Explorer for valid terminal names.
Property: DAQmx_DigEdge_StartTrig_Src
Property: DAQmx_DigEdge_StartTrig_Edge
Source Device: cDAQ3
Source Terminal: port0/line1/StartTrigger

Task Name: _unnamedTask<1>

Status Code: -89120

Do I miss anything here?

Thanks,

Dmitry

0 Kudos
Message 3 of 6
(5,688 Views)

Dimash7,

 

Thanks for keeping me updated. I researched some information related to the error you’re receiving and found some information that might be helpful. First off, what language are you using? Is this CVI? What SPI bus are you using? What is your setup with your 9171 and 9402? Your issue could be that you are not calling the line properly so the data isn’t even getting to the buffer. I saw a helpful KB (http://digital.ni.com/public.nsf/allkb/E88C1861990F0DFE8625714F007517CF?OpenDocument) that talks about this specific error being propagated by the way the terminal is referenced. In your code you reference “cDAQ3Mod1/port0/line0” when it may in fact need to be “/cDAQ3Mod1/port0/line0”. Please let me know if this error persists or if this KB is helpful. Thanks for letting me help.

Blake C.
Applications Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 4 of 6
(5,670 Views)

Thanks Blake for your help!

I'm using C language to programm my device. I'm trying to write a software that implements SPI protocol on top of 9402 box.

 

Your hint didn't help - the same issue.

My problem is definetely in a triggering setup, because if I remove trigger setup and stay only with write operation, it works well and I can see signals I generate on a scope connected to line1. So, terminal:

 

cDAQ3Mod1/port0/line1 and /cDAQ3Mod1/port0/line1 works well, but after trigger setup it becomes to be:

/cDAQ3Mod1/port0/line1/StartTrigger and it doesn't work.

 

I will appreciate any idea how this issue can be solved.

 

Thanks,

Dima

0 Kudos
Message 5 of 6
(5,655 Views)

Dimash7,

In line 8, what terminal does ‘trigName’ reference in MAX? I found in our help files that the second object in the DAQmxCfgDigEdgeStartTrig function should be “The name of a terminal where there is a digital signal to use as the source of the trigger.” Does this terminal name match the terminal name in MAX? If they are different, what is the terminal name in MAX for the terminal you’re attempting to reference?

Blake C.
Applications Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 6 of 6
(5,641 Views)