Connect with us

Weight scale programming logic

Discussion in 'Microcontrollers, Programming and IoT' started by Stefaans5111, Feb 1, 2021.

Scroll to continue with content
  1. Stefaans5111

    Stefaans5111

    3
    0
    Feb 1, 2021
    Hi all,

    I am hoping someone could assist with the logic to which weight scales are programmed in the industry to display weight. I am referring to load cell controller displays, jewelry scales, kitchen scales etc.

    I am currently making a milligram scale using a Arduino Uno, HX711 ADC and a load cell that forms part of a larger project. To thus far the scale is programmed to continuously display the weight result every 100ms. It displays the weight up to 0.005g quite consistently with negligible drift.

    When looking at other scales on the market the weight does not seem to be continuously displayed all the time. As far as I can see it displays the weight continuously until it registers that the weight has reached a stable condition then it only displays the stabilized weight. That is until there is a change in the weight on the scale (added / removed weight) where it will repeat process again until a new stabilized condition. For a "stable condition" I am assuming that the scale is detecting whether the weight has stayed within a certain range of the current value over a specified amount of time.

    Is my understanding of the logic to which the scales are programmed correct? Or is it done in another way?
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,442
    2,628
    Nov 17, 2011
    Why do you think that is a difference? As long as the weight doesn't change you will not be able to distinguish a "frozen" display from one that is continuously updated with the same value over and over.
    To be able to detect a change in weight the controller will have to read the sensor data continuously anyway.
    Of course, you could program a certain "insensitivity" into your data acquisition such that the weight has to change by a certain amount before the display is updated. This could help stabilize the display at the cost of a loss in accuracy because changes in weight below that threshold will not be displayed.
    Alternatively, imho more suitable to highly accurate measurement you can use some form of noise suppression to stabilize the display. Simply averaging the measured value with the previously displayed value will improve the stability considerably. Using weighted average you can balance the speed at which the display updates to a new value versus the robustness against noise. The algorithm is super easy:
    Code:
    average = (measured_value × percentage) + (average × (1 - percentage))
    percentage being a value between 0 ... 1.
    With percentage = 1 you will have only the newly acquired value (no averaging at all). With percentage = 0 you will have only the old value (a useless case). By varying percentage you can achieve the desired balance. Start e.g. with percentage = 0.5 and see how your scale behaves. Values for percentage between 0.3 to 0.7 I have used in the past with good results.
     
  3. bertus

    bertus Moderator

    1,761
    677
    Nov 8, 2019
  4. Stefaans5111

    Stefaans5111

    3
    0
    Feb 1, 2021
    The reason would be that various scales that I have worked with has a "stable" indicator that goes "on" once the scale has stabilized.

    In particular, I currently have a digital scale where the manufacturer claims it is able to measure to 0.005g. It is not a one of the cheapest scales nor a expensive laboratory scale where I use it to measure powder. When trickling the powder onto the scale the display responds to changes of 0.005g. That is until the weight is indicated as "stable" then it requires a change of 0.01g - 0.02g to be added in order for the display to register the change where after it then registers changes of 0.005g. This is what lead me to believe that the weight is frozen.
     
  5. Stefaans5111

    Stefaans5111

    3
    0
    Feb 1, 2021
    Thanks Bertus, I've noticed that the commercial scales usually have some sort of draft cover.

    I am planning to implement this onto the scale as well as I have seen that when there is a slight draft in the environment it has a effect on the load cell output.
     
  6. Harald Kapp

    Harald Kapp Moderator Moderator

    11,442
    2,628
    Nov 17, 2011
    Sounds logical. However, once the display is frozen the accuracy is reduced from 0.005 g to .01 as the display will not recognize a change smaller than that. If that's what you want, fine. If not, the proposed averaging method can deal with smaller changes, too.
    You can combine averaging and a lock indicator: if the average doesn't change for a certain amount of measurements (e.g. 10 measurements), a lock indicator can be lit to indicate that the measurements is stable without compromising the detection of small changes.
     
  7. hevans1944

    hevans1944 Hop - AC8NS

    4,607
    2,151
    Jun 21, 2012
    It has been awhile (1960s to 1970s time frame) since I have worked with commercial load cells. AFAIK, all load cells are analog devices, Wheatstone bridge configurations of thin-film strain gauges, often with temperature compensation.

    The digital "magic" only enters the design after the load cell analog signal is properly signal-conditioned to an appropriate analog-to-digital conversion range. Often this analog circuitry includes sensitivity and bridge-balance controls, although that is no longer absolutely necessary with high-resolution A/D conversion.

    I haven't tried to design and build a laboratory-grade balance that can measure to milligram or better accuracy. For powder throwing into re-loadable shell casings, I use an Ohaus mechanical scale to calibrate a volumetric powder thrower. I also own a micro-gram resolution mechanical balance, but haven't had a reason to use it for many years. It requires manual manipulation of the balance weights using a complicated mechanism that lifts the weights from their storage positions and places them (internally) opposite the weighing pan. It's a really nice precision balance with the weighing pan surrounded by sliding glass doors on either side, and balance indicated by an illumination source, mirror, and focusing optics to display a moving micro-gram scale on a ground-glass screen. The balance arm release had two positions, with different dampening at each position, that was useful in "zeroing" in on the pan weight when the initial "guess" manually dialed in was waaaay off base.

    I really like this antique, but it has since been replaced in every modern laboratory with load-cell and force-balance digital electronic weighing systems, which are much easier and more convenient to use. Many have desktop or laptop digital computer links too. My bathroom scale doesn't have a computer interface, but it does auto-magically measure my weight every morning. Tap on the scale to turn it on and allow the electronics to subtract out tare. Then step on the platform and wait a few seconds for your weight to appear, expressed in pounds and tenths of pounds. After observing the reading, step off and the scale auto-magically powers down. I really like my digital bathroom scale. Battery life is excellent since it uses an LCD display.

    One home application for laboratory-grade balances is to determine water "hardness" by weighing water-soaked "filter paper" before and after all the water has evaporated. The weight of the residue remaining represents the actual hardness of the water. Or, if you have a kit handy, you can get accurate hardness determination through an ion titration procedure. But where is the fun in that?
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-