com.phidgets
Class BridgePhidget

java.lang.Object
  extended bycom.phidgets.Phidget
      extended bycom.phidgets.BridgePhidget

public final class BridgePhidget
extends Phidget

This class represents a Phidget Bridge. All methods to manipulate the Phidget Bridge are implemented in this class. See your device's User Guide for more specific API details, technical information, and revision details. The User Guide, along with other resources, can be found on the product page for your device.

Author:
Phidgets Inc.

Field Summary
static int PHIDGET_BRIDGE_GAIN_1
          1 Gain.
static int PHIDGET_BRIDGE_GAIN_128
          128 Gain.
static int PHIDGET_BRIDGE_GAIN_16
          16 Gain.
static int PHIDGET_BRIDGE_GAIN_32
          32 Gain.
static int PHIDGET_BRIDGE_GAIN_64
          64 Gain.
static int PHIDGET_BRIDGE_GAIN_8
          8 Gain.
static int PHIDGET_BRIDGE_GAIN_UNKNOWN
          Unknown Gain.
 
Fields inherited from class com.phidgets.Phidget
PHIDCLASS_ACCELEROMETER, PHIDCLASS_ADVANCEDSERVO, PHIDCLASS_ANALOG, PHIDCLASS_BRIDGE, PHIDCLASS_ENCODER, PHIDCLASS_FREQUENCYCOUNTER, PHIDCLASS_GPS, PHIDCLASS_INTERFACEKIT, PHIDCLASS_LED, PHIDCLASS_MOTORCONTROL, PHIDCLASS_NOTHING, PHIDCLASS_PHSENSOR, PHIDCLASS_RFID, PHIDCLASS_SERVO, PHIDCLASS_STEPPER, PHIDCLASS_TEMPERATURESENSOR, PHIDCLASS_TEXTLCD, PHIDCLASS_TEXTLED, PHIDCLASS_WEIGHTSENSOR, PHIDGET_LOG_CRITICAL, PHIDGET_LOG_DEBUG, PHIDGET_LOG_ERROR, PHIDGET_LOG_INFO, PHIDGET_LOG_VERBOSE, PHIDGET_LOG_WARNING, PHIDID_ACCELEROMETER_2AXIS, PHIDID_ACCELEROMETER_3AXIS, PHIDID_ADVANCEDSERVO_1MOTOR, PHIDID_ADVANCEDSERVO_8MOTOR, PHIDID_ANALOG_4OUTPUT, PHIDID_BIPOLAR_STEPPER_1MOTOR, PHIDID_BRIDGE_4INPUT, PHIDID_ENCODER_1ENCODER_1INPUT, PHIDID_ENCODER_HS_1ENCODER, PHIDID_ENCODER_HS_4ENCODER_4INPUT, PHIDID_FREQUENCYCOUNTER_2INPUT, PHIDID_GPS, PHIDID_INTERFACEKIT_0_0_4, PHIDID_INTERFACEKIT_0_0_8, PHIDID_INTERFACEKIT_0_16_16, PHIDID_INTERFACEKIT_0_8_8_w_LCD, PHIDID_INTERFACEKIT_2_2_2, PHIDID_INTERFACEKIT_4_8_8, PHIDID_INTERFACEKIT_8_8_8, PHIDID_INTERFACEKIT_8_8_8_w_LCD, PHIDID_IR, PHIDID_LED_64, PHIDID_LED_64_ADV, PHIDID_LINEAR_TOUCH, PHIDID_MOTORCONTROL_1MOTOR, PHIDID_MOTORCONTROL_HC_2MOTOR, PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT, PHIDID_NOTHING, PHIDID_PHSENSOR, PHIDID_RFID, PHIDID_RFID_2OUTPUT, PHIDID_RFID_2OUTPUT_READ_WRITE, PHIDID_ROTARY_TOUCH, PHIDID_SERVO_1MOTOR, PHIDID_SERVO_1MOTOR_OLD, PHIDID_SERVO_4MOTOR, PHIDID_SERVO_4MOTOR_OLD, PHIDID_SPATIAL_ACCEL_3AXIS, PHIDID_SPATIAL_ACCEL_GYRO_COMPASS, PHIDID_TEMPERATURESENSOR, PHIDID_TEMPERATURESENSOR_4, PHIDID_TEMPERATURESENSOR_IR, PHIDID_TEXTLCD_2x20, PHIDID_TEXTLCD_2x20_w_0_8_8, PHIDID_TEXTLCD_2x20_w_8_8_8, PHIDID_TEXTLCD_ADAPTER, PHIDID_TEXTLED_1x8, PHIDID_TEXTLED_4x8, PHIDID_UNIPOLAR_STEPPER_4MOTOR, PHIDID_WEIGHTSENSOR
 
