Maxbotix MB7077 sonar
Maxbotix MB7077 sensor (suitable for use under water).
This sensor can be used in air or in water - although you may need to add extra gloop to make it water proof.
The sonar can output data in a variety of formats - but this library uses the analogue output from the 'AN' pin to an ADC pin on your micro controller.
The device can be powered using either 3.3v or 5v BUT your choice will depend on the reference voltage used by the ADC on your board. ie using 3.3v to power the device from a board that uses 5v as its ADC reference voltage will give wrong readings. But worse: powering the device with 5v from a board that expects a maximum ADC input of 3.3v may fry the ADC unit on your board.
The device can measure up to about 700cm with a 5v supply and up to about 600cm with a 3.3v supply.
The returned range from the device is based on the speed of sound and hence will vary depending upon the medium where it lives. For example: sound travels 4.3 times faster under water than it does through air. For this reason: you can specify whether the device is normally under water in Project Designer.
If your robot is amphibious then you can change the 'inWater' member variable at runtime to reflect the current environment for the device using setInWater
Assuming you have called your sensor 'myDistance' in Project Designer then it can be accessed as follows:-
DISTANCE_TYPE cm = myDistance.getDistance();
cout << "Distance=" << cm;
Or dumped to the standard out destination using:-
cout << myDistance;
- isInWater - Return TRUE if you have told the sensor that it is underwater or FALSE if not.
- setInWater - Tell the sensor whether it is underwater or not. Given that is an acoustic sensor then this is necessary as sound travels at different speed through air and through water.
- dump - Dump the last read sensor values to the standard output device.
- dumpTo - Dump the contents of the sensor to the specified output stream.
- getDistance - Returns the distance in whole cm detected by the sensor during the last read().
- getTimeLastRead - Returns the value of the clock at the time when the sensor was last read.
- read - Read the sensor and store its current values. Returns TRUE if the sensor has been read successfully, or FALSE if the sensor is busy in which case the read values are unchanged.