Shop OBEX P1 Docs P2 Docs Learn Events
Memsic 2125 Code Help (Negative Numbers) — Parallax Forums

Memsic 2125 Code Help (Negative Numbers)

denden Posts: 1
edited 2006-03-01 15:19 in BASIC Stamp
    i need a way to control the mx2125 accelerometer so temp does not effect it i am using it in the vertical position. dividing y by x as the reselt. it works in positive but negitive numbers

Post Edited By Moderator (Chris Savage (Parallax)) : 3/1/2006 4:48:36 AM GMT


Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-01 04:49
    You forgot a subject line, but I corrected this one for you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-01 15:19
    Here's a trick you can use when one or both values are negative.·

    ·IF (xVal.BIT15 ^ yVal.BIT15) THEN
    ·· result = 0 - (ABS xVal / ABS yVal)
    ·ELSE
    ·· result = ABS xVal / ABS yVal
    ·ENDIF
    ·DEBUG SDEC result

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.