Constructor Summary
BridgePhidget()
           
 
Method Summary
 void addBridgeDataListener(BridgeDataListener l)
          Adds a bridge data listener.
 double getBridgeMax(int index)
          Returns the maximum value that the selected bridge can measure, in mV/V.
 double getBridgeMin(int index)
          Returns the minimum value that the selected bridge can measure, in mV/V.
 double getBridgeValue(int index)
          Returns the value of the selected input, in mV/V.
 int getDataRate()
          Returns the data rate, in ms.
 int getDataRateMax()
          Gets the maximum supported data rate, in ms.
 int getDataRateMin()
          Gets the minimum supported data rate, in ms.
 boolean getEnabled(int index)
          Returns the enabled state of the specified bridge.
 int getGain(int index)
          Returns the gain for the selected bridge.
 int getInputCount()
          Returns the number of bridges.
 void removeBridgeDataListener(BridgeDataListener l)
           
 void setDataRate(int rate)
          Sets the data rate, in ms.
 void setEnabled(int index, boolean state)
          Sets the enabled state of the specified bridge.
 void setGain(int index, int gain)
          Sets the gain for the selected bridge.
 
Methods inherited from class com.phidgets.Phidget
addAttachListener, addDetachListener, addErrorListener, addServerConnectListener, addServerDisconnectListener, close, disableLogging, enableLogging, equals, getDeviceClass, getDeviceID, getDeviceLabel, getDeviceName, getDeviceType, getDeviceVersion, getLibraryVersion, getSerialNumber, getServerAddress, getServerID, getServerPort, isAttached, isAttachedToServer, log, open, open, open, open, open, openAny, openAny, openAny, openAny, openAny, openLabel, openLabel, openLabel, openLabel, openLabel, removeAttachListener, removeDetachListener, removeErrorListener, removeServerConnectListener, removeServerDisconnectListener, setDeviceLabel, toString, waitForAttachment, waitForAttachment
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PHIDGET_BRIDGE_GAIN_1

public static final int PHIDGET_BRIDGE_GAIN_1
1 Gain. This is used with getGain and setGain

See Also:
Constant Field Values

PHIDGET_BRIDGE_GAIN_8

public static final int PHIDGET_BRIDGE_GAIN_8
8 Gain. This is used with getGain and setGain

See Also:
Constant Field Values

PHIDGET_BRIDGE_GAIN_16

public static final int PHIDGET_BRIDGE_GAIN_16
16 Gain. This is used with getGain and setGain

See Also:
Constant Field Values

PHIDGET_BRIDGE_GAIN_32

public static final int PHIDGET_BRIDGE_GAIN_32
32 Gain. This is used with getGain and setGain

See Also:
Constant Field Values

PHIDGET_BRIDGE_GAIN_64

public static final int PHIDGET_BRIDGE_GAIN_64
64 Gain. This is used with getGain and setGain

See Also:
Constant Field Values

PHIDGET_BRIDGE_GAIN_128

public static final int PHIDGET_BRIDGE_GAIN_128
128 Gain. This is used with getGain and setGain

See Also:
Constant Field Values

PHIDGET_BRIDGE_GAIN_UNKNOWN

public static final int PHIDGET_BRIDGE_GAIN_UNKNOWN
Unknown Gain. This is used with getGain and setGain

See Also:
Constant Field Values
Constructor Detail

BridgePhidget

public BridgePhidget()
              throws PhidgetException
Method Detail

getInputCount

public int getInputCount()
                  throws PhidgetException
Returns the number of bridges.

Returns:
Number of bridges
Throws:
PhidgetException

getBridgeValue

public double getBridgeValue(int index)
                      throws PhidgetException
Returns the value of the selected input, in mV/V. If the input is not enabled, an EPHIDGET_UNKNOWNVAL exception will be thrown. If the bridge is saturated , this will be equal to BridgeMax or BridgeMin and an error event will be fired - in this case, gain should be reduced if possible.

Parameters:
index - Index of the bridge
Returns:
bridge value
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getBridgeMin

public double getBridgeMin(int index)
                    throws PhidgetException
Returns the minimum value that the selected bridge can measure, in mV/V. This value will depend on the selected gain. At a gain of 1, BridgeMin == -1000 mV/V.

Parameters:
index - Index of the bridge
Returns:
minimum value
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getBridgeMax

