Shop OBEX P1 Docs P2 Docs Learn Events
debug SBIN bit creep — Parallax Forums

debug SBIN bit creep

working on hacking up code. 1st problem to overcome 2's complement, the web tells me if the MSB is 1, it's NEG, cool.
I tacked in; DEBUG BIN X, and DEBUG SBIN x. even added X=0 inside the do loop but SBIN x just keeps growing from the 2-3 bit signed value I expect (0 ideally) to 10-12bits big after ~~hour.
the original raw X stays "normal", the BIN X stays like I expect.
any clues or pointers?

thanks
dave

PAUSE 10 ' Give sensor needed power up time
I2COUT SDA, WRITE_DATA, MODE, [Cont_Mode] ' Send continuous output

DO
x = 0
GOSUB GetRawReading ' Get RAW Compass reading

'RAW X,Y,Z data...
DEBUG HOME, CR, "RAW Data", CR
DEBUG " X = ",11, SDEC x
DEBUG " Y = ",11, SDEC y
DEBUG " Z = ",11, SDEC z, CR
DEBUG BIN x, CR ' test 2s comp
DEBUG SBIN x, CR
PAUSE 1000
'x = 0
GOSUB GetAzimuth

'Calculated Heading in Degrees

brads = azimuth 'get angle
degr = brads */ 361 'convert to degrees

DEBUG " Degree " ,11, SDEC degr 'display degrees

LOOP
Sign In or Register to comment.