public class BrickletLoadCell extends Device
Modifier and Type | Class and Description |
---|---|
class |
BrickletLoadCell.Configuration |
class |
BrickletLoadCell.WeightCallbackThreshold |
static interface |
BrickletLoadCell.WeightListener
This listener is triggered periodically with the period that is set by
setWeightCallbackPeriod(long) . |
static interface |
BrickletLoadCell.WeightReachedListener
This listener is triggered when the threshold as set by
setWeightCallbackThreshold(char, int, int) is reached. |
Device.Identity
Constructor and Description |
---|
BrickletLoadCell(java.lang.String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and Description |
---|---|
void |
addWeightListener(BrickletLoadCell.WeightListener listener)
Adds a Weight listener.
|
void |
addWeightReachedListener(BrickletLoadCell.WeightReachedListener listener)
Adds a WeightReached listener.
|
void |
calibrate(long weight)
To calibrate your Load Cell Bricklet you have to
* empty the scale and call this function with 0 and
* add a known weight to the scale and call this function with the weight.
|
BrickletLoadCell.Configuration |
getConfiguration()
Returns the configuration as set by
setConfiguration(short, short) . |
long |
getDebouncePeriod()
Returns the debounce period as set by
setDebouncePeriod(long) . |
Device.Identity |
getIdentity()
Returns the UID, the UID where the Bricklet is connected to,
the position, the hardware and firmware version as well as the
device identifier.
|
short |
getMovingAverage()
Returns the length moving average as set by
setMovingAverage(short) . |
int |
getWeight()
Returns the currently measured weight.
|
long |
getWeightCallbackPeriod()
Returns the period as set by
setWeightCallbackPeriod(long) . |
BrickletLoadCell.WeightCallbackThreshold |
getWeightCallbackThreshold()
Returns the threshold as set by
setWeightCallbackThreshold(char, int, int) . |
boolean |
isLEDOn()
Returns *true* if the led is on, *false* otherwise.
|
void |
ledOff()
Turns the LED off.
|
void |
ledOn()
Turns the LED on.
|
void |
removeWeightListener(BrickletLoadCell.WeightListener listener)
Removes a Weight listener.
|
void |
removeWeightReachedListener(BrickletLoadCell.WeightReachedListener listener)
Removes a WeightReached listener.
|
void |
setConfiguration(short rate,
short gain)
The measurement rate and gain are configurable.
|
void |
setDebouncePeriod(long debounce)
Sets the period with which the threshold listener
*
BrickletLoadCell.WeightReachedListener
is triggered, if the threshold
* setWeightCallbackThreshold(char, int, int)
keeps being reached. |
void |
setMovingAverage(short average)
Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
for the weight value.
|
void |
setWeightCallbackPeriod(long period)
Sets the period with which the
BrickletLoadCell.WeightListener listener is triggered
periodically. |
void |
setWeightCallbackThreshold(char option,
int min,
int max)
Sets the thresholds for the
BrickletLoadCell.WeightReachedListener listener. |
void |
tare()
Sets the currently measured weight as tare weight.
|
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
public static final int DEVICE_IDENTIFIER
public static final java.lang.String DEVICE_DISPLAY_NAME
public static final byte FUNCTION_GET_WEIGHT
public static final byte FUNCTION_SET_WEIGHT_CALLBACK_PERIOD
public static final byte FUNCTION_GET_WEIGHT_CALLBACK_PERIOD
public static final byte FUNCTION_SET_WEIGHT_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_WEIGHT_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_DEBOUNCE_PERIOD
public static final byte FUNCTION_GET_DEBOUNCE_PERIOD
public static final byte FUNCTION_SET_MOVING_AVERAGE
public static final byte FUNCTION_GET_MOVING_AVERAGE
public static final byte FUNCTION_LED_ON
public static final byte FUNCTION_LED_OFF
public static final byte FUNCTION_IS_LED_ON
public static final byte FUNCTION_CALIBRATE
public static final byte FUNCTION_TARE
public static final byte FUNCTION_SET_CONFIGURATION
public static final byte FUNCTION_GET_CONFIGURATION
public static final byte FUNCTION_GET_IDENTITY
public static final char THRESHOLD_OPTION_OFF
public static final char THRESHOLD_OPTION_OUTSIDE
public static final char THRESHOLD_OPTION_INSIDE
public static final char THRESHOLD_OPTION_SMALLER
public static final char THRESHOLD_OPTION_GREATER
public static final short RATE_10HZ
public static final short RATE_80HZ
public static final short GAIN_128X
public static final short GAIN_64X
public static final short GAIN_32X
public BrickletLoadCell(java.lang.String uid, IPConnection ipcon)
public int getWeight() throws TinkerforgeException
BrickletLoadCell.WeightListener
listener and set the period with
setWeightCallbackPeriod(long)
.TinkerforgeException
public void setWeightCallbackPeriod(long period) throws TinkerforgeException
BrickletLoadCell.WeightListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletLoadCell.WeightListener
listener is only triggered if the weight has changed since the
last triggering.TinkerforgeException
public long getWeightCallbackPeriod() throws TinkerforgeException
setWeightCallbackPeriod(long)
.TinkerforgeException
public void setWeightCallbackThreshold(char option, int min, int max) throws TinkerforgeException
BrickletLoadCell.WeightReachedListener
listener.
The following options are possible:
\verbatim
"Option", "Description"
"'x'", "Listener is turned off"
"'o'", "Listener is triggered when the weight is *outside* the min and max values"
"'i'", "Listener is triggered when the weight is *inside* the min and max values"
"'<'", "Listener is triggered when the weight is smaller than the min value (max is ignored)"
"'>'", "Listener is triggered when the weight is greater than the min value (max is ignored)"
\endverbatimTinkerforgeException
public BrickletLoadCell.WeightCallbackThreshold getWeightCallbackThreshold() throws TinkerforgeException
setWeightCallbackThreshold(char, int, int)
.TinkerforgeException
public void setDebouncePeriod(long debounce) throws TinkerforgeException
BrickletLoadCell.WeightReachedListener
is triggered, if the threshold
* setWeightCallbackThreshold(char, int, int)
keeps being reached.TinkerforgeException
public long getDebouncePeriod() throws TinkerforgeException
setDebouncePeriod(long)
.TinkerforgeException
public void setMovingAverage(short average) throws TinkerforgeException
TinkerforgeException
public short getMovingAverage() throws TinkerforgeException
setMovingAverage(short)
.TinkerforgeException
public void ledOn() throws TinkerforgeException
TinkerforgeException
public void ledOff() throws TinkerforgeException
TinkerforgeException
public boolean isLEDOn() throws TinkerforgeException
TinkerforgeException
public void calibrate(long weight) throws TinkerforgeException
TinkerforgeException
public void tare() throws TinkerforgeException
TinkerforgeException
public void setConfiguration(short rate, short gain) throws TinkerforgeException
setMovingAverage(short)
) to the measurements.
The gain can be 128x, 64x or 32x. It represents a measurement range of
±20mV, ±40mV and ±80mV respectively. The Load Cell Bricklet uses an
excitation voltage of 5V and most load cells use an output of 2mV/V. That
means the voltage range is ±15mV for most load cells (i.e. gain of 128x
is best). If you don't know what all of this means you should keep it at
128x, it will most likely be correct.
The configuration is saved in the EEPROM of the Bricklet and only
needs to be done once.
We recommend to use the Brick Viewer for configuration, you don't need
to call this function in your source code.TinkerforgeException
public BrickletLoadCell.Configuration getConfiguration() throws TinkerforgeException
setConfiguration(short, short)
.TinkerforgeException
public Device.Identity getIdentity() throws TinkerforgeException
getIdentity
in class Device
TinkerforgeException
public void addWeightListener(BrickletLoadCell.WeightListener listener)
public void removeWeightListener(BrickletLoadCell.WeightListener listener)
public void addWeightReachedListener(BrickletLoadCell.WeightReachedListener listener)
public void removeWeightReachedListener(BrickletLoadCell.WeightReachedListener listener)
Copyright © 2020 Tinkerforge GmbH. All rights reserved.