Shop OBEX P1 Docs P2 Docs Learn Events
Display Help — Parallax Forums

Display Help

Tom PTom P Posts: 97
edited 2008-07-09 15:10 in BASIC Stamp
I Need help with a display problem.
Below is a program section which displays wind speed.
Orignal program·displayed speed via the debug screen,see at third line from bottom.
I'am also trying to send the display out the serial port but have a display problem.
HERE is the PROBLEM:
If speed is 3.9 miles per hour on the debug screen, I get .39 out the serial display.
Can't seem to get the display on the LCD to read the decimal in the right place.
Please help with idea
thanks
Tom


' *******************************
' Retrieve and display wind speed
' -- mph = rps * 2.453
' *******************************
'
Show_Wind_Speed:
· eeAddr = DS2423
· GOSUB Load_SN
· ' get starting count
· '
· OWOUT OWpin, OW_FERst, [noparse][[/noparse]ODMatchROM]
· OWOUT OWpin, OW_HighSpd, [noparse][[/noparse]STR romData\8, ReadMemCntr, $DF, $01]
· OWIN· OWpin, (OW_HighSpd | OW_BERst), [noparse][[/noparse]cntrA.LOWBYTE, cntrA.LOWBYTE, cntrA.HIGHBYTE]
· PAUSE 2500··································· ' = revs for 5 seconds
· GOSUB Comm_Status
· IF (commStat = CommOkay) THEN Get_End_Count
· GOTO Main2··································· ' abort if comm down
· ' get ending count
· '
Get_End_Count:
· OWOUT OWpin, OW_FERst, [noparse][[/noparse]ODMatchROM]
· OWOUT OWpin, OW_HighSpd, [noparse][[/noparse]STR romData\8, ReadMemCntr, $DF, $01]
· OWIN· OWpin, (OW_HighSpd | OW_BERst), [noparse][[/noparse]cntrB.LOWBYTE, cntrB.LOWBYTE, cntrB.HIGHBYTE]
Calc_CPS:
· rps = cntrB - cntrA·························· ' get diffential count
· IF (cntrB >= cntrA) THEN Calc_Speed
· rps = rps + $FFFF···························· ' correct for rollover
Calc_Speed:
· speed = rps */ $04E7························· ' rps * 4.906 (tenths @ 5 seconds)
· DEBUG MoveTo, 19, 7
· width = 3···································· ' width of whole portion
· rjNum = speed / 10··························· ' get whole portion
· GOSUB RJ_Print······························· ' print it
· DEBUG ".", DEC1 speed, " mph "··············· ' then print tenths
DISPLAY
· SEROUT TX,bdmd,[noparse][[/noparse]".",DEC2 speed," MPH",10,13]
DISPLAY
· GOTO Main2

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-07-09 13:30
    Hi Tom, I'm thinking the serial format should be as follows, you have already derived the whole and fractional parts so the calculations probably won't be neccessary but it's something you can use as a stand alone to test the results.

    speed=39
    speed_fraction=speed//10
    speed_int=speed/10

    SEROUT TX,bdmd,[noparse][[/noparse]DEC speed_int,".",DEC speed_fraction," MPH",10,13]

    Jeff T.
  • Tom PTom P Posts: 97
    edited 2008-07-09 14:36
    Jeff:

    I'am not sure if I understand?

    SEROUT TX,bdmd,[noparse][[/noparse]DEC speed_int,".",DEC speed_fraction," MPH",10,13]
    If I insert the SEROUT line above, then the program wants to have the definition below?

    speed_fraction=speed//10
    speed_int=speed/10

    Do I add all these lines to the program, if so where?
    Need a bit more help!
    thanks
    Tom
  • Tom PTom P Posts: 97
    edited 2008-07-09 15:10
    Jeff:

    I figured out how to display the Windspeed.

    When I chnaged the SEROUT to:

    SEROUT TX,bdmd,[noparse][[/noparse]DEC speed/10,".",DEC speed//10," MPH",10,13]

    the· display began to work fine.

    thanks

    Tom
Sign In or Register to comment.