cancel
Showing results for 
Search instead for 
Did you mean: 

Ultrasonic sensor reading stuck at a particular value after few hours of proper operation

Hemanth V
Associate

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;

}

1 REPLY 1

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.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..