LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

programing PXI-6509

 

Hi;

 

I must do a high level function to write/read a DIO PXI-6509 port

I am using NIDAQmx library functions as low level functions.

 

The question is, what is the better way to do this?

 

option1:

 

<pseudocode>

 

high_level_function()

{

1.DAQmxCreateTask

2.DAQmxCreateDOChan / DAQmxCreateDIChan

3.DAQmxStartTask

4.DAQmxWriteDigitalU8 / DAQmxReadDigitalU8

5.DAQmxStopTask

6.DAQmxClearTask

}

 

So, in this option everytime you call this function, you have to do all the low level functions

 

option2:

 

<pseudocode>

 

high_level_function_1()

{

1.DAQmxCreateTask

2.DAQmxCreateDOChan / DAQmxCreateDIChan

3.DAQmxStartTask

 

}

 

high_level_function_2(taskHandle)

{

1.DAQmxWriteDigitalU8 / DAQmxReadDigitalU8

}

 

high_level_function_3()

{

1.DAQmxStopTask

2.DAQmxClearTask

 

So, in this option the task remaind created while the program are running,

and I have tu use global variable (TaskHandle myTaskHandle) because of high_level_function_2 have it as parameter

and I have to use this function in another file.c of the project.

 

I hope to be enough clear.

 

any suggestions?

 

 

 

 

 

 

 

0 Kudos
Message 1 of 3
(3,681 Views)

Norak

 

I have used option 2 for a silimar requirement.  To limit the scope of the global (and hide all of the excessive overhead that NIDAQmx requires for simple functions) place the functions in a seperate c file  or build the functions into a DLL.  

 

Option 2 is also my recomendation because it is only a single task that is running continousally the valules on the output ports will remain constant  i do not beleve that the valules written to the port will remain constant when the NIDAQmx task is closed. 

 

 

Colin

 

0 Kudos
Message 2 of 3
(3,671 Views)

 

Hi,

 

thanks for your replay.

I check that if the task finish the DIO set remain in its state...

 

 

0 Kudos
Message 3 of 3
(3,664 Views)