Capture the weight from a scale with differentiated digits using our 232key software

This article describes how you can capture the weight from a weighing instrument with differentiated digits using 232key Plus.

What are differentiated digits?

When looking at the display of an approved class I or class II weighing instrument, you might notice that one or more digits are visually differentiated from the others:

Differentiated digits on A&D EK-610i approved class II weighing instrument

This is also called an “auxiliary indicating device” and is supposed to remind the user that on these instruments, the actual scale interval (d) is not the same as the verification scale interval (e). For the scale shown above, e is 0.1 g and d is 0.01 g. Since e is used to determine the maximum permissible error, we can consider¬†the differentiated digit(s) to be less accurate (but that’s not the topic of this article).

How to use 232key to capture differentiated digits

Some scales do not only visually differentiate the last digit(s), they also use a separator when transmitting them to a PC (or a printer). Instead of receiving a string like “250.01”, the software running on the PC would receive something like “250.0/1” or “250.0[1]”.

When using our virtual keyboard wedge software 232key, this separating character prevents the weight value from being captured completely. Instead, 232key only captures “250.0” (highlighted in blue in 232key’s event log):

232key event log: differentiated digit not captured

Fortunately, you can easily fix this in the Plus version of our software in just two steps (both are necessary).

1. Modify the regular expression to ensure all required characters are captured

Let’s continue using ‘/’ (slash) as a separator for this example. By default, most device profiles in 232key are meant to capture numbers and therefore 232key will stop capturing when it encounters the first non-numeric character. We have to change this behavior to make sure that 232key captures the digits preceding the separator, the separator itself and the following digit(s).

To do so, we first select the device profile we want to use (we’ll go with “Generic measurement instrument” in this example), and then click on the “Customize…” button to open the regular expression dialog:

232key: Regular expression dialog

The current regular expression captures the first number it encounters (which can be positive or negative and have a dot or comma as a decimal separator):

([-+]?\s*[0-9]*[\.,]?[0-9]+)

By expanding it as below we can instruct 232key to match a slash (‘/’) and the following digits, too:

([-+]?\s*[0-9]*[\.,]?[0-9]+/[0-9]+)

Depending on the selected device profile, the regular expression shown in the dialog might look different. What’s important is that it has to be expanded to include the separator and the differentiated digits.

Note: If the separator character used by your scale has a special significance in regular expressions, it must be preceded by a backslash ‘\’. Examples: Round and square “open bracket” characters ‘(‘ and ‘[‘. For the round bracket ‘(‘ as a separator character, the regex would be:

([-+]?\s*[0-9]*[\.,]?[0-9]+\([0-9]+)

2. Remove the separator

Thanks to the modified regular expression, 232key is now able to capture the entire value transmitted from the scale, including the separator.

However, this will result in a number format error (java.lang.NumberFormatException) if a numeric device is selected in the input tab. If a text device is selected, the separator would be included in the characters typed by 232key. Both of these outcomes are undesirable.

Therefore, we have to instruct 232key to remove the separator from the captured data by going to the “Process” tab and entering it in the “Remove” text field:

232key process tab: remove separator

Once this second step is completed, 232key will handle differentiated digits correctly: When the scale sends “250.0/1”, 232key types “250.01” into the target application (e.g. a spreadsheet):

Weight typed into spreadsheet

Note that you may have to adapt these instructions to match the separator sent by your scale. As mentioned, you’ll also need a paid 232key Plus license to enable the functionality shown in this article. Please don’t hesitate to contact us should you need a trial license. For assistance, please post in our support forum.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

One thought on “Capture the weight from a scale with differentiated digits using our 232key software”