Mixing AD conversion and DIO writes

Hi,

I'm looking for some advice for how to best achieve some sampling
requirements using Comedi. I'm using a card, NI AT-MIO-16E-10, which
is rather old but should be OK for my purpose. This card supports
100kS/sec and has a 12bit AD converter.

I need to do both AD conversions on 4 channels as well as toggle some
digital I/O lines every so often. Ideally, the digital I/O lines needs
to be toggled every few hundred milliseconds but it's not that time
critical. The digital I/Os are used to keep a watchdog alive on a
connected board. I also need to sample data on 4 channels (all with
potentially different ranges) and then run those samples through a
filter. I don't need continous sampling though, but while sampling I'd
like to sample rather quickly so that I don't get aliased noise. I
also can't toggle the digital I/O lines while sampling, noise from the
digital I/O lines will distort the AD conversions.

So what I was looking to do was something like this:

Sample on 4 channels _at_ 25kS/sec each = 100kS/sec total.

If I sample 20000 samples total that should should take about 250ms or
so, and should give me 5000 samples per channel. Assuming each sample
is 2 bytes, this should also fit in the default buffer which at least
for my card seems to be 64kB. After taking the 20000 samples I can
process this data, run it through the filter etc, as well as toggle
the digial I/O line and then start the process over again.

Question is, should I use a command to do this ? Does this mean I need
to start a command that makes 5000 scans and then stops or is there a
better way ? How can I check if the command is done without relying on
counting the number of bytes that I can read() from the device (what
happens if there is an error ?). Any thought/ideas are welcome !

Thanks
-- 
Daniel Nilsson

Received on 2005-03-13Z03:15:36