RoboJDETM v2.0

com.ridgesoft.robotics.sensors
Class DevantechSRF08

java.lang.Object
  extended by com.ridgesoft.robotics.SonarRangeFinder
      extended by com.ridgesoft.robotics.sensors.DevantechSRF08
All Implemented Interfaces:
RangeFinder

public class DevantechSRF08
extends SonarRangeFinder

Class to interface with the Devantech SRF08 ultrasonic range finder.


Constructor Summary
DevantechSRF08(I2CMaster i2cMaster)
          Constructs a DevantechSRF08 object using the default device address, 0xe0.
DevantechSRF08(I2CMaster i2cMaster, int deviceAddress)
          Constructs a DevantechSRF08 object.
 
Method Summary
 int[] getEchoData()
          Gets the echo data array from the SRF08.
 int getEchoDelay()
          Gets the echo delay.
 int getSoftwareRevision()
          Gets the software revsion of the device's software.
 void ping()
          Generates a ping requesting ranging results in microseconds.
 void rangeCentimeters(boolean annMode)
          Generates a ping requesting ranging results in inches.
 void rangeInches(boolean annMode)
          Generates a ping requesting ranging results in inches.
 void rangeMicroseconds(boolean annMode)
          Generates a ping requesting ranging results in microseconds.
 int readLightSensor()
          Reads the light sensor on the SRF08.
static void setDeviceAddress(I2CMaster i2cMaster, int initialAddress, int desiredAddress)
          Changes the I2C device address of the SRF08.
 void setGainRegister(int gain)
          Sets the gain register.
 void setRangeRegister(int range)
          Sets the range register.
 
Methods inherited from class com.ridgesoft.robotics.SonarRangeFinder
getDistanceCm, getDistanceInches
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Constructor Detail

DevantechSRF08

public DevantechSRF08(I2CMaster i2cMaster)
Constructs a DevantechSRF08 object using the default device address, 0xe0.

Parameters:
i2cMaster - I2C object for the bus the range finder connects to

DevantechSRF08

public DevantechSRF08(I2CMaster i2cMaster,
                      int deviceAddress)
Constructs a DevantechSRF08 object.

Parameters:
i2cMaster - I2C object for the bus the range finder connects to
deviceAddress - I2C device address of the range finder
Method Detail

getEchoData

public int[] getEchoData()
                  throws IOException
Gets the echo data array from the SRF08.

Invocation of to this method must be preceeded by a call to rangeInches, rangeCentimeters, rangeMicroseconds or ping, followed by a delay while the ranging operation compeletes (65 ms, unless the range register has been set).

Returns:
int array containing the results of the previous ranging command. The units of the result are determined by ranging command.
Throws:
IOException

getEchoDelay

public int getEchoDelay()
Gets the echo delay.

This method and the other methods of the SonarRangeFinder class should only be used in conjunction with the ping method. The result returned by this method will be incorrect if rangeInches or rangeCentimeters is used.

Specified by:
getEchoDelay in class SonarRangeFinder
Returns:
delay time until the echo of the ping is heard in microseconds -1 if no data

getSoftwareRevision

public int getSoftwareRevision()
                        throws IOException
Gets the software revsion of the device's software.

Returns:
software revision number
Throws:
IOException

ping

public void ping()
Generates a ping requesting ranging results in microseconds.

Specified by:
ping in interface RangeFinder
Specified by:
ping in class SonarRangeFinder

rangeCentimeters

public void rangeCentimeters(boolean annMode)
                      throws IOException
Generates a ping requesting ranging results in inches.

Note: Do not use this method if you will be reading the range with the methods getEchoDelay, getDistanceInches or getDistanceCm. Use the ping method instead.

Parameters:
annMode - true if Artificial Neural Network mode should be used
Throws:
IOException

rangeInches

public void rangeInches(boolean annMode)
                 throws IOException
Generates a ping requesting ranging results in inches.

Note: Do not use this method if you will be reading the range with the methods getEchoDelay, getDistanceInches or getDistanceCm. Use the ping method instead.

Parameters:
annMode - true if Artificial Neural Network mode should be used
Throws:
IOException

rangeMicroseconds

public void rangeMicroseconds(boolean annMode)
                       throws IOException
Generates a ping requesting ranging results in microseconds.

Note: Do not use this method if you will be reading the range with the methods getEchoDelay, getDistanceInches or getDistanceCm. Use the ping method instead.

Parameters:
annMode - true if Artificial Neural Network mode should be used
Throws:
IOException

readLightSensor

public int readLightSensor()
Reads the light sensor on the SRF08.

Returns:
light sensor reading (0-255) or -1 if no data

setDeviceAddress

public static void setDeviceAddress(I2CMaster i2cMaster,
                                    int initialAddress,
                                    int desiredAddress)
                             throws IOException
Changes the I2C device address of the SRF08.

This is used to change the address so multiple SRF08s can be used on the same I2C bus. Only one SRF08 should be connected to the bus when this method is called. See the technical reference documentation for more information.

Parameters:
i2cMaster - reference to the I2C bus
initialAddress - inital I2C device address of the SRF08 (factory default: 0xe0)
desiredAddress - desired I2C address (see technical documentation)
Throws:
IOException

setGainRegister

public void setGainRegister(int gain)
                     throws IOException
Sets the gain register.

See the technical reference documentation for more information.

Throws:
IOException

setRangeRegister

public void setRangeRegister(int range)
                      throws IOException
Sets the range register.

See the technical reference documentation for more information.

Throws:
IOException

RoboJDETM v2.0

Copyright (c) 2003-2009 RidgeSoft, LLC. All rights reserved.
www.ridgesoft.com