Package com.tinkerforge
Class BrickletCurrent12
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletCurrent12
-
public class BrickletCurrent12 extends Device
Measures AC/DC current between -12.5A and +12.5A
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletCurrent12.AnalogValueCallbackThreshold
static interface
BrickletCurrent12.AnalogValueListener
This listener is triggered periodically with the period that is set bysetAnalogValueCallbackPeriod(long)
.static interface
BrickletCurrent12.AnalogValueReachedListener
This listener is triggered when the threshold as set bysetAnalogValueCallbackThreshold(char, int, int)
is reached.class
BrickletCurrent12.CurrentCallbackThreshold
static interface
BrickletCurrent12.CurrentListener
This listener is triggered periodically with the period that is set bysetCurrentCallbackPeriod(long)
.static interface
BrickletCurrent12.CurrentReachedListener
This listener is triggered when the threshold as set bysetCurrentCallbackThreshold(char, short, short)
is reached.static interface
BrickletCurrent12.OverCurrentListener
This listener is triggered when an over current is measured (seeisOverCurrent()
).-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEVICE_DISPLAY_NAME
static int
DEVICE_IDENTIFIER
static byte
FUNCTION_CALIBRATE
static byte
FUNCTION_GET_ANALOG_VALUE
static byte
FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD
static byte
FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD
static byte
FUNCTION_GET_CURRENT
static byte
FUNCTION_GET_CURRENT_CALLBACK_PERIOD
static byte
FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD
static byte
FUNCTION_GET_DEBOUNCE_PERIOD
static byte
FUNCTION_GET_IDENTITY
static byte
FUNCTION_IS_OVER_CURRENT
static byte
FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD
static byte
FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD
static byte
FUNCTION_SET_CURRENT_CALLBACK_PERIOD
static byte
FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD
static byte
FUNCTION_SET_DEBOUNCE_PERIOD
static char
THRESHOLD_OPTION_GREATER
static char
THRESHOLD_OPTION_INSIDE
static char
THRESHOLD_OPTION_OFF
static char
THRESHOLD_OPTION_OUTSIDE
static char
THRESHOLD_OPTION_SMALLER
-
Constructor Summary
Constructors Constructor Description BrickletCurrent12(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAnalogValueListener(BrickletCurrent12.AnalogValueListener listener)
Adds a AnalogValue listener.void
addAnalogValueReachedListener(BrickletCurrent12.AnalogValueReachedListener listener)
Adds a AnalogValueReached listener.void
addCurrentListener(BrickletCurrent12.CurrentListener listener)
Adds a Current listener.void
addCurrentReachedListener(BrickletCurrent12.CurrentReachedListener listener)
Adds a CurrentReached listener.void
addOverCurrentListener(BrickletCurrent12.OverCurrentListener listener)
Adds a OverCurrent listener.void
calibrate()
Calibrates the 0 value of the sensor.int
getAnalogValue()
Returns the value as read by a 12-bit analog-to-digital converter.long
getAnalogValueCallbackPeriod()
Returns the period as set bysetAnalogValueCallbackPeriod(long)
.BrickletCurrent12.AnalogValueCallbackThreshold
getAnalogValueCallbackThreshold()
Returns the threshold as set bysetAnalogValueCallbackThreshold(char, int, int)
.short
getCurrent()
Returns the current of the sensor.long
getCurrentCallbackPeriod()
Returns the period as set bysetCurrentCallbackPeriod(long)
.BrickletCurrent12.CurrentCallbackThreshold
getCurrentCallbackThreshold()
Returns the threshold as set bysetCurrentCallbackThreshold(char, short, short)
.long
getDebouncePeriod()
Returns the debounce period as set bysetDebouncePeriod(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.boolean
isOverCurrent()
Returns *true* if more than 12.5A were measured.void
removeAnalogValueListener(BrickletCurrent12.AnalogValueListener listener)
Removes a AnalogValue listener.void
removeAnalogValueReachedListener(BrickletCurrent12.AnalogValueReachedListener listener)
Removes a AnalogValueReached listener.void
removeCurrentListener(BrickletCurrent12.CurrentListener listener)
Removes a Current listener.void
removeCurrentReachedListener(BrickletCurrent12.CurrentReachedListener listener)
Removes a CurrentReached listener.void
removeOverCurrentListener(BrickletCurrent12.OverCurrentListener listener)
Removes a OverCurrent listener.void
setAnalogValueCallbackPeriod(long period)
Sets the period with which theBrickletCurrent12.AnalogValueListener
listener is triggered periodically.void
setAnalogValueCallbackThreshold(char option, int min, int max)
Sets the thresholds for theBrickletCurrent12.AnalogValueReachedListener
listener.void
setCurrentCallbackPeriod(long period)
Sets the period with which theBrickletCurrent12.CurrentListener
listener is triggered periodically.void
setCurrentCallbackThreshold(char option, short min, short max)
Sets the thresholds for theBrickletCurrent12.CurrentReachedListener
listener.void
setDebouncePeriod(long debounce)
Sets the period with which the threshold listeners *BrickletCurrent12.CurrentReachedListener
, *BrickletCurrent12.AnalogValueReachedListener
are triggered, if the thresholds *setCurrentCallbackThreshold(char, short, short)
, *setAnalogValueCallbackThreshold(char, int, int)
keep being reached.-
Methods inherited from class com.tinkerforge.DeviceBase
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
-
-
-
-
Field Detail
-
DEVICE_IDENTIFIER
public static final int DEVICE_IDENTIFIER
- See Also:
- Constant Field Values
-
DEVICE_DISPLAY_NAME
public static final java.lang.String DEVICE_DISPLAY_NAME
- See Also:
- Constant Field Values
-
FUNCTION_GET_CURRENT
public static final byte FUNCTION_GET_CURRENT
- See Also:
- Constant Field Values
-
FUNCTION_CALIBRATE
public static final byte FUNCTION_CALIBRATE
- See Also:
- Constant Field Values
-
FUNCTION_IS_OVER_CURRENT
public static final byte FUNCTION_IS_OVER_CURRENT
- See Also:
- Constant Field Values
-
FUNCTION_GET_ANALOG_VALUE
public static final byte FUNCTION_GET_ANALOG_VALUE
- See Also:
- Constant Field Values
-
FUNCTION_SET_CURRENT_CALLBACK_PERIOD
public static final byte FUNCTION_SET_CURRENT_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_CURRENT_CALLBACK_PERIOD
public static final byte FUNCTION_GET_CURRENT_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_SET_DEBOUNCE_PERIOD
public static final byte FUNCTION_SET_DEBOUNCE_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_DEBOUNCE_PERIOD
public static final byte FUNCTION_GET_DEBOUNCE_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_IDENTITY
public static final byte FUNCTION_GET_IDENTITY
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_OFF
public static final char THRESHOLD_OPTION_OFF
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_OUTSIDE
public static final char THRESHOLD_OPTION_OUTSIDE
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_INSIDE
public static final char THRESHOLD_OPTION_INSIDE
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_SMALLER
public static final char THRESHOLD_OPTION_SMALLER
- See Also:
- Constant Field Values
-
THRESHOLD_OPTION_GREATER
public static final char THRESHOLD_OPTION_GREATER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletCurrent12
public BrickletCurrent12(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid. and adds it to the IP Connection \c ipcon.
-
-
Method Detail
-
getCurrent
public short getCurrent() throws TinkerforgeException
Returns the current of the sensor. If you want to get the current periodically, it is recommended to use theBrickletCurrent12.CurrentListener
listener and set the period withsetCurrentCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
calibrate
public void calibrate() throws TinkerforgeException
Calibrates the 0 value of the sensor. You have to call this function when there is no current present. The zero point of the current sensor is depending on the exact properties of the analog-to-digital converter, the length of the Bricklet cable and the temperature. Thus, if you change the Brick or the environment in which the Bricklet is used, you might have to recalibrate. The resulting calibration will be saved on the EEPROM of the Current Bricklet.- Throws:
TinkerforgeException
-
isOverCurrent
public boolean isOverCurrent() throws TinkerforgeException
Returns *true* if more than 12.5A were measured. \note To reset this value you have to power cycle the Bricklet.- Throws:
TinkerforgeException
-
getAnalogValue
public int getAnalogValue() throws TinkerforgeException
Returns the value as read by a 12-bit analog-to-digital converter. \note The value returned bygetCurrent()
is averaged over several samples to yield less noise, whilegetAnalogValue()
gives back raw unfiltered analog values. The only reason to usegetAnalogValue()
is, if you need the full resolution of the analog-to-digital converter. If you want the analog value periodically, it is recommended to use theBrickletCurrent12.AnalogValueListener
listener and set the period withsetAnalogValueCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setCurrentCallbackPeriod
public void setCurrentCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletCurrent12.CurrentListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletCurrent12.CurrentListener
listener is only triggered if the current has changed since the last triggering.- Throws:
TinkerforgeException
-
getCurrentCallbackPeriod
public long getCurrentCallbackPeriod() throws TinkerforgeException
Returns the period as set bysetCurrentCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setAnalogValueCallbackPeriod
public void setAnalogValueCallbackPeriod(long period) throws TinkerforgeException
Sets the period with which theBrickletCurrent12.AnalogValueListener
listener is triggered periodically. A value of 0 turns the listener off. TheBrickletCurrent12.AnalogValueListener
listener is only triggered if the analog value has changed since the last triggering.- Throws:
TinkerforgeException
-
getAnalogValueCallbackPeriod
public long getAnalogValueCallbackPeriod() throws TinkerforgeException
Returns the period as set bysetAnalogValueCallbackPeriod(long)
.- Throws:
TinkerforgeException
-
setCurrentCallbackThreshold
public void setCurrentCallbackThreshold(char option, short min, short max) throws TinkerforgeException
Sets the thresholds for theBrickletCurrent12.CurrentReachedListener
listener. The following options are possible: \verbatim "Option", "Description" "'x'", "Listener is turned off" "'o'", "Listener is triggered when the current is *outside* the min and max values" "'i'", "Listener is triggered when the current is *inside* the min and max values" "'<'", "Listener is triggered when the current is smaller than the min value (max is ignored)" "'>'", "Listener is triggered when the current is greater than the min value (max is ignored)" \endverbatim- Throws:
TinkerforgeException
-
getCurrentCallbackThreshold
public BrickletCurrent12.CurrentCallbackThreshold getCurrentCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetCurrentCallbackThreshold(char, short, short)
.- Throws:
TinkerforgeException
-
setAnalogValueCallbackThreshold
public void setAnalogValueCallbackThreshold(char option, int min, int max) throws TinkerforgeException
Sets the thresholds for theBrickletCurrent12.AnalogValueReachedListener
listener. The following options are possible: \verbatim "Option", "Description" "'x'", "Listener is turned off" "'o'", "Listener is triggered when the analog value is *outside* the min and max values" "'i'", "Listener is triggered when the analog value is *inside* the min and max values" "'<'", "Listener is triggered when the analog value is smaller than the min value (max is ignored)" "'>'", "Listener is triggered when the analog value is greater than the min value (max is ignored)" \endverbatim- Throws:
TinkerforgeException
-
getAnalogValueCallbackThreshold
public BrickletCurrent12.AnalogValueCallbackThreshold getAnalogValueCallbackThreshold() throws TinkerforgeException
Returns the threshold as set bysetAnalogValueCallbackThreshold(char, int, int)
.- Throws:
TinkerforgeException
-
setDebouncePeriod
public void setDebouncePeriod(long debounce) throws TinkerforgeException
Sets the period with which the threshold listeners *BrickletCurrent12.CurrentReachedListener
, *BrickletCurrent12.AnalogValueReachedListener
are triggered, if the thresholds *setCurrentCallbackThreshold(char, short, short)
, *setAnalogValueCallbackThreshold(char, int, int)
keep being reached.- Throws:
TinkerforgeException
-
getDebouncePeriod
public long getDebouncePeriod() throws TinkerforgeException
Returns the debounce period as set bysetDebouncePeriod(long)
.- Throws:
TinkerforgeException
-
getIdentity
public Device.Identity getIdentity() throws TinkerforgeException
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier. The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'. The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|- Specified by:
getIdentity
in classDevice
- Throws:
TinkerforgeException
-
addCurrentListener
public void addCurrentListener(BrickletCurrent12.CurrentListener listener)
Adds a Current listener.
-
removeCurrentListener
public void removeCurrentListener(BrickletCurrent12.CurrentListener listener)
Removes a Current listener.
-
addAnalogValueListener
public void addAnalogValueListener(BrickletCurrent12.AnalogValueListener listener)
Adds a AnalogValue listener.
-
removeAnalogValueListener
public void removeAnalogValueListener(BrickletCurrent12.AnalogValueListener listener)
Removes a AnalogValue listener.
-
addCurrentReachedListener
public void addCurrentReachedListener(BrickletCurrent12.CurrentReachedListener listener)
Adds a CurrentReached listener.
-
removeCurrentReachedListener
public void removeCurrentReachedListener(BrickletCurrent12.CurrentReachedListener listener)
Removes a CurrentReached listener.
-
addAnalogValueReachedListener
public void addAnalogValueReachedListener(BrickletCurrent12.AnalogValueReachedListener listener)
Adds a AnalogValueReached listener.
-
removeAnalogValueReachedListener
public void removeAnalogValueReachedListener(BrickletCurrent12.AnalogValueReachedListener listener)
Removes a AnalogValueReached listener.
-
addOverCurrentListener
public void addOverCurrentListener(BrickletCurrent12.OverCurrentListener listener)
Adds a OverCurrent listener.
-
removeOverCurrentListener
public void removeOverCurrentListener(BrickletCurrent12.OverCurrentListener listener)
Removes a OverCurrent listener.
-
-