 LouisJL
		
			LouisJL
		
		
		
		
		
		
		
		
	
			09-15-2005 07:19 PM
 WM_John_Weeks
		
			WM_John_Weeks
		
		
		
		
		
		
		
		
	
			09-16-2005 10:49 AM
09-16-2005 11:19 AM
The code resulting in the divide by zero is listed below. The line where the divide by zero error occurs is marked by
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <stdio.h>
#include "NIDAQmx.h"
#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }
int main(int argc, char *argv[])
{
 int32       error=0;
 TaskHandle  taskHandle=0;
 int32       read;
 float64     data[1000];
 char        errBuff[2048]={'\0'};
 /*********************************************/
 /*/ DAQmx Configure Code
 /*********************************************/
 DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
 DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"USBDAQ/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
 DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));
 /*********************************************/
 /*/ DAQmx Start Code
 /*********************************************/
 DAQmxErrChk (DAQmxStartTask(taskHandle));//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 /*********************************************/
 /*/ DAQmx Read Code
 /*********************************************/
 DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data,1000,&read,NULL));
printf("Acquired %d points\n",read);
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;
}
 WM_John_Weeks
		
			WM_John_Weeks
		
		
		
		
		
		
		
		
	
			09-16-2005 11:33 AM - edited 09-16-2005 11:33 AM
Message Edited by WM John Weeks on 09-16-2005 09:37 AM
 Pellaeon
		
			Pellaeon
		
		
		
		
		
		
		
		
	
			12-11-2005 06:36 AM
 WM_John_Weeks
		
			WM_John_Weeks
		
		
		
		
		
		
		
		
	
			12-12-2005 10:46 AM
12-12-2005 03:36 PM
Hi Pallaeon,
DAQmx with Borland Delphi is not officially supported. However, I found a knowledgebase with information that should help you with the "divide by zero" exception: Can I Make NI-DAQmx Calls From Borland Delphi?
LouisJL: I think that John Weeks has provided a viable workaround to the problem. You can also try upgrading to a newer version of the DAQmx driver and running some shipping examples to see if you still receive the error.
Regards,
Hal L. 
 Pellaeon
		
			Pellaeon
		
		
		
		
		
		
		
		
	
			12-13-2005 02:00 AM
