Ultrasonic Ranger Finder

Where do I look for a way to program the ultrasonic range finder I bought for the Vex?

If you are using easyC you should be able to open the ranger finder project and that should get you going. If you are using MPLAB, look at Vex Robotics Downloads - Vex Sensor Test on our Support page .

What is the output of the ultrasonic sensor in (cm, in, etc)?

The direct output of the Ultrasonic Senor is either a High or a Low. Your code that you write determines how you interpret the results from the Sensor. See the “Inventors Guide” at http://www.vexlabs.com/vex-robotics-ultrasonic-range-finder-kit.shtml for details on how the Ultrasonic Range Finder works.

I just tried to use 3 Ultrasonic sensors. The first one reports values ranging from 2 or 3 up to 99. That is good.

The second sensor reports values from 2 or 3 up to about 34. In that range the reports are a good match with what the first sensor reports. Occasionally the second one will report an appropriate number greater than mid-30s (that is a close match with what the first sensor supplies); but these are few and far between.

The third sensor behaves like the second one, except that it almost never reports anything above a 2 or a 3.

Is this a symptom you recognize? If it is can you recommend a course of action? With the exception of their limited ranges of usefullness, the malfunctioning sensors appear to be working fine.

This does not sound normal but this also depends on what you are doing with the sensor data in your code. There is Ultrasonic Test code that we have that will report a data value on the terminal window of the IFI Loader. We see responses from about 2 to about 50 over the range of the sensor.

The Sensor that almost never reports anything above 2 or 3 most likely has problems. If the Tx and Rx sensors under the cover are out of alignment, they will not work. If the unit is under warranty return it. If not, you can try removing the cover and change the position of the Tx and Rx sensors and get the unit to start working. This should never be done on a working unit. You may change the alignment and never get it back into the proper working position.**

About adjusting the Sensors’ Tx/Rx modules. How are they mounted? Are the mounting materials sensitive enough to heat to be damaged by sitting in a car? Do you bend them or loosen them with a tiny screw driver? Any advice before I crack one open?

**Here are some things to look at. It is best to disconnect the Ultrasonic sensor from the VEX before taking it apart. The Tx and Rx modules are soldered to a circuit board with 2 pins each. You can change their orientation by pushing them closer together or further apart, no screw driver adjustment is needed. Be careful not to change the circular circumference of the module by bending it, you do not want to put a dent in the side of the module. These modules should have rubber covers on the top. Make sure these covers are seated properly and even all the way around.

There are the Input and Output wires that feed between the Tx and Rx Modules. Repositioning the Input and Output wires, plus changing the angle of the Tx and Rx modules and adjusting the rubber grommets can reduce the acoustic coupling from the TX module to the RX module to get your unit working.**

In the inventers guide it told me to plug both connectors into adjacent interupt ports but I connected the input to digital input 11 and the output to interupt 1. Now my questions, first I downloaded the test code and I don’t understand what it is telling me. I get the scrolling "0"s and when I wave my hand in front I get the occasional “1”, what does this mean? Second am I supposed to program for the distance parameters? (maybe like “if object detected in 12 inches then”) Please give me some ideas as the “ULTRASONICTEST” is not helping

The Vex Sensor Test on our Downloads page http://www.vexlabs.com/vex-robotics-downloads.shtml only provides a quick go/no-go test for the sensor. It changes from a 0 or 1 depending on whether an object is detected about 1 foot away. The instructions VexSensorTestProcedure-revA.pdf ask you to connect the Ultra Sonic sensor’s input to the Vex Micro Controller Analog/Digital 4 output, and the Ultra Sonic sensor’s output to the Vex Micro Controller Interrupt 1 input. If you monitor the Vex Controller Analog/Digital 15 line you will see it go high when the Ultra Sonic sensor detects an object about 1 foot away. In the C program user_routines_sensor_test.c, you will see the program sets rc_dig_out15 to a “1” when fltHiResCounter is between 16 and 19. This counter value equals the round trip time of sound for an object 1 foot away.

