Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about DAQmxCreateDOChan / DAQmxWriteDigitalLines (NI-USB 6501)

Hi,

I'm creating an application in Java in which i call (trough JNI) the functions DAQmx C functions. I've been searching the forums and other documentation, but couldn't find an answer to my question.

I need to write an algorithm that (very simlply) puts an array of outputs to hi. However, i can't figure out how the DAQmxCreateDOChan and the DAQmxWriteDigitalLines functions work exactly. Let me explain myself through an example:

- phase1: i create a channel with the DAQmxCreateDOChan, specifying a list of lines (sparated by commas as stated in the C reference help). Lets say i put lines 0, 1, 2, and 4to HI. I guess the function call in this case will look llike this, assuming all operations are on dev0:

DAQmxCreateDOChan(taskHandle,"dev0/line0, dev0/line1, dev0/line2, dev0/line4",DAQmx_Val_ChanForAllLines));
I call the DAQmxWriteDigitalLines, and lines 0, 1, 2 and 4 are set to HI. No problems there, i guess.

- phase2: i create another digital channel with DAQmxCreateDOChan, specyfying another listof lines. Lets say lines 1, 2 and 4. Functon call will look like this then:

DAQmxCreateDOChan(taskHandle,"dev0/line1, dev0/line2, dev0/line4",DAQmx_Val_ChanForAllLines));
Again, I call the DAQmxWriteDigitalLines function.

But then my questions is: how is the DAQmxWriteDigitalLines function going to handle this ? 

- Will line1 be set to LOW?
- And will lines 1, 2 and 4 stay HI thoughout the whole process, without interuption ?

The reason why I ask is the following: in the above example, I can not (and this is very important) have an interuption at any given moment in the 'HI-state' of lines 1, 2 and 4. I absolutely have to make sure that, in between switching, there is no interuption in the HI state of lines 1, 2 and 4. If there is a small interuption, my program is worthless. 

Another questin: in my example: do i need to clear the task through the DAQmxClearTask functon? I assume i have to ?

Thanks in advance for your ideas and hints. These are my first steps in the NI-DAQmx libraries, so i'm still learning a lot. I'm sorry if some of my questions are too obvious and are  traceable in the documentation.

Kind regards,

Sander

Message Edited by SanderG on 03-25-2009 03:42 PM
0 Kudos
Message 1 of 3
(6,035 Views)

Hi Sander

 

When you are going to create a second task using some of the same lines, while another one is already running, you are most likely to receive an error, because the output lines are already reserved. So I would advise to simply create one task containing all the lines you will need to write to.

 

Also, when a state has been set on a certain line, it will stay in that state untill a new state has been set or you reset the line states. See the following article about this:

 

http://digital.ni.com/public.nsf/allkb/E309E3FCC758DB1586256C8600702CE1?OpenDocument

 

The clear task also would not be necessary to use troughout the program. It is best to just start your task once, and stop/clear it only at the end of your program, when all I/O operations are finished.

 

A nice and quick tutorial about the most needed DAQmx functions can be found here:

 

http://zone.ni.com/devzone/cda/tut/p/id/2835

 

Best Regards

Michiel
Applications Engineer
NI Belgium
http://www.ni.com/ask
0 Kudos
Message 2 of 3
(6,019 Views)

Hi Michiel,

 

Thanks for your answer, it certainly gave me a lot of ideas. It's good to know that there will not be an interruption when a line was already set to 1.

 

After reading the articles, i know what to do !

 

Many thanks,

 

Sander

0 Kudos
Message 3 of 3
(5,996 Views)