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;
}
/*********************************************************************/