Gerhard Fuernkranz wrote:
Am 27.06.2010 10:13, schrieb Klaus Karcher:I thought I got the trick in i1pro_meas_to_abssens(): if (rval>= maxpve) rval -= 0x00010000; /* Convert to -ve */ but I still get many overflows. (I use the maxpve value returned from i1pro_getmisc(): 0xfa00)Hi Klaus, I must admit that I can't assess this piece of code, since I don't know how rval is supposed to be encoded. The code suggests that we're dealing with an asymmetric, signed 16-bit encoding, which can encode more positive than negative numbers (given the actual maxvpe value of 0xfa00). Granted that this assumption is correct, I'm wondering, though, whether it is really an "overflow" if negative numbers are returned, or whether these are still valid readings (albeit negative ones).
second trial (I should /think/ before clicking "send" ;-) yes, as far as I understand, the valid range shoud be [-1536 ... 63999]. The raw values (rval) are read in as big-endian unsinged short: static int buf2ushort(unsigned char *buf) { int val; val = (0xff & buf[0]); val = ((val << 8) + (0xff & buf[1])); return val; } and shifted by -2^16 if they are >= maxpve: if (rval>= maxpve) rval -= 0x00010000;But the jump discontinuities I get in the result suggest that I'm doing something wrong.
Klaus