Page 1 of 1

Phidget Bridge Control: Manually request/schedule measurement event?

Posted: Wed Nov 17, 2021 3:01 am
by cheister
Hi, I am working on a project with load cells for a scale where I need to do a measurement at a certain point of time. I build a scale which works as a user interface and recognizes if something is put on the scale and identifies the item based on it weight. I am using the JavaScript API with a PhidgetBridge 4-Input and the PhidgeControl Server.

Ideally it should register the exact weight of the item(s) put on the scale. I raised the ev threshold so that it fires only if an item of a certain minimum weight is placed on the scale. This works so far. The problem is, that the scale creates false positives due to the vibration of the scale construction, when putting an item onto the scale or removing it or moving items on the scale. To double check if a measurement is valid I would like to request a new measurement on demand to compare/validate.

In the API description I found a way to get the last measurement. But in case of a false positive, the last measurement would be the false positive, so I can not use it to validate it. Is there a way to request a measurement on demand so that I can wait a few milliseconds after each event and request a new one for a validation? Many thanks, C.

Re: Phidget Bridge Control: Manually request/schedule measurement event?

Posted: Wed Nov 17, 2021 9:42 am
by mparadis
Which API call are you using to get the last measurement? "getVoltageRatio" will give you the most up-to-date measurement, which is effectively the same as an on-demand read.

If you want to execute a piece of code after a certain period of time, you can look up JavaScript's setTimeout function.

There's another way you could potentially deal with false positives from vibration when objects are placed on or removed from the scale- When you see a non-zero value on the scale, use the voltageRatioChange event to start filling up a buffer with readings over the next second or so. Once the buffer is filled, you can examine it to determine if the weight measurement has been stable long enough to count as an actual object and not a false positive.

Re: Phidget Bridge Control: Manually request/schedule measurement event?

Posted: Fri Nov 26, 2021 11:07 am
by cheister
Many thanks @mparadis and sorry for the late answer. The Buffer is a good idea I wrote a tiny ring buffer for this and will try this. I originally used the "onVoltageRatioInput0_VoltageRatioChange" event and the ratio that comes with it as well as "getVoltageRatio" to acquire the ratio manually.