Shop OBEX P1 Docs P2 Docs Learn Events
Displaying accelerometer readings — Parallax Forums

Displaying accelerometer readings

Earl FosterEarl Foster Posts: 185
edited 2008-03-01 00:54 in Learn with BlocklyProp
I am working in chapter 3: Tilt with the Memsic Accelerometer from the Smart Sensors and Applications SIC course.· Activity 4 has me scaling my readings and displaying the results to the terminal or a LCD screen from -100 to 100.·
·
In both displays if I do not clear the characters after every reading I will get invalid display readings once I hit 100 or my first negative 2 digit number.
For example:
·
X = 99············ First reading
X = 100·········· Second reading
X = 990·········· Third reading should be 99
X = 750·········· Fourth reading should be 75

or

X = -15·········· First negative reading
X = 155········· Positive reading of 15
X = -100········ Max negative
X = 9900········ Should be 99
·
Unless I clear the display first I will get garbage displaying.· This gives me a flicking effect that is not very desirable.· I can increase the pause but then I get a delay in my readings and it is just a slower flicker.
·
Is there a better way of clearing the undesirable characters without the flicking?
·
' {$STAMP BS2}
' {$PBASIC 2.5}
·
x VAR Word
y VAR Word
·
'...Initialize LCD
PAUSE 200
SEROUT 14, 84, [noparse][[/noparse]22, 12]
PAUSE 5
·
·
DO
·· PULSIN 6, 1, x
·· PULSIN 7, 1, y
·· x = (x MIN 1875 MAX 3125) - 1875 ** 10538 - 100
·· y = (y MIN 1875 MAX 3125) - 1875 ** 10538 - 100
·· DEBUG HOME, CLS, SDEC ? x, SDEC ? y
·· SEROUT 14, 84, [noparse][[/noparse]128, SDEC ? x, SDEC ? y]
·· PAUSE 100
·· SEROUT 14, 84, [noparse][[/noparse]12]
LOOP


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
WWW.HAPB.NET

"Don't ask yourself what the world needs - ask yourself what makes you come alive, and then go do it." - H.T.Whitman

Comments

  • Earl FosterEarl Foster Posts: 185
    edited 2008-03-01 00:28
    Found it - use the CLREOL to clear the characters

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    WWW.HAPB.NET

    "Don't ask yourself what the world needs - ask yourself what makes you come alive, and then go do it." - H.T.Whitman
  • Earl FosterEarl Foster Posts: 185
    edited 2008-03-01 00:54
    Here is the code that clears the display without the flickering

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    x VAR Word
    y VAR Word

    '...Initialize LCD
    PAUSE 200
    SEROUT 14, 84, [noparse][[/noparse]22, 12]
    PAUSE 5


    DO
    PULSIN 6, 1, x
    PULSIN 7, 1, y
    x = (x MIN 1875 MAX 3125) - 1875 ** 10538 - 100
    y = (y MIN 1875 MAX 3125) - 1875 ** 10538 - 100
    DEBUG HOME, CLREOL, SDEC ? x, CLREOL, SDEC ? y
    SEROUT 14, 84, [noparse][[/noparse]12]
    PAUSE 5
    SEROUT 14, 84, [noparse][[/noparse]SDEC ? x, SDEC ? y]
    PAUSE 100
    LOOP

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    WWW.HAPB.NET

    "Don't ask yourself what the world needs - ask yourself what makes you come alive, and then go do it." - H.T.Whitman
Sign In or Register to comment.