Maxbotix ultrasonic distance sensor library

Fork of MaxbotixDriver by Daniel Casner

Embed: (wiki syntax)

« Back to documentation index

Sonar Class Reference

Sonar Class Reference

Object representation of a sonar instance. More...

#include <sonar.h>

Public Member Functions

 Sonar (PinName input, Timer &t)
 Sets up the driver and starts taking measurements.
int readCm ()
 Returns range in cm as int.
int read ()
 Returns range in uS as int.
 operator int ()
 Returns the range in CM as an int.
bool getRange (int *outRawDistance, int *outDistance, float temperature)
 getrange - Get the range in cm.

Detailed Description

Object representation of a sonar instance.

Definition at line 12 of file sonar.h.


Constructor & Destructor Documentation

Sonar ( PinName  input,
Timer &  t 
)

Sets up the driver and starts taking measurements.

Parameters:
inputThe pin to read pulses from
tA running timer instance used to measure pulse width. Note that the timer must have been started or results will be invalid.

Definition at line 4 of file sonar.cpp.


Member Function Documentation

bool getRange ( int *  outRawDistance,
int *  outDistance,
float  temperature 
)

getrange - Get the range in cm.

Need to enable sensor first, waiting briefly for it to power up. Request temperature sensor to take a reading. Disable ultrasonic sensor after use for power saving. Returns uncompensated, compensated and temperature values by reference. Calling function can still do checks to determine whether to use reading or not.

Parameters:
outRawDistance- Raw uncompensated distance
outDistance- Compensated distance if temperature available, otherwise raw distance
outTemperature- Temperature reading
Returns:
boolean true returned form function for valid reading. false for <23cm or out of range

Definition at line 109 of file sonar.cpp.

operator int (  )

Returns the range in CM as an int.

Definition at line 21 of file sonar.cpp.

int read (  )

Returns range in uS as int.

Definition at line 13 of file sonar.cpp.

int readCm (  )

Returns range in cm as int.

Definition at line 17 of file sonar.cpp.