Weigh Scale Display Flicker
Mohamed Refky
Posts: 47
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
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
· 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