12-05-2007 07:29 AM
#include
<stdio.h>#include
<NIDAQmx.h>#define
DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int
main(void){
int32 error=0,k=0;
TaskHandle taskHandle=0;
TaskHandle taskHandleCtr=0;
uInt64 sampsPerChanToAcquire=50;
int32 numSampsPerChan=50;
int j;float64 rate=100;
uInt32 data[8]={1,0,1,0,1,0,1,0};
char errBuff[2048]={'\0'}; /*********************************************/ // DAQmx Configure Code /*********************************************/DAQmxErrChk (DAQmxCreateTask(
"",&taskHandle));DAQmxErrChk (DAQmxCreateTask(
"",&taskHandleCtr));rate=40;
numSampsPerChan=60;
printf(
"digueu:\n");scanf (
"%d",&j);k=j;
DAQmxErrChk (DAQmxCreateDOChan(taskHandle,
"Dev1/port0","",DAQmx_Val_ChanForAllLines));DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,
"/Dev1/Ctr0InternalOutput",1,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandleCtr,
"Dev1/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0,rate,0.5));DAQmxErrChk (DAQmxCfgImplicitTiming (taskHandleCtr,DAQmx_Val_FiniteSamps,500));
/*********************************************/ // DAQmx Write Code /*********************************************/DAQmxErrChk (DAQmxWriteDigitalU32(taskHandle,k,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));
/*********************************************/ // DAQmx Start Code /*********************************************/DAQmxErrChk (DAQmxStartTask(taskHandle));
DAQmxErrChk (DAQmxStartTask(taskHandleCtr));
}
12-12-2007 02:56 AM
Hi
Novice 22
what is exactly the problem that you have when you run the program with scanf?
does the function not work properly? What is the error code?
What is the environment where you are programming? And what is the type of C
that you are using? ANSI C, C, C++, Visual C...
The code is right so I suppose that you forgot link
the library or the path is wrong.
12-13-2007 11:59 AM
the problem is with the function scanf. When i used it, i can not write digital lines.
I have no signal on port when i use scanf
Environment: VC++ 2005, programming in ansi c.
Thank you,
Novice