From: David Schleef Date: Fri, 2 Jun 2000 21:52:45 +0000 (+0000) Subject: rewrite X-Git-Tag: r0_7_10~13 X-Git-Url: http://git.tremily.us/?p=comedilib.git;a=commitdiff_plain;h=3aeb987160ac4184033f674aebee5628675ec8d3 rewrite --- diff --git a/demo/mode2.c b/demo/mode2.c index 45013e3..fd17b43 100644 --- a/demo/mode2.c +++ b/demo/mode2.c @@ -1,15 +1,17 @@ /* - A little input demo for mode 2 + A little input demo for mode 4 - Mode 2 uses two different timers to convert samples. - The primary timer determines the time between scans, - and the secondary timer determines the time between - samples in a scan. + Mode 4 uses an external trigger to repeatedly trigger a + scan of samples. (This is different from mode 3, which + triggers an individual sample.) Thus, for each external + trigger, n_chan samples are converted. - The time between scans is in trigval; the time - between samples is selected by trigval1. Conversion - from seconds or Hz is done using the standard timer - routines. + If you have multiple external trigger lines, the + particular trigger line is selected by trigval. + + The time between samples in a scan is selected + by trigval1. Conversion from seconds or Hz is done + using the standard timer routines. */ @@ -22,41 +24,62 @@ #include #include -#define N_SCANS 10 -#define N_CHANS 16 +#define N_SCANS 4 +#define N_CHANS 4 int subdevice = 0; -int chan=0; -int range = 0; -int aref = AREF_GROUND; +int channels[N_CHANS] = { 0, 1, 2, 3 }; double freq = 1000; +int range = 0; +int aref = 3; +int external_trigger_number = 0; -#define N_SAMPLES 1000 +#define N_SAMPLES (N_CHANS*N_SCANS) -double data[N_SAMPLES]; +sampl_t data[N_SAMPLES]; int main(int argc, char *argv[]) { char *fn = NULL; - int i; + comedi_trig it; + int err; + int n,i; comedi_t *dev; + double actual_freq; + unsigned int chan[N_CHANS]; - fn = "/dev/comedi0"; + fn = "/dev/comedi3"; dev = comedi_open(fn); -#if 0 - for(i=0;i<10;i++){ - range=comedi_find_range(dev,subdevice,chan,0,-i,i); - printf("%d\n",range); + it.subdev = 0; + it.mode = 2; + it.flags = 0; + it.n_chan = 1; + it.chanlist = chan; + it.data = data; + it.n = N_SCANS; + it.trigsrc = 0; + it.trigvar = 10000; + it.trigvar1 = 10000; + + /* pack the channel list */ + for(i=0;i