Package com.tinkerforge
Class BrickletIndustrialDualAnalogIn
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletIndustrialDualAnalogIn
-
public class BrickletIndustrialDualAnalogIn extends Device
Measures two DC voltages between -35V and +35V with 24bit resolution each
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BrickletIndustrialDualAnalogIn.Calibration
class
BrickletIndustrialDualAnalogIn.VoltageCallbackThreshold
static interface
BrickletIndustrialDualAnalogIn.VoltageListener
This listener is triggered periodically with the period that is set bysetVoltageCallbackPeriod(short, long)
.static interface
BrickletIndustrialDualAnalogIn.VoltageReachedListener
This listener is triggered when the threshold as set bysetVoltageCallbackThreshold(short, char, int, int)
is reached.-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BrickletIndustrialDualAnalogIn(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
addVoltageListener(BrickletIndustrialDualAnalogIn.VoltageListener listener)
Adds a Voltage listener.void
addVoltageReachedListener(BrickletIndustrialDualAnalogIn.VoltageReachedListener listener)
Adds a VoltageReached listener.int[]
getADCValues()
Returns the ADC values as given by the MCP3911 IC.BrickletIndustrialDualAnalogIn.Calibration
getCalibration()
Returns the calibration as set bysetCalibration(int[], int[])
.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.short
getSampleRate()
Returns the sample rate as set bysetSampleRate(short)
.int
getVoltage(short channel)
Returns the voltage for the given channel.long
getVoltageCallbackPeriod(short channel)
Returns the period as set bysetVoltageCallbackPeriod(short, long)
.BrickletIndustrialDualAnalogIn.VoltageCallbackThreshold
getVoltageCallbackThreshold(short channel)
Returns the threshold as set bysetVoltageCallbackThreshold(short, char, int, int)
.void
removeVoltageListener(BrickletIndustrialDualAnalogIn.VoltageListener listener)
Removes a Voltage listener.void
removeVoltageReachedListener(BrickletIndustrialDualAnalogIn.VoltageReachedListener listener)
Removes a VoltageReached listener.void
setCalibration(int[] offset, int[] gain)
Sets offset and gain of MCP3911 internal calibration registers.void
setDebouncePeriod(long debounce)
Sets the period with which the threshold listener *BrickletIndustrialDualAnalogIn.VoltageReachedListener
is triggered, if the threshold *setVoltageCallbackThreshold(short, char, int, int)
keeps being reached.void
setSampleRate(short rate)
Sets the sample rate.void
setVoltageCallbackPeriod(short channel, long period)
Sets the period with which theBrickletIndustrialDualAnalogIn.VoltageListener
listener is triggered periodically for the given channel.void
setVoltageCallbackThreshold(short channel, char option, int min, int max)
Sets the thresholds for theBrickletIndustrialDualAnalogIn.VoltageReachedListener
listener for the given channel.-
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_VOLTAGE
public static final byte FUNCTION_GET_VOLTAGE
- See Also:
- Constant Field Values
-
FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD
- See Also:
- Constant Field Values
-
FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD
- See Also:
- Constant Field Values
-
FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_VOLTAGE_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_SET_SAMPLE_RATE
public static final byte FUNCTION_SET_SAMPLE_RATE
- See Also:
- Constant Field Values
-
FUNCTION_GET_SAMPLE_RATE
public static final byte FUNCTION_GET_SAMPLE_RATE
- See Also:
- Constant Field Values
-
FUNCTION_SET_CALIBRATION
public static final byte FUNCTION_SET_CALIBRATION
- See Also:
- Constant Field Values
-
FUNCTION_GET_CALIBRATION
public static final byte FUNCTION_GET_CALIBRATION
- See Also:
- Constant Field Values
-
FUNCTION_GET_ADC_VALUES
public static final byte FUNCTION_GET_ADC_VALUES
- 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
-
SAMPLE_RATE_976_SPS
public static final short SAMPLE_RATE_976_SPS
- See Also:
- Constant Field Values
-
SAMPLE_RATE_488_SPS
public static final short SAMPLE_RATE_488_SPS
- See Also:
- Constant Field Values
-
SAMPLE_RATE_244_SPS
public static final short SAMPLE_RATE_244_SPS
- See Also:
- Constant Field Values
-
SAMPLE_RATE_122_SPS
public static final short SAMPLE_RATE_122_SPS
- See Also:
- Constant Field Values
-
SAMPLE_RATE_61_SPS
public static final short SAMPLE_RATE_61_SPS
- See Also:
- Constant Field Values
-
SAMPLE_RATE_4_SPS
public static final short SAMPLE_RATE_4_SPS
- See Also:
- Constant Field Values
-
SAMPLE_RATE_2_SPS
public static final short SAMPLE_RATE_2_SPS
- See Also:
- Constant Field Values
-
SAMPLE_RATE_1_SPS
public static final short SAMPLE_RATE_1_SPS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletIndustrialDualAnalogIn
public BrickletIndustrialDualAnalogIn(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
-
getVoltage
public int getVoltage(short channel) throws TinkerforgeException
Returns the voltage for the given channel. If you want to get the voltage periodically, it is recommended to use theBrickletIndustrialDualAnalogIn.VoltageListener
listener and set the period withsetVoltageCallbackPeriod(short, long)
.- Throws:
TinkerforgeException
-
setVoltageCallbackPeriod
public void setVoltageCallbackPeriod(short channel, long period) throws TinkerforgeException
Sets the period with which theBrickletIndustrialDualAnalogIn.VoltageListener
listener is triggered periodically for the given channel. A value of 0 turns the listener off. TheBrickletIndustrialDualAnalogIn.VoltageListener
listener is only triggered if the voltage has changed since the last triggering.- Throws:
TinkerforgeException
-
getVoltageCallbackPeriod
public long getVoltageCallbackPeriod(short channel) throws TinkerforgeException
Returns the period as set bysetVoltageCallbackPeriod(short, long)
.- Throws:
TinkerforgeException
-
setVoltageCallbackThreshold
public void setVoltageCallbackThreshold(short channel, char option, int min, int max) throws TinkerforgeException
Sets the thresholds for theBrickletIndustrialDualAnalogIn.VoltageReachedListener
listener for the given channel. The following options are possible: \verbatim "Option", "Description" "'x'", "Listener is turned off" "'o'", "Listener is triggered when the voltage is *outside* the min and max values" "'i'", "Listener is triggered when the voltage is *inside* the min and max values" "'<'", "Listener is triggered when the voltage is smaller than the min value (max is ignored)" "'>'", "Listener is triggered when the voltage is greater than the min value (max is ignored)" \endverbatim- Throws:
TinkerforgeException
-
getVoltageCallbackThreshold
public BrickletIndustrialDualAnalogIn.VoltageCallbackThreshold getVoltageCallbackThreshold(short channel) throws TinkerforgeException
Returns the threshold as set bysetVoltageCallbackThreshold(short, char, int, int)
.- Throws:
TinkerforgeException
-
setDebouncePeriod
public void setDebouncePeriod(long debounce) throws TinkerforgeException
Sets the period with which the threshold listener *BrickletIndustrialDualAnalogIn.VoltageReachedListener
is triggered, if the threshold *setVoltageCallbackThreshold(short, char, int, int)
keeps being reached.- Throws:
TinkerforgeException
-
getDebouncePeriod
public long getDebouncePeriod() throws TinkerforgeException
Returns the debounce period as set bysetDebouncePeriod(long)
.- Throws:
TinkerforgeException
-
setSampleRate
public void setSampleRate(short rate) throws TinkerforgeException
Sets the sample rate. The sample rate can be between 1 sample per second and 976 samples per second. Decreasing the sample rate will also decrease the noise on the data.- Throws:
TinkerforgeException
-
getSampleRate
public short getSampleRate() throws TinkerforgeException
Returns the sample rate as set bysetSampleRate(short)
.- Throws:
TinkerforgeException
-
setCalibration
public void setCalibration(int[] offset, int[] gain) throws TinkerforgeException
Sets offset and gain of MCP3911 internal calibration registers. See MCP3911 datasheet 7.7 and 7.8. The Industrial Dual Analog In Bricklet is already factory calibrated by Tinkerforge. It should not be necessary for you to use this function- Throws:
TinkerforgeException
-
getCalibration
public BrickletIndustrialDualAnalogIn.Calibration getCalibration() throws TinkerforgeException
Returns the calibration as set bysetCalibration(int[], int[])
.- Throws:
TinkerforgeException
-
getADCValues
public int[] getADCValues() throws TinkerforgeException
Returns the ADC values as given by the MCP3911 IC. This function is needed for proper calibration, seesetCalibration(int[], int[])
.- 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
-
addVoltageListener
public void addVoltageListener(BrickletIndustrialDualAnalogIn.VoltageListener listener)
Adds a Voltage listener.
-
removeVoltageListener
public void removeVoltageListener(BrickletIndustrialDualAnalogIn.VoltageListener listener)
Removes a Voltage listener.
-
addVoltageReachedListener
public void addVoltageReachedListener(BrickletIndustrialDualAnalogIn.VoltageReachedListener listener)
Adds a VoltageReached listener.
-
removeVoltageReachedListener
public void removeVoltageReachedListener(BrickletIndustrialDualAnalogIn.VoltageReachedListener listener)
Removes a VoltageReached listener.
-
-