For programming, please refer to the web site location http://www.vexlabs.com/vex-robotics-ultrasonic-range-finder-kit.shtml for the latest inventor’s guide. The input and output descriptions have been corrected compared to what is packaged with the sensor.

An easy place to start for code examples might be the ChiefDelphi link [http://chiefdelphi.com/forums/showthread.php?t=42717. Look down the page to see the code and instructions contained in file SONAR_0.3.ZIP. Basically, use a pulse to start the Ultra-Sonic sensor’s input, and monitor the difference in time between the high and low of the Ultra-Sonic sensor output.

Please note that Innovation First does not guarantee, nor support, either of the program modules.](http://chiefdelphi.com/forums/showthread.php?t=42717. Look down the page to see the code and instructions contained in file SONAR_0.3.ZIP. Basically, use a pulse to start the Ultra-Sonic sensor’s input, and monitor the difference in time between the high and low of the Ultra-Sonic sensor output.)

What are the full capabilities of the range finder? Also how effective would it be at going to a specific location, avoiding obstacles, and telling a rover to go to a specific location?

The range finder gives you data on how far/close you are to an object, therefore; you can avoid obstacles. If your specific location is to stop inches from an object, the range finder is what you need.

I have downloaded the Vex Sensor Test code from your web site and I’m having trouble getting the ultrasonic sensor to respond. I have each of the other sensors working properly; optical encoder, light sensor, and line follower working. I’m having trouble with just the ultrasonic sensor.

I am using the MPLAB and C18 compiler with the Vex_library_auton_debug.lib library. I have the sensor’s output connection going to the Interrupt 1 position and the trigger pulse input on the Analog/Digital pisition 4.

I have the four LED’s which display output as expected with the exception of the Ultrasonic display. I’m using the IFI loader’s Terminal Window to see results from each of the other sensors.

How can I determine if the Ultrasonic sensor is defective? What should I try next?

**It appears you are connecting the VEX correctly to the ultra-sonic sensor, but here it is in more detail:

Download the hex code found at: http://www.vexlabs.com/vex-robotics-downloads.shtml (Vex Sensor Test) into your VEX Controller

Hardware wise, connect the black / red / yellow input cable to one of your VEX Controller outputs. The VEX controller will produce a nominal 13 microsecond high “start” pulse to start the Ultrasonic Range Finder (Radio Shack VEX part number: 276-2155). You can hear a tic-tic-tic sound coming out of the ultrasonic if you hold it close to your ear.

Connect the black / red / orange output cable to your VEX Controller input. If you can monitor it with an oscilloscope, it will normally be low. It will go high about 225 microseconds after the start pulse. This is when the “ping” is sent out of the ultrasonic sensor. When the ultrasonic sensor hears the ping after it bounces off of the target and returns, it will set the orange wire low. Your VEX Controller software should detect the time between the high going and low going transitions.

The speed of sound is about 1131 feet per second, which correlates to 0.0136 inches per microsecond. So if the timer indicated 400 microseconds, 400 microseconds x 0.0136 inches per microsecond gives 5.43 inches. Remember that this is the round trip distance. So divide 5.43 inches by 2 to get 2.72 inches from the ultrasonic sensor to the target.

If this does not help, try another sensor or another VEX Controller. **

How many Ultra’s can be used on 1 Vex Micro? Once before I had 4 working, But I was wondering if 5 or 6 is possible.

You can have 4, you only have 4 Timers available in the micro-processor.

If I point the Ultrasonic Range Finder at a triangle, will it see it?

The closer the object, larger the object or the more parallel to the base of the Sensor, the greater the reflection back to the Sensor and thus you will see it. When trying to see a triangle or an object that has a sloped surface, you may or may not see the object. Depending on what angle you hit the triangle with the ping from the Sensor; the ping may hit the triangle, bounce to another object and then bounce back to the sensor or even never get back to the Sensor. This could give you a distance measurement error or you may not see the echo at all. Thus your readings can be influenced by the angle you have your Sensor mounted, the angle of the surface on the object you are trying to detect, and even the texture of the surface. With these factors working against you, you will need to experiment. Try the Ultrasonic Range Finder over a variety of angles and distances to the object you are trying to detect and see if you get the results you want.