05-05-2009 04:51 AM
Hi,
The product I using is NI-USB-6229.
Currently I am developing my own application to connect to the machine by using delphi, I get the API from http://digital.ni.com/public.nsf/allkb/A6715AA42405ACD786256F0A00633B8F.
My problem is with the digital I/O. I would like to set the state of the lines to "high". Following is my code:
ErrorMsg:=DAQmxCreateTask('task',@TaskHandle);
ErrorMsg:=DAQmxCreateDOChan(TaskHandle,'Dev1/port0/line8','a',DAQmx_Val_ChanForAllLines);
ErrorMsg:=DAQmxSetDOLineStatesStartState(Taskhandle,'Dev1/port0/line8',10192);
ErrorMsg:=DAQmxStartTask(TaskHandle);
However, the program failed at the 3rd line, I catch the error msg by using this function:
DAQmxGetExtendedErrorInfo(errorstr,194);
It return me following error message:
Measurements:Specified property is not supported by the device or it is not applicable to the task.
Property:DAQmx_DO_LineState
Channel Name:a
Task Name:task
StatusCode:-200452
What I want to do is just same like the "Digital I/O" tab of "test panels" in "Measurements & Automation".
I want to change the direction of the line(input or output) and the state of the line (high or low) then start it.
I not sure what going wrong with my code or my coding direction is totally wrong?
At the time being, I would like to mention that, it is functioning perfectly in Measurements & Automation tool.
I highly appreciate your help.Thank you.
05-07-2009 03:08 AM
Hi Pnh,
In the program that you do, you were creating a DO task and then you set up a start up states of the particular line. It is not the right function to use to set a digital data as in the test panel in MAX.
You probably would like to take a look at the example code on how to do simple digital signal generation as copied below.
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateDOChan(taskHandle,"Dev1/port0","",DAQmx_Val_ChanForAllLines));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
/*********************************************/
// DAQmx Write Code
/*********************************************/
DAQmxErrChk (DAQmxWriteDigitalU32(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,&data,&written,NULL));
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
I hope that this explanation helps.
09-26-2011 06:43 AM
Hello! Can anyone tell me what is DAQmxSetDOLineStatesStartState used for? I would like to configure a NI-PCI-6723 board so that its digital I/O ports to be outputs and with the '0' logic on each digital line when the board is powered up. By default, I see that the lines are in '1' at startup and this bothers me! Can I change this so the lines startup with '0'? I'm wondering if the function "DAQmxSetDOLineStatesStartState" helps me with my task. Can anyone please help me with this problem?