- From: Calin A. Culianu <calin_at_ajvar.org>
- Date: Tue, 27 Dec 2005 17:05:02 -0500 (EST)
Hi, I'm using an NI 6025e board and I wanted to do streaming asynchronous acquisition with multiple channels (16 AI channels) at 10kHz. That's 160kS/s, which is under the board's rated 200kS/s. Anyway, I am trying to do this, with as one would expect, a comedi command. However, the data looks horrible. It looks as though the samples are intermeshed with samples from other channels. Has anyone else had this problem? I am doing this using kcomedilib from a realtime task on RTLinux, by the way. Here is how I am setting up the comedi_cmd struct: cmd.subdev = ai_subdev; cmd.flags = TRIG_WAKE_EOS|TRIG_RT|TRIG_ROUND_DOWN; cmd.start_src = TRIG_NOW; cmd.start_arg = 0; cmd.scan_begin_src = TRIG_TIMER; cmd.scan_begin_arg = 166000; /* roughly 6 kHz */ cmd.convert_src = TRIG_TIMER; cmd.convert_arg = 5000; /* Settling time of 5us? What do I put here?! */ cmd.scan_end_src = TRIG_COUNT; cmd.scan_end_arg = 16; /* do 16 channels */ cmd.stop_src = TRIG_NONE; cmd.stop_arg = 0; for (i = 0; i < 16; ++i) chanlist[i] = CR_PACK(i, 0, AREF_GROUND); /* default gain and aref.. */ cmd.chanlist = chanlist; cmd.chanlist_len = i; And I am using a callback function that is called for each scan. It basically takes the data from a comedi_mmap()'d region (as imlpemented in kcomedilib). I first figure out how much data I have, by calling comedi_get_buffer_contents(). I figure out the offset into the buffer that the driver wants me to read from by calling comedi_get_buffer_offset(). I then copy the data, assuming it is sampl_t type, into some other memory region for processing. I then indicate the data was consumed by calling comedi_mark_buffer_read(). Anyway I have nailed this down to comedi -- why does it appear to interleave and intersperse separate channels in my scan? I was expecting the channels to appear in memory as defined in the chanlist above --- but for each scan they seem to somtimes appear that way, and at other times be interleaved and interspersed. What gives? Any help would be appreciated!! -Calin
Received on 2005-12-27Z22:05:02