09-24-2009 09:11 AM
Hi,
I want to construct a program for my NI USB 6009 (using Visual Studios/C++ 6.0) which:
1. Receive a trigg-signal and on the first rising signal start to write digital signals, after a certain delay.
2. After writing a certain amount of digital signals it should read an analog signal.
I have tried to write in different ways but I only receive errors... I would be glad for some tips and help. I am new in the area and excuse if I have done fatal errors.
This is one of my programs:
__________________________________________________________________________________________________________________
//ADC-program
// Definitions
#include "stdafx.h"
#include "NIDAQmx.h"
#include <stdio.h>
#include <cstdio>
#include <iostream>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
using namespace std;
int main(void)
{
int32 error=0;
char errBuff[2048]={'\0'};
TaskHandle taskHandle_1=0;
int32 aver_num=80; //samples to be written to Boxcar
const uInt8 dig_char_writ ={1}; //digitala char to write
int32 skrivna=0; //samples written to Boxcar
DAQmxErrChk (DAQmxCreateTask("Task_1",&taskHandle_1));
DAQmxErrChk (DAQmxCreateDOChan(taskHandle_1,"Dev1/port0/line7","",DAQmx_Val_ChanPerLine));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandle_1,"Dev1/ctr0",DAQmx_Val_Rising));
DAQmxErrChk (DAQmxCfgImplicitTiming(taskHandle_1,DAQmx_Val_FiniteSamps,1);
DAQmxErrChk (DAQmxWriteDigitalU8(taskHandle_1,aver_num, 1, 10.0, DAQmx_Val_GroupByChannel,&dig_char_writ,&skrivna,NULL));
DAQmxErrChk (DAQmxStartTask(taskHandle_1));
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle_1!=0 )
{
DAQmxStopTask(taskHandle_1);
DAQmxClearTask(taskHandle_1);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
____________________________________________________________________________________________________________________
This is what I receive, what is wrong and can I do like this? How to make it work?
1>igen5.cpp
1>.\igen5.cpp(32) : fatal error C1057: unexpected end of file in macro expansion
1>Build log was saved at "file://c:\Documents and Settings\Hanna\My Documents\Visual Studio 2008\Projects\T_win32consoleapplication\T_win32consoleapplication\Release\BuildLog.htm"
1>T_win32consoleapplication - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Kind Regards, Hanna
11-11-2009 09:16 AM