DULMEN.net   Follow me on Facebook Contact DULMEN.net  

WeightKey - Programming@DULMEN.net

WeightKey
A small highly configurable application that communicates with a RS232 compatible scale and converts the weight value to a keystroke. The look of the program can be adapted to match your destination application.

 
Features
-Shows an emulated LCD display on screen with current weight value
-Position, size and background of the emulated LCD display are configurable
-Generates a keystroke with the current value upon pressing a configurable key
-Prevents typing errors and the need for manual rounding or other conversions of the displayed weight
-Formatting of the weight value is configurable
-Optimized to work in conjunction with the Ohous T31 indicators and Mettler Toledo scales
-Needs TTF LCD font ("Repetition Scrolling", repet___.ttf, included)
-Designed to be used in conjunction with StartVK
 
Description
If you need to type a weight displayed on a digital scale on a computer over and over again, this program can help. Most (proffesional) digital scales have a RS232 (serial) interface which can be used to connect the scale to a computer. Depending on the scales specifications it can send the displayed weight continiously and/or respond to a request from the computer.
WeightKey can handle both situations and by pressing its hotkey it sends the weight to the computers keyboard buffer. The active field in the target application gets filled with the displayed weight.

The look and feel of WeightKey is highly configurable. You can make your own background, adjust the font size and position, configure the rounding of the displayed weight, asign keys to push the displayed weight into the keyboardbuffer or show the configuration window, set a minimum weight and adjust the format of the displayed weight and of that from the weight it sends as a keystroke. See the configuration file for all settings.

Because I didn't have a scale at home I used an old 56k modem for testing purposes. I configured WeightKey to request the modems maximum speed all the time (request string ATI0) on which it responds with 57600. Version 1.3 can also handle a scale that sends the weight continiously. For this I wrote a simple program (SendWeight, see screenshots and downloads below) that simulates this behaviour by sending a random weight all the time.

Make sure the scale is propperly configured to handle the requests from WeightKey. Especialy on the tested Mettler Toledo scales the Print->Mode needed to be set to Dialog. On all scales the RS232 settings need to match the settings used in the WeightKey scale configuration file (baudrate, data bits, stop bit, parity, handshake).
 
Screenshots
  
WeightKey displayed value
WeightKey error codeWeightKey configurationWeightSend screenshot
 
Commandline options
No command-line options available.
 
Configuration file settings
[ApplicationOptions]
DisplayPosX Left position of the LCD display in pixels
DisplayPosY Top position of the LCD display in pixels
Background Background picture
FontSize Font size in pixels for LCD display (default = 48)
FontOffsetX Left position of displayes weight in pixels (values < 1 are relative to font width)
FontOffsetY Top position of displayes weight in pixels (values < 1 are relative to font height)
DisplayWidth Width of the display in pixels (0 = same as background, 1 = relative to font width)
DisplayHeight Height of the display in pixels (0 = same as background, 1 = relative to font height)
ShowTicker Display flashing point on every RS232 send/receive (0 = off, 1 = on)
OptionsKey Keypress to choose the scale type (default = ^+F8 = Ctrl-Shift-F8) *
SendKey Keypress to generate the keystroke with current weight (default = F8) *
Settings Settings file for scale
* NOTE: Default start of application with key +F8 (Shift-F8) if combined with StartVK v1.7 (or higher).
 
WeightKey can handle several scale settings saved as "WeightKey_****.ini". The active setting can be selected from WeightKeys configuration window.

[ScaleType]
ScaleName The name of the scale setting displayed in the dropdown box on the configuration window
[RS232Options]
ComPort Serial port connected to scale indicator (default = COM1)
Baudrate Communication baudrate (default = 9600)
Parity Communication parity (default = N)
DataBits Communication data bits (default = 8)
StopBits Communication stop bits (default = 1)
XonXoff Communication Xon/Xoff (0 = off, 1 = on, default = 1)
ReadBuffer Number of bytes to read from the serial port (1..255, default = 31)
RequestString Request string to send to scale indicator, blank skips the request (default = blank)
DelayTime Time between value updates in ms (1000-3000, default = 1000)
[WeightOptions]
Unit Unit to be displayed on the LCD display (default = kg)
DisplayFormat Format for the displayed weight (default = 0000.0)
KeyFormat Format for the keystroke (default = 0000)
Round Round displayed value (0 = down, 1 = normal, 2 = up) *
AddValue Value to add to displayed value (default = 0)
TooLowValue Value too low to be true (default = 0)
* Someone really wanted this strange option: rounding to halfs (50 = down, 51 = normal, 52 = up). In my opinion a mathmetic nightmare so lets just keep quiet about it :)
 
Error codes
E0 No data from COM port received (message box)
E1 Problem creating the structure that contains the RS232 COM port number, baud rate, etc. (message box)
E2 Problem creating the RS232 COM file handle, e.g. COM port does not exist (message box)
E3 Cannot set the COM port state, COM port number, baud rate, etc. (message box)
E4 Cannot set the COM port timeouts (message box)
E5 Problem closing RS232 file handle (message box)
E6 Problem writing data to COM port (E6 in display)
E7 Problem reading data from COM port (E7 in display)
E8 Received data is not a valid weight, e.g. not a number (E8 in display)
E9 Error on display or value is too low (message box)
 
Version history
v1.0 Initial setup
v1.1 Added round option (up/down/normal)
Added support for Mettler Toledo scales
Splitted the settings file in two (Application and Scale settings)
Added a "too low" option at wich the keystroke is not generated
Improved internal error handling
Bug 01: finish current loop and disconnect RS232 connection before exit
v1.2 Changed About window to Options window (added scale selection/restart and exit buttons)
Added hotkey to open Options window
Removed restart and close hotkeys
Added optional fixed value to add to displayed value
Rearranged startup sequence to improved error handling
Bug 01: set RS232 communication as critical
v1.3 Added read only mode (no request send, scale print set to auto)
Added option to skip the RS232 request by leaving the RequestString setting blank
 
Known bugs
Bug no. Version Fixed in Description
01 v1.0 v1.2 OHaus T31P indicator freezes sometimes (at logging on/off user account ?)
 
Future enhancements
None at this moment.
 
Download
Please read the legal notice first, allthough you probably heard it before :)


Copyright 2018 DULMEN.net. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY DULMEN.net ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL DULMEN.net OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of DULMEN.net.


You can download WeightKey as a compressed folder containing all files needed. No need to install the software, just unzip, adapt the configuration file WeightKey.ini and run WeightKey.exe.
WeightKey is free for personal and bussiness use and is free to distribute as is as long as the program is not altered and accompanied with the WeightKey text file.

VersionFileSize
v1.3WeightKey_v1.3.zip506,21 KB (518356 bytes)
v1.3WeightKey_v1.3.7z431,48 KB (441836 bytes)
v1.2WeightKey_v1.2.zip505,23 KB (517358 bytes)
v1.2WeightKey_v1.2.7z431,2 KB (441549 bytes)
v1.0WeightKey_WeightSend_v1.0.zip399,65 KB (409239 bytes)
v1.0WeightKey_WeightSend_v1.0.7z325,18 KB (332984 bytes)
WeightKey_UniSystems Indicator E2075 - B02490.pdf740 KB (757758 bytes)
WeightKey_METTLER TOLEDO - IND425 BB35 (EN).pdf918,13 KB (940167 bytes)
WeightKey_METTLER TOLEDO - BBK 432 35 DLA (EN).pdf1,39 MB (1459949 bytes)
 
 
DULMEN.net © v8 2018 - Designed & written by Arno van Dulmen