John Kauffman

09-21-2008, 09:05 PM

The sample code (attached) from Parallax for the Memsic 2125 dual axis accelerometer picks up an xRaw value from the sensor and then uses the following code to display the value in units of g.

··· DEBUG "X Input...· ",

········· ...

········· "G Force... ", (xmG.BIT15 * 13 + " "),

········· DEC (ABS xmG / 1000), ".", DEC3 (ABS xmG), " g",

········· ...

The G force is displayed in three parts:

(when needed) a minus sign from·· ·(xmG.BIT15 * 13 + " ")

units from·································· DEC (ABS xmG / 1000),

and thousandths from·················· ".", DEC3 (ABS xmG), " g",

I see how the digits are produced, but I don't understand how the code (xmG.BIT15 * 13 + " ") produces·a minus sign for a negative value and no character·for a positive value.

Thanks.

··· DEBUG "X Input...· ",

········· ...

········· "G Force... ", (xmG.BIT15 * 13 + " "),

········· DEC (ABS xmG / 1000), ".", DEC3 (ABS xmG), " g",

········· ...

The G force is displayed in three parts:

(when needed) a minus sign from·· ·(xmG.BIT15 * 13 + " ")

units from·································· DEC (ABS xmG / 1000),

and thousandths from·················· ".", DEC3 (ABS xmG), " g",

I see how the digits are produced, but I don't understand how the code (xmG.BIT15 * 13 + " ") produces·a minus sign for a negative value and no character·for a positive value.

Thanks.