Re: Slow varying inputs

On Thu, Mar 10, 2005 at 09:35:38PM -0500, Sandy Pond wrote:
> On Thu, 2005-03-10 at 18:38 -0500, Daniel Nilsson wrote:
> > On Tue, Mar 08, 2005 at 10:07:15AM -0500, Sandy Pond wrote:
> > > On Sun, 2005-03-06 at 22:26 -0500, Daniel Nilsson wrote:
> > So the next question is then where I put in the filter... What I did
> > what just scale my samples from float by a factor (10000 in my case )
> > so that I could treat them as unsigned short int (16bits). My A/D
> > converter is a 16 bit converter as well, but I can't quite figure out
> > from the Comedi documentation if this means I can run the samples
> > directly from the read() command through the filter or if I first need
> > to do the comedi_to_phys() function ? How is the sign information
> > stored ? 
> 
> Well.  Normally, in all the equipment I've ever used, D/A and A/D
> converters read and write unsigned integers.  For bipolar ranges the "0
> Volts" is usually half range.  
> 
> Example, for a 16 bit A/D.  Full range would be 2^16 or 65536 counts.
> If the full scale range of the A/D is set to 0/+5 Volts, then a count of
> 0 would represent 0 Volts and a count of 65535 would represent +5 Volts.
> If the range is set to -5/+5 Volts, then a count of 0 would be -5 Volts
> and a count of 65535 would be +5 Volts.  Then half range or 32767 counts
> would represent 0 Volts.  The routine I attached was written to operate
> on the raw A/D or D/A counts, therefore, is not applicable for signed
> integers.
> 
> What you want to do is run the raw 16 bit A/D samples through the filter
> before they are converted to floats.  If you convert to floats then back
> to integers you are losing accuracy in your data.  

I have looked into this some more and indeed this is the way the
comedi drivers work as well. The 16 bit data that comes from the board
are as far as I can tell just the 16 bits coming from the AD converter
which works like you described above. I tried inserting your filter
code before converting the samples to floats and that works just fine.

I was getting confused since I thought I had a 16bit AD converted
which I actually don't, it's a 12 bit converter... Let's just say that
it helps to read the correct manual !

Looks like this gives an efficient filtering solution, thanks for the
code and your help ! I would think your filter code should be a good
candidate to replace the slow-varying API that today is deprecated.

Thanks
-- 
Daniel Nilsson

Received on 2005-03-13Z03:22:34