07-19-2005 02:33 AM - edited 07-19-2005 02:33 AM
Message Edited by Rolly on 07-19-2005 04:34 PM
07-19-2005 09:13 AM
07-19-2005 09:31 AM
Hello,
I don't think DAQmx has the sort of function generation to choose from as if LabVIEW, but it is ok, I manage to overcome with proper array data. thx anyway
08-12-2005 01:52 AM
Hi all,
I managed to construct square waves of different amplitude (varying voltage output) and I want to change amplitudes on-the-fly using DAQmx C-functions. There is the code and the scope output. There is a gap while I stop the 1st sqwave generation then starts the next, but such gap is not desirable and must be eliminated, can anyone gives me a hand on this issue?
Thanks,
Rolly
Code:
08-12-2005 07:47 AM
08-12-2005 09:58 AM
08-13-2005 01:53 AM - edited 08-13-2005 01:53 AM
Hi,
Thanks for your advice, I am trying with no-regeneration mode and I found the following codes from NI website but forget exactly where it from, it compiles ok but as it runs, VC++ prompted with stack overflow error!? Where has it gone wrong? I am using a PCMCIA 6062E with Interrupt... Thanks!
// DAQmx_wfm_noregen.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <math.h>
#include <NIDAQmx.h>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#define PI 3.141592653
#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }
int main(void)
{
int32 error=0;
TaskHandle taskHandle=0;
char errBuff[2048]={'\0'};
bool32 done=0;
int i=0;
int32 written;
uInt32 writeBufferSpaceAvailable;
float64 data[250000*8];
for(;i<250000*8;i++)
data[i] = 9.95*sin((double)i*2.0*PI/100000.0);
/*********************************************/
/*/ DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"SCC1Mod17/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",250000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,250000*2));
DAQmxErrChk (DAQmxCfgOutputBuffer (taskHandle, 250000*2));
DAQmxErrChk (DAQmxSetWriteRegenMode(taskHandle,DAQmx_Val_DoNotAllowRegen));
/*********************************************/
/*/ DAQmx Write Code
/*********************************************/
DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle,250000,0,-1,DAQmx_Val_GroupByScanNumber,data,&written,NULL));
/*********************************************/
/*/ DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
printf("Generating voltage continuously. Press any key to interrupt\n");
while(!_kbhit())
{
DAQmxErrChk (DAQmxGetWriteSpaceAvail(taskHandle, &writeBufferSpaceAvailable));
printf("writeBufferSpaceAvailable : %d\n",writeBufferSpaceAvailable);
if(writeBufferSpaceAvailable > 250000)
{
DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle,250000,0,-1,DAQmx_Val_GroupByScanNumber,data,&written,NULL));
printf("data written : %d\n",written);
}
Sleep(100);
}
_getch();
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;
}
Message Edited by Rolly on 08-13-2005 03:55 PM
08-13-2005 02:10 AM
08-15-2005 12:11 PM
08-15-2005 10:38 PM
HI Daniel,
Please take a look at the attached pictures, the error prompt for the 1st no-regeneration example code, and the square waveform output I want to achieve.
Thx,
Rolly