Ok so I've been using one of these modules.
It has an i/p pin which initiates a ping of 8 40kc cycles, at the end of which an o/p pin goes hi until the module receives an echo.
In software I continuously send ping commands and measure the width of the o/p pulse to see if the target is within a specified range.
The software worked well when I was prototyping it, however when implemented in the main code it doesnt work, if you send continuous pings to the module it works, but if you leave the module for 0.5 seconds then come back to it and give it a ping command, the first ping gives an erroneous result, as if the target was 0mm away from the sensor, the module has power constantly and there is a wait time in the code startup.
I dont really have much time in my code to do a dummy read, as if the module works properly which it sometimes does first ping it can take a mS or so to complete the measurement.
Any ideas how I can get the module to work first ping.
It has an i/p pin which initiates a ping of 8 40kc cycles, at the end of which an o/p pin goes hi until the module receives an echo.
In software I continuously send ping commands and measure the width of the o/p pulse to see if the target is within a specified range.
The software worked well when I was prototyping it, however when implemented in the main code it doesnt work, if you send continuous pings to the module it works, but if you leave the module for 0.5 seconds then come back to it and give it a ping command, the first ping gives an erroneous result, as if the target was 0mm away from the sensor, the module has power constantly and there is a wait time in the code startup.
I dont really have much time in my code to do a dummy read, as if the module works properly which it sometimes does first ping it can take a mS or so to complete the measurement.
Any ideas how I can get the module to work first ping.