2018-08-26 06:47 AM
Hi
I am trying to integrate maxbotix MB1003 sensor onto Nucleo L073RZ board. Nucleo board is running mbed OS. After few hours of proper operation, ultrasonic readings get stuck at a particular value like 420 mm. Sensor operation is simple triggered operation, have attached sample code below. Can anyone point out what could be the possible cause.
Thanks
Hemanth
Timer sonar;
int sonar_checkdist()
{
sonar.reset();
trigger = 1;
wait_us(25.0);
trigger = 0;
//wait for echo high
while (echo==0) {};
//echo high, so start timer
sonar.start();
//wait for echo low
while (echo==1) {};
//stop timer and read value
sonar.stop();
//subtract software overhead timer delay, scale to cm & roundup
distance = (((sonar.read_us()-correction))/10.0) + 0.5;
return distance;
}
2018-08-26 08:01 AM
Work backward, put a scope on the sensor analog output, or use other interfaces, and confirm if the sensor is the source of the measurement, or if there is some issue on the software side.