I need the information about this programme: 1.Memory used at different stages of your programme. 2.Data types used. 3. Variable scope (where each variable can be accessed from). 4. Efficiency of functions in your programme.
Group 46: Robot Report Team members: WaiFung Au Student number:570536 Team members: Guanyuan Huang Student number:551286 1. Introduction In this work we are implementing a collision free robot. Components used in robot is Wheels, Motor, Ultrasonic sensor, Arduino Uno, H-bridge(l293d) and a battery. There are two active wheels and one passive wheel placed on the robot. Two active wheels are connected to two 12v motors. Those two motors were connected to a h-bridge ic. There are two pins on the motor. One is connected to out1(out3) and another to out2(out4) of h-bridge. Another motor is connected to out3 and out4 of the h-bridge. In1, In2, In3, In4 of the h-bridge is connected to Arduino pins 8 to 11 as in the schematic. A batter is connected to power pins of h-bridge. This batter is used to power up the h-bridge. The L293D H-Bridge driver is the most commonly used driver for two-way driving applications. This L293D IC allows the DC motor to run in any direction. The L293D is a 16-pin IC that can control the assembly of two DC motors simultaneously in any direction. This means that you can control two DC motors with one L293D IC. Because inside there are two H-bridge circuits. The L293D can also operate small and quiet large motors. There are various ways to build H-bridge motor control circuits, such as using transistors, relays and L293D / L298. Before going into detail, let us first look at what an H-bridge circuit is. Behaviour of the motor depending on the input conditions will be as follows: INPUT 1INPUT 2ENABLE 1,2Result INPUT 3INPUT 4ENABLE 3,4 001Stop 011Anti-clockwise rotation 101Clockwise rotation 111Stop The main component used to detect collision is ultrasonic range sensor. Two ultrasonic sensors were placed on both sides of the robot. It is an intelligent device which can sense obstacle on both sides. When the obstacle is detected, it will turn the robot in opposite direction. The ultrasonic sensor works on the same principles as the radar system. The ultrasonic sensor converts electrical energy into sound waves and vice versa. A sound wave signal is an ultrasonic wave that travels at frequencies above 18kHz. The popular HC SR04 ultrasonic sensor generates ultrasonic waves at a frequency of 40kHz. Typically, a microcontroller is used to communicate with the ultrasonic sensor. To begin measuring distance, the microcontroller sends an excitation signal to the ultrasonic sensor. The duty cycle of this excitation signal for the HC-SR04 ultrasonic sensor is 10µS. When triggered, the ultrasonic sensor generates eight sound (ultrasonic) wave bursts and starts counting the time. As soon as the reflected (echo) signal is received, the timer will stop. Output of the ultrasonic sensor Pins of Ultrasonic sensor VCC is the power supply for HC-SR04 Ultrasonic distance sensor which we connect the 5V pin on the Arduino. Trig (Trigger) pin is used to trigger the ultrasonic sound pulses. Echo pin produces a pulse when the reflected signal is received. The length of the pulse is proportional to the time it took for the transmitted signal to be detected. GND should be connected to the ground of Arduino. The above schematic shows how the components were paced and connected to the Arduino microcontroller. Left ultrasonic sensor’s echo pin is connected to pin 4 and echo pin to pin 5 of Arduino. Right ultrasonic sensor’s echo pin is connected to pin 2 and echo pin to pin 3 of Arduino. Ground and vcc pin of the ultrasonic sensor is connected to gnd pin and 5v pin of Arduino. Inbuilt LED in pin number 13 is set High when a obstacle is detected on either one sensor. The digital inputs and outputs (digital I/O) on the Arduino are what allow you to connect the Arduino sensors, actuators, and other ICs. Learning how to use them will allow you to use the Arduino to do some really useful things, such as reading switch inputs, lighting indicators, and controlling relay outputs. The Arduino functions associated with digital signals that we will be using in this tutorial are: pinMode() digitalRead() digitalWrite() pinMode (pin_number, mode) Because the Arduino digital I/O pins can be used for either input or output, you should first configure the pins you intend to use for digital I/O with this function. pin is the number of the pin you wish to configure. mode must be one of three values: INPUT, OUTPUT, our INPUT_PULLUP. When mode is set to INPUT_PULLUP, a 20 kohm pullup resistor is internally connected to the pin to force the input HIGH if there is nothing connected to the pin. digitalWrite(pin_number,value) This function writes a digital value to a pin. pin specifies which Arduino pin the digital value will be written to, and value is the digital value to which the pin is set. value must be either HIGH or LOW. digitalRead(pin_number) This function reads a digital value from a pin. pin is the number of the digital I/O pin you want to read. This function returns one of two values: HIGH or LOW. 2. Software Design Programming for the robot is done in c on Arduino IDE. Arduino program contains two functions, which are listed below · void setup () · void loop () 2.1 void setup () This function is used to initialize i/o’s of Arduino. In our program we initialised pins 8 to 11 as output using pin Mode function and made those pin low using digital write function. 2.2 Void loop () This function is like a while loop in c programming. It will be running continuously without any interruption. In our program we are storing the distance value from left ultrasonic sensor cm1 variable which is declared as integer. After 15 milli seconds of delay we are storing the distance value from right ultrasonic sensor cm2 variable which is also declared as integer. We are using Else-If statement to run the motor in correct direction. If cm1(left sensor value) value is less than 15 (which is out of boundary value) the left motor should run forward and right motor should run in reverse direction. Left motor is runed forward by making pin 9 HIGH and pin 8 LOW. Right motor is runed reverse by making pin 10 HIGH and pin 11 LOW. If cm2(right sensor value) value is less than 15 (which is out of boundary value) the right motor should run forward and left motor should run in reverse direction. Right motor is runed forward by making pin 11 HIGH and pin 10 LOW. Left motor is runed reverse by making pin 8 HIGH and pin 9 LOW. If cm1 and cm2 not satisfying above two conditions the both motors will be running in forward direction. To make both motors to run in forward direction Pin 9 is set HIGH and pin 8 is set LOW and pin is set 11 HIGH and pin 10 is set LOW. 2.3 readUltrasonicDistance(int echoPin, int triggerPin) Variable echoPin and triggerPin is integer data type used to store the pin number of Arduino which is connected to echo pin and trigger pin of the ultrasonic sensor. This function is called twise in the voidloop() function with different pin number to store two different sensor values in two different variables. Trigger pin is set as output by using the function pinMode(triggerPin, INPUT) and it is set LOW by using function digitalWrite(triggerPin, LOW)after 2 micro seconds of delay this trigger pin set as HIGH by using function digitalWrite(triggerPin, HIGH) after 10 micro seconds trigger pin is set LOW by using function digitalWrite(triggerPin, LOW). Now the echo pin is set as input by using the function pinMode(echoPin, INPUT) pulseIn function used to determine the time to get back the echo signal from the ultrasonic sensor. Which is the converted to centimetre value by dividing the echo value by 58. 3. Result Implementation of collision free robot using ultrasonic distance sensor and Arduino uno is successful. Which is tested in all possible combination of distance values. First, test for the sensors and the LED reaction. Two side sensors are both working. When sensors detected something in front of it. The LED light will keep light on. Otherwise, the LED light will off. Next, test the motors. When nothing is in front of the sensors, the robot will keep running in a circle shape. When the right range sensor detected something, the left motor will turn backward, and the right motor still move forward. So the robot will rotate to left about 90 degrees. On the other hand, When the left range sensor detected something, the right motor will turn backward, and the left motor still move forward. So the robot will rotate to right about 90 degrees. However, our testing robot has some hardware problems. The right motor can’t turn backward. Therefore, the right motor stop when the left range sensor detected something. About this situation is not the program problem, is the motor hardware someplace broken. 4. Conclusion The program has successfully implemented the robotic c program in Arduino. Also, successfully worked on the robot. The sensors can detect correctly, the LED light is light on correctly. Also, the motors are working correctly when sensors detected something in front of it. However, the robot hardware has some problems with the right motor. If the robot is totally fine, it can better performance. Also, our testing is held on the last day to test the robot and program. Therefore, we can’t use another robot to do the test again. To improve this situation, we should start testing earlier. So, we have more time to improve our robot performances. 5. Appendix int cm1; int cm2; long readUltrasonicDistance(int echoPin, int triggerPin) { pinMode(triggerPin, OUTPUT); // Clear the trigger digitalWrite(triggerPin, LOW); delayMicroseconds(2); // Sets the trigger pin to HIGH state for 10 microseconds digitalWrite(triggerPin, HIGH); delayMicroseconds(10); digitalWrite(triggerPin, LOW); pinMode(echoPin, INPUT); // Reads the echo pin, and returns the sound wave travel time in microseconds return pulseIn(echoPin, HIGH); } void setup() { Serial.begin(9600); pinMode(13, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, LOW); digitalWrite(11, LOW); digitalWrite(13, LOW); } void loop() { cm1 = readUltrasonicDistance(2,3) / 58; delay(15); // Wait for 15 millisecond(s) cm2 = readUltrasonicDistance(4,5) / 58;