Re: NI 6259 - Strange values for positive input voltate on analog in

On Friday 06 October 2006 04:38 am, M. Koehrer wrote:
> Hi Dave,
>
> thanks for your reply!
>
> >> Whenever the input voltage is negative, the value of data in
> >> comedi_data_read() is fine, it is something between 0x00000000 and
> >> 0x00007fff.
> >> However, whenever the input voltage is positive, the higher two bytes
> >> of data become 0xffff, the values are 0xffff8000 (for 0V) up to
> >> 0xffffffff (5V which is the maximum here). It looks as if the higher
> >> two bytes get set to 0xffff whenever the voltage becomes positive.
> >
> >Sounds like a the lsampl_t value obtained from comedi_data_read() is
> >somehow getting treated as a signed value that is then cast to a signed
> >32-bit value somewhere.   Can you post a code snippet that shows how
> >you're using comedi_data_read and the variable that gets the data.
>
> That was my first idea aswell. However, I deeped into the kernel driver
> and did a rt_printk there.
>
> In ni_mio_common (CVS version) at line 1378 I do a:
>                         if(boardtype.reg_type == ni_reg_m_series)
>                         {
>                                 data[n] =
> ni_readl(M_Offset_AI_FIFO_Data); rt_printk("ni_mio_common: %i:
> data[n]==%x\n", __LINE__, data[n]); data[n] += signbits;
>                         }else
>                         {
>                                 d = ni_readw(ADC_FIFO_Data_Register);
>                                 d += signbits; /* subtle: needs to be
> short addition */ data[n] = d;
>                         }
> For a positive input value (+0.5V) data[n] is ffff8c57,
> for a negative input value (-0.5V) data[n] is 73d2

Okay, I've masked off the bogus most significant bits in the driver.  By 
the way, does comedilib/demo/cmd work for your board?  As I recall, I had 
to make some guesses as to how dma worked with 16 bit or less boards.

-- 
Frank

Received on 2006-10-09Z23:45:19