problems with code NI_6704

Hi All;
 I got the code working here it is;
======================================
/*
 * Based on Tutorial example #2
 * Part of Comedilib
 *
 * Copyright (c) 1999,2000 David A. Schleef <ds_at_schleef.org>
 *
 * This file may be freely modified, distributed, and combined with
 * other software, as long as proper attribution is given in the
 * source code.
 *
 * This code was modified to show a write to a dac, followed by a
 * delayed read.
 */

#include <stdio.h>		/* for printf() */
#include <comedilib.h>

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[])
{
	comedi_t *cf;
	lsampl_t data;
	int maxdata,i;
	double volts;
	comedi_range *cr;
	unsigned int delay = 1000000;

	cf = comedi_open("/dev/comedi0");
	maxdata = comedi_get_maxdata(cf, subdev, chan);
	cr = comedi_get_range(cf, subdev, chan, range);
	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.000;
	data = comedi_from_phys(volts, cr, maxdata);
	for (i=0;i<16; i++) //hit all 16 voltage channels
		comedi_data_write(cf, subdev, i,0, aref, data);
	comedi_data_read_delayed(cf, subdev, chan, range, aref, &data, delay);
	// use the delayed read to allow the dacs to settle
	volts = comedi_to_phys(data, cr, maxdata);
	printf("0x%X %g\n", data, volts);
	return 0;
}
 

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

Received on 2005-04-13Z17:51:15