- From: rph <rph_at_inventati.org>
- Date: Fri, 27 Aug 2004 16:10:47 +0200
Hi to all,
I'm not much in confidence in writing programs for acquiring datas. I installed comedi in my debian laptop and I just want to acquire the 16 analog input channels of my ni-daq 6024e pcmcia in a continuous way with a given sampling rate. My problems come in reading the data buffer.
I wrote this kind of program:
#include <iostream>
#include <comedilib.h>
int main(int argc, char* argv)
{
unsigned int freq = 100;
comedi_t* device = comedi_open("/dev/comedi0");
unsigned int inp_subdevice = comedi_find_subdevice_by_type(device,COMEDI_SUBD_AI,0);
unsigned int out_subdevice = comedi_find_subdevice_by_type(device,COMEDI_SUBD_AO,0);
unsigned int aref = AREF_GROUND;
unsigned int out_channel = 0;
unsigned int channel = 0;
unsigned int n_chan = 16;
unsigned int range = 0;
comedi_range* rng = comedi_get_range(device,inp_subdevice,channel,range);
unsigned int chanlist[n_chan];
for (int i=0;i<n_chan;i++)
chanlist[i]=CR_PACK(channel+i,range,aref);
double out_voltage = 5; // 5 volts for output channel
lsampl_t maxdata = comedi_get_maxdata(device,inp_subdevice,out_channel);
unsigned int data_len = 160;
lsampl_t data[data_len];
memset(data,0,data_len);
cmd->subdev = inp_subdevice;
cmd->flags = 0;
cmd->start_src = TRIG_NOW;
cmd->start_arg = 0;
cmd->scan_begin_src = TRIG_TIMER;
cmd->scan_begin_arg = 1e9/freq;
cmd->convert_src = TRIG_TIMER;
cmd->convert_arg = 5000; /* given by test */
cmd->scan_end_src = TRIG_COUNT;
cmd->scan_end_arg = n_chan; /* number of channels = 16 */
cmd->stop_src = TRIG_NONE;
cmd->stop_arg = 0;
cmd->chanlist = chanlist;
cmd->chanlist_len = n_chan;
ret=comedi_command(device,cmd);
return 0;
}
and now I just wanto to put the 16 channels datas in a buffer and be able to read them and to write in a file i.e.
Can anoyone help me please?
thanks,
Raphael Bartalesi
Received on 2004-08-27Z13:10:47