Re: Continuous Acquisition

I'm using a much later version of the driver but this works for me:

#include <stdio.h> /* for printf() */
#include <comedilib.h>
#include <sys/times.h>
#define LowestPossibleVoltage  -10.0;
#define HighestPossibleVolated  10.0;

int subdev = 0; /* change this to your input subdevice */
int chan = 3; /* change this to your channel */
//int range = 0; /* more on this later */
int aref = AREF_GROUND; /* more on this later */
double voltdiff = 2.0;
double MaxVoltageReached = LowestPossibleVoltage;


int main(int argc,char *argv[])
{
  comedi_range *range;
 int maxdata;

  double volts;
  int lastcheck = 0;
  comedi_t *it;
  lsampl_t data;
  it=comedi_open("/dev/comedi0");
  lastcheck = times(0);

  range = comedi_get_range(it, subdev, CR_CHAN(chan), CR_RANGE(chan));
  maxdata = comedi_get_maxdata(it, subdev, CR_CHAN(chan));

  while(1)
    {
      //pause for a little while
      while(times(0)- lastcheck <10);

      comedi_data_read(it,subdev,CR_CHAN(chan),CR_RANGE(chan),
AREF_GROUND,&data
);
      volts = comedi_to_phys(data, range, maxdata);
      if (volts >MaxVoltageReached) MaxVoltageReached = volts;
      printf("Data: %d\tVolts: %f\tMax Volatage: %f\n",data -1600, volts,
MaxVol
tageReached);
      lastcheck = times(0);
    }
  return 0;
}


/Jeremiah

Received on 2003-10-18Z15:17:44