com.phidgets
Class FrequencyCounterPhidget

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

public final class FrequencyCounterPhidget
extends Phidget

This class represents a Phidget Frequency Counter. All methods to read manipulate the Phidget Frequency Counter 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_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL
          Logic-Level Filter Type.
static int PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN
          Unknown Filter Type.
static int PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING
          Zero-Crossing Filter Type.
 
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
FrequencyCounterPhidget()
           
 
Method Summary
 void addFrequencyCounterCountListener(FrequencyCounterCountListener l)
          Adds a count listener.
 boolean getEnabled(int index)
          Returns the enabled state on the specified channel.
 int getFilter(int index)
          Gets the channel filter mode.
 double getFrequency(int index)
          Returns the last calcualted frequency on the specified channel, in Hz.
 int getFrequencyInputCount()
          Returns the number of channels.
 int getTimeout(int index)
          Returns the timeout value, in microseconds.
 long getTotalCount(int index)
          Returns the total number of pulses detected on the specified channel since the Phidget was opened, or since the last reset.
 long getTotalTime(int index)
          Returns the total elapsed tiem since Phidget was opened, or since the last reset, in microseconds.
 void removeFrequencyCounterCountListener(FrequencyCounterCountListener l)
           
 void reset(int index)
          Resets the getTotalCount and getTotalTime counters to 0 for the specified channel.
 void setEnabled(int index, boolean state)
          Gets the enabled state on the specified channel.
 void setFilter(int index, int type)
          Sets the channel filter mode.
 void setTimeout(int index, int timeout)
          Sets the timeout value, in microseconds.
 
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_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING

public static final int PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING
Zero-Crossing Filter Type. This is used with getFilter and setFilter

See Also:
Constant Field Values

PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL

public static final int PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL
Logic-Level Filter Type. This is used with getFilter and setFilter

See Also:
Constant Field Values

PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN

public static final int PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN
Unknown Filter Type. This is used with getFilter and setFilter

See Also:
Constant Field Values
Constructor Detail

FrequencyCounterPhidget

public FrequencyCounterPhidget()
                        throws PhidgetException
Method Detail

getFrequencyInputCount

public int getFrequencyInputCount()
                           throws PhidgetException
Returns the number of channels.

Returns:
Number of inputs
Throws:
PhidgetException

getFrequency

public double getFrequency(int index)
                    throws PhidgetException
Returns the last calcualted frequency on the specified channel, in Hz. This function will return 0 if the getTimeout value elapses without detecting a signal. Frequency is recalculated up to 31.25 times a second, depending on the pulse rate.

Parameters:
index - Index of the channel
Returns:
frequency of the channel
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.

getTotalCount

public long getTotalCount(int index)
                   throws PhidgetException
Returns the total number of pulses detected on the specified channel since the Phidget was opened, or since the last reset.

Parameters:
index - Index of the channel
Returns:
total number of pulses
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.

getTotalTime

public long getTotalTime(int index)
                  throws PhidgetException
Returns the total elapsed tiem since Phidget was opened, or since the last reset, in microseconds. This time corresponds to the getTotalCount property.

Parameters:
index - Index of the channel
Returns:
total time, in microseconds
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.

getTimeout

public int getTimeout(int index)
               throws PhidgetException
Returns the timeout value, in microseconds. This value is used to set the time to wait without detecting a signal before reporting 0 Hz. The valid range is 0.1 - 100 seconds(100,000 - 100,000,000 microseconds). 0.1 timeout represents the lowest frequency that will be measurable.

Parameters:
index - Index of the channel
Returns:
timeout 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.

setTimeout

public void setTimeout(int index,
                       int timeout)
                throws PhidgetException
Sets the timeout value, in microseconds. This value is used to set the time to wait without detecting a signal before reporting 0 Hz. The valid range is 0.1 - 100 seconds(100,000 - 100,000,000 microseconds). 0.1 timeout represents the lowest frequency that will be measurable.

Parameters:
index - Index of the channel
timeout - new timeout value
Throws:
PhidgetException - If this Phidget is not opened and attached, the index is out of range or the the timeout value 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 on the specified channel. When the channel is disabled, it will no longer register counts. TotalTime and TotalCount properties will not be incremented until the channel is re-enabled.

Parameters:
index - Index of the channel
Returns:
state
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
Gets the enabled state on the specified channel. When the channel is disabled, it will no longer register counts. TotalTime and TotalCount properties will not be incremented until the channel is re-enabled.

Parameters:
index - Index of the channel
state - new enabled state
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.

getFilter

public int getFilter(int index)
              throws PhidgetException
Gets the channel filter mode. This controls the type of signal that the Frequency Counter will respond to - either a zero-centered or a logic-level signal.

The possible values for type are PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING, PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL, PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN

Parameters:
index - Index of the channel
Returns:
filter type
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.

setFilter

public void setFilter(int index,
                      int type)
               throws PhidgetException
Sets the channel filter mode. This controls the type of signal that the Frequency Counter will respond to - either a zero-centered or a logic-level signal.

The possible values for type are PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_ZERO_CROSSING, PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_LOGIC_LEVEL, PHIDGET_FREQUENCYCOUNTER_FILTERTYPE_UNKNOWN

Parameters:
index - Index of the channel
type - new filter type
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.

reset

public void reset(int index)
           throws PhidgetException
Resets the getTotalCount and getTotalTime counters to 0 for the specified channel. For best performance, this should be called when the channel is disabled.

Parameters:
index - Index of the channel
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.

addFrequencyCounterCountListener

public final void addFrequencyCounterCountListener(FrequencyCounterCountListener l)
Adds a count listener. The count handler is a method that will be called whenever some counts have been detected. This event will fire up to 31.25 times a second, depending on the pulse rate. The time is in microseconds and represents the amount of time in which the number of counts occured. This event can be used to calculate frequency independently of the phidget21 library frequency implementation. This event will fire with a count of 0 once, after the Timeout time has elapsed with no counts for a channel, to indicate 0 Hz.

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

Parameters:
l - An implemetation of the FrequencyCounterCountListener interface

removeFrequencyCounterCountListener

public final void removeFrequencyCounterCountListener(FrequencyCounterCountListener l)