How to use the Ohaus Defender 5000 demo kit suitcase

The demo kit allows you to easily test the many interfaces available for the Ohaus Defender 5000 indicator. Its sturdy case is well suited for shipping.

Follow these steps to start using it:

  1. The required components and cables can be found in the compartment on the left side (1).
  2. Connect the load cell simulator (2) (3).

This device simulates the load cell that is normally installed in the weighing platform. Make sure that the pointers on the gauge are at 0, but do not turn on the scale yet.

  1. Set the selector knob (4) to the interface you want to test (e.g. WiFi/BT).
  2. If necessary, plug in the WiFi/Bluetooth dongle (5).
  3. Connect the device to AC power and switch it on.

Turn the load cell simulator counterclockwise to increase the weight:

The configuration of the interface is done in the menu of the scale. Printed instructions are included in the case (6).

When using a WiFi or wired Ethernet connection, the device acts as a TCP server. By default, the IP address is assigned automatically (DHCP). WiFi uses port 6060 and Ethernet port 9761.

After establishing a connection as a TCP client (e.g. using PuTTY), you can request the weight by using one of the commands listed in the manual. The “P” command corresponds to pressing the Print button on the scale. The device will answer using the default template:

This template can be changed in the menu. The menu also allows you to select a different capacity or graduation.

Note: A micro SD card is included in the device, but it cannot be easily accessed.

Reading the weight from an Ohaus Defender 5000 scale with PHP

Please consider: A single-threaded, synchronous programming language with blocking I/O calls like PHP may not be the best choice for communicating with a scale. The following post is not meant as a recommendation for PHP.

Defender 5000 scales can be equipped with a WiFi or wired Ethernet interface. The scale acts as a TCP server and your script establishes a persistent connection as a TCP client.

You can then use one of the following methods to send the weight from the scale to your PHP application:

  • Send a command to the scale to request the weight (described in this post).
  • Wait until the operator presses the PRINT button.
  • Configure the scale to send each stable weight automatically.
  • Set the scale to a continuous transmission mode (it will send several values per second).

Please see the Defender 5000 manual (PDF) for further information.

You can easily test the communication via wired Ethernet or WiFi by using PuTTY in “raw” mode:

PuTTY raw tcp connection
The WiFi dongle uses port 6060 (wired Ethernet: port 9761), the IP address is assigned via DHCP by default.

Defender 5000 scale: weight in PuTTY
IP (immediate print) command used to request the weight and reply sent by the scale (N: net weight, G: gross weight, T: tare weight).

Using PHP to communicate with the scale

For demonstration purposes, I’ve adapted example #2 (simple TCP/IP client) from the official documentation:

<?php
error_reporting(E_ALL);

echo "TCP/IP Connection\n";

/* Ohaus Defender 5000 WLAN interface uses port 6060 by default, Ethernet interface uses port 9761 */
$service_port = 6060;

/* IP address of the scale, can be displayed/set in the menu */
$address = "192.168.0.195";

/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
    echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
} else {
    echo "OK.\n";
}

echo "Attempting to connect to '$address' on port '$service_port'...";
$result = socket_connect($socket, $address, $service_port);
if ($result === false) {
    echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n";
} else {
    echo "OK.\n";
}

$in = "IP\r\n"; //IP command (Immediate Print) - supported commands depend on the manufacturer, model and LFT settings
$out = '';

echo "Sending command...";
socket_write($socket, $in, strlen($in));
echo "OK.\n";

echo "Reading response:\n\n";
while ($out = socket_read($socket, 128, PHP_NORMAL_READ)) {
    echo $out;
}

echo "Closing socket...";
socket_close($socket);
echo "OK.\n\n";

When socket_read encounters carriage return or line feed, it returns the data received from the scale. By default, these characters are sent by the scale at the end of each line.

The PHP script produced the following output:

Defender 5000 weight requested with PHP

You can modify the output template through the menu of the scale or by using the Ohaus Scale Mate software, e.g. to send just the net weight and date/time:

Ohaus Defender 5000 custom template

You’ll find a list of commands supported by the scale in the user manual (chapter 5, “interface command”). Note that each command has to be followed by carriage return and line feed.

In the script, I used the “IP” (immediate print) command, which tells the scale to send the weight immediately (whether it is stable or not). This command is available on all recent Ohaus scales. One notable exception are legal-for-trade (LFT) models, which only support the P command (similar to pressing the print button) and in some cases the SP command (stable print, send weight as soon as it has stabilized).

Tip: The Ohaus Defender 5000 also supports many MT-SICS commands. This means that you could send commands such as “SI” (send immediately) and receive a reply in a standardized format which is independent of the template set in the scale:
MT-SICS response Ohaus Defender 5000

Please note that I’m not a PHP expert and that I don’t recommend using PHP. This article is only supposed to be a very basic demonstration. Other programming languages such a C#, Java, server-side JavaScript (node.js) or Python may be more suitable.


The header photo shows a Defender 5000 communication test case (a hard case with a built-in Defender 5000 indicator with all optional communication interfaces installed).

How to connect your scale to a network (Ethernet) using Moxa’s NPort 5110A

Many scales and balances are equipped with an RS-232 interface. Moxa’s NPort series and similar serial device servers allow you to connect such scales to a network (Ethernet). In this article, I’ll show you how to connect a Moxa NPort 5110A to an Ohaus scale and how to configure and test it.

1. Physical connection

The Moxa Nport 5110A has an RS-232 port (DE9M) on one side and an Ethernet port on the other side:

Data cables (red) are not included.

