Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ Examples Problem

Hello,
 
Yesterday i asked how to drive a motor with DAQ card in C but no one response. Anyway, i used the code in the Examples..
 
Write to digital port code... But it didn't work, i have some problems. And there is no place that we can read the details of NIDAQ functions, company ust wrote the functions that's all. They didn't have any data sheet to understand what each function is doing. All i had the header file. Now my question is i want to send to motor driver to HIGH and LOW. In the code i set data(variable) 1 or 0 but it didn't work out. What is the reason? Second point i am sending this 1 and 0 only one line in one port for example port0/line2 why i am activating all channel at the beginning(DAQmxCreateDOChan(....))??? My last question is about Writing to port function (DAQmxWriteDigitalU32(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,&data,&written,NULL); ).. Could you please give me what parameters are these??? Which line i am writing in that port0.. Which parameter consists that.
 
I also see the example for writing the whole channel to 1 and 0... I tried with it also but it didn't work out.. And i dont want to write anything to all channel everytime. I am just using few of them so i don't need to set 8 lines in the port always..
 
I really need help here i hope someone will answer this question.. Thank you.
 
And i hope NI prepared better datasheets for the functions(better than header files :)).
 
Thanks again...
 
/*********************************************************************/
#include <stdio.h>
#include <NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
 int         error=0;
 TaskHandle taskHandle=0;
 uInt32      data=0xffffffff;
 char        errBuff[2048]={'\0'};
 int32  written;
 /*********************************************/
 // 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));
Error:
 if( DAQmxFailed(error) )
  DAQmxGetExtendedErrorInfo(errBuff,2048);
 if( taskHandle!=0 ) {
  /*********************************************/
  // DAQmx Stop Code
  /*********************************************/
  DAQmxStopTask(taskHandle);
  DAQmxClearTask(taskHandle);
 }
 if( DAQmxFailed(error) )
  printf("DAQmx Error: %s\n",errBuff);
 printf("End of program, press Enter key to quit\n");
 getchar();
 return 0;
}
 
/*********************************************************************/
0 Kudos
Message 1 of 5
(3,660 Views)
Did you not install all of the files? Look in Start>Programs>National Instruments>NI-DAQ. See if you don't have the NI-DAQmx C Reference Help listed there.
0 Kudos
Message 2 of 5
(3,657 Views)

Thank you sooo much. I am really sorry because i said there is no reference for functions. Now i understand each point in the code.

But there is one last thing i wanna askone last thing.

Am i right using 1 or 0 as a HIGH and LOW in the code.

 

I mean you know HIGH and LOW in digital I/O, i am using 1 and 0... Is this right or i need to use something special to get this?

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

Hello everyone,

 

At the end i found the solution. While writing to digital lines in the ports in the example NI is using that function :

DAQmxWriteDigitalU32(...)

With that function it isn't writing to the port. However used another function WriteDigitalLines function it worked out. So it is working very good right now. And to the everyone, when i used writing digital lines function, 1 is HIGH and 0 is LOW.

But i dont know why it didnt work out with Write Digital U32 function..

0 Kudos
Message 4 of 5
(3,609 Views)
could you please write the whole c-program.i need it.Thanks in advance.
0 Kudos
Message 5 of 5
(3,382 Views)