Shop OBEX P1 Docs P2 Docs Learn Events
Weigh Scale Display Flicker — Parallax Forums

Weigh Scale Display Flicker

Mohamed RefkyMohamed Refky Posts: 47
edited 2006-02-25 12:59 in BASIC Stamp
Hello,
In my weigh scale project the most right digit ( 00.000Kg) flickers between two numbers,this
will be less with 0.5 sec between readings.I wish to keep the display stable by adding a code
decides in every display cycle whether the displayed weight is the same as the previous
one.If it is the same the display will not change.If the difference is less than certain value
the old display will still displayed. If the difference is higher than that value it will update the
display.

Any code idea will be appreciated.

Here is the main program:
main:
PAUSE 10
IF IN0 = 0 THEN keypress 'check for key press.
IF timer > 50 THEN program 'wait 1/2 sec between reading.
timer = timer + 1
GOTO main
program:
GOSUB getdata
GOSUB Maxdisplay
GOSUB control
timer = 0
GOTO main

Thank You
Mohamed Refky

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-24 23:55
    You might consider rounding that digit unless you really thing your scale output is that accurate.· If you can live with 10 gram resolution you can do this:

    · weight = (weight + 5) / 10

    Say, for example, your raw value of weight·was flickering betwee 12345 and 12346 grams.· By applying the formula above you would get

    · 12345 + 5 = 12350 / 10 = 1235 (display as 12.35)
    · 12346 + 5 = 12351 / 10 = 1235 (display as 12.35)

    If this is not acceptable then what you'll want to do is a bit of digital filtering.·Here's one way that prevents roll-over of Word variables:

    · weight = 0
    · FOR idx = 1 TO 5
    ··· GOSUB Read_Weight
    ··· weight = weight + (rawWeight / 5)
    · NEXT

    This is very similar to averaging five readings.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • neotericneoteric Posts: 144
    edited 2006-02-25 12:59
    I was thinking of doing a weigh scale project.· Could you tell me what you are doing, have done, and what parts you are using?· VERY COOL
Sign In or Register to comment.