The Resistors

Me En 495R Mechatronics Competition, Brigham Young University

Range Finder Module

Our initial approach involved using two sonar range finders. We planned to have a range finder facing in our robot's forward direction, with another facing in the backward direction. By moving forward and backward, we could equalize the distance from the robot to a wall from both in front and behind. We would equalize the distance once, rotate the robot by ninety degrees, and equalize again. This should locate us to the approximate center of the arena where we can then make simple rotations to aim at hoops. We chose to use the HC-SR04 as our sensor based on cost and availabiilty. After making a test rig for the sonar method, it was deemed insufficient and was replaced by a method of localization using microswitches.

Background on the HC-SR04 Ultrasonic Sensor

The HC-SR04 ultrasonic sensor uses sonar to detect the distance to an object. It works by timing the delay between the emission and receipt of sonar pulses. The HC-SR04 is a module commonly used by the Arduino community and is very simple to set up and use. The module itself has only four pins, Vcc, GND, Trig, and Echo. The module runs on a 5V voltage supply. The Trig and Echo pins are connected to a microcontroller's output and input pin respectively. The microcontroller is responsible for sending a short pulse of at least 10 micro-seconds. The HC-SR04 sends eight ultrasonic pulses on the falling edge of the pulse sent by the microcontroller. After receiving and processing the delay, the module outputs a pulse proportional to the distance from the target on the echo pin. The microcontroller can time the pulse received from the echo pin and post-process it to represent the distance in desired units. The HC-SR04 boasts a maximum accuracy of 3mm with a minimum range of 2cm and a maximum of 4m.

Experimentation

To test the application of the HC-SR04 to our project, we prototypes a setup where one module faced forward on a breadboard and the other pointed in the opposite direction. We controlled the modules using a PIC24F04KA201. The test procedure was looped as follows:

  1. Measure the distance to a wall from the front module, call it Distance1
  2. Measure the distance to a wall from the rear module, call it Distance2
  3. Subtract Distance2 from Distance1
  4. If the result of (3) is greater than zero plus some threshold, move forward
  5. Else if the results of (3) is less than zero minus some threshold, move backward
  6. Else, do nothing- the robot should be roughly centered

Results

The experimental procedure above was successful; however, there were significant levels of noise measurements, even when tested within the arena. Even when the robot clearly needed to move forward, erroneous measurements indicated the it should move backward. Likewise, when the robot was centered, erroneous measurements indicated otherwise. Although on a high level this method did work, it was not suitable for the accuracy required by our approach to the competition; thus we tailored our approach to replace the sonar modules with microswitches.