SunSPOT API V6.0


com.sun.spot.sensorboard.io
Class AnalogInput

java.lang.Object
  extended by com.sun.spot.resources.Resource
      extended by com.sun.spot.sensorboard.io.AnalogInput
All Implemented Interfaces:
IResource, IAnalogInput, IMeasurementInfo, ITransducer, IBasicPin

public class AnalogInput
extends Resource
implements IBasicPin, IAnalogInput, IMeasurementInfo

Simple implementation of IAnalogInput.

Note: By default the maximum rate that a scalar input can be read is ~58 Hz, i.e. reading it every 17.1 milliseconds. For faster readings the ADT7411 must be set to use its fast conversion rate that will allow reading every 0.579 milliseconds (or 1667 Hz). Note that setting the ADT7411 to fast mode may cause readings of A0 to become inaccurate.


Field Summary
protected  PinDescriptor index
           
protected  IADCController myController
           
 
Constructor Summary
AnalogInput(PinDescriptor idx, IADCController cntrl)
           
 
Method Summary
 SensorEvent createSensorEvent()
          Create a SensorEvent of the appropriate type for this sensor.
 double getAccuracy()
          Returns the accuracy of the sensor (in the current measurement range) as a percentage of reading (=data value).
 String getDescription()
          This method returns a readable description of the sensor.
 PinDescriptor getIndex()
          Return the PinDescriptor associated with this input pin.
 double getMaxSamplingRate()
          Return the maximum sampling rate per second for this sensor.
 double getMaxValue()
          Returns the current maximum value of the sensor (in the current measurement range).
 double getMinValue()
          Returns the current minimum value of the sensor (in the current measurement range).
 double getResolution()
          Returns the resolution of the range (in the current measurement range).
 double getVoltage()
          Get the ADC value in voltage
 void saveEventState(SensorEvent evt)
          Save the current sensor state in the specified event.
 String toString()
          Return the name of this pin
 
Methods inherited from class com.sun.spot.resources.Resource
addTag, getTags, getTagValue, hasTag, removeTag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sun.spot.resources.IResource
addTag, getTags, getTagValue, hasTag, removeTag
 

Field Detail

index

protected PinDescriptor index

myController

protected IADCController myController
Constructor Detail

AnalogInput

public AnalogInput(PinDescriptor idx,
                   IADCController cntrl)
Method Detail

toString

public String toString()
Return the name of this pin

Overrides:
toString in class Object
Returns:
the name of this pin

getIndex

public PinDescriptor getIndex()
Return the PinDescriptor associated with this input pin.

Specified by:
getIndex in interface IBasicPin
Returns:
the PinDescriptor associated with this input pin.

getVoltage

public double getVoltage()
Get the ADC value in voltage

Specified by:
getVoltage in interface IAnalogInput
Returns:
Voltage applied to the ADC pin.

getDescription

public String getDescription()
Description copied from interface: ITransducer
This method returns a readable description of the sensor. The description should tell the essentials of the sensor, including at least the sensor type (accelerometer, microphone, thermometer). The returned string MUST not be null or an empty string.

Specified by:
getDescription in interface ITransducer
Returns:
the description of the sensor

getMaxSamplingRate

public double getMaxSamplingRate()
Description copied from interface: ITransducer
Return the maximum sampling rate per second for this sensor.

Specified by:
getMaxSamplingRate in interface ITransducer
Returns:
the maximum sampling rate per second for this sensor or 0 if not applicable.

getMinValue

public double getMinValue()
Description copied from interface: IMeasurementInfo
Returns the current minimum value of the sensor (in the current measurement range).

Specified by:
getMinValue in interface IMeasurementInfo
Returns:
the min value of the sensor

getMaxValue

public double getMaxValue()
Description copied from interface: IMeasurementInfo
Returns the current maximum value of the sensor (in the current measurement range).

Specified by:
getMaxValue in interface IMeasurementInfo
Returns:
the max value of the sensor

getResolution

public double getResolution()
Description copied from interface: IMeasurementInfo
Returns the resolution of the range (in the current measurement range). The resolution is the minimum amount of change in the input of a sensor that can be detected as a change in the output. Resolution is a property of the transducer of a sensor but the input and output ranges and word length of the A/D converter usually set the limitations for the resolution of a digital sensor.

Specified by:
getResolution in interface IMeasurementInfo
Returns:
resolution of the sensor

getAccuracy

public double getAccuracy()
Description copied from interface: IMeasurementInfo
Returns the accuracy of the sensor (in the current measurement range) as a percentage of reading (=data value). Because this accuracy value describes the relative measurement error, greater values indicate a less accurate sensor. The accuracy value is within: 0 ≤ accuracy < 1

Specified by:
getAccuracy in interface IMeasurementInfo
Returns:
the accuracy of the sensor. If the accuracy is not known, a value of -1 is returned.

createSensorEvent

public SensorEvent createSensorEvent()
Description copied from interface: ITransducer
Create a SensorEvent of the appropriate type for this sensor.

Specified by:
createSensorEvent in interface ITransducer
Returns:
a SensorEvent of the appropriate type for this sensor.

saveEventState

public void saveEventState(SensorEvent evt)
Description copied from interface: ITransducer
Save the current sensor state in the specified event.

Specified by:
saveEventState in interface ITransducer
Parameters:
evt - the event to store the sensor state in

SunSPOT API V6.0


Copyright © 2006-2010 Oracle. All Rights Reserved.