Question about comedi_{to,from}_phys()

Hi list,

I've got a few questions concerning the conversion functions to and from
physical units. 
For the record, I'm working with an NI PCI-6024E card with 12 bits
analog out and in (a -10V to 10V range). 

When I use comedi_from_phys() to send 0V to the AO, it sends a bit value
of 2048. Which seems correct to me. When I send 0V to the AI it reads
2048 (which, again, seems correct), but comedi_to_phys() converts it to
0.002442V. Which seems incorrect to me. 

When I looked at the source code of comedi_to_phys() in range.c of
comedilib, I found that the bit value is divided by maxdata (4095 in my
case) and not maxdata + 1, which is the total number of bitlevels
available. 
Could someone explain to me why that is?

I see that dividing by maxdata + 1 gives a problem when the maximum bit
value (4095) is read in. This would (in my case) not be converted to
10V, but to 9.995. However, in that case this would be only value that
is "wrong" (but since the out-of-range behaviour is set to NaN by
default when the maxdata bit value is measured this would not be a
problem, I think).

Am I missing something here, or is would it be better to devide by
maxdata +1 indeed?


Lennart.

-- 
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
L.C. Karssen
Department of Physics and Astronomy
Faculty of Science
Utrecht University
Princetonplein 1
3584 CC  Utrecht
The Netherlands

tel.: +31 (0)30-253-2208
fax.: +31 (0)30-253-7468
e-mail: L.C.Karssen_at_phys.uu.nl
www: http://www1.phys.uu.nl/wwwaoud
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

Received on 2007-06-01Z15:10:43