Our software 232key was originally designed to make it as easy as possible to capture the weight sent by a scale or balance (and then transmit it to another application as simulated keystrokes). As most weighing instruments also include the unit and possibly other characters, 232key assumes that the first (decimal) number it encounters is the weight. If you also want to capture the date and time sent from a scale, this can lead to unwanted results.
Capturing the net weight
Let’s look at a simple example first. Below you’ll see the data received from an Ohaus Scout STX scale configured to transmit only the net weight (as it appears in the event log in 232key):
Net: 302.4 g ? N<13><10>
The blue characters were captured by 232key using the “Ohaus” device profile. In this example, 232key managed to successfully capture the weight.
Capturing the net and tare weight
If we set the scale to send both the net and tare weight, the event log shows that 232key still captures both values:
Net: 302.4 g ? N<13><10> Tare: 7.9 g T<13><10>
To have them appear in separate columns in spreadsheet applications like Excel, OpenOffice Calc or Google Sheets, we can go the output tab and modify the end with settings as shown below:
Alternating the “TAB” with the “Enter” key every 2 value will produce the desired result (shown in Google Sheets):
Capturing date and time
Things get significantly more complicated if we configure the scale to also send the date and time. The event log now looks as follows:
11/17/2017 15:04:21<13><10> Net: 302.4 g N<13><10> Tare: 7.9 g T<13><10>
Using its default strategy of capturing the first number in each line, 232key only captures “11” and ignores the rest of the combined date/time line (as the backslash cannot be a part of a decimal number).
We can try to fix this by going to the device tab and setting the device to “Barcode alphanumeric extended” (available in the Plus version). This device appears in italics, which means that it is a “text” device instead of a “numeric” device. Note: Do not click the set defaults button after making this change.
As the scale is now sending three lines of data, we should also enter the number “3” in the end with settings in the output tab:
If we press the print button on the scale again, the event log will show that all data has been captured by 232key:
11/17/2017 15:09:51<13><10> Net: 302.2 g N<13><10> Tare: 7.9 g T<13><10>
The output in Google Sheets looks as follows:
If we simply wanted to record all data sent from the scale, this would be fine. However, it is not ideal for further processing for two reasons:
- Date and time appear together in one column.
- The measurement values are not recognized as numbers because the cells contain additional text.
232key does currently not support extracting multiple values from one line of data, so there’s nothing we can do about the first issue. Unfortunately, our Ohaus Scout STX scale cannot send the date and time in separate lines.
The second issue can be fixed using custom regular expressions. To do this, go to the device tab, click on the customize button and replace the existing regular expression with the following one:
Note: This regular expressions assumes the scale is using the 24 hour time format.
The event log and the output in the spreadsheet now look as follows:
15:38:40 11/17/2017 15:39:01<13><10> 15:38:40 Net: 302.2 g N<13><10> 15:38:40 Tare: 7.9 g T<13><10>
The cells containing the net and tare weights are recognized as numbers and can be used for further calculations.
If we just wanted to capture the time (and maybe add a “date” column manually), we could use the following regular expression:
- The regular expressions above have been customized to work with the Ohaus Scout STX scale (configured to send the date, time and weight). They might not work with other scales and balances.
- As we’re now using a “text” device, the computation and rounding settings in the process tab have been disabled (you can’t round non-numeric characters).
- The option to change the decimal separator from a dot to a comma is also no longer available (and our custom regular expression does not capture decimal numbers using a comma as the separator).
- For data logging purposes, consider using our new Simple Data Logger software instead of 232key. It has the ability to add the date and time to each weight. The CSV files it produces can be easily opened in Excel and other spreadsheet apps.
As of version 0.2.0, our Simple Data Logger software can communicate with Ohaus scales and balances equipped with an Ethernet interface. The Ethernet interface is a convenient substitute for the dated RS-232 interface.
Please note that the Terminator setting from the COM port group (above) is also used for TCP/IP connections. We’ll update the user interface in a future release to make this clearer.
For further information on how to use Simple Data Logger, please refer our previous blog post.
We’ve released the first version of our data logging software “Simple Data Logger” (SDL). You can download and install it from simpledatalogger.com.
Please note that this early version is not yet feature complete and could be unstable. It is free to use for testing purposes, but the final version will require a paid license. Please report any bugs you might encounter in the comments below or by email to firstname.lastname@example.org. The software will update itself automatically as we fix bugs and add more features.
Purpose of Simple Data Logger
SDL receives data sent from a device connected to your computer and writes it to a file. It currently supports devices connected to a COM port (RS-232, USB virtual COM port, Bluetooth SPP) which send data in ASCII format. It can either capture all printable characters (suitable for devices like bar code readers) or the first numeric value it encounters (suitable for measurement instruments like scales and balances). It can optionally add the date and time to the recorded data and transform the decimal separator of numbers from a dot to a comma (if required).
Files written by Simple Data Logger can easily be opened in Excel or other spreadsheet applications.
How to use Simple Data Logger
The user interface is organized in tabs. Start by adjusting the settings in the Device tab, then go to the File tab and choose the file which SDL should use to save the data. Start and stop data collection from the Start tab.
Choose the connected device. If your device is not listed, select “Generic text device” (to capture alphanumeric data) or “Generic measurement device” (to capture numeric values).
Choose the COM port your device is connected to. Click on Set default parameters for device if your device is listed, otherwise set the interface parameters and terminator to match your device’s settings. The terminator is the last character sent in each line of data. Enter it as a decimal value (e.g. ” 10″ for line feed or ” 13″ for carriage return). Please consult the manual that came with your device if necessary.
Choose a File for data logging (if it exists, data will be appended, if it doesn’t, it will be created).
Set the Options to match your locale (for easy import in Excel and other spreadsheet software):
- US: Decimal separator = Dot, Value separator = Comma
- Germany: Decimal separator = Comma, Value separator = Semicolon
Press Start to start data collection and Stop to stop it (button text changes). Notifications, errors and received data will show up in the event log.
Currently missing functionality (will be added before the final version is released)
- Profiles for many devices.
Ethernet support (Raw TCP ” protocol” as used by Ohaus scales and balances).
- Custom regular expressions (used to capture data).
- Timer/polling (send commands to the connected device, e.g. to request the weight from a scale every second).
- Processing captured data before writing it to a file (e.g. to remove unwanted characters).
- Improved Event Log functionality (show or highlight captured data, disable logging).
- Application settings (connect to device on program start, minimize to notification area).
- Licensing functionality.
Known bugs (ordered by severity)
The user interface can become unresponsive after collecting a very large amount of data (several hundred thousand values). In this case, logging still continues but can no longer be stopped. Refresh button for COM ports does not work as expected.
- Custom date and time formats entered in the File tab are always marked as invalid.
- Browser does not open when links to simpledatalogger.com are clicked.
IP address is marked as invalid when left empty, even when using COM port.
- A&D device name is shown as “AD” in the Start tab.
I pressed Start and nothing happened!
If no data shows up in the Event Log, please make sure that you’ve chosen the correct port in the Device tab and that the interface parameters match you device’s settings.
What’s the difference between SDL and 232key?
232key does not write data to a file, instead, it transforms it into (simulated) keystrokes and enters it into another application. 232key enables you to easily integrate serial devices such as scales and balances into your workflow. Unlike SDL, it should not run unattended and is not well-suited for data logging purposes.
How much will SDL cost? Will there be a free version? Can I already buy a license?
There will be no free version of SDL. License prices will be similar to 232key. You will be able to buy a license when we release the final version (testing versions will eventually stop working).
Why release a version so early?
Even at this point, we believe that SDL is already more useful than some of the software published by weighing instrument manufacturers.
Why did it take so long to write this software? Isn’t it quite similar to 232key?
SDL was entirely rewritten in C# and uses the .NET framework. It is not a modified version of 232key (which was written in Java).
232key uses pre-defined regular expressions to match the data coming from the connected device and to capture the value you’re interested in. In this article, we’ll demonstrate the use of custom regular expressions (available in the paid Plus version) to capture the (net) weight from a balance and avoid capturing values we do not want to be typed. The instructions posted below can be applied to all kinds of serial devices (not only balances and scales).
When 232key captures too many values
For this example, we’ll be using an Adam Equipment HCB 3001 portable precision balance. It’s equipped with an RS-232 and USB interface. Either one works with 232key:
232key comes with a device profile for this balance. When you select it in the input tab and then press “Set defaults” to set the interface parameters, the following message appears:
This message asks you to modify the balance’s output format so that it only sends the (net) weight to the connected PC. If you change this setting, you won’t have to modify the regular expression in 232key as shown below. However, many other balances and scales have a fixed output format which cannot be modified (you can find multiple real-life example in our support forum). To simulate this problem, we’re keeping the balance set to output format 1 (default setting). As we’re about to see, this output format is not ideal for use with 232key.
In the output tab, we instruct 232key to press the enter key after typing the weight (clearly separating the captured values as they’re being typed):
If we now place an object on the balance, switch to an application like Notepad and press the print key, 232key types not just the weight, but 3 values, e.g.:
Weighing a second object leads to the following output:
A look at the event log in 232key reveals the problem with output format 1: The scale does not only send the weight over the interface, but also the number of accumulations and the total accumulated weight, each in a separate line. 232key captures and types all of these values (as it has no way of knowing which value you’re interested in). This is indicated by the characters in blue in the event log (note how they correspond to the output above):
Capturing the right value
To make sure that 232key only captures the weight from the first line and nothing else, we have to find out what makes this line unique. One candidate would be the unit (“g”), but unfortunately it also appears on the third line:
GS 108.6 g No. 01 Total. 108.6 g
However, only the first line starts with “GS” (which – according to the user manual – stands for “gross weight”). Therefore, we have to make sure that 232key only matches lines starting with “GS”. To do so, we go to the input tab and click on “Customize…”. This brings up a dialog which lets us modify the regular expression associated with this device:
The regular expression shown above captures the first (decimal) number it encounters. You don’t have to fully understand it, it’s sufficient to add “GS” in front of it to make sure 232key only matches lines where these characters appear before the desired value:
When weighing the same two objects again, 232key now only captures the weight from the data sent by the balance (as highlighted in blue in the event log):
In many cases, it’s really that easy to prevent 232key from capturing too many values. All you have to do is find out what makes the line containing the desired value(s) unique and modify the regular expression accordingly. However, as discussed below, sometimes things can get a bit more complicated.
White space and negative values
The space characters sent by the balance after “GS” are currently being matched by the “\s*” expression inside the parentheses. (“\s*” means “match a whitespace character between zero and unlimited times”):
If the balance were to send a negative value, the fact that “\s*” appears after “[-+]” in the regular expression could become a problem. This depends on the position of the minus sign in the data sent by the balance:
- “GS– 108.6 g” would be matched,
- “GS –108.6 g” would not.
The regular expression above instructs 232key to look for “GS” and white space characters (between zero and unlimited times) ahead of the weight (and ahead of a potential minus or plus sign). Do we need it for the Adam Highland balance used in this example? We can’t say, because unfortunately it refused to send (“print”) any negative weights at all. For the following examples, we’ll be reverting to our previous regular expression.
Alternations and capture groups
There’s something else we did not consider: Remember that “GS” stands for gross weight? What happens if we tare a container, place an object inside and then press the print key? 232key does not type anything! A look at the event log reveals that the scale sent “NT” for net weight instead of “GS”. As this does not match our regular expression, 232key ignores the entire line:
This can be fixed by using an alternation that matches either “GS” or “NT”:
However, testing this new expression shows that we’ve made things worse. Not only did 232key not type anything, the event log also contains several error messages:
We forgot to consider that 232key will always capture and process the data from the first capture group only. A capture group is marked by round parentheses and we’ve just inadvertently added a new one which captures either “GS” or “NT”. 232key then tried to convert these characters into a number, which obviously had to fail.
The solution is to mark it as a non-capturing group by adding “?:” as the first characters inside the parentheses. This means that the group is used for matching, but not for capturing data:
Testing this expression shows that 232key now works as expected and also captures the net weight:
This is just one example of how you can use custom regular expressions in 232key Plus. If you want to learn more about regular expressions, this Quick Start guide is a great place to get started. If you need help creating a custom regular expression for your device, please post your question in our support forum.
This article describes how you can capture the weight from a weighing instrument with differentiated digits using 232key Plus.
What are differentiated digits (a.k.a. “auxiliary indicating device”)?
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:
This is supposed to remind the user that on these instruments, the actual scale interval (d) is a multiple of 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 maybe “250.0”.
As far as our virtual keyboard wedge software 232key is concerned, this additional separating character will prevent it from capturing the entire weight value. Instead, it would only capture “250.0” (highlighted in blue in 232key’s event log):
Fortunately, you can easily fix this in the Plus version of our software in just two steps.
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:
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):
By expanding it as below we can instruct 232key to match a slash (“/”) and the following digits, too:
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.
2. Remove the separator
Thanks to the modified regular expression, 232key is now able to capture the entire value sent from the scale, including the separator. However, it would then either show a number format error (if we’ve selected a numeric device in the input tab) or type the data including the separator into the target application (if we’ve selected a text device). Both of these outcomes are not desirable.
Therefore, we also 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:
Once this second step is completed, 232key handles differentiated digits correctly: When the scale sends “250.0/1”, 232key types “250.01” into the target application (e.g. a spreadsheet):
Obviously, you might 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 email us or post in our support forum.
232key version 2016.2.3 comes with the ability to ignore consecutive duplicates. This means that you can instruct 232key to ignore identical data captured several times in a row. I’ll explain this new feature with two usage examples.
Usage example 1: Manually transferring the weight from a scale
Let’s say that you’ve set up 232key to capture the weight from a scale and type it into a parcel processing software running on a PC. To send the weight from the scale, the user presses the “Print” button on the scale’s indicator:
Everything works fine, except that sometimes the button is inadvertently pressed twice, generating two parcel labels. You can use 232key’s new feature to prevent this from happening by checking the “ignore consecutive duplicates” option:
The new ignore function will prevent the second weight from being typed. However, sometimes you might actually encounter two parcels with the same weight in a row. The second parcel would now be ignored by 232key. To fix this, click on the “Adjust…” button and enter a time limit (in milliseconds, e.g. “3000” for 3 seconds):
Any data received after the indicated time has passed is no longer ignored. Each new captured value resets the timer.
Usage example 2: Using auto print mode
In auto print mode, a scale sends the weight automatically without requiring the user to press a button. Not all scales are equipped with this mode and not all auto print modes work in the same way. The Ohaus T31P indicator used in our example has a very simple auto-print mode: It sends every stable weight to the connected PC. This can cause issues if the weight of an item fluctuates between two values: The scale might send these values several times for as long as the item remains on the platform (e.g. 20.00 and 20.05 [kg]).
This is where the second setting in the “ignore consecutive duplicates” dialog comes into play: By defining a tolerance, 232key ignores a range of values. For our example, we’d enter a tolerance of ±0.05:
Now, when the scales sends a weight of 20.05 after just having sent 20.00, it is considered a duplicate and is not typed by 232key.
- The tolerance setting is only available if you’ve selected a numeric device in the “input” tab. It doesn’t make sense to apply a tolerance to text devices, e.g. barcodes received from a barcode reader.
- If data is captured by 232key, it becomes the new reference for both the tolerance and timeout setting even if it is ignored (unless it’s empty, i.e. it contains no printable characters). For our second example with a tolerance setting of 0.05, this means that a value of 20.00 (received first) would be typed, but 20.05 (second) and also 20.10 (third) would be ignored (20.05 + 0.05 = 20.10).
- We recommend that you set a timeout in addition to the tolerance setting to restrict the ignore function (but you don’t have to).
- The new ignore function is not meant to be used with scales working in continuous mode (continuously transferring data several times per second).
Our popular virtual keyboard wedge software 232key is about to receive a major update with significant user interface improvements as well as new functionality.
The first thing you’ll notice in the new version is that the tabs have been renamed and that a new tab has been added:
Input: This used to be the “Interface” tab. It lets you specify from where 232key receives its input, i.e. from which device connected to which interface. Eventually, this tab will also include an option to capture data using custom regular expressions (planned for version 1.7) and further interface options (TCP/IP and possibly USB HID in addition to RS-232/COM port).
Convert: Here, you can tell 232key to convert the data captured from the connected device. A new operation allows you to remove (or keep) the first (or last) x characters, which can be useful if your device sends additional data which you do not want to keep. The multiplication, division and rounding operations which used to appear in the “Format” tab can also be found here. All of these operations are optional, therefore you can ignore the entire tab if no conversion is required.
Output: This tab contains all settings related to the simulated keyboard (and sound) output (e.g. keyboard type, additional keys to be sent before or after the data). These are the settings from the “Format” tab which were not moved to the “Convert” tab.
We hope that the reorganized tabs make working with 232key easier even as we keep adding new features. We’re now going to run extensive tests to ensure that our software works as reliably as ever. We look forward to releasing 232key version 1.60 in the coming week.