UniteLabs
Reference

Mettler Toledo WXS series

Connect a Mettler Toledo WXS series balance through GroundControl, then tare it and read a stable weight from Python.

What you need

ItemDetail
InstrumentA WXS balance, powered on, with an empty pan. Mettler Toledo specifies a warm-up of at least 120 minutes after power-up.
ConnectivityThe load cell connects to the electronic unit with a special cable supplied by the manufacturer. The electronic unit connects to the computer with an RS232 cable.
ConnectorMettler Toledo WXS, package unitelabs-mettler-toledo-wxs 0.3.0 or later.
Vendor softwareNone.
MachineA computer connected to the balance, running GroundControl.
AccessA tenant and a user account for the UniteLabs Platform and GroundControl.
NotebookThe IDE in the UniteLabs Platform, or a development machine with the UniteLabs SDK.

Install and configure the connector

  1. In GroundControl, add a device and search for WXS205SDU/15 (Connector configuration).
  2. Choose to set up the connector automatically and download the correct connector version. This guide uses version 0.3.0.
  3. Fill in the General Configuration:
    FieldValue
    serial_portThe serial port of the balance. Defaults to /dev/ttyUSB0, a Linux port name. Set it to the port of your balance, for example /dev/cu.usbserial-XXXX on macOS or COM3 on Windows.
    simulation_modeDefaults to true: the connector returns sample values, including weights in milligrams, raises random errors, and does not open the serial port. Set to false to use the balance.
  4. The default name of the SiLA server is Mettler Toledo WXS. You can change it in GroundControl under the Local Network settings, in the Name field.
  5. Start the connector with simulation_mode set to false and enable Platform connectivity. The connector registers the features WeighingService, DeviceInformation, DeviceControl, and SimulationController. Note the service name for Python.

To switch between the simulator and the balance without restarting, run start_real_mode or start_simulation_mode under Simulation Controller.

First successful test

You can test the balance from the Devices view in GroundControl or the Platform, from a notebook (Platform IDE), from a Python script on your computer, or from a UniteLabs workflow.

The Devices view lists your devices and lets you send commands to the balance without writing code. GroundControl and the Platform show the same interface, so the steps are the same in both. Test in GroundControl does not require access to the Platform or internet.

  1. Clear the weighing pan.
  2. Select the Devices tab, then your balance, for example Mettler Toledo WXS.
  3. To read the model, find Device Information and select Read Model Designation. Select the lightning-bolt button to run the command. The Response panel shows Command executed. and the model designation.
  4. To tare the balance with the pan empty, find Weighing Service and select Tare. Select the lightning-bolt button. The response shows Tare Weight, Unit, and Is Stable. The screenshot below shows the Tare command and its response, from a connector in simulation mode, so the values are sample values.
  5. Place a sample on the pan. In Weighing Service, select Weight Immediately and select the lightning-bolt button. The response shows Weight Value, Unit, and Is Stable, in the balance's current display unit.

Tare and Weight Immediately return without waiting for the balance to settle, and Is Stable shows whether the value was stable. Tare Stable and Stable Weight wait until the balance is stable and return the same values without Is Stable. They fail with TimeoutExceededError if the balance does not settle within request_timeout.

In simulation mode, the commands return sample values and fail at random. Run the command again.

Known quirks and errors

You seeIt meansDo this
Weights change on their own, in milligramsSimulation mode is on. The connector returns sample weights that change between calls.Set simulation_mode to false and restart the connector.
Calls fail at random with BalanceInternalError, BalanceParameterError, ResponseFormatError, or other balance errorsSimulation mode is on. The connector returns random errors to exercise error handling.Set simulation_mode to false and restart the connector.
The connector cannot open the serial portserial_port does not name the port of the balance.Set serial_port to the port the balance uses on the connector's computer.
TimeoutExceededError from stable_weight, tare_stable, or zero_stableThe balance did not settle within request_timeout. Higher readability settings, drafts, and vibration lengthen settling time. The balance itself stops waiting after about 40 seconds (vendor manual, section 4.1).Increase request_timeout. With a value above 40, or null, the balance gives up first and the call raises BalanceInternalError. Lower the readability with set_readability. Check that the balance is level and the location free of drafts and vibration.
BalanceInternalErrorThe balance is not ready, for example right after it starts or restarts.Wait a few seconds and retry.
BalanceInternalError from stable_weight, tare_stable, or zero_stable long after power-upThe balance could not zero itself at power-up, for example because of drafts or vibration. Stable commands fail until a zero succeeds.Check the ambient conditions. Read weight_immediately: a reading more than a few digits from zero confirms the problem. Then run zero_stable, or temporarily raise the stability criteria with set_stability_criteria.
Underloaded from tare_stable, stable_weight, or weight_immediatelyThe balance reads below its zero. This happens when the zero was set with a weight on the weighing pan, and the load later drops below that weight. The balance sets a zero at every power-up and restart, including the restart after set_readability, so a vial on the pan at those moments has the same effect.Remove the vial and everything else from the pan. Run zero_stable on the empty pan, then place the vial and run tare_stable. Always power up the balance and change the readability with the pan empty.
OverloadedThe weight is above the balance's range.Remove the load.
Tare and readability settings resetset_readability restarts the weighing module, sets a new zero, and clears the tare memory.Set the readability first, then zero and tare.
Run zero and zero_stable only with an empty pan. All later readings, including the tare weight, are measured relative to the new zero.

More snippets

  • Change the display unit: await scale.weighing_service.set_unit(unit="mg"). Supported units are g, mg, oz, and ozt.
  • Preset a tare weight: await scale.weighing_service.set_tare_weight(tare_preset_value=12.5, unit="g"). The balance rounds the value to its readability.
  • Clear the tare memory: await scale.weighing_service.clear_tare_weight().
  • Stop a running command: await scale.device_control.cancel_command() ends zeroing, taring, and other running processes.
  • Read the stability criteria: await scale.device_control.read_stability_criteria() returns the bandwidth and observation period for weighing, taring, and zeroing.

Connector reference

Browse the connected balance's features and commands in the Devices view, or list them in Python with the scale variable from the first test:

print(scale.modules.keys())
print((await scale.weighing_service).actions.keys())

The first line lists the modules, and the second line lists the actions of weighing_service. Replace weighing_service with another module name to list its actions.

Vendor documentation

Refer to Mettler Toledo's Instructions for Installation and Operation of the WXS and WXT weighing modules for detailed setup and operation instructions.

Last updated