Ultrasonic sensor output always 0


I’m trying to use the Ultrasonic Range Finder with the VEX Microcontroller using PROS IDE ( http://purdueros.sourceforge.net/doc/index.htm ). I’ve made sure that the INPUT of the sensor is connected to a lower digital port number and the OUTPUT is connected to the consecutive higher port number. I’ve used the API ‘ultrasonicGet’ from PROS to obtain the distance but the distance returned is always zero. I tried with different port numbers on the VEX microcontroller but the same behavior occurs. I tested by placing the VEX microcontroller on a flat surface and placing a flat object at some distance (about 100 cm away). Here is a snapshot of the code used. Can someone help me get the ultrasonic sensor return correct values?


Do you have to set the pin modes? I thought you just had to call ultrasonicInit and create an Ultrasonic type

You dont have to set the pin modes for ultrasonics, ultrasonicInit will set the pin modes and interrupt

I think you may have a faulty ultrasonic sensor or you are not positioning it right, remember the sensor detects distance in a cone shape, so if its flat on the ground its probably detecting the foam tiles in front of it

I had this issue with a sonar sensor and quadrature encoder. These two sensors are rather fragile and you may have just broken your ultrasonic sensor physically but there is hope! When I had this problem with my encoder and sonar I had to redownload firmware to the cortex with RobotC a few times and they started working again. I’ll have to see tomorrow if their still working but its at least temporary.