Re: multiq3 driver: wrong value returned

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 13 October 2003 03:02 pm, Frank Mori Hess wrote:
> On Monday 13 October 2003 01:57 pm, Peter Gawthrop wrote:
> > Hi,
> >
> > I am using comedi-0.7.67 with the multiq3 driver modified to avoid the
> > "Fix incorrect return value of AI insn function" (see most recent cvs
> > mod.)
> >
> > The analogue input (Quanser Consulting MultiQ-3) seems to return the
> > correct voltage V when V is negative. But when V is positive, it
> > returns V-5 volts. This seems to happen on all channels.
>
> Are you sure it doesn't return -5-V for negative V?  That's what I get
> it should be when looking at the docs and driver.

Hmm, actually the docs contradict themselves.  Anyways, here is a patch 
against 0.7.67 that will probably work.


fmhess_at_morizuma:~/cvs/comedi/comedi/drivers> cvs diff -ubB -r r0_7_67x -r 
1.19 multiq3.c
Index: multiq3.c
===================================================================
RCS file: /var/cvs/comedi/comedi/drivers/multiq3.c,v
retrieving revision 1.17
retrieving revision 1.19
diff -u -b -B -r1.17 -r1.19
- --- multiq3.c   15 Feb 2003 18:35:46 -0000      1.17
+++ multiq3.c   13 Oct 2003 20:12:34 -0000      1.19
_at__at_ -103,7 +103,8 _at__at_
 {
        int i,n;
        int chan;
        unsigned int hi, lo;
+       int16_t raw_data;

        chan = CR_CHAN(insn->chanspec);
        outw(MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan<<3),
_at__at_ -125,10 +126,12 _at__at_

                hi = inb(dev->iobase + MULTIQ3_AD_CS);
                lo = inb(dev->iobase + MULTIQ3_AD_CS);
- -               data[n] = ((hi << 8) | lo) & 0xfff;
+               raw_data = ((hi << 8) & 0xff00) | (lo & 0xff);
+               raw_data += 0x1000;
+               data[n] = raw_data & 0x1fff;
        }

- -       return i;
+       return n;
 }

 static int multiq3_ao_insn_read(comedi_device *dev, comedi_subdevice *s,


- -- 
Frank

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/iwkB5vihyNWuA4URAkAEAKCrGLjZNaJ1UMwp0Iqe0yHmbeTsHgCgz06p
xhIiatoZcBipiFEr+stzX4Y=
=gZbZ
-----END PGP SIGNATURE-----

Received on 2003-10-13Z19:20:16