Skip to content

Balance

This module provides a class for the balance.

ATTRIBUTE DESCRIPTION
G

Acceleration due to gravity

TYPE: float

CLASS DESCRIPTION
Balance

Balance class

Documentation last updated: 2025-02-22

Balance

Balance(
    port: str,
    stabilize_timeout: float = 10,
    force_tolerance: float = 1.5,
    mass_tolerance: float = 0.15,
    *,
    calibration_factor: float = 1.0,
    correction_parameters: tuple[float] = (1.0, 0.0),
    baudrate: int = 115200,
    verbose: bool = False,
    **kwargs,
)

Bases: LoadCell

Balance class for interfacing with a balance.

ATTRIBUTE DESCRIPTION
mass_tolerance

The tolerance for the mass measurement.

TYPE: float

force_tolerance

Tolerance for force

TYPE: float

stabilize_timeout

Time to wait for the device to stabilize

TYPE: float

baseline

Baseline value

TYPE: int

calibration_factor

counts per unit force

TYPE: float

correction_parameters

polynomial correction parameters, starting with highest order

TYPE: tuple[float]

buffer

data buffer for the device

TYPE: deque

buffer_df

data buffer as a DataFrame

TYPE: DataFrame

records

records for the device

TYPE: deque

records_df

records as a DataFrame

TYPE: DataFrame

record_event

event for recording data

TYPE: Event

program

program to run

TYPE: Program

runs

dictionary of runs

TYPE: dict

n_runs

number of runs

TYPE: int

connection_details

connection details for the device

TYPE: dict

device

device object that communicates with physical tool

TYPE: Device

flags

flags for the class

TYPE: SimpleNamespace[str, bool]

is_busy

whether the device is busy

TYPE: bool

is_connected

whether the device is connected

TYPE: bool

METHOD DESCRIPTION
connect

Connect to the device

getDataframe

Get a DataFrame from the data store

atMass

Check if the balance is at a specific mass

getMass

Get the mass measured by the balance

tare

Tare the balance

getAttributes

Get attributes

getData

Get data from device

atForce

Check if the device is at the target force

getForce

Get force

getValue

Get value

reset

Reset the device

zero

Set current reading as baseline

disconnect

disconnect from the device

execute

execute task

resetFlags

reset all flags to class attribute _default_flags

run

alias for execute()

shutdown

shutdown procedure for tool

Initialize the balance.

PARAMETER DESCRIPTION
port

The port to connect to.

TYPE: str

stabilize_timeout

The time to wait for the balance to stabilize.

TYPE: float DEFAULT: 10

force_tolerance

The tolerance for the force measurement.

TYPE: float DEFAULT: 1.5

mass_tolerance

The tolerance for the mass measurement

TYPE: float DEFAULT: 0.15

calibration_factor

The calibration factor for the balance.

TYPE: float DEFAULT: 1.0

correction_parameters

The correction parameters for the balance.

TYPE: tuple[float] DEFAULT: (1.0, 0.0)

baudrate

The baudrate for the balance.

TYPE: int DEFAULT: 115200

verbose

The verbosity of the balance.

TYPE: bool DEFAULT: False

atMass

atMass(mass: float) -> float

Check if the balance is at a specific mass.

PARAMETER DESCRIPTION
mass

The mass to check for.

TYPE: float

RETURNS DESCRIPTION
float

The force measured by the balance.

TYPE: float

getMass

getMass() -> float

Get the mass measured by the balance.

RETURNS DESCRIPTION
float

The mass measured by the balance.

TYPE: float

tare

tare(wait: float = 5.0)

Tare the balance.

PARAMETER DESCRIPTION
wait

The time to wait after taring.

TYPE: float DEFAULT: 5.0