public double getBridgeMax(int index)
                    throws PhidgetException
Returns the maximum value that the selected bridge can measure, in mV/V. This value will depend on the selected gain. At a gain of 1, BridgeMin == 1000 mV/V.

Parameters:
index - Index of the bridge
Returns:
maximum value
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getEnabled

public boolean getEnabled(int index)
                   throws PhidgetException
Returns the enabled state of the specified bridge. This applies power between +5v and Ground, and starts measuring the differential on the +/- pins. By default, all bridges are disabled, and need to be explicitly enabled on startup.

Parameters:
index - Index of the bridge
Returns:
state of the specified bridge
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is invalid. See open for information on determining if a device is attached.

setEnabled

public void setEnabled(int index,
                       boolean state)
                throws PhidgetException
Sets the enabled state of the specified bridge. This applies power between +5v and Ground, and starts measuring the differential on the +/- pins. By default, all bridges are disabled, and need to be explicitly enabled on startup.

Parameters:
index - Index of the bridge
state - new state of the specified bridge
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is invalid. See open for information on determining if a device is attached.

getGain

public int getGain(int index)
            throws PhidgetException
Returns the gain for the selected bridge. Note that increasing the gains will reduce the measurable voltage difference by the gain factor, with +-1000 mV/V being the maximum, with no gain. The possible values for gain are PHIDGET_BRIDGE_GAIN_1, PHIDGET_BRIDGE_GAIN_8, PHIDGET_BRIDGE_GAIN_16, PHIDGET_BRIDGE_GAIN_32, PHIDGET_BRIDGE_GAIN_64, PHIDGET_BRIDGE_GAIN_128, PHIDGET_BRIDGE_GAIN_UNKNOWN

Parameters:
index - Index of the bridge
Returns:
gain
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is invalid. See open for information on determining if a device is attached.

setGain

public void setGain(int index,
                    int gain)
             throws PhidgetException
Sets the gain for the selected bridge. Note that increasing the gains will reduce the measurable voltage difference by the gain factor, with +-1000 mV/V being the maximum, with no gain.

The possible values for gain are PHIDGET_BRIDGE_GAIN_1, PHIDGET_BRIDGE_GAIN_8, PHIDGET_BRIDGE_GAIN_16, PHIDGET_BRIDGE_GAIN_32, PHIDGET_BRIDGE_GAIN_64, PHIDGET_BRIDGE_GAIN_128, PHIDGET_BRIDGE_GAIN_UNKNOWN

Parameters:
index - Index of the bridge
gain - new gain
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is invalid. See open for information on determining if a device is attached.

getDataRate

public int getDataRate()
                throws PhidgetException
Returns the data rate, in ms. Data rate applies to all 4 bridges simultaneously. Setting a slower data rate will reduce noise at the cost of sample time. Also note that each bridge is being sampled only 1/4 of the time - this is okay for very stable signals, but for changing signals, it is best to set a higher sampling rate and do averaging in the software.

Data rate must be a multiple of 8ms. Trying to set something between multiplies of 8 will cause an EPHIDGET_INVALIDARG exception.

Returns:
Data Rate
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is invalid. See open for information on determining if a device is attached.

setDataRate

public void setDataRate(int rate)
                 throws PhidgetException
Sets the data rate, in ms. Data rate applies to all 4 bridges simultaneously. Setting a slower data rate will reduce noise at the cost of sample time. Also note that each bridge is being sampled only 1/4 of the time - this is okay for very stable signals, but for changing signals, it is best to set a higher sampling rate and do averaging in the software.

Data rate must be a multiple of 8ms. Trying to set something between multiplies of 8 will cause an EPHIDGET_INVALIDARG exception.

Parameters:
rate - new data rate
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the data rate is out of range See open for information on determining if a device is attached.

getDataRateMin

public int getDataRateMin()
                   throws PhidgetException
Gets the minimum supported data rate, in ms.

Returns:
minimum supported data rate
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

getDataRateMax

public int getDataRateMax()
                   throws PhidgetException
Gets the maximum supported data rate, in ms.

Returns:
maximum supported data rate
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

addBridgeDataListener

public final void addBridgeDataListener(BridgeDataListener l)
Adds a bridge data listener. The bridge data handler is a method that will be called at the specified data rate, for each enabled bridge. Value is the bridgeValue, in mV/V.

There is no limit on the number of bridge data handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the BridgeDataListener interface

removeBridgeDataListener

public final void removeBridgeDataListener(BridgeDataListener l)