Balance
Recorded Data
The Balance records the following attribute during operation:
grams
: The weight reading value of the balance in grams.
Python API
The Balance can be controlled and monitored using the Aqueduct Python API. The Python code for interacting with the balance can be found in the aqueduct-py repository.
The balance.py
module provides functions and classes to control the balance and retrieve weight readings. You can use this API to perform weight measurements and integrate the balance into your Python applications and automation scripts.
To use the Python API, you can import the Balance
class from the balance.py
module and create an instance of the balance. Then, you can call the available methods to retrieve weight readings and perform other operations.
Here's an example of how to use the Balance API:
"""Balance Example Script
This script demonstrates the usage of the `Balance` device from the
Aqueduct library. It connects to an Aqueduct instance,
initializes the system, and performs operations on the balance device.
"""
import time
from aqueduct.core.aq import Aqueduct
from aqueduct.core.aq import InitParams
from aqueduct.devices.balance import Balance
# Parse the initialization parameters from the command line
params = InitParams.parse()
# Initialize the Aqueduct instance with the provided parameters
aq = Aqueduct(params.user_id, params.ip_address, params.port)
# Perform system initialization if specified
aq.initialize(params.init)
# Set the command delay for the Aqueduct instance
aq.set_command_delay(0.05)
# Get the balance device from the Aqueduct instance
balance: Balance = aq.devices.get("balance_000001")
# Continuously perform operations on the balance device
while True:
# Set simulated rates of change for the balance device
balance_rocs = [5]
balance.set_sim_rates_of_change(balance_rocs)
# Get and print the weight readings from the balance device in grams
print(balance.grams)
# Pause for 5 seconds
time.sleep(5)
# Get and print the weight readings again
print(balance.grams)
# Perform a tare operation on the balance device for the first input
balance.tare(0)
Please refer to the aqueduct-py repository for more details on how to use the Python API with the Balance.
Supported Hardware
- with the Aqueduct 4 x RS232 device node, supports communication with up to 4 Ohaus Adventurer or Scout models via RS232 connectivity (RS232 accessory)