A few weeks ago, we implemented a hanging scale and, to do so, we wrote a short Android application which displayed the weight. This week, we are improving this application so that it can also automatically count the number of objects on the scale depending on a reference value.
The principle is simple: instead of counting by hand the objects, we weigh the total weight that we then divide by the unit weight. This process is widely used in industries, in particular to count small objects, such as screws or Lego blocks. Obviously, this works only for identical objects with a scale which is accurate enough.
To make it work, you simply need a reference measure, for example 5 screws weighing 2 gr. Then, the computation is trivial, it's a rule of three: total weight X reference number / reference weight. To come back to our example, if you measure 100 gr of screws, there are 250 screws because 100 * 5 / 2 = 250.
You may think that such a useful function is implemented on all the commercially available scales, but it's not the case. Most of the time, this function doesn't exist. For the few scales which implement this function, the interface is so complex that you can't even use it.
We therefore decided to add this possibility to our Android YScale application, which we described in a previous post.
The YScale application
The application now has three tabs. The first one contains the traditional view of the application, that is the measured weight and a graph of the weight evolution over 30 seconds.
The first tab displays the weight
The second tab allows you to count objects. The number of counted units is displayed in the center, as well as the total measured weight in a smaller font. On the lower left, you have the reference measure used for the computation.
The second tab displays the number of objects
The third tab enables you to configure the Yocto-Bridge as well as the application. First, you have the "tare" button to tare the scale. Then, you have the configuration parameters to count objects, and finally a button enabling you to enter the load cell calibration parameters.
The third tab displays the parameters
Load cell calibration
If you haven't calibrated the Yocto-Bridge with the VirtualHub, you can enter the correspondence between the ratiometric measure and the measured physical weight with the "configure load cell" button on the parameter tab.
The load cell configuration parameters
You can use the theoretical value figuring on the calibration certificate, but it is usually more accurate to measure an exact value by taking into account the whole weighing system with a standard weight. For more information on these parameters, you can read the Yocto-Bridge documentation.
First, you must enter the reference measure which is used for the computations. You can enter the reference weight either manually or automatically by using the measured value. Then, you must enter the corresponding number of objects. You can also define a name for the measured objects.
The reference parameters for 5 screws weighing 2.09 grams
When you have entered these parameters, the "count" tab displays the number of objects in the weighing pane, using these data.
Here are 156 screws at 2.09 grams each
In closing ...
We didn't detail the application code because 99% of the changes are in interface management, and the last percent is a simple rule of three. Moreover, the complete code is available on GitHub: https://github.com/yoctopuce-examples/yscale
However, we decided to publish this application on Google Play because we noticed that this application was quite useful and that it could also help other customers. Actually, it is likely that we used this application to prepare your order if you ordered a large number of Fix-2.5mm in bulk.