Hi,
Shooting from the hip a bit here....
Since the ATN expects 8bit two's complement values I'm not sure it's going to work when you give it your x and y variables since they are both 16bit variables - even if the values in them are in +/-127 range. Ah, never mind, it probably will since the low byte of the word will look identical anyway....
Richard,
You can't simply shift a two's complement number like that, you'll drop the sign.
You need to remember the sign, shift the abs value and restore the sign
Code:
Sign VAR BIT
Reading VAR WORD
x VAR BYTE
Sign = Reading.15
x = ABS(Reading) >> 4
If Sign THEN x = -x
/Henrik.
Bookmarks