problems with code

Hi All;
 I'm still not having any luck with the NI_6704 card. Here is the code I'm trying based on the tut2.c in comedilib

// snip of headers

int subdev = 0;			/* change this to your input subdevice */
int chan = 0;			/* change this to your channel */
int range = 0;			/* more on this later */
int aref = 0;		/* more on this later */

int main(int argc, char *argv[])
{
	char s[80];
	comedi_t *cf;
	lsampl_t data;
	int maxdata,i;
	double volts;
	comedi_range *cr;
	unsigned int delay = 1000000;

	cf = comedi_open("/dev/comedi0");
	strcpy(s, comedi_get_board_name(cf));
	printf ("\n found %s",s);
	maxdata = comedi_get_maxdata(cf, subdev, chan);
	cr = comedi_get_range(cf, subdev, chan, range);
	printf ("\n maxdat is %d, cr is %d",maxdata,*cr);
	comedi_data_read(cf, subdev, chan, range, aref, &data);
	volts = comedi_to_phys(data, cr, maxdata);
	printf("\n0x%X %g\n", data, volts);
	volts= 0.00;
	data = comedi_from_phys(volts, cr, maxdata);
	for (i=0;i<16; i++)
		comedi_data_write(cf, subdev, i, cr, aref, &data);
	
	comedi_data_read_delayed(cf, subdev, chan, range, aref, &data, delay);
	volts = comedi_to_phys(data, cr, maxdata);
	printf("0x%X %g\n", data, volts);
	return 0;
}
 

 when compiled and run I get;

found PCI-6704
maxdat is 65535, cr is 0
0x0 nan
0x8000 0.00015259

 but the voltage stays at -10.240, and if I rerun the program I get the same output.
Any ideas on what I'm doing wrong?
Pat



==========================
Pat Ford
Realtime systems Developer
National Research Council
Canada

Received on 2005-04-13Z14:46:49