Skip to content

Load Cell

This module provides a class for the load cell.

ATTRIBUTE DESCRIPTION
READ_FORMAT

Format for reading data

TYPE: str

ValueData

NamedTuple for value data

TYPE: NamedTuple

CLASS DESCRIPTION
LoadCell

Load cell class

Documentation last updated: 2025-02-22

G module-attribute

G = 9.81

Acceleration due to Earth's gravity

LoadCell

LoadCell(
    port: str,
    stabilize_timeout: float = 1,
    force_tolerance: float = 0.01,
    *,
    calibration_factor: float = 1.0,
    correction_parameters: tuple[float] = (1.0, 0.0),
    baudrate: int = 115200,
    verbose: bool = False,
    **kwargs,
)

Bases: Measurer

Load cell

ATTRIBUTE DESCRIPTION
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

getAttributes

Get attributes

getData

Get data from device

getDataframe

Get data as a DataFrame

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 LoadCell class

PARAMETER DESCRIPTION
port

Serial port

TYPE: str

stabilize_timeout

Time to wait for the device to stabilize

TYPE: float DEFAULT: 1

force_tolerance

Tolerance for force

TYPE: float DEFAULT: 0.01

calibration_factor

counts per unit force

TYPE: float DEFAULT: 1.0

correction_parameters

polynomial correction parameters, starting with highest order

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

baudrate

Baudrate for serial communication

TYPE: int DEFAULT: 115200

verbose

Print verbose output

TYPE: bool DEFAULT: False

atForce

atForce(
    force: float,
    current_force: float | None = None,
    *,
    tolerance: float | None = None,
    stabilize_timeout: float = 0,
) -> bool

Check if the device is at the target temperature

PARAMETER DESCRIPTION
force

Target force

TYPE: float

tolerance

Tolerance for force

TYPE: float DEFAULT: None

stabilize_timeout

Time to wait for the device to stabilize

TYPE: float DEFAULT: 0

RETURNS DESCRIPTION
bool

True if the device is at the target force

TYPE: bool

getAttributes

getAttributes() -> dict

Get attributes

RETURNS DESCRIPTION
dict

Attributes

TYPE: dict

getData

getData(*args, **kwargs) -> ValueData | None

Get data from device

RETURNS DESCRIPTION
ValueData

Value data

TYPE: ValueData | None

getForce

getForce() -> float | None

Get force

RETURNS DESCRIPTION
float

Force

TYPE: float | None

getValue

getValue() -> float | None

Get value

RETURNS DESCRIPTION
float

Value

TYPE: float | None

zero

zero(timeout: int = 5)

Set current reading as baseline

PARAMETER DESCRIPTION
timeout

Time to wait for the device to stabilize. Defaults to 5.

TYPE: int DEFAULT: 5