Reading distance from SRF05 range finder

I am currently able to read distance from the SRF05 range finder. However I faced a problem when the sensor is detecting distance of more than the maximum range which is 4metre. When this happen I will get a negative value. Is there a way to limit the value so that even when the distance sense is more than 4metre, the output value will be a positive value larger than 4metre and not a negative value.

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Negative value?

     

    Uh, sounds like you might've messed up somewhere with the variable declarations. Sonar output should be unsigned.... You may be getting an overflow?

     

    The SRF sensors output a large PW if a target is out of range or if the target is too close (because it doesn't detect a ping in the time that its ready), so it might be better to call the value as "out of range" instead of "its over 4m."

     

    Hope that helps...

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…