Fascinated by our robot's ability to balance itself in SegBot mode, our team set out to expand on its capabilities by making the robot move autonomously. We wanted a robot that could maintain its balance and navigate dynamically through whatever environment it was in. We built the robot to respond to three different frequencies, 900, 1100, and 1900 Hz, to execute commands that will allow the robot to increase its speed while maintaining its balance.
For this project, our team was focused on two main things: Implementing the wall-following command into our SegBot code and enabling the servo arm to detect when there is a wall on either side of the robot. The goal for this project was to have the robot first enter into SegBot mode. After it has been calibrated in its upright position, it transitions into wall-following mode, scanning for walls using its mounted IR sensors. When a wall is detected on the right, the robot follows it. If no wall is detected, the server arm swings to the left side to check for a left wall, seamlessly transitioning between modes to ensure continuous navigation.
The robot’s speed is controlled by using sound frequencies that will be detected by the robot’s microphone. The specific frequency ranges that trigger the speed adjustments are as follows: 900 Hz = slow speed, 1100 Hz = medium speed, and 1900 Hz = High speed.
CADOur team also utilized Solidworks to design and 3D print some custom parts, including a sensor a new robot stand with a motor mount attached, and a servo-mounted arm. This modular design allows the robot to integrate its components seamlessly and operate effectively.
Printing/AssemblySound Frequency Identification
The robot's speed is modulated by the frequency of detected sounds. Specifically, three frequency bands correspond to different speed levels: slow, medium, and fast. The frequency bands are defined as [300–550] Hz, [1050–1250] Hz, and [1750–2000] Hz, respectively. These bands are carefully selected to ensure that their cutoff frequencies do not overlap, minimizing interference.
For sound detection, ePWM 4 is used to sample the microphone input at a frequency of 5000 Hz, achieved by setting the TBPRD register to 10000. ePWM 5 is not used for this purpose because it is allocated to the servo motor, and the two devices operate with different periods, making them incompatible for shared use.
To enable sound recognition, the robot records detected tones over a 10-second window. This functionality is implemented using three counter variables and a trigger variable, where trigger specifies the duration (in seconds) for storing the sound data. For visual feedback, the robot displays a letter on its interface based on the detected frequency band: A for the first band (slow speed), B for the second band (medium speed), and C for the third band (fast speed).
As shown in the code snippet, the data counters reset each time a tone is detected. If no sound is heard, the vref value would be set to 0.2, corresponding to the robot's default speed.
The following block of code located in the SWI_isr interrupt function in final_main.c used to run the robot is where the functionality of wall-following and wall-detection are executed. The robot should work by first giving itself time to calibrate for balancing. Then, more time is dedicated to start the balancing process. Once balanced, the robot starts swinging its arm until it detects a wall and starts following the wall at the speed that is set by the frequency of any sounds it detects. The robot shall continue wall following until it detects that there will not be a wall anymore, usually when there is an incoming corner. At this point, the robot stops moving forward or turning and swings its sensor arm the opposite direction of where it was wall following to try to detect a wall. If a wall is detected, the arm stays in that direction and the robot will start following that wall instead. Otherwise, it swings back the arm to the original side and does a corner turn, continuing wall following.
The code block starts when delay_counter is greater than 10 which means the robot has been “on” for greater than 10 seconds, allowing the robot to go through the Segbot balance calibration and start balancing. The robot then starts measuring the distance of the nearest wall using the sensor attached to the servo arm assigning it to disright. turning_check is a variable that represents the “wall checking state” of the robot. If it is 0, the robot is not checking the side across the wall it is following–also referred to as the opposite wall– and therefore will just continue to set the servo at the same angle. turning represents the state of the robot, and it is either in the process of a corner turn(turning =1) or not (turning=0). When it is in the process of a turn, it will not try to detect another wall and will just continue following its current wall. The turning state ends when the average distance of the wall taken every 0.1 second is less than the reference value it is supposed to keep away from the wall. When it is not turning, the robot will also check the average distance of the wall, but once it calculates that the average is greater than a certain distance(in this case 2.2 times the reference distance) then the robot will start checking the opposite wall. Turning check will be set to 1 and a counter for the “checking time” is started. The arm is swung to the opposite side, at a temporary angle for the servo, and the robot stops moving until either the counter for “checking time” reaches a certain value or the robot detects a wall on the opposite wall because the average distance it calculates is less than a certain threshold. If the counter reaches the specified time and the average distance of the nearest wall is not less than the threshold, then the robot goes into the turning state and swings back the arm to the original side. If the average distance goes below the threshold, it means a wall has been detected and the temporary servo angle is made the set angle for the servo.
The proportional controls for right and left wall following are decided using the set angle of the servo.
Comments