erjiang / usbscale

Reads weight data from USB scales.
GNU General Public License v3.0
91 stars 22 forks source link

Zero scale #1

Closed tehChromic closed 4 years ago

tehChromic commented 12 years ago

hi, I have the entry level mail scale that comes with a mail.com account. I'm wondering if there is a way to reset the scale in order to "zero" it, without having to unplug it.

thanks

erjiang commented 12 years ago

Zero'ing hasn't been implemented yet, and I also don't have a scale with me to test it. Maybe in a few months, unless somebody submits a patch.

erjiang commented 11 years ago

Need to investigate sending a Scale Control Report:

byte 0: 2 (report ID) byte 1: 2 (zero scale ON, EZR OFF)

erjiang commented 8 years ago

This comment was left on my blog by reader "FletchFFletch", and I'm recording it here for future reference:

You can zero out a stamps.com 550 scale by sending a 0x04 and 0x01 to it.

erjiang commented 8 years ago

The code in the zero-scale branch is able to zero a Stamps.com Model 510 5LB scale. To do the "tare" operation, run ./usbscale zero.

It should print

tared
0 oz

Then place your item on the scale and run ./usbscale normally to get the weight.

If it fails, it'll print out something to stderr.

Looking for people to test this out - want to check that it works on other scales. If you're able to try it out, post a comment saying what kind of scale you have and whether or not it worked for you. Thanks!

sanmai commented 8 years ago

Doesn't work with 2474:0550 (Stamps.com Stainless Steel 5 lb. Digital Scale).

Here's transcript:

$ ./usbscale
0.9 oz
$ ./usbscale
0.9 oz
$ ./usbscale zero
tared
Scale is zero'd...
^C
$ ./usbscale 
Scale is zero'd...
^C

After zeroing it can't read anything from the scale.

Neither display changes.

erjiang commented 8 years ago

@sanmai Interesting...

If you put something on the scale before starting the program, does it work? If you put something on the scale after starting the program, does it work?

Sounds like latter case does not work, but maybe former case does?

"Scale is zero'd..." means that the scale is at zero and is stable. Since usbscale queries in a loop, once you put something on scale it should next display "Weighing..." and then when scale is stable, it should display the weight.

sanmai commented 8 years ago

Nothing in the output if I move things off and on. This is the first thing I tried.

jrddunbr commented 7 years ago

So this actually works with my scale, 1446:6a73 (X.J.GROUP Stamps.com Model 510 5LB Scale)

$ sudo ./usbscale # nothing on scale
0 oz
$ sudo ./usbscale # placed phone on scale and then ran
9 oz
$ sudo ./usbscale zero
tared
9 oz
$ sudo ./usbscale # phone still on scale
0 oz
$ sudo ./usbscale # removed phone from scale and then ran
Scale reports Under Zero # Had to place phone on scale, only other way to resolve is ^C
0 oz
$ sudo ./usbscale zero # Phone taken off of scale, and then ran
tared
Scale reports Under Zero
0 oz
$ sudo ./usbscale # Nothing on scale still
0 oz
$ sudo ./usbscale # placed phone on scale and then ran
9 oz

Generally, when the scale reports under zero, you have to place the object back on, and then it will complete. In the end, it did zero out the scale.

I have noticed a slight bug occasionally while zeroing, it appears to be a race condition of sorts?

System information:

$ uname -a
Linux jtop 4.9.60-1-MANJARO #1 SMP PREEMPT Thu Nov 2 13:08:20 UTC 2017 x86_64 GNU/Linux

I have libusb1.0.21-2 installed

PS. Thanks for the great software. Breathes useful life into what would otherwise be waste.

berkinet commented 5 years ago

The tare feature just saved me an hour's worth of hacking a relay in series with the 510 scale's on/off switch. Thanks. BTW, my application for the scale is to detect the presence of mail in a mailbox. The tare feature is ultimately not needed, at least not very often. But, while I am still playing with the installation, like changing the platform I mounted on the scale, it is a real help.

Thanks.

erjiang commented 5 years ago

@berkinet Glad to get your feedback, and to hear that it worked for you. Unfortunately it looks like results are mixed depending on the type of scale, which is the main thing blocking this from being merged. Maybe I should go ahead and merge it and mark it as an experimental feature.

berkinet commented 5 years ago

May I suggest you could make tare setting (I.e. recognizing argv[1]) conditional on the scale type, possibly by adding a column to 50-usb-scale.rules. Or, #IFDEF TARE it in the code.

BTW, in my application I call usbscale from a shell script that loops every 60 seconds comparing each read to the previous one. The 510 is particularly good for this because it can stay powered on. I will probably end up adding that ability, as well as a metric conversion, to your code. But, for now the script was easier.

BTW, do you know of anyway to increase the granularity of the weight detection. Right now I can't see anything below 2 oz. I have used other load cells that were good down to a gram -- of course they also had fairly severe temperature drift.

And... thanks for sharing your work.

erjiang commented 4 years ago

I went ahead and merged the zero-scale branch, despite the fact that it doesn't seem to work on all scales. It's possible that some scales just don't follow the standard. There's no conditional on the scale type for this feature, but hopefully once someone figures out it doesn't work with their scale they won't keep trying to use it.