To communicate with your scale, you’ll need a matching RS-232 cable. The Ohaus Defender 3000 scale used in this example requires a DE9M to DE9F straight (1:1) cable:

Ohaus scale with Ethernet connection through Moxa NPort 5110A

Once the physical connection to the scale has been established, the Moxa NPort has to be configured. There are several ways to do so. I prefer the following method:

  1. Connect the NPort directly to a single computer (not a LAN) with an Ethernet cable.
  2. Use the NPort Administator software included with the device to configure it.

2. Network configuration

Start the NPort Administrator and locate your NPort by clicking on the Search button:NPort Administrator: Search

It should be found at the default IP address (192.168.127.254).

Note: It’s not always necessary to change your PC’s IP address if you’re running the NPort Administrator software. However, if you receive error messages during the following steps, try to temporarily set your computer’s IP address to an address on the same subnet (such as 192.168.127.1).

Select the Ethernet connection under Control Panel > Network and Internet > Network connections, right-click on it and choose Properties, then select Internet Protocol Version 4 (TCP/IPv4) and click on Properties. Make a note of your current settings so that you can restore them later, then enter the temporary IP address:
Ethernet IP address setting in Windows 10

If the NPort is shown as locked, right-click on it and select Unlock:
NPort Administrator: UnlockThe default password is “moxa”.

Right-click again and select Configure, then select the Network tab:
NPort Administrator: Network configurationEnter a static IP address, subnet mask and gateway that work on your network (or select DHCP or BOOTP for automatic address assignment, though this is not recommended for most operating modes).

To make the NPort accessible on our network, I set its IP address to 192.168.0.253:
NPort Administrator: Modified network settings

With the network configuration complete, you can disconnect the NPort 5110A from your computer and connect it to your network (LAN).

3. RS-232 configuration

It is essential that both the NPort and the scale use the same settings for the serial port (RS-232). In the Serial tab, select the port (the NPort 5110A only has one, but you still have to select it), check Modify and click on Settings:
NPort Administrator: Default serial settings

Enter the RS-232 settings found in your scale’s menu or user manual. The default settings of our Ohaus Defender 3000 scale are shown in the screenshot below:NPort Administrator: Serial configuration (RS-232)

Important: By default, the NPort is set to CTS/RTS flow control! You cannot change this setting when using the Setup Wizard through the web console. As mentioned before, I recommend using the NPort Administrator software instead.

4. Set an operating mode

To change the mode, go to the Operating Mode tab, check Modify, select the port and click on Settings:NPort Administrator: Operating Mode

The NPort 5110A supports several operating modes, I will only discuss the following two here:

  • Real COM mode: This mode allows you to create a virtual COM port on a PC and use the scale as if it were connected directly to that PC. This is very useful when you’re using software which only supports connections to COM ports and cannot communicate over TCP/IP (such as our 232key virtual keyboard wedge software).
    Please note that you’ll have to install a virtual COM port driver on the PC that communicates with the scale. In my tests on Windows 10, setting up the COM port through NPort Administrator did not create a new virtual COM port on the system. However, using the NPort Windows Driver Manager worked.
  • TCP Server: The NPort acts as a server, waiting for incoming connections from TCP clients on port 4001 (or on another user-defined port). The maximum number of concurrent connections can be changed from 1 (default) to up to 8. This mode works with software like our Simple Data Logger and many others.
    NPort Administartor: TCP Server mode

    Note: It is not necessary to set the data packing options unless you want to optimize either for minimal latency or maximum throughput. By default, the device will try to find a reasonable compromise (this is likely achieved by observing the delay between the data received over RS-232 to determine when a “line” of data is complete).

    When I set the scale to continuous transmission mode (wich has no delay between the weight values), the NPort packed 104 bytes in each Ethernet frame, corresponding to almost 6 weight values (the scale sends 80 values/s):
    Wireshark screenshot

For further details and for information on the other modes, please consult the user manual.

5. Run a test

Depending on the operating mode chosen above, you’ll have to use different programs to test the NPort 5110A. In addition to the software I’ve already mentioned above, you could use the following:

Real COM mode

A terminal program like Termite or HTerm can connect to the virtual COM port. Make sure that the connection parameters correspond to the settings of your scale.

TCP Server

You can use PuTTY set to “Raw” TCP mode to act as a TCP client:
PuTTY configurationThe following screenshot shows commands sent to the scale and the replies:PuTTY communication with Ohaus scaleAnother option is our free TCPTester software. It repeatedly sends a user-defined command to the scale (e.g. to request the weight). Once a reply has been received, the command is repeated:

TCPTester tcp utility used to test Moxa NPort connected to Ohaus scale
TCPTester free TCP test utility available from Smartlux

During testing, it can be useful to observe the LEDs on the NPort:

  • The “Ready” LED should be green.
  • The “Link” LED is green when the NPort has established a 100 Mbs Ethernet connection and orange on a 10 Mbps connection.
  • The Tx/Rx LED flashes orange when the NPort receives data from the scale and flashes green when the NPort is sends data to the scale over the serial port. Therefore, If you’re sending commands to a scale, you should be able to see it flash green. A reply from the scale would cause the LED to flash orange. If this is too difficult to see, consider using the web console to diagnose connection issues (I found it worked best in Firefox):
    Moxa web console monitor async

I hope this article has been useful. What are your experiences with Moxa’s NPort serial device servers? Please don’t hesitate to leave a comment! For support, please contact Moxa or your vendor.

Did you find this article helpful? You can support this blog by purchasing a PDF version for US$2/copy (contains no additional information).