EE319 Project Report ALBERT
-
Upload
chris-holmes -
Category
Documents
-
view
142 -
download
1
Transcript of EE319 Project Report ALBERT
Dublin City University
EE319 – Electromechanical Systems
Mini-Project Report 2015
A.L.B.E.R.T
Student Name(s) Student ID Programme
Diarmuid Kelleher
13447892
ME
David Gallagher
xx
ECE
Chris Holmes
xx
ECE
Group Number 13
Date 08/12/2015
Contents Design Brief: ..................................................................................................................................................................... 3
Equipment and Procedure: ................................................................................................................................................ 3
Equipment: .................................................................................................................................................................... 3
i. 2WD Mobile Platform ...................................................................................................................................... 3
ii. IR Distance Measuring Sensor .......................................................................................................................... 3
iii. SN754410 H-Bridge ..................................................................................................................................... 3
iv. Arduino Uno ................................................................................................................................................. 3
v. Analogue joystick ............................................................................................................................................. 4
vi. DPDT Switch ................................................................................................................................................ 4
Procedure: ..................................................................................................................................................................... 4
i. Week 7: Building of robot platform and test motors and IR sensor ................................................................. 4
ii. Week 8: Tested the servo and sensor combined ............................................................................................... 4
iii. Week 9: Assembled the entire robot ............................................................................................................. 4
iv. Week 10: Added our unique feature ............................................................................................................. 5
v. Week 11: Made presentation and report ........................................................................................................... 5
Unique Aspect: .................................................................................................................................................................. 5
2 modes: ........................................................................................................................................................................ 5
Automated decision making: ........................................................................................................................................ 5
Manual control using a PlayStation1 joystick:.............................................................................................................. 6
Code: ................................................................................................................................................................................. 7
Final Product: .................................................................................................................................................................. 10
ALBERT: .................................................................................................................................................................... 10
Pre-Tidy: ..................................................................................................................................................................... 10
Post-Tidy: .................................................................................................................................................................... 11
Problems: ........................................................................................................................................................................ 13
No Common Ground ................................................................................................................................................... 13
Broken IR sensor ......................................................................................................................................................... 13
Constant Definition in Motor Code ............................................................................................................................ 13
What we learned: ............................................................................................................................................................ 14
Step-by-step analysis is key to efficiency: .................................................................................................................. 14
Things don’t “just happen”: ........................................................................................................................................ 14
That despite its “single loop” framework, the Arduino is a powerful tool in engineering: ........................................ 14
Recommendations: .......................................................................................................................................................... 14
Mini-Project Structure: ............................................................................................................................................... 14
Team Allocation ...................................................................................................................................................... 14
Arduino Tutorial ..................................................................................................................................................... 14
Recommendations for participating students: ............................................................................................................. 14
Keep organized ....................................................................................................................................................... 14
Work on each part separately .................................................................................................................................. 14
Design Brief:
The design brief was as follows:
Design and build an Arduino controlled device
Use an IR sensor and servo motor to collision detect
Interface with Arduino to control drive motor speeds and rotation directions
Introduce a unique aspect to your device
Equipment and Procedure:
Equipment:
i. 2WD Mobile Platform
The two wheel drive robot used in this project ca be controlled by a number of microcontrollers including the Arduino
platform. There is a large amount of sample code and sample circuits available online that can be used with the
Arduino and the two wheel drive robot. The motors are mounted to an aluminum alloy body. The setup of the motors
allow a near zero turning radius.
Complete Machine weight: 445g
Wheel Diameter: 65mm
Max speed: 61cm/s
ii. IR Distance Measuring Sensor
Model used: Sharp GP2Y0A02YK0F
This IR distance measuring sensor has a measuring range of 20 to 150 cm and outputs an analogue output. The sensor
consists of a combination of a position sensitive detector, an infrared emitting diode and a processing circuit. The
device outputs a voltage that corresponds to the distance being measured.
Size: 299.5x13x21.6mm
Consumption current: 33mA
Supply voltage: 4.5 to 5.5 V
iii. SN754410 H-Bridge
The SN74410 H-Bridge a quadruple high-current half-h driver which is used to drive the 2 high-speed motors. The
device provides bidirectional drive currents up to 1 A at voltages from 4.5 V to 36 V.
Recommended operating conditions MIN MAX UNIT
Output supply voltage ,Vcc1 4.5 5.5 V
Output supply voltage ,Vcc2 4.5 36 V
High-level input voltage, Vih 2 5.5 V
Low-level input voltage, Vil 0.3 0.8 V
iv. Arduino Uno
The Uno is a microcontroller board that has 14 digital input/output pins, 6 analogue inputs, a 15MHz quartz crystal, a
USB connection, a power jack and a reset button. It is an extremely adaptable and diverse microcontroller. If
something goes wrong, the chip can be replaced for very little. This is what makes the Arduino Uno such a popular
device. There is a massive library of Arduino code and sample projects that use the Arduino boards online.
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Digital I/O Pins 14
PWM Digital I/O Pins 6
Analog Input Pins 6
Flash memory 32KB
SRAM 2KB
EEPROM 1KB
Clock speed 16MHz
v. Analogue joystick
The analogue joystick was taken form a PlayStation1 controller. These were very accurate and simple to hook up, due
to the fact that the 2 potentiometers (One for Xaxis the other for Yaxis) and their circuitry was built into the unit, and
as such no additional circuitry was required to extrapolate values from the potentiometer. The joystick requires a 3V
power supply and outputs analogue values 0-660 representing the X|Y position of the joystick.
vi. DPDT Switch
Scavenged from a 1st Year Electronics Kit, this was used to switch between modes. Its 2 positions allowed the Arduino
to decide as to whether it was receiving a HIGH or LOW value. If LOW, it worked of its own accord in Automatic
mode whereas if HIGH, it relied on a user input from the aforementioned joystick.
Procedure:
The team met twice a week, on Wednesdays and Fridays for weeks 7 to 11
i. Week 7: Building of robot platform and test motors and IR sensor
Aims: Have robot platform constructed, motors in position and running, test IR sensor
First was to set up the robot with the motors in place and test them with the SN755410 H-Bridge, the circuit we used
for this can be seen below:
Figure 1 - A rough schematic produced in the early stages
Next was to test the IR sensor, the sensor was connected to the Arduino and sample code was used to output the values
to the serial monitor.
ii. Week 8: Tested the servo and sensor combined
Aims: Get the servo and sensor combination working
First was to get the servo rotating 180 degrees side to side. This was controlled from the Arduino next was to set up
the sensor on the rotating servo
iii. Week 9: Assembled the entire robot
Aims: Have full collision detection movement working on the robot
Figure 2 - A basic diagram of the bot at the end of Week 9
The robot was fully assembled and the collision detection code was added to the Arduino.
iv. Week 10: Added our unique feature
The unique feature for the robot was manual control. We sourced a joystick from a PlayStation1 controller. This
output from the joystick was then used to controller the motor speed and direction of the robot.
v. Week 11: Made presentation and report
The compilation of the report began as early as Week 9. We decided that your best approach would be to draft a
report, then use the compiled information to produce a presentation that would accurately reflect the final report.
Figure 3- A graph displaying how our time was divided over the 5 weeks
Unique Aspect:
The robot had a number of unique features:
2 modes: Automatic
Manual
This was controlled by the DPDT Switch.
Automated decision making: Turns left/right depending on read value
20%
40%
10%10%
20%30%
WEEKS 7 -11:
Equipment Testing Code Testing Assembly Presentation Report
Mode Select:
0: Automatic
1: Manual
Figure 4 - DPDT Mode Select
This was implemented by using the “modulo” or “%” function. Here the number was divided by 2 and checks for a
remainder. If reminder exists it’s ODD, otherwise it’s EVEN.
The automated Arduino loop was as follows:
Figure 5 - Automatic FOR Loop Cycle
Manual control using a PlayStation1 joystick: User defined speed control
The Joysticks dual potentiometers and associated integrated circuitry output an analogue signal between 0 and 660
each. These were then mapped to -255 and 255 respectively, allowing the newly mapped values to be fed into the
motors directly to vary speed.
The manual Arduino loop was as follows:
Figure 6 - Manual Loop Cycle
IF RIGHT_SWEEP Complete
• Initiate LEFT_SWEEP
Reads IR Value
IF IR > 550
• Move forward
IF IR < 550
• Turn Left if EVEN
• Turn Right if ODD
IF LEFT_SWEEP Complete
• Initiate RIGHT_SWEEP
Reads IR Value
IF IR > 550
• Move forward
IF IR < 550
• Turn Left/Right
Checks for JoyStick Input
If -20 < X|X< +20|
-20 < Y|Y< +20
HOME: No Movement
IF Y > +20
•Move forward
• The closer to +255, the faster it moves
IF Y < -20
•Move backwards
• The closer to -255, the faster it moves
IF X > +20
• Turn left
• The closer to +255, the faster it moves
IF X < -20
• Turn right
• The closer to -255, the faster it moves
Automatic
Manual
Code:
//”The following are the initial declarations for the Arduino Loop. The integrated Arduino Servo header file is
included. The various pin names and respective numbers are demoted for easier trouble shooting and code
recognition”// #include <Servo.h>
Servo myservo;
int sensorpin_M_A = 4;
int val_M_A = 0;
int pos = 50;
int sensorpin = 1;
int val = 1;
int sensorpin_FB = 3;
int val_FB = 0;
int sensorpin_LR = 5;
int val_LR = 0;
int UP = 3;
int DOWN = 5;
int LEFT = 2;
int RIGHT = 7;
int motor_left[] = {3, 5};
int motor_right[] = {6, 11};
//”void setup is run only once per power up. It is the first snippet of code ran prior to initiating the main loop. Its
purpose is to initiate the declorations stated above and prepare them for use in the loop”// void setup(){
Serial.begin(9600);
pinMode(LEFT, OUTPUT);
pinMode(UP, OUTPUT);
pinMode(DOWN, OUTPUT);
pinMode(RIGHT, OUTPUT);
myservo.attach(10);
int j;
for(j = 0; j < 2; j++){
pinMode(motor_left[j], OUTPUT);
pinMode(motor_right[j], OUTPUT);
}}
//”The beginning of the main loop”// void loop(){
//”The value of an input pin is read. This pin is the MODE pin, the point at which the Arduino decides whether it is in
AUTOMATIC or MANUAL mode. HIGH is considered to be a value greater than 800. Anything less is considered
LOW.”// val_M_A = analogRead(sensorpin_M_A);
Serial.println(val_M_A);
//”The read value is greater than 800, thus MANUAL Mode has been initiated. 2 pins are now read, one for the
Forward&Back or YAxis, the other for Left&Right or XAxis.”// if(val_M_A < 800){
val_FB = analogRead(sensorpin_FB);
val_LR = analogRead(sensorpin_LR);
//”The values are mapped to between -255 and +255”// val_FB = map(val_FB, 10, 660, -255, 255);
val_LR = map(val_LR, 0, 645, -255, 255);
//”The HOME positions are checked for”// if(val_LR < 17 && val_LR > -35)
{
val_LR = 0;
}
if(val_FB < 17 && val_FB > -35)
{
val_FB = 0;
}
//”If both values for F&B and L&R are 0, it is considered home and neither motor moves”// if(val_FB == 0 && val_LR == 0)
{
analogWrite(motor_left[0], 0);
analogWrite(motor_left[1], 0);
analogWrite(motor_right[0], 0);
analogWrite(motor_right[1], 0);
}
//”This snippet considers the scenario where F&B is 0 but L&R is not”// if(val_FB == 0 && val_LR != 0)
{
//”If L&R is greater than mapped 17 it turns left with a speed corresponding to the position of L&R. The greater the
value, the faster it turns”// if(val_LR > 17)
{
analogWrite(motor_left[0], 0);
analogWrite(motor_left[1], val_LR);
analogWrite(motor_right[0], val_LR);
analogWrite(motor_right[1], 0);}
//”If L&R is less than mapped -35 it turns right with a speed corresponding to the position of L&R. Again, the greater
the value, the faster it turns”// if(val_LR < -35)
{
//”It must be noted for this instance that the value of L&R must be inversed in order to have a usable value.”// val_LR = -val_LR;
analogWrite(motor_left[0], val_LR);
analogWrite(motor_left[1], 0);
analogWrite(motor_right[0], 0);
analogWrite(motor_right[1], val_LR);
}
}
//”The following snippet considers the scenario where F&B does not equal 0 but L&R does”// if(val_FB != 0 && val_LR == 0)
{
//”If F&B is greater than mapped 17 it moves forward with a speed corresponding to the position of F&B. The greater
the value, the faster it moves”// if(val_FB > 17)
{
analogWrite(motor_left[0], val_FB);
analogWrite(motor_left[1], 0);
analogWrite(motor_right[0], val_FB);
analogWrite(motor_right[1], 0);
}
//”If F&B is less than mapped -35 it reverses with a speed corresponding to the position of F&B. Again, the greater the
value, the faster reverses”// if(val_FB < -35)
{
//”It must be noted for this instance that the value of F&B must be inversed in order to have a usable value.”// val_FB = -val_FB;
analogWrite(motor_left[0], 0);
analogWrite(motor_left[1], val_FB);
analogWrite(motor_right[0], 0);
analogWrite(motor_right[1], val_FB);
}
}
}
//”We now consider the situation where the read MODE pin value is less than 800, and thusly AUTOMATIC Mode
has been initiated. Here only one pin is read, the pin corresponding to the IR sensor”// if((val_M_A > 800)){
//”The following for loop is used to sweep the IR Servo anticlockwise”// for (pos = 50; pos <= 140; pos += 1)
{
myservo.write(pos);
//”The IR Value is read”// val = analogRead(sensorpin);
Serial.println(val);
delay(10);
//”If the IR Sensor returns a value greater than 550 or 8”s, it continues driving forward”// if (val < 550)
{
drive_forward();
}
//”Otherwise, if less than 550, it divides the value by 2 and checks for a remainder. If remainder doesn’t exist, it turns
left, and turns right if one does exist”// if (val > 550)
{
if(val%2==0)
{
drive_backwards();
delay(750);
turn_left();
delay(750);
}
else
{
drive_backwards();
delay(750);
turn_right();
delay(750);
}
}
}
//”The following for loop is used to sweep the IR Servo clockwise”// for (pos = 140; pos >= 50; pos -= 1)
{
myservo.write(pos);
//”The IR Value is read”// val = analogRead(sensorpin);
Serial.println(val);
delay(10);
//”If the IR Sensor returns a value greater than 550 or 8”s, it continues driving forward”// if (val < 550)
{
drive_forward();
}
//”Otherwise, if less than 550, it divides the value by 2 and checks for a remainder. If remainder doesn’t exist, it turns
left, and turns right if one does exist”// if (val > 550)
{
if(val%2==0)
{
drive_backwards();
delay(750);
turn_left();
delay(750);
}
else
{
drive_backwards();
delay(750);
turn_right();
delay(750);
}
}
}
}
}
//”The following snippets are sub routines. These are called during the above loop to preform smaller tasks, making
the overall code neater and easier to write and be understood.”// void drive_backward()
{
analogWrite(motor_left[0], 100);
analogWrite(motor_left[1], 0);
analogWrite(motor_right[0], 100);
analogWrite(motor_right[1], 0);
}
void drive_forward()
{
analogWrite(motor_left[0], 0);
analogWrite(motor_left[1], 100);
analogWrite(motor_right[0], 0);
analogWrite(motor_right[1], 100);
}
void turn_left()
{
analogWrite(motor_left[0], 0);
analogWrite(motor_left[1], 100);
analogWrite(motor_right[0], 100);
analogWrite(motor_right[1], 0);
}
void turn_right()
{
analogWrite(motor_left[0], 100);
analogWrite(motor_left[1], 0);
analogWrite(motor_right[0], 0);
analogWrite(motor_right[1], 100);
}
Final Product:
ALBERT: ALBERT stands for the Automated & Livefeed Bot Engineered for infaRed Tracking.
a) Pre-Tidy:
The following are photos from Weeks 7-9. They were taken just after the first official assembly.
Figure 7 - Sideview of ALBERT MK1
Figure 8 - Sideview of ALBERT MK1
Figure 9 - ALBERT MK1’s Rats Nest of Wires
b) Post-Tidy:
The following are photos from Weeks 10 & 11. Once the Joystick was installed and we were happy with its
performance, we decided that the wiring could be much neater and better colour-coded.
Figure 10 - Overhead of ALBERT MK2
Figure 11 - Front View of ALBERT MK2
Figure 12 - CloseUp of ALBERT MK2's Wiring
Problems:
No Common Ground
After uploading the Arduino code to the Arduino Uno chip, we carried out an integration test. We tested to see if the
motor and sensor worked together simultaneously. We saw that the sensor was taking readings but the motor was not
working.
How we solved the problem:
Firstly, we checked to see if the battery was charged with a voltmeter. The battery was working fine, so there
was no problem arising from the power source.
Next, we scanned through the circuit thoroughly multiple times until we found that the circuit did not have a
common ground. Having a common ground in a circuit is very important because it ensures that there is a closed
loop, thus starting the electrical cycle over and over again.
When the problem was identified, we made sure that motor and the sensor was connected to a common ground
so the circuit could have a return cycle.
After connecting up the circuit, we carried out the integration test again and it was a success.
Broken IR sensor
When we tested to see if the IR sensor was working properly, we saw that it produced a sine wave with a
range of 80 – 112. It was supposed to act as a collision detector and tell the robot platform the distance
calculated for a collision with a nearby wall.
We checked the IR sensor code, but everything seemed to be okay.
Next, we used a different sensor to see if the sensor was broken. Our query was answered when we found that
the second IR sensor worked perfectly as it was able to scan for the distance of the wall from robot platform.
Constant Definition in Motor Code
When we integrated the Arduino code to the motor, we saw that robot platform started to spin in circles. This was not
the outcome that we expected. It was clear there was a mistake somewhere in the code.
int j; // Problem came from here. We forgot include ‘int j’//
for(j = 0; j < 2; j++) {
pinMode(motor_left[j], OUTPUT);
pinMode(motor_right[j], OUTPUT);
}
After scanning through the code, we identified the problem straight away. The j variable was not declared as an ‘int’
variable, which lead to a malfunction in the physical implementation of the code causing a failure in movement. After
declarating the j variable, the robot started and performed as expected.
What we learned:
Step-by-step analysis is key to efficiency:
Testing of hardware and its respective code
Implementing nested codes to interface with one another
Things don’t “just happen”:
There is always a reason behind things not working from missing code to incorrect wiring
That despite its “single loop” framework, the Arduino is a powerful tool in engineering:
The key to unlocking its potential is understanding the various aspects of the hardware you're using and how it
interfaces with different components
Recommendations:
Overall, the mini-project was very enjoyable. It was a challenging experience that helped us obtain required skills and
knowledge needed in a working environment. This section will consist of recommendations and opinions from the
student’s perspective, ie what we felt worked well and things that could be improved on.
Mini-Project Structure:
Team Allocation
The team allocation for the mini-project was a great idea. Every team had to have at least one ME student and one ECE
student. Having a variety of engineering backgrounds really improves the team’s overall knowledge. ECE and ME
students would have different strengths, so it is easier for the team to assign different tasks to each member. Also, the
students are exposed to different ways of thinking and creativity, which is very beneficial for adapting to other
backgrounds in team projects in the work place. We recommend that this type of team allocation should be used for all
future years.
Arduino Tutorial
One aspect that could be improved for the mini-project would be an Arduino tutorial before the designated labs for
constructing the robot platform. It would have been very helpful to have a better understanding on what code would be
needed. This would have made team members more confident in the labs. Also, time in the labs would have been used
more efficiently instead of looking online to see what commands to use, which was a very time-consuming process.
Recommendations for participating students:
Keep organized
Organization is a key for the success of any team project. It is good for team morale because everyone is on a same page
and knows exactly what has to be done. A good tip to being organized is to set deadlines for tasks to be completed. We
had four weeks for our team project to be completed, therefore we split the workload into four weeks (4 parts). Another
tip would be to set up a time for meetings, where we can discuss and express any ideas and monitor if the deadlines are
being met.
Work on each part separately
Always work on a separate part. This avoids confusion and makes it easier to find a problem, if one occurs. Do not
construct the whole project and expect that it is going to work on the first attempt. Always perform a unit test, where
you will see if the part of the car is working individually. If it passes the unit test, perform an integration test and see if
different combinations of parts work with each other.