ME 4543: Mechatronics
Lab Section: 0AC
1
Table of Contents
2.0 Personnel ............................................................................................................................... 1
3.0 Intro and Summary .................................................................................................................. 2
3.1 Intro ...................................................................................................................................... 2
3.2 Summary ............................................................................................................................ 2
4.2 Component Fabrication ........................................................................................................ 3
4.2.1 Chassis ............................................................................................................................ 3
4.2.2 Propulsion .................................................................................................................... 4
4.2.3 Housing Dome .............................................................................................................. 6
4.3 Electronics .......................................................................................................................... 7
4.3.1 Sensors ............................................................................................................................ 7
4.3.2 Actuators ...................................................................................................................... 7
4.3.3 Miscellaneous Electronics .............................................................................................. 8
4.4 Bill of Materials (BOM) ....................................................................................................... 8
6.0 Lessons Learned and Suggestions ............................................................................................12
6.1 Lessons learned......................................................................................................................12
6.2 Suggestions........................................................................................................................13
7.0 Appendix ..............................................................................................................................15
7.1 Arduino Code ........................................................................................................................15
7.2 Tables and Figures ..............................................................................................................23
7.2.1 Tables.............................................................................................................................23
7.2.2 Figures ........................................................................................................................25
ii
2.0 Personnel
Table 1 below provides a breakdown of the task responsibilities by main and secondary
personnel on them.
Table 1: Project Responsibilities Broken Down by Personnel
TASK MAIN PERSONNEL SECONDARY PERSONNEL
Articulated Structure Design Jessica Jessica, Danny
Chassis Design Ty Danny, Jessica
Chassis Modifications Danny Ty, Jessica
Sensor Interfacing Ty Danny
Programming Ty Jessica
Motor Controller Ty Jessica
Programming
Project Report: Danny Jessica, Ty
Aesthetic Modifications Jessica Ty
Wire Routing and Clean Up Jessica, Ty Danny
Project Organization Jessica Ty, Danny
General Technician Work Jessica, Danny Ty
3D Printing Ty, Danny Jessica
Table 2 below provides a breakdown of the report (in order of the report).
Personnel Danny
1
Robot and Sensor Programming Ty
References Jessica, Ty
As a group, we applied the skills for Arduino learned in the mechatronics lab. We were
instructed to design, program and build a wheeled robot that in 60 seconds will push another robot
out of a circle with a three-foot diameter. We were given mass, volume, cost and power constraints.
3.2 Summary
The first group meeting we had for this project we strategized a plan of attack for the
competition. Then, we created the base to fit the dimensions we were required to meet. As a group,
we designed every single piece that went into our robot: the gears, the gear box, gear pinions, the
frames for the motors to sit in wheels, rims, and axles and frame. All the designs were 3D printed
and tested before applying an epoxy for permanent positioning. We positioned the sensors in the
most desirable positions and created a protective layer of foam to place on the base. Wiring the
components was the last step to finish the mechanical part of the robot. We had issues with wiring
the day the milestones were due. A few wires were not secured and became unfastened while
transporting and became tangled. So, we placed a breadboard under a cover we printed to connect
all the wires more securely and easier to diagnose any future issues.
2
robot. A MonoPrice Select Mini 3D Printer was used with 1.75mm PLA plastic to fabricate the
main components of the robot, excluding the wheels, rims, and axles.
The main components fabricated, where the chassis, and the housing dome. Smaller
components fabricated were stability bars for the ultrasonic sensor, and pinions for the DC motor
gears. Refer to Figure 1 for a view of the bottom of the robots chassis.
3
On top and below of the chassis sit pieces of foam. The foam serves as support for other
components that were attached to the robot, including the motor driver, and the vertical supports
for the ultrasonic sensor. On the underside, pieces of foam were attached to provide housing and
connection for the IR sensors on either side of the robot. See Figure 2 below.
4.2.2 Propulsion
Parts that were bought include the small wheels and their shafts, serving as axles. The
two large wheels were already owned. Figure 2 above shows how the configuration is set up in a
way that the two large wheels serve as the main mode of transportation, distributing the torque
generated from the DC motors, through the gearbox, into the ground. The smaller wheels serve
as supports for the robot when it moves in any direction.
4
One of the more challenging tasks was to modify the gearboxes to be fully assembled,
both onto the chassis as well as fixed to the DC motors. The first problem was tackled by drilling
small holes into the gearboxes to allow the clamping bolts, holding the chassis together, to stick
into the gearboxes. Adhesion of the gearboxes to the chassis was performed by using a hot glue
gun. The other major task was fixing the DC motors to the gearboxes. Before the team could do
this, a second problem had to be addressed. Gear pinions had to be design, printed, tested and
outfitted to allow for the best contact between the DC motor shaft and the gears within the gear
box. Figure 3 below shows a sample of the different gear pinions printed out.
5
4.2.3 Housing Dome
The housing dome, pictured in Figure 4 below, was also 3D printed. Its purpose is to
protect much of the wiring that routes from the sensors to the Arduino Nano. The sides of the
dome were designed to serve as a protective wheel well, in efforts to minimize damage or
disconnection of parts by impacts from other robots. The face of the dome also serves for
aesthetic pleasure, with LEDs inside indicating different modes within the program being
triggered.
6
wheel set. These axles were fixed into place by poking them into the foam. This enabled the
ultrasonic sensor to be at a center of the robot, have a commanding view of the robot, and to
be, theoretically, furthest away and therefore relatively safe from enemy robots.
4.3 Electronics
4.3.1 Sensors
For this robot, the two types of sensors used were an ultrasonic range finder sensor and
six infrared obstacle avoidance sensors (referred to as IR throughout the report).
The ultrasonic sensor used is an Ultrasonic Ranging Module HC-SR04. Its purpose is to
send out ultrasonic waves through the echo pulse output and receive them back through the
trigger pulse input. By measuring the time it took for the signal to return the program is able to
estimate an object's approximate location. Apart from this being a very commonly used
ultrasonic sensor and already owned, this sensor was selected because it provides adequate
measurement given the conditions of the competition. It is able to give measurements between 2
cm to 400 cm of non-contact distance at an accuracy of up to 3 mm. As mentioned above, the
ultrasonic sensor was clamped to the rotating arm of the servo motor at the very top of the robot.
This was done to ensure full visibility of the battle area. The ultrasonic sensors purpose is to
detect where the enemy robot is located.
The IR sensors used were six OSOYOO Infrared Obstacle Avoidance Sensor Module
sensors. These were selected because they are cheap, widely available, and relatively easy to set
up on the programming end. The IR sensors were strategically placed, three at each end,
separated at an angle of around 45 degrees from the center axis of the robot. This sensor
placement selection was done to ensure that full visibility of the white line would be achievable
come battle day.
4.3.2 Actuators
Two actuators were used for this robot. A servo motor was used to provide for rotation of
the ultrasonic sensor atop the robot. Two DC motors were used to provide propulsion of the
wheels.
The servo motor used was a SG90 9g Micro Servo motor by Tower Pro. This motor was
previously owned and selected because it provided the necessary arm rotation of 180 degrees. As
7
mentioned above, the servo motor is elevated from the center of the robot and has the ultrasonic
sensor clamped to its rotating arm. With the 180-degree rotation and ultrasonic sensor clamped
in place on the arm, the servo motor provides a full 360 view of the battle area for ultrasonic
sensor above.
The two DC motors used are 3V Small DC Motors. These motors are used to provide
propulsion of the robot by providing torque through the rotation of the motor shafts to the gears
within the gearbox and provide rotation of the large wheels. They are used in consonance with a
motor driver.
As mentioned above, the DC motors were used with a L298N Dual Motor Control
Module. This motor driver served as the connection between the DC motors and the Arduino
program created, which allowed the voltage provided to the motors to be reversed, cut off, and
modulated to the motors to provide for rotation and propulsion of the robot.
An Arduino Nano was used as the microcontroller for the robot. It was pasted to the
underside of the chassis, as pictured in Figure 1 above.
A generic breadboard was also used along with a four double-A battery housing. These
were also pasted on the underside of the chassis.
A generic RGB LED module was used as the source of light within the housing dome to
provide aesthetic and visual indicators of the robots mode.
8
Motor BN8
9
Parts
10
To detect another object in its path, the bot held a servo-mounted ultrasonic range finder
that continuously rotated between 0 and 180 degrees in front of its path. Similar to the testing
method for the IR sensors, the serial values received from the ultrasonic sensor were first observed
in the serial monitor so that specific values could be converted to centimeters and allow the bot to
run a specific function if an object was detected within a certain distance.
To control the servo motor, the function scanEnvironment() allowed the servo motor to
rotate its position between 0 and 180 degrees, indicated by the pos integer. While the servo motor
turned the ultrasonic sensor, lineCheck() was called in every iteration of the for loop and the
ultrasonic sensor updated its readings as well. This allowed the bot to continuously check for a
white line or an object in its path while the loop was running, where white line detection was the
overarching controller of the robots behavior.
Operation of the two DC motors was accomplished by utilizing the l298n motor driver. In
the program code, the integers enA and enB provided pwm voltage values to a specific motor to
control their speed, and the integers In1, In2, In3, and In4 were given either HIGH or LOW output
values (sent 5 volts from the Arduino) to control the direction of the motors. For example, if In1
and In2 connected to each of the terminals on one of the DC motors, sending HIGH to In1 and
LOW to In2 would run the motor shaft in the clockwise direction, and reversing these output values
would turn the motor shaft in the opposite direction.
The final component included in the robot design was the RGB led that displayed a specific
color and brightness if a specific function was called. For instance, if the ultrasonic sensor detected
an object within a set range, the led would flash red to indicate the object detection. This proved
to be very useful while iterating the design so that the detection of a white line or object could be
indicated with assurance.
Ultimately, by separating the electronic controls into different functions, the development
of the code was a quick process, and the overall script was more organized because of the
minimal redundancy in the code.
11
6.0 Lessons Learned and Suggestions
6.1 Lessons learned
12
6.2 Suggestions
I would suggest forming a game plan before beginning the project. This allows people to
discuss what they are more experienced with doing. To form a great plan, read all sources of
instructions and designate a clear list of responsibilities. I would not only suggest an overall plan
for the entire project but a plan for each meeting. This will ensure less downtime and better
efficiency with the sub-projects happening.
Prepare in advance when possible. Due to us 3D printing most of our components, it took
a lot of time to just have the components ready for build. We also had to double check
compatibility due to mistakes in calculations, typos or large tolerances. 3D printing early is key
to ensuring everything is compatible. If the team is unable to 3D print, make sure parts are
ordered and ready to build as soon as possible.
Dont wait until last minute. Even if everyone on the team is experienced with robotics and
understands the fundamentals, everyone has a different method of problem solving. Starting early
will help the team figure out how to balance roles and communicate effectively. Finishing the
project early will also help to any last-minute glitches that could happen with bad software or
hardware. Transporting the robot could also be a test with how well the robot is put together. So,
get the parts, start early, finish early and transport to campus for milestones as soon as possible.
Make sure the robot can sense from all directions constantly. Our robot has a rotating
ultrasonic sensor on the top. It was pointed out after our robot that was finished that our robot has
a potential blind spot. One suggestion to improve our robot would be to eliminate any potential
blind spots or weaknesses for the competition.
If possible, start from scratch. As a group, we designed every single piece that went into
our robot. We designed the base, the gears, the gearbox and the frame. Though this project was
much more work compared to a kit, we could learn more and apply more previously learned skills.
We could see the entire engineering process from this project. We created a game strategy,
designed the parts, 3D printed those parts, programmed everything using our own methods, built
the robot and did our own wiring. Building the robot from the ground gave every team member
the ability to get the maximum learning experience from the project.
13
7.0 Appendix
7.1 Arduino Code // motor one
int enA = 5;
#include <Servo.h>
int in1 = 4;
int in2 = 6;
// servo motor
Servo myServo;
// motor two
int delta = 1;
int enB = 9;
int angle = 0; // change to float
int in3 = 7;
int in4 = 8;
// ultrasonic sensor
#define trigPin 2
// leds
#define echoPin 3
int greenPin = 13;
int bluePin = 10;
long distance; // 54.5 readings per cm
int redPin = 11;
boolean detected = false;
int brightness = 0;
// IR sensors
int fadeAmount = 5;
int IR1 = A1;
int IR2 = A2;
void setup()
int IR3 = A3;
{
int IR4 = A4;
myServo.attach(12);
int IR5 = A5;
int IR6 = A6;
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
int detect1;
pinMode(echoPin, INPUT);
int detect2;
int detect3;
pinMode(enA, OUTPUT);
int detect4;
pinMode(enB, OUTPUT);
int detect5;
pinMode(in1, OUTPUT);
int detect6;
pinMode(in2, OUTPUT);
15
pinMode(in1, OUTPUT); digitalWrite(in3, LOW);
pinMode(in2, OUTPUT); digitalWrite(in4, HIGH);
digitalWrite(in1, LOW);
// motor operations digitalWrite(in2, LOW);
digitalWrite(in3, HIGH); // turn right
wheel
void HOLYSH*TREVERSE() digitalWrite(in4, LOW);
{
for (int i = 0; i < 150; i++) frightened();
{
analogWrite(enA, i); delay(10);
analogWrite(enB, i); }
}
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH); void CUTLEFTJUSTALITTLE()
16
{ frightened();
for (int i = 50; i < 150; i++)
{ delay(10);
analogWrite(enA, 0); }
analogWrite(enB, i); }
17
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH); angry();
digitalWrite(in4, LOW);
lineCheck();
for (int i = 0; i < 100; i++)
{ delay(5);
analogWrite(enA, i); }
analogWrite(enB, i); }
void SLOWLYONWARD()
{
analogWrite(enA, 0); // color sequences
analogWrite(enB, 0);
18
if (brightness == 0 || brightness > 150) //
void frightened() reverse the direction of the fading at the
{ ends of the fade:
brightness = 100; {
fadeAmount = -fadeAmount;
brightness = brightness + fadeAmount; }
analogWrite(bluePin, brightness); }
analogWrite(greenPin, 0);
analogWrite(redPin, 0);
// bot behavior
if (brightness == 0 || brightness == 255)
// reverse the direction of the fading at the
ends of the fade: void scanEnvironment()
{ {
fadeAmount = -fadeAmount; MOTORSOFF();
}
} myServo.write(0);
19
distance = pulseIn(echoPin, HIGH); digitalWrite(trigPin, HIGH);
Serial.println(distance); delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
myServo.write(angle); distance = pulseIn(echoPin, HIGH);
delay(15); Serial.println(distance);
20
if ((detect2 < 50))
{ MOTORSOFF();
scaredBotdetect2();
} }
21
delay(10);
}
ONWARD();
MOTORSOFF();
}
void scaredBotdetect4() // sharp right turn
{
CUTRIGHT();
MOTORSOFF();
}
void scaredBotdetect5() // slow right turn
{
CUTRIGHTJUSTALITTLE();
MOTORSOFF();
}
void scaredBotdetect6() // GTFO
{
ONWARD();
MOTORSOFF();
}
22
7.2 Tables and Figures
7.2.1 Tables
Personnel Danny
References Jessica, Ty
23
Table 3: Bill of Materials
24
Pcs.)
7.2.2 Figures
25
Figure 1: Bottom View of Chassis
26
Figure 4: Housing Dome
27