Re: negative voltage reading problem with cmd.c and ni_pcimio

Hi!

If it's 16 bit, just try ^0x8000. That should do the job. A 0 in comedi 
means the most negative value and a 65535 is the most positive value if 
you have 16 bit. Can't remember the functions exactly but there is a 
function to get the maxvalue (here 65535) and there is one which 
converts raw data to real physical values.

/Bernd

www:	http://www.berndporr.me.uk/
         http://www.linux-usb-daq.co.uk/
Mobile:	+44 (0)7769 506746
Work:	+44 (0)141 330 5237
         Department of Electronics & Electrical Engineering
         Room 519, Rankine Building, Oakfield Avenue,
         Glasgow, G12 8LT


Naoko Kurahashi wrote:
> Hi,
> 
> Thank you for your advice. I adventured my way through the sourcecode
> ni_mio_common.c. (I'm still confused about the difference between high and
> low data which are divided after ni_readl)
> I've been trying XOR-ing as you suggested. Since 'data' is 16bits, I tried
> data^0xffff and this changes negative values to positive values and gives
> something between 2048 - 4096 (upper half of my 4096 resolution, not lower),
> but I still don't know how to change it to the comedi equivalent of negative
> voltages (0-2047 in my case). also, if I do this operation to 'data', if the
> input was truely positive, the value of 'data' again shoots up to the
> 63000's. Is there a good way around this? Did I understand your advice right? 
> 
> I don't have a formal background in signal processing or engineering for
> that matter, which means I'm misunderstanding many things, but I thought 2's
> complement data format means that I have to subtract 1 before I invert the
> 1's and 0's. Is this still the case here?
> 
> Thank you for your patience in advising me. 
> Naoko
> 
> Quoting Bernd Porr <BerndPorr_at_f2s.com>:
> 
> 
>>Hi!
>>
>>Seems so that the sign bit of the converter is not interpreted in the 
>>right way. Comedi uses unsigned data but some A/D converters give the 
>>data in two-complement form. The driver should "undo" this by XOR the 
>>appropriate bit(s):
>>
>>comedi_buf_put(s->async,(this_usbduxsub->inBuffer[i])^0x800);
>>
>>Might be a bug in the driver.
>>
>>/Bernd
>>
>>www:    http://www.berndporr.me.uk/
>>         http://www.linux-usb-daq.co.uk/
>>Mobile: +44 (0)7769 506746
>>Work:   +44 (0)141 330 5237
>>         Department of Electronics & Electrical Engineering
>>         Room 519, Rankine Building, Oakfield Avenue,
>>         Glasgow, G12 8LT
>>
>>
>>Naoko Kurahashi wrote:
>>
>>>Hi, 
>>>I've been battling a weird problem today of not being able to acquire
>>>negative voltage values with my NI PCI MIO card. When executing the cmd
>>
>>demo
>>
>>>program, for example, every time the input voltage is < 0, the
>>
>>acquired
>>
>>>value shoots up to 63000 or so (max res for my card is 4096). I have
>>
>>my
>>
>>>range set to 3 (bipolar +/-1V). when I set it to unipolar 0-5V, the
>>
>>negative
>>
>>>values just give 0 and everything looks fine.
>>>
>>>Maybe my problem is hardware related, or I'm just missing something
>>
>>very
>>
>>>simple because I'm very tired, but I am out of things to try. Please
>>
>>let me
>>
>>>know if you have any suggestions or have experienced similar problems.
>>>
>>>Thank you,
>>>Naoko Kurahashi
>>>
>>>_______________________________________________
>>>comedi mailing list
>>>comedi_at_comedi.org
>>>https://cvs.comedi.org/cgi-bin/mailman/listinfo/comedi
>>
> 
> 

Received on 2004-06-15Z21:48:41