SlideShare a Scribd company logo
1 of 25
Download to read offline
The Engineer’s Guide to SumoBots
Don’t Panic!
The SumoBot Executive 2014
January 1, 2016
1
Contents
1 Introduction 4
2 What is a Sumobot? 4
3 What is a Robot? 4
4 Designing Your Robot 5
5 Mechanical Design 5
5.1 Rough Sketches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5.2 CAD implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
5.3 The CAD Checklist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
6 Electrical Design 6
6.1 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
6.2 Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6.2.1 DC Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6.2.2 Servomotors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6.2.3 A note about Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6.3 Power Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
6.3.1 The Motor Power System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
6.3.2 H-Bridges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
6.4 The Logic Power System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
7 Software Design 10
7.1 Finite State Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
7.2 Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
7.2.1 Declare variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
7.2.2 Set up your ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
7.2.3 The main program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
7.2.4 Writing functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
7.3 Pulse Width Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.3.1 How does it work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
8 Conclusion 14
A Arduino Anatomy 15
B The CAD Checklist 17
C Hooking Up Sensors and H-Bridges 18
D Sample SumoBot Code 19
2
E PMWs in Arduinos 24
E.1 Analog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
E.2 PWM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3
1 Introduction
Welcome to the McMaster Sumobot competition! This handbook will give you a basic understand-
ing of the components and systems needed to make your first Sumobot.
2 What is a Sumobot?
A Sumobot is exactly what it sounds like: a sumo-wrestling robot. More specifically, Sumobots are
autonomous robots programmed to push other Sumobots out of a ring without getting pushed out
themselves. Our competition follows the international regulations for Sumobot size and shape, as
outlined in the McMaster Sumobot Rulebook.
3 What is a Robot?
Autonomous robots aren’t so different from animals if you think about it. Robots and animals both
observe their surroundings before deciding what to do, and they use similar tools in the process:
• Animals use sensory organs like eyes and ears to collect information from the environment.
A robot’s sensory systems do the same thing.
• The brain takes information from the sensory organs and uses it to come up with an appro-
priate response to the environment. Robots have processing systems for this purpose.
• Once the brain has decided what the animal should do, it sends signals to the rest of the body
through the nervous system. A robot’s “nervous system” is made of electrical wires.
• The animal moves around using its limbs. Robots have many types of limbs, but they all
need motors to work.
So if you want to build a functional Sumobot, you need four things: a sensory system to
collect data, a processing system to convert data into behavior, a motor output system to
perform those behaviors, and a wiring system that connects them all together. First, let’s talk
about a robot’s senses. We all know how sensory systems work in animals: the eyes, ears, nose,
tongue, and skin work together to collect information, just like how a robot’s sensors gather data
from the environment. But that’s all it is: raw data. Your eyes can’t tell you what you’re looking
at; they just absorb light. Your tongue can’t tell you what you’re eating; it just absorbs chemicals.
If you want to know what you’re eating — if you want to understand and interpret the information
provided to you by your tongue — you need a brain.
A robot’s brain is called a microcontroller or microprocessor. The robot’s sensors send
information to the microcontroller, which then interprets that information based on a man-made
system of logic. The man (or woman), in this case, is you. You decide how your microcontroller
converts sensory input to motor output. You wire the robot’s sensors so the data goes where it
needs to. You write the code, you upload it to the microcontroller, and you watch your robot do
the exact opposite of what ’it should, because no one gets it right on their first try. But when you
do get it right — when your little robot finally figures out how to push other robots out of the ring
— you’ll feel as proud as any parent and deservedly so.
4
Most amateur robot enthusiasts use the Arduino brand of microcontroller. You will use the
Arduino Uno. There are many different kinds of Arduino, each with its own purpose, but the
Arduino Uno is best for our designs. It’s usually installed in simple robots like Sumobots, which
only use a few sensors and motors. Your Sumobot will probably be limited to DC motors,
which will help it move around the ring, but depending on your design you might use other, more
complex devices, like servomotors. That covers the basics. If you have any other questions about
designing robots, choosing parts, or following Sumobot guidelines, just keep reading, and you’ll find
what you’re looking for. Good luck!
4 Designing Your Robot
A robot’s design can be broken down into three components
• Mechanical Design
• Electrical Design
• Software Design
These components are all equally important, and they depend on each-other to function properly.
If one component is faulty, the whole design suffers, and your robot will refuse to work. But if every
component is well thought-out and properly coordinated, everything should work perfectly. Let’s
start with mechanical design.
5 Mechanical Design
You should already be familiar with the mechanical design process, but we’ll give you some pointers
just in case. Over the course of this project, you’ll probably come up with several design ideas for
your Sumobot. These designs may be very different from one-another; they might use different
parts, differently shaped chassis, etc. Chassis and robot parts are expensive, and they can be
difficult to swap out, so make sure your design is as complete as possible before you start
building. Don’t commit to anything unless you’re absolutely sure your current design is the one
you want to use. For a complete description of Sumobot size regulations, refer to the McMaster
Sumobot rulebook. To reiterate, the design stage is the most critical part of your project. If you
aren’t absolutely sure about your current design, ask your mentors for their opinion. That’s why
they’re there.
For a complete description of Sumobot size regulations, please refer to the McMaster Sumobot
rulebook.
To reiterate, the design stage is the most critical part of your project. If you’re not absolutely
sure about your current design, then ask! That’s why your mentors are there.
5.1 Rough Sketches
The first thing your group should do is sit down and sketch out some ideas. You don’t need any
special software to brainstorm; all you need is a pen, some paper, and a good imagination. When
you all agree on a design, you can safely move to the next step.
5
5.2 CAD implementation
With your design complete, you will now make a CAD model of the robot’s chassis. If you’re not
familiar with CAD or 3D printing, just talk to your mentor, and they’ll tell you everything you
need to know. Think of the chassis as an exoskeleton: something that protects the robot’s inner
body while keeping everything secure. If the chassis is too small or too oddly-shaped, none of the
robot’s parts will fit. But if it’s too bulky or roomy, the robot’s parts will fall out. To prevent this,
you should constantly ask yourself these questions while designing the CAD:
5.3 The CAD Checklist
• Does our design meet the requirements and constraints of the competition?
• Where will each sensor go?
– Can every sensor be wired to the Arduino?
– Can every sensor see the environment?
• Are the Arduino’s supporting wires secure?
• Can we reach the battery easily?
– Can the batteries power the Arduino, sensors, motors, and other components?
– Are these components all receiving power from the battery?
• Are the motors in the right place?
– Do the motors touch the ground (via the wheels)?
– Can they actually move the robot?
If you can answer “yes” to all of these questions, you’re ready to move on.
6 Electrical Design
Now that you know how your robot looks, it’s time to really think about what goes inside: the
sensors, the motors, the Arduino, the power source, and the wires connecting them all. For an
explanation of the Arduino’s various ports, pins, and connections, refer to Appendix A.
6.1 Sensors
When choosing sensors for your robot, keep these questions in mind:
1. How will your SumoBot detect the boundaries of the ring?
2. How will your SumoBot detect other robots?
Different sensors detect different things, and they detect these things in different ways. Some
sensors can only tell you whether stimuli are “DETECTED” or “NOT DETECTED,” while others
provide more detailed information, such as your robot’s distance from the stimulus. Every sensor
has its pros and cons. You may have to use two or more sensors, each one compensating for
another’s weakness. It’s a difficult decision, so to make things easier, we created this chart:
6
Table 1: Sensor Properties
SENSOR MECHANISM OF
DETECTION
ADVANTAGES DISADVANTAGES
Infrared(IR)
Emits and Detects IR
Light
Little interference from
noise
Target must be in direct line of
sight
Low power requirement Short range only
Easy to use Signal can be absorbed by dark
surfaces
Relatively inexpensive Relatively low sensitivity for dis-
tance measurements
Unaffected by climate Large dead zone
Ultrasonic
Emits and detects
sound waves greater
than 18 kHz
Short and long range Must consider Doppler effect if
your opponent’s robot is fast
Very sensitive distance
measurements
Irregular or coarse surfaces de-
flect the signal
Easy to use Relatively expensive
Little-to-no dead zone Lots of High Frequency Noise
Easy to use Affected by climate
Photo-resistor
Semiconductor resis-
tance decreases in light
and increases in the
dark
Easy to use Does not provide distance
Relatively inexpensive Low sensitivity for low levels of
lightl
Unaffected by climate Time delay between signal detec-
tion and output
Optical sensor
IR and optical light Similar to IR Similar to IR
Detects light in the
IR and optical electro-
magnetic range, 300-
1100 nm (varies be-
tween manufacturers)
*Dead zone refers to the sensor’s “blind spot,” where data becomes unreliable.
7
This table can be helpful, but only for a surface-level reference. If you want to know more about
a sensor’s capabilities, READ THE MANUFACTURER’S DATA SHEET. Only then will
you know for sure if a sensor does what you need it to. And remember: the Sumobot ring is black
with a white border. Your robot will probably have to differentiate between and respond to these
colors.
6.2 Actuators
6.2.1 DC Motors
DC motors power the robot’s wheels, making them a vital component of the motor system. For a
basic understanding of how DC motors work, watch this two-minute video: video
Every motor is different, as is every wheel, so choose carefully. And while you’re choosing, keep
these things in mind:
1. One DC motor can power a single wheel. If your robot has two wheels, it needs two motors; if
it has four wheels, it needs four motors. A robot with two motors is lightweight, inexpensive,
energy-conscious, and relatively easy to wire, but it doesn’t have as much power to fall back
on. Robots with four motors are pricier, heavier, and more difficult to manage, but their
extra power could make a difference. Again, choose carefully.
2. A DC motor is connected to its wheel by two gears: the driven gear and the drive gear.
The driven gear (or ring) is powered by the motor itself, while the drive gear (or pinion)
turns the wheel. Gear ratio is the difference between the numbers of teeth on these two
types of gears. The more teeth the driven gear has relative to the drive gear, the higher the
gear ratio becomes, and the faster the drive gear will turn. If your robot has small wheels, its
DC motors also have small drive gears, which means the robot can move at higher speeds.But
speed isn’t the only thing that matters. You also have to consider torque, the rotational
force transferred from the motor to the wheels. A robot with lots of torque can move uphill
more easily and push weaker robots out of the ring, giving it a competitive advantage. The
bigger the drive gears, the bigger the torque, meaning a robot with large wheels and low gear
ratio has a lot of power backing it up. So, when choosing the size of your robot’s wheels, ask
yourself which is more important: speed or torque?
6.2.2 Servomotors
A servomotor is a device that makes small, precise changes in the angular position of the robot’s
armatures. A single servomotor contains a DC motor and a sensor. The sensor detects the arma-
ture’s angle, compares it to the angle at which the armature should be, and sends feedback to the
DC motor, which then corrects the armature’s position. They’re great for keeping your robot on
track, but they usually can’t move farther than 180 degrees, meaning they can only correct small
errors. Keep this in mind when designing your robot. You can use servomotors to mount sensors,
rotate parts of your robot, or perform other functions. Like almost everything else in this project,
it’s up to you.
6.2.3 A note about Motors
No matter how similar a pair of motors may seem, they will always move at slightly different speeds,
even when given the same throttle. You may have to adjust each motor’s throttle individually to
8
keep your robot from swerving.
6.3 Power Systems
Your robot will have two power systems: a motor power system and a logic power system.
Crisscrossing the power systems will burn your microcontroller — it’s not meant to handle large
voltages and amperages — so keep these systems separate.
6.3.1 The Motor Power System
It’s time to connect the Arduino to the motors. All you have to do is build an electrical circuit,
and you’re done, right? Oh, if only it were that simple. . .
This process puts your Arduino in danger for two reasons. First, a motor is a power generator,
so it will probably try to send a current back into the Arduino. Second, motors create something
called back electromotive force (or back EMF for short). Back EMF comes from the difference
in relative motion between the motor’s armature and magnetic field, and manifests itself as a voltage
that pushes against any incoming current. This includes the current coming from your Arduino, so
you’ll have to take some precautions.
These precautions come in the form of an H Bridge.
6.3.2 H-Bridges
H Bridges take signals from the microcontroller and increase their power with amplifier circuits.
They also prevent current from going back the way it came. To give you a better idea of how an H
Bridge works, we stole this diagram from Wikipedia:
Figure 1: How H-Bridges work
The switches only allow current to move forwards; it cannot go back. S1 and S4 close at the
same time to go forwards, while S2 and S3 close simultaneously to go backwards. Hooking up an H
Bridge is straightforward enough. Just use the wiring diagram in Appendix B for reference. And
try not to short anything.
9
6.4 The Logic Power System
The Arduino Uno has a recommended input voltage of 7-12 V. Anything below 7 V won’t have
enough voltage to power the Arduino. Anything above 12 V could damage the microcontroller. We
recommend using a 9 V battery, but other batteries are fine as long as they stay within the 7-12 V
limit.
7 Software Design
So. . . everything’s hooked up. You’ve got your sensors working, your motors calibrated, and your
wires sorted out. Now it’s time for the real “fun”: programming the Arduino. I know what you’re
thinking. You want to boot up your computer and start typing code. Well, don’t. You’ll have no
clue where to begin. Instead, take some time to figure out how you want your robot to behave,
then create a finite state machine (FSM).
7.1 Finite State Machines
A finite state machine is like a list of every action a system can take. At any time, an FSM can
exist in one of many possible states. When certain conditions are met, the FSM will transition
from one state to another. One of the simplest FSMs out there is a blinking light:
Figure 2: The Blinking Finite State Diagram
As you can see, there are two bubbles; these represent the state of the light. These states are
on and off. The arrows are where states can go if conditions are met.
For example, suppose the light is on. The system will remain in that state until one second is
passed. When that condition is met, the system will switch its state to where the arrow points.
10
Your system will not be more complicated; it will have more states to consider. What will your
robot do when it sees a white line, what about when it sees your opponent?
It’s ok for this part to be difficult; it is one of the most challenging parts of the entire ordeal.
But some time spent here will reap rewards in the future.
7.2 Coding
The Arduino has its own programming language, one similar to Java or C. If you have experience
with these languages, Arduino programming shouldn’t be too hard. If not, don’t worry! The
language is fairly straightforward, and there are tons of online resources to help you out. (This
handbook is also pretty helpful, FYI.)
Let’s go through the blinking light program discussed in the FSM section. We’ll break it down
bit by bit to show you how each function contributes to the program in its entirety.
7.2.1 Declare variables
The first thing you always do is declare your variables. If you want to use a pin, declare it here
with an easy-to-read variable name. Leave a comment with // in case you forget which variables
are which.
// On most Arduino boards , pin 13 i s connected to the LED.
// Give i t a name :
int led = 13;
int state = 0;
7.2.2 Set up your ports
Once you’ve declared all your variables, it’s time to tell the pins what to do. Go to the setup area
and declare whether the pins are analog, digital, input, or output.
void setup () {
S e r i a l . begin (9600);
// I n i t i a l i z e the d i g i t a l pin as an output f o r the LED.
pinMode ( led , OUTPUT) ;
}
7.2.3 The main program
A microcontroller system has lots of sensors and actuators to keep track of, and it needs to maintain
them all in real time. If it didn’t, your robot would drive itself off a cliff, because its actuators
couldn’t react fast enough to incoming sensory data. The Arduino can’t keep an eye on everything
at once, so instead it runs in a constant loop, checking its conditions over and over until the machine
turns off. This means the Arduino will repeat your code in an infinite cycle. There are two common
types of checking behaviour:
1. Polling is when the microcontroller periodically checks on a sensor or actuator, usually as
part of an infinite loop. This would be like if you peeked out the window while waiting for a
friend to come to your house.
11
2. When a sensor or actuator sends an alert to the microcontroller, it’s called an interrupt. This
would be like if your friend rang the doorbell when they arrived.
Sometimes a poorly-coded polling program gets stuck on a single statement, repeating endlessly.
These statements are always “while” statements, so don’t use “while” statements unless you really
know what you’re doing.
// The loop routine runs over and over again :
void loop () {
switch ( state ) {
case 0:
// Turn the LED on . HIGH i s the voltage l e v e l .
digitalWrite ( led , HIGH) ;
// Wait fo r one second (1000 m i l l i s e c o n d s . )
delay (1000);
state = 1; // Switch the state
break ;
case 1:
// Turn the LED o f f . LOW i s the voltage l e v e l .
digitalWrite ( led , LOW) ;
delay (1000);
state = 0; // Switch the state
break ;
}
}
7.2.4 Writing functions
You’ll probably have to duplicate certain pieces of code in the loop function. For example, a code
that tells the robot how to turn left or right is going to show up a lot. You may want to write
separate modules for repeated functions to reduce the size and redundancy of your code. See
Appendix C for examples. Put together, the code looks like this:
/∗
Blink :
Turns an LED on f o r one second , then o f f f o r one second .
Repeats i n f i n i t e l y .
This example code i s in the public domain .
∗/
// Step 1: Declare your v a r i a b l e s .
// On most Arduino boards , pin 13 i s connected to the LED.
// Give i t a name :
int led = 13;
state = 0;
12
// Step 2: Set up your pins
// the setup routine runs once when you press r e s e t :
void setup () {
// I n i t i a l i z e the d i g i t a l pin as an output .
pinMode ( led , OUTPUT) ;
}
// Step 3: The main program
// The loop routine runs over and over again forever :
void loop () {
switch ( state ) {
case 0:
// Turn the LED on . HIGH i s the voltage l e v e l .
digitalWrite ( led , HIGH) ;
// Wait fo r one second (1000 m i l l i s e c o n d s ) .
delay (1000);
state = 1; // Switch the state
break ;
case 1:
// Turn the LED o f f . LOW i s the voltage l e v e l .
digitalWrite ( led , LOW) ;
delay (1000); // Wait f o r one second .
state = 0; // Switch the state
break ;
}
}
Once the FSM is complete, upload it to your Sumobot’s Arduino and see if it works. If you don’t
know how to upload the code, see Appendix D for a step-by-step run through. For a comprehensive
explanation of the Arduino’s programming language, go to this website: http://arduino.cc/en/Reference/HomePage.
If you run into any problems, try Googling a solution. Online forums are surprisingly helpful.
7.3 Pulse Width Modulation
Sensors and actuators can send and receive two different types of signals: analog and digital.
Analog signals represent the world as a series of gradients, where the slightest change in sound
frequency or EM wavelength is detected, measured, and sent to the Arduino as an equally slight
change in voltage. By contrast, digital signals can only say whether something is “DETECTED”
or “NOT DETECTED.”
Most motor drivers and actuators have two possible outputs (“OFF” and “ON,” where “ON”
is the fastest speed possible), which means they can only respond to digital signals. Unfortunately,
most sensors use analog signals, making it hard for the Arduino to relay information from the
sensors to the motors.
Thankfully, we can represent analog information as a digital signal using a technique called
pulse width modulation (PWM). Most modern sensors, motor drivers, and actuators rely on
PWM.
13
7.3.1 How does it work?
Imagine you have a light switch with two possible states: ON and OFF. The lights are too bright
when turned ON, but there’s no way to make them dimmer without turning them completely OFF.
If you flick the light switch ON and OFF very quickly — faster than human hands can move —
you can control the brightness of the room in gradients. The longer you leave the light switch ON
before turning it OFF (and remember, you’re still flicking the switch faster than humanly possible)
the brighter the lights appear to be. The longer you leave the lights OFF before turning them back
on, the dimmer the room becomes. You are using digital inputs to simulate analog outputs.
The microcontroller does something similar. Every few milliseconds, the Arduino sends a 5V
“pulse” of electricity to the motors. The greater the sensor’s signal, the longer the pulse lasts
relative to the milliseconds-long interval. The longer the pulse lasts, the longer the motors stay
ON, and the faster the robot moves.
For example, let’s say the interval is two milliseconds long. A 5V analog signal will produce
a pulse that lasts the entire two milliseconds; if the signal is sustained, your robot will eventually
reach top speed. A 2.5V analog signal will produce a 1 millisecond long pulse, which puts the robot
at half-speed. A 0V signal doesn’t produce any pulse at all, so the robot will decelerate to a halt.
Unlike a light switch, your robot’s motors cannot instantly change speeds. They need time to
accelerate or decelerate to the desired pace. Keep this in mind while programming your Arduino’s
PWM.
Appendix E shows the difference between PWMs and analog implementation in Arduino code.
8 Conclusion
We hope this guide was a useful introduction to Sumobots. Below you’ll find the appendix, where
we put most of our charts, diagrams, and extra pieces of information. If you have any questions
this guide couldn’t answer, just talk to your mentors or send an email to Vinay Yuvashankar at
yuvashv@mcmaster.ca. Good Luck!
14
A Arduino Anatomy
This picture, with all its parts and pins, might seem complicated to someone who’s never used a
microcontroller before. Don’t worry — it’s not as hard as it looks. And to prove it, we made a
chart for easy reference! Parts are listed clockwise from “External Power Supply” to “Reset Pin.”
Figure 3: The Arduino
15
Port Function
External power supply Plug for the battery that powers the Arduino
and sensors. Use a separate power supply for
the motors.
Analog reference pin You probably won’t use this pin. Provides a
reference voltage for Analog inputs. Default is
5 V, but can be changed.
Digital ground Ground wires for digital inputs and all outputs
must terminate here.
Digital I/O pins Digital inputs and all outputs are connected
here. 12 pins available for digital inputs and
outputs, numbered 2-13.
Serial out (TX) Uses serial communication to send data to a
computer or other device
Serial in (RX) Uses serial communication to receive data from
said device
Reset button Erases all programming embedded on the Ar-
duino. Don’t push it by accident!
In-circuit serial programmer You probably won’t use this pin. Allows you to
burn sketches onto the Arduino board through
an external programmer instead of the boot-
loader (which loads the OS).
ATMega328 microcontroller This is the processor. Contains 32 KB of mem-
ory.
Analog in pins Connection point for sensors that take Analog
readings. 6 pins are available for Analog in-
puts.
Voltage in You probably won’t use this pin. An alterna-
tive to the Arduino’s external power supply.
Ground pins Connection point for ground wires from Analog
inputs. There are two ports. It doesn’t matter
which one you use.
5 Volt power pin This pin has 5 V (relative to the ground). Sen-
sors and motors that require 5 V or Vcc should
be wired to this pin.
3.3 Volt power pin This pin has 3.3 V (relative to the ground).
Sensors and motors that require 3.3 V or Vcc
should be wired to this pin.
Reset pin Will reset the Arduino if it receives a positive
voltage
16
B The CAD Checklist
• Ensure design is within competition constraints
• Ensure that all sensors have been considered (IR and Distance)
– Ensure that all sensors can be wired
– Ensure that sensors are able to see the environment
• Ensure that Arduinos and supporting wires are in a secure place
• Ensure that Batteries are at an easily accessible place
– Ensure that all components (Sensors, Actuators and Arduinos) can be powered from the
battery
• Ensure Motors are at the correct place
– Ensure that motors can touch the ground and move the robot
17
C Hooking Up Sensors and H-Bridges
Figure 4: The Arduino
http://bildr.org/2011/03/various-proximity-sensors-arduino/ has a great tutorial on
hooking up sensors to the arduino.
18
D Sample SumoBot Code
// Declare pins f o r the right motor .
const int motor pin1 = 5;
const int motor pin2 = 6;
// Declare pins f o r the l e f t motor .
const int motor pin3 = 10;
const int motor pin4 = 11;
// Declare pins f o r p h o t o r e s i s t o r s and the IR sensor .
const int IRSens = 0;
const int PHOTO1 = 1;
const int PHOTO2 = 2;
const int PHOTO3 = 3;
const int PHOTO4 = 4;
// Declare p h o t o r e s i s t o r s cut−o f f values f o r black−white detection .
// This i s what you came up with a f t e r t e s t i n g :
int InitVal1 = 120;
int InitVal2 = 50;
int InitVal3 = 270;
int InitVal4 = 190;
// Step 2: Set up your ports
void setup () {
// Data t r a v e l s through the s e r i a l data stream at the 9600 band .
S e r i a l . begin (9600);
// Set up motor pins .
pinMode ( motor pin1 , OUTPUT) ;
.
// Set up sensor pins .
pinMode (PHOTO1, INPUT) ;
. . .
}
// Step 3: Writing functions
// Helpful as these examples may be ,
// y o u l l probably have to write other functions on your own .
// This next function i s a debugging tool that
// prints sensor readings f o r your own sake .
//The Arduino d o e s n t actually use checkSens () to check the sensors .
19
void checkSens () {
S e r i a l . print (” Distance : ” ) ;
S e r i a l . print ( analogRead ( 0 ) ) ;
S e r i a l . print (” tPhoto 1: ” ) ;
S e r i a l . print ( analogRead (PHOTO1) ) ;
S e r i a l . print (” tPhoto 2: ” ) ;
S e r i a l . print ( analogRead (PHOTO2) ) ;
S e r i a l . print (” tPhoto 3: ” ) ;
S e r i a l . print ( analogRead (PHOTO3) ) ;
S e r i a l . print (” tPhoto 4: ” ) ;
S e r i a l . println ( analogRead (PHOTO4) ) ; }
// This function t e l l s the motors to move forward :
void forward () {
analogWrite ( motor pin1 , 0 ) ;
analogWrite ( motor pin2 , 1 5 0 ) ;
analogWrite ( motor pin3 , 1 5 0 ) ;
analogWrite ( motor pin4 , 0 ) ;
}
// This function stops a l l motors :
void halt () {
AnalogWrite ( motor pin1 , 0 ) ;
AnalogWrite ( motor pin2 , 0 ) ;
AnalogWrite ( motor pin3 , 0 ) ;
AnalogWrite ( motor pin4 , 0 ) ; }
// Step 4: The main code
//Your main code w i l l be much longer than the provided example ,
//but i t should give you an idea of where to s t a r t :
void loop () {
checkSens ( ) ;
//Get readings from the sensors that can be stored as v a r i a b l e s .
unsigned int read1 = analogRead (PHOTO1) ;
unsigned int read2 = analogRead (PHOTO2) ;
unsigned int read3 = analogRead (PHOTO3) ;
unsigned int read4 = analogRead (PHOTO4) ;
unsigned int thing = analogRead ( IRSens ) ;
// Decision−making code :
i f ( ( read1 > InitVal1 ) && ( read2 > InitVal2 )) {
// I f both front sensors detect white :
halt ( ) ;
}
20
e l s e { forward ;}
}
Put together , the code looks l i k e t h i s :
// Declare pins f o r the right motor .
const int motor pin1 = 5;
const int motor pin2 = 6;
// Declare pins f o r l e f t motor
const int motor pin3 = 10;
const int motor pin4 = 11;
// Declare pins f o r p h o t o r e s i s t o r s and the IR sensor .
const int IRSens = 0;
const int PHOTO1 = 1;
const int PHOTO2 = 2;
const int PHOTO3 = 3;
const int PHOTO4 = 4;
// Declare p h o t o r e s i s t o r s cut−o f f values f o r black−white detection .
// This i s what you came up with a f t e r t e s t i n g :
int InitVal1 = 120;
int InitVal2 = 50;
int InitVal3 = 270;
int InitVal4 = 190;
//Get readings from the sensors that can be stored as v a r i a b l e s :
unsigned int read1 ;
unsigned int read2 ;
unsigned int read3 ;
unsigned int read4 ;
unsigned int thing ;
void setup () {
// Data t r a v e l s through the s e r i a l data stream at the 9600 band .
S e r i a l . begin (9600);
// Set up motor pins .
pinMode ( motor pin1 , OUTPUT) ;
.
// Set up sensor pins .
pinMode (PHOTO1, INPUT) ;
. . .
21
}
// Tells you what the sensors see .
// D o e s n t make the Arduino check the sensors .
void checkSens () {
S e r i a l . print (” Distance : ” ) ;
S e r i a l . print ( analogRead ( 0 ) ) ;
S e r i a l . print (” tPhoto 1: ” ) ;
S e r i a l . print ( analogRead (PHOTO1) ) ;
S e r i a l . print (” tPhoto 2: ” ) ;
S e r i a l . print ( analogRead (PHOTO2) ) ;
S e r i a l . print (” tPhoto 3: ” ) ;
S e r i a l . print ( analogRead (PHOTO3) ) ;
S e r i a l . print (” tPhoto 4: ” ) ;
S e r i a l . println ( analogRead (PHOTO4) ) ; }
// Tells the motors to move forward :
void forward () {
analogWrite ( motor pin1 , 0 ) ;
analogWrite ( motor pin2 , 1 5 0 ) ;
analogWrite ( motor pin3 , 1 5 0 ) ;
analogWrite ( motor pin4 , 0 ) ;
}
// Stops a l l motors :
void halt () {
AnalogWrite ( motor pin1 , 0 ) ;
AnalogWrite ( motor pin2 , 0 ) ;
AnalogWrite ( motor pin3 , 0 ) ;
AnalogWrite ( motor pin4 , 0 ) ; }
void loop () {
checkSens ( ) ;
//Get readings from the sensors that can be stored as v a r i a b l e s :
read1 = analogRead (PHOTO1) ;
read2 = analogRead (PHOTO2) ;
read3 = analogRead (PHOTO3) ;
read4 = analogRead (PHOTO4) ;
thing = analogRead ( IRSens ) ;
// Decision−making code :
i f ( ( read1 > InitVal1 ) && ( read2 > InitVal2 )) {
// I f both front sensors detect white :
halt ( ) ;
}
22
e l s e { forward ;}
}
23
E PMWs in Arduinos
PWM signals make coding much easier. With PWM, you don’t have to worry about remapping
input values to match output values. PWM signals are represented in 8 bits, so values range between
0 and 255, with 0 representing 0V and 255 representing 5V. The code needed to read and write
digital signals is similar to the code needed for analog signals; the only difference is the syntax,
which is described below:
E.1 Analog
// First , map the pins .
const int analogInPin = A0; // Analog input
const int analogOutPin = 9; // Analog output
// Define other v a r i a b l e s :
int InputValue = 0;
int OutputValue = 0;
void setup () {
S e r i a l . begin (9600);
}
void loop () {
// Tell i t how to read the analog input value :
ImputValue = analogRead ( analogInPin ) ;
// Do a l l necessary c a l c u l a t i o n s and r e s c a l e
// the values so they f a l l between 0 and 255.
OutputValue = map( InputValue , 0 , 1023 , 0 , 255);
// Change the analog output value .
analogWrite ( analogOutPin , OutputValue ) ;
}
E.2 PWM
// First , map the pins .
cons t i n t digitalInputPin = 10; // D i g i t a l Input
const int digitalOutPin = 9; // D i g i t a l Output
// Define other v a r i a b l e s :
int InputValue = 0;
int OutputValue = 0;
24
void setup () {
S e r i a l . begin (9600);
pinMode ( digitalInputPin , OUTPUT) ;
pinMode ( digitalOutputPin , INPUT) ;
}
void loop () {
// Tell i t how to read the d i g i t a l input value :
InputValue = digitalRead ( digitalInputPin ) ;
// It isn ’ t necessary to r e s c a l e d i g i t a l values ,
// because they already f a l l between 0 and
// 255.
OutputValue = map( InputValue , 0 , 255 , 0 , 255);
// Output the necessary d i g i t a l value .
digitalWrite ( digitalOutputPin , OutputValue )
}
25

More Related Content

What's hot

인터맥스캐너 Intermec SF61B 2D 포켓타입 모바일스캐너 매뉴얼
인터맥스캐너 Intermec SF61B 2D 포켓타입 모바일스캐너 매뉴얼인터맥스캐너 Intermec SF61B 2D 포켓타입 모바일스캐너 매뉴얼
인터맥스캐너 Intermec SF61B 2D 포켓타입 모바일스캐너 매뉴얼
HION IT
 
Team Omni L2 Requirements Revised
Team Omni L2 Requirements RevisedTeam Omni L2 Requirements Revised
Team Omni L2 Requirements Revised
Andrew Daws
 
Memory Management in the Java HotSpot Virtual Machine
Memory Management in the Java HotSpot Virtual MachineMemory Management in the Java HotSpot Virtual Machine
Memory Management in the Java HotSpot Virtual Machine
white paper
 

What's hot (18)

Metasploit
MetasploitMetasploit
Metasploit
 
Man hinh dieu khien
Man hinh dieu khienMan hinh dieu khien
Man hinh dieu khien
 
인터맥스캐너 Intermec SF61B 2D 포켓타입 모바일스캐너 매뉴얼
인터맥스캐너 Intermec SF61B 2D 포켓타입 모바일스캐너 매뉴얼인터맥스캐너 Intermec SF61B 2D 포켓타입 모바일스캐너 매뉴얼
인터맥스캐너 Intermec SF61B 2D 포켓타입 모바일스캐너 매뉴얼
 
Team Omni L2 Requirements Revised
Team Omni L2 Requirements RevisedTeam Omni L2 Requirements Revised
Team Omni L2 Requirements Revised
 
Discovering st32
Discovering st32Discovering st32
Discovering st32
 
USB OTG
USB OTGUSB OTG
USB OTG
 
En acq810 fw manual b
En  acq810 fw manual bEn  acq810 fw manual b
En acq810 fw manual b
 
20 Magnificos proyectos para ARDUINO
20 Magnificos proyectos para ARDUINO20 Magnificos proyectos para ARDUINO
20 Magnificos proyectos para ARDUINO
 
Tài liệu biến tần ABB ACS850
Tài liệu biến tần ABB ACS850Tài liệu biến tần ABB ACS850
Tài liệu biến tần ABB ACS850
 
Smart Street System
Smart Street SystemSmart Street System
Smart Street System
 
Valentine One radar detector manual
Valentine One radar detector manualValentine One radar detector manual
Valentine One radar detector manual
 
XORP manual
XORP manualXORP manual
XORP manual
 
Smart dsp os_user_guide
Smart dsp os_user_guideSmart dsp os_user_guide
Smart dsp os_user_guide
 
Smart otdr JDSU
Smart otdr JDSUSmart otdr JDSU
Smart otdr JDSU
 
Memory Management in the Java HotSpot Virtual Machine
Memory Management in the Java HotSpot Virtual MachineMemory Management in the Java HotSpot Virtual Machine
Memory Management in the Java HotSpot Virtual Machine
 
wronski_ugthesis[1]
wronski_ugthesis[1]wronski_ugthesis[1]
wronski_ugthesis[1]
 
Jdsu mts 2000_manual
Jdsu mts 2000_manualJdsu mts 2000_manual
Jdsu mts 2000_manual
 
Proline Promag L 800-Electromagnetic Flowmeter
Proline Promag L 800-Electromagnetic FlowmeterProline Promag L 800-Electromagnetic Flowmeter
Proline Promag L 800-Electromagnetic Flowmeter
 

Similar to The SumoBot Handbook_final

Final Report 9505482 5845742
Final Report 9505482 5845742Final Report 9505482 5845742
Final Report 9505482 5845742
Bawantha Liyanage
 
ACCELEROMETER BASED HAND GESTURE CONTROLLED ROBOT USING ARDUINO
ACCELEROMETER BASED HAND GESTURE CONTROLLED ROBOT USING ARDUINOACCELEROMETER BASED HAND GESTURE CONTROLLED ROBOT USING ARDUINO
ACCELEROMETER BASED HAND GESTURE CONTROLLED ROBOT USING ARDUINO
Snehasis Mondal
 
Embeded microcontroler
Embeded microcontrolerEmbeded microcontroler
Embeded microcontroler
Yugo Sulistyo
 
Arduino bộ vi điều khiển cho tất cả chúng ta part 1
Arduino bộ vi điều khiển cho tất cả chúng ta part 1Arduino bộ vi điều khiển cho tất cả chúng ta part 1
Arduino bộ vi điều khiển cho tất cả chúng ta part 1
tungdientu
 
INTRODUCTION TO EMBEDD.docx
INTRODUCTION TO EMBEDD.docxINTRODUCTION TO EMBEDD.docx
INTRODUCTION TO EMBEDD.docx
vrickens
 
ImplementationOFDMFPGA
ImplementationOFDMFPGAImplementationOFDMFPGA
ImplementationOFDMFPGA
Nikita Pinto
 
Report on e-Notice App (An Android Application)
Report on e-Notice App (An Android Application)Report on e-Notice App (An Android Application)
Report on e-Notice App (An Android Application)
Priyanka Kapoor
 
INTRODUCTION TO EMBEDDED SYSTEMSA CYBER-PHYS.docx
INTRODUCTION TO EMBEDDED SYSTEMSA CYBER-PHYS.docxINTRODUCTION TO EMBEDDED SYSTEMSA CYBER-PHYS.docx
INTRODUCTION TO EMBEDDED SYSTEMSA CYBER-PHYS.docx
vrickens
 
Balaji,frontline embedded system design using 8051 microcontrollers
Balaji,frontline   embedded system design using 8051 microcontrollersBalaji,frontline   embedded system design using 8051 microcontrollers
Balaji,frontline embedded system design using 8051 microcontrollers
WindyAyu4
 

Similar to The SumoBot Handbook_final (20)

Final Report 9505482 5845742
Final Report 9505482 5845742Final Report 9505482 5845742
Final Report 9505482 5845742
 
ACCELEROMETER BASED HAND GESTURE CONTROLLED ROBOT USING ARDUINO
ACCELEROMETER BASED HAND GESTURE CONTROLLED ROBOT USING ARDUINOACCELEROMETER BASED HAND GESTURE CONTROLLED ROBOT USING ARDUINO
ACCELEROMETER BASED HAND GESTURE CONTROLLED ROBOT USING ARDUINO
 
Arduino_Project_Report
Arduino_Project_ReportArduino_Project_Report
Arduino_Project_Report
 
VENDING_MACHINE_2023-2024
VENDING_MACHINE_2023-2024VENDING_MACHINE_2023-2024
VENDING_MACHINE_2023-2024
 
Sonar Project Report
Sonar Project ReportSonar Project Report
Sonar Project Report
 
Bitirme Tezim
Bitirme TezimBitirme Tezim
Bitirme Tezim
 
Embeded microcontroler
Embeded microcontrolerEmbeded microcontroler
Embeded microcontroler
 
Thesis Report
Thesis ReportThesis Report
Thesis Report
 
Arduino bộ vi điều khiển cho tất cả chúng ta part 1
Arduino bộ vi điều khiển cho tất cả chúng ta part 1Arduino bộ vi điều khiển cho tất cả chúng ta part 1
Arduino bộ vi điều khiển cho tất cả chúng ta part 1
 
2D ROBOTIC PLOTTER
2D ROBOTIC PLOTTER2D ROBOTIC PLOTTER
2D ROBOTIC PLOTTER
 
report
reportreport
report
 
INTRODUCTION TO EMBEDD.docx
INTRODUCTION TO EMBEDD.docxINTRODUCTION TO EMBEDD.docx
INTRODUCTION TO EMBEDD.docx
 
Final Report
Final ReportFinal Report
Final Report
 
ImplementationOFDMFPGA
ImplementationOFDMFPGAImplementationOFDMFPGA
ImplementationOFDMFPGA
 
Report on e-Notice App (An Android Application)
Report on e-Notice App (An Android Application)Report on e-Notice App (An Android Application)
Report on e-Notice App (An Android Application)
 
Smart Traffic Management System using Internet of Things (IoT)-btech-cse-04-0...
Smart Traffic Management System using Internet of Things (IoT)-btech-cse-04-0...Smart Traffic Management System using Internet of Things (IoT)-btech-cse-04-0...
Smart Traffic Management System using Internet of Things (IoT)-btech-cse-04-0...
 
Rapid programmering start
Rapid programmering startRapid programmering start
Rapid programmering start
 
INTRODUCTION TO EMBEDDED SYSTEMSA CYBER-PHYS.docx
INTRODUCTION TO EMBEDDED SYSTEMSA CYBER-PHYS.docxINTRODUCTION TO EMBEDDED SYSTEMSA CYBER-PHYS.docx
INTRODUCTION TO EMBEDDED SYSTEMSA CYBER-PHYS.docx
 
Balaji,frontline embedded system design using 8051 microcontrollers
Balaji,frontline   embedded system design using 8051 microcontrollersBalaji,frontline   embedded system design using 8051 microcontrollers
Balaji,frontline embedded system design using 8051 microcontrollers
 
Accident reporting system using mems
Accident reporting system using memsAccident reporting system using mems
Accident reporting system using mems
 

The SumoBot Handbook_final

  • 1. The Engineer’s Guide to SumoBots Don’t Panic! The SumoBot Executive 2014 January 1, 2016 1
  • 2. Contents 1 Introduction 4 2 What is a Sumobot? 4 3 What is a Robot? 4 4 Designing Your Robot 5 5 Mechanical Design 5 5.1 Rough Sketches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 5.2 CAD implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 5.3 The CAD Checklist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 6 Electrical Design 6 6.1 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 6.2 Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 6.2.1 DC Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 6.2.2 Servomotors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 6.2.3 A note about Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 6.3 Power Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6.3.1 The Motor Power System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6.3.2 H-Bridges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6.4 The Logic Power System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 7 Software Design 10 7.1 Finite State Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 7.2 Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 7.2.1 Declare variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 7.2.2 Set up your ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 7.2.3 The main program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 7.2.4 Writing functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 7.3 Pulse Width Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 7.3.1 How does it work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 8 Conclusion 14 A Arduino Anatomy 15 B The CAD Checklist 17 C Hooking Up Sensors and H-Bridges 18 D Sample SumoBot Code 19 2
  • 3. E PMWs in Arduinos 24 E.1 Analog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 E.2 PWM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3
  • 4. 1 Introduction Welcome to the McMaster Sumobot competition! This handbook will give you a basic understand- ing of the components and systems needed to make your first Sumobot. 2 What is a Sumobot? A Sumobot is exactly what it sounds like: a sumo-wrestling robot. More specifically, Sumobots are autonomous robots programmed to push other Sumobots out of a ring without getting pushed out themselves. Our competition follows the international regulations for Sumobot size and shape, as outlined in the McMaster Sumobot Rulebook. 3 What is a Robot? Autonomous robots aren’t so different from animals if you think about it. Robots and animals both observe their surroundings before deciding what to do, and they use similar tools in the process: • Animals use sensory organs like eyes and ears to collect information from the environment. A robot’s sensory systems do the same thing. • The brain takes information from the sensory organs and uses it to come up with an appro- priate response to the environment. Robots have processing systems for this purpose. • Once the brain has decided what the animal should do, it sends signals to the rest of the body through the nervous system. A robot’s “nervous system” is made of electrical wires. • The animal moves around using its limbs. Robots have many types of limbs, but they all need motors to work. So if you want to build a functional Sumobot, you need four things: a sensory system to collect data, a processing system to convert data into behavior, a motor output system to perform those behaviors, and a wiring system that connects them all together. First, let’s talk about a robot’s senses. We all know how sensory systems work in animals: the eyes, ears, nose, tongue, and skin work together to collect information, just like how a robot’s sensors gather data from the environment. But that’s all it is: raw data. Your eyes can’t tell you what you’re looking at; they just absorb light. Your tongue can’t tell you what you’re eating; it just absorbs chemicals. If you want to know what you’re eating — if you want to understand and interpret the information provided to you by your tongue — you need a brain. A robot’s brain is called a microcontroller or microprocessor. The robot’s sensors send information to the microcontroller, which then interprets that information based on a man-made system of logic. The man (or woman), in this case, is you. You decide how your microcontroller converts sensory input to motor output. You wire the robot’s sensors so the data goes where it needs to. You write the code, you upload it to the microcontroller, and you watch your robot do the exact opposite of what ’it should, because no one gets it right on their first try. But when you do get it right — when your little robot finally figures out how to push other robots out of the ring — you’ll feel as proud as any parent and deservedly so. 4
  • 5. Most amateur robot enthusiasts use the Arduino brand of microcontroller. You will use the Arduino Uno. There are many different kinds of Arduino, each with its own purpose, but the Arduino Uno is best for our designs. It’s usually installed in simple robots like Sumobots, which only use a few sensors and motors. Your Sumobot will probably be limited to DC motors, which will help it move around the ring, but depending on your design you might use other, more complex devices, like servomotors. That covers the basics. If you have any other questions about designing robots, choosing parts, or following Sumobot guidelines, just keep reading, and you’ll find what you’re looking for. Good luck! 4 Designing Your Robot A robot’s design can be broken down into three components • Mechanical Design • Electrical Design • Software Design These components are all equally important, and they depend on each-other to function properly. If one component is faulty, the whole design suffers, and your robot will refuse to work. But if every component is well thought-out and properly coordinated, everything should work perfectly. Let’s start with mechanical design. 5 Mechanical Design You should already be familiar with the mechanical design process, but we’ll give you some pointers just in case. Over the course of this project, you’ll probably come up with several design ideas for your Sumobot. These designs may be very different from one-another; they might use different parts, differently shaped chassis, etc. Chassis and robot parts are expensive, and they can be difficult to swap out, so make sure your design is as complete as possible before you start building. Don’t commit to anything unless you’re absolutely sure your current design is the one you want to use. For a complete description of Sumobot size regulations, refer to the McMaster Sumobot rulebook. To reiterate, the design stage is the most critical part of your project. If you aren’t absolutely sure about your current design, ask your mentors for their opinion. That’s why they’re there. For a complete description of Sumobot size regulations, please refer to the McMaster Sumobot rulebook. To reiterate, the design stage is the most critical part of your project. If you’re not absolutely sure about your current design, then ask! That’s why your mentors are there. 5.1 Rough Sketches The first thing your group should do is sit down and sketch out some ideas. You don’t need any special software to brainstorm; all you need is a pen, some paper, and a good imagination. When you all agree on a design, you can safely move to the next step. 5
  • 6. 5.2 CAD implementation With your design complete, you will now make a CAD model of the robot’s chassis. If you’re not familiar with CAD or 3D printing, just talk to your mentor, and they’ll tell you everything you need to know. Think of the chassis as an exoskeleton: something that protects the robot’s inner body while keeping everything secure. If the chassis is too small or too oddly-shaped, none of the robot’s parts will fit. But if it’s too bulky or roomy, the robot’s parts will fall out. To prevent this, you should constantly ask yourself these questions while designing the CAD: 5.3 The CAD Checklist • Does our design meet the requirements and constraints of the competition? • Where will each sensor go? – Can every sensor be wired to the Arduino? – Can every sensor see the environment? • Are the Arduino’s supporting wires secure? • Can we reach the battery easily? – Can the batteries power the Arduino, sensors, motors, and other components? – Are these components all receiving power from the battery? • Are the motors in the right place? – Do the motors touch the ground (via the wheels)? – Can they actually move the robot? If you can answer “yes” to all of these questions, you’re ready to move on. 6 Electrical Design Now that you know how your robot looks, it’s time to really think about what goes inside: the sensors, the motors, the Arduino, the power source, and the wires connecting them all. For an explanation of the Arduino’s various ports, pins, and connections, refer to Appendix A. 6.1 Sensors When choosing sensors for your robot, keep these questions in mind: 1. How will your SumoBot detect the boundaries of the ring? 2. How will your SumoBot detect other robots? Different sensors detect different things, and they detect these things in different ways. Some sensors can only tell you whether stimuli are “DETECTED” or “NOT DETECTED,” while others provide more detailed information, such as your robot’s distance from the stimulus. Every sensor has its pros and cons. You may have to use two or more sensors, each one compensating for another’s weakness. It’s a difficult decision, so to make things easier, we created this chart: 6
  • 7. Table 1: Sensor Properties SENSOR MECHANISM OF DETECTION ADVANTAGES DISADVANTAGES Infrared(IR) Emits and Detects IR Light Little interference from noise Target must be in direct line of sight Low power requirement Short range only Easy to use Signal can be absorbed by dark surfaces Relatively inexpensive Relatively low sensitivity for dis- tance measurements Unaffected by climate Large dead zone Ultrasonic Emits and detects sound waves greater than 18 kHz Short and long range Must consider Doppler effect if your opponent’s robot is fast Very sensitive distance measurements Irregular or coarse surfaces de- flect the signal Easy to use Relatively expensive Little-to-no dead zone Lots of High Frequency Noise Easy to use Affected by climate Photo-resistor Semiconductor resis- tance decreases in light and increases in the dark Easy to use Does not provide distance Relatively inexpensive Low sensitivity for low levels of lightl Unaffected by climate Time delay between signal detec- tion and output Optical sensor IR and optical light Similar to IR Similar to IR Detects light in the IR and optical electro- magnetic range, 300- 1100 nm (varies be- tween manufacturers) *Dead zone refers to the sensor’s “blind spot,” where data becomes unreliable. 7
  • 8. This table can be helpful, but only for a surface-level reference. If you want to know more about a sensor’s capabilities, READ THE MANUFACTURER’S DATA SHEET. Only then will you know for sure if a sensor does what you need it to. And remember: the Sumobot ring is black with a white border. Your robot will probably have to differentiate between and respond to these colors. 6.2 Actuators 6.2.1 DC Motors DC motors power the robot’s wheels, making them a vital component of the motor system. For a basic understanding of how DC motors work, watch this two-minute video: video Every motor is different, as is every wheel, so choose carefully. And while you’re choosing, keep these things in mind: 1. One DC motor can power a single wheel. If your robot has two wheels, it needs two motors; if it has four wheels, it needs four motors. A robot with two motors is lightweight, inexpensive, energy-conscious, and relatively easy to wire, but it doesn’t have as much power to fall back on. Robots with four motors are pricier, heavier, and more difficult to manage, but their extra power could make a difference. Again, choose carefully. 2. A DC motor is connected to its wheel by two gears: the driven gear and the drive gear. The driven gear (or ring) is powered by the motor itself, while the drive gear (or pinion) turns the wheel. Gear ratio is the difference between the numbers of teeth on these two types of gears. The more teeth the driven gear has relative to the drive gear, the higher the gear ratio becomes, and the faster the drive gear will turn. If your robot has small wheels, its DC motors also have small drive gears, which means the robot can move at higher speeds.But speed isn’t the only thing that matters. You also have to consider torque, the rotational force transferred from the motor to the wheels. A robot with lots of torque can move uphill more easily and push weaker robots out of the ring, giving it a competitive advantage. The bigger the drive gears, the bigger the torque, meaning a robot with large wheels and low gear ratio has a lot of power backing it up. So, when choosing the size of your robot’s wheels, ask yourself which is more important: speed or torque? 6.2.2 Servomotors A servomotor is a device that makes small, precise changes in the angular position of the robot’s armatures. A single servomotor contains a DC motor and a sensor. The sensor detects the arma- ture’s angle, compares it to the angle at which the armature should be, and sends feedback to the DC motor, which then corrects the armature’s position. They’re great for keeping your robot on track, but they usually can’t move farther than 180 degrees, meaning they can only correct small errors. Keep this in mind when designing your robot. You can use servomotors to mount sensors, rotate parts of your robot, or perform other functions. Like almost everything else in this project, it’s up to you. 6.2.3 A note about Motors No matter how similar a pair of motors may seem, they will always move at slightly different speeds, even when given the same throttle. You may have to adjust each motor’s throttle individually to 8
  • 9. keep your robot from swerving. 6.3 Power Systems Your robot will have two power systems: a motor power system and a logic power system. Crisscrossing the power systems will burn your microcontroller — it’s not meant to handle large voltages and amperages — so keep these systems separate. 6.3.1 The Motor Power System It’s time to connect the Arduino to the motors. All you have to do is build an electrical circuit, and you’re done, right? Oh, if only it were that simple. . . This process puts your Arduino in danger for two reasons. First, a motor is a power generator, so it will probably try to send a current back into the Arduino. Second, motors create something called back electromotive force (or back EMF for short). Back EMF comes from the difference in relative motion between the motor’s armature and magnetic field, and manifests itself as a voltage that pushes against any incoming current. This includes the current coming from your Arduino, so you’ll have to take some precautions. These precautions come in the form of an H Bridge. 6.3.2 H-Bridges H Bridges take signals from the microcontroller and increase their power with amplifier circuits. They also prevent current from going back the way it came. To give you a better idea of how an H Bridge works, we stole this diagram from Wikipedia: Figure 1: How H-Bridges work The switches only allow current to move forwards; it cannot go back. S1 and S4 close at the same time to go forwards, while S2 and S3 close simultaneously to go backwards. Hooking up an H Bridge is straightforward enough. Just use the wiring diagram in Appendix B for reference. And try not to short anything. 9
  • 10. 6.4 The Logic Power System The Arduino Uno has a recommended input voltage of 7-12 V. Anything below 7 V won’t have enough voltage to power the Arduino. Anything above 12 V could damage the microcontroller. We recommend using a 9 V battery, but other batteries are fine as long as they stay within the 7-12 V limit. 7 Software Design So. . . everything’s hooked up. You’ve got your sensors working, your motors calibrated, and your wires sorted out. Now it’s time for the real “fun”: programming the Arduino. I know what you’re thinking. You want to boot up your computer and start typing code. Well, don’t. You’ll have no clue where to begin. Instead, take some time to figure out how you want your robot to behave, then create a finite state machine (FSM). 7.1 Finite State Machines A finite state machine is like a list of every action a system can take. At any time, an FSM can exist in one of many possible states. When certain conditions are met, the FSM will transition from one state to another. One of the simplest FSMs out there is a blinking light: Figure 2: The Blinking Finite State Diagram As you can see, there are two bubbles; these represent the state of the light. These states are on and off. The arrows are where states can go if conditions are met. For example, suppose the light is on. The system will remain in that state until one second is passed. When that condition is met, the system will switch its state to where the arrow points. 10
  • 11. Your system will not be more complicated; it will have more states to consider. What will your robot do when it sees a white line, what about when it sees your opponent? It’s ok for this part to be difficult; it is one of the most challenging parts of the entire ordeal. But some time spent here will reap rewards in the future. 7.2 Coding The Arduino has its own programming language, one similar to Java or C. If you have experience with these languages, Arduino programming shouldn’t be too hard. If not, don’t worry! The language is fairly straightforward, and there are tons of online resources to help you out. (This handbook is also pretty helpful, FYI.) Let’s go through the blinking light program discussed in the FSM section. We’ll break it down bit by bit to show you how each function contributes to the program in its entirety. 7.2.1 Declare variables The first thing you always do is declare your variables. If you want to use a pin, declare it here with an easy-to-read variable name. Leave a comment with // in case you forget which variables are which. // On most Arduino boards , pin 13 i s connected to the LED. // Give i t a name : int led = 13; int state = 0; 7.2.2 Set up your ports Once you’ve declared all your variables, it’s time to tell the pins what to do. Go to the setup area and declare whether the pins are analog, digital, input, or output. void setup () { S e r i a l . begin (9600); // I n i t i a l i z e the d i g i t a l pin as an output f o r the LED. pinMode ( led , OUTPUT) ; } 7.2.3 The main program A microcontroller system has lots of sensors and actuators to keep track of, and it needs to maintain them all in real time. If it didn’t, your robot would drive itself off a cliff, because its actuators couldn’t react fast enough to incoming sensory data. The Arduino can’t keep an eye on everything at once, so instead it runs in a constant loop, checking its conditions over and over until the machine turns off. This means the Arduino will repeat your code in an infinite cycle. There are two common types of checking behaviour: 1. Polling is when the microcontroller periodically checks on a sensor or actuator, usually as part of an infinite loop. This would be like if you peeked out the window while waiting for a friend to come to your house. 11
  • 12. 2. When a sensor or actuator sends an alert to the microcontroller, it’s called an interrupt. This would be like if your friend rang the doorbell when they arrived. Sometimes a poorly-coded polling program gets stuck on a single statement, repeating endlessly. These statements are always “while” statements, so don’t use “while” statements unless you really know what you’re doing. // The loop routine runs over and over again : void loop () { switch ( state ) { case 0: // Turn the LED on . HIGH i s the voltage l e v e l . digitalWrite ( led , HIGH) ; // Wait fo r one second (1000 m i l l i s e c o n d s . ) delay (1000); state = 1; // Switch the state break ; case 1: // Turn the LED o f f . LOW i s the voltage l e v e l . digitalWrite ( led , LOW) ; delay (1000); state = 0; // Switch the state break ; } } 7.2.4 Writing functions You’ll probably have to duplicate certain pieces of code in the loop function. For example, a code that tells the robot how to turn left or right is going to show up a lot. You may want to write separate modules for repeated functions to reduce the size and redundancy of your code. See Appendix C for examples. Put together, the code looks like this: /∗ Blink : Turns an LED on f o r one second , then o f f f o r one second . Repeats i n f i n i t e l y . This example code i s in the public domain . ∗/ // Step 1: Declare your v a r i a b l e s . // On most Arduino boards , pin 13 i s connected to the LED. // Give i t a name : int led = 13; state = 0; 12
  • 13. // Step 2: Set up your pins // the setup routine runs once when you press r e s e t : void setup () { // I n i t i a l i z e the d i g i t a l pin as an output . pinMode ( led , OUTPUT) ; } // Step 3: The main program // The loop routine runs over and over again forever : void loop () { switch ( state ) { case 0: // Turn the LED on . HIGH i s the voltage l e v e l . digitalWrite ( led , HIGH) ; // Wait fo r one second (1000 m i l l i s e c o n d s ) . delay (1000); state = 1; // Switch the state break ; case 1: // Turn the LED o f f . LOW i s the voltage l e v e l . digitalWrite ( led , LOW) ; delay (1000); // Wait f o r one second . state = 0; // Switch the state break ; } } Once the FSM is complete, upload it to your Sumobot’s Arduino and see if it works. If you don’t know how to upload the code, see Appendix D for a step-by-step run through. For a comprehensive explanation of the Arduino’s programming language, go to this website: http://arduino.cc/en/Reference/HomePage. If you run into any problems, try Googling a solution. Online forums are surprisingly helpful. 7.3 Pulse Width Modulation Sensors and actuators can send and receive two different types of signals: analog and digital. Analog signals represent the world as a series of gradients, where the slightest change in sound frequency or EM wavelength is detected, measured, and sent to the Arduino as an equally slight change in voltage. By contrast, digital signals can only say whether something is “DETECTED” or “NOT DETECTED.” Most motor drivers and actuators have two possible outputs (“OFF” and “ON,” where “ON” is the fastest speed possible), which means they can only respond to digital signals. Unfortunately, most sensors use analog signals, making it hard for the Arduino to relay information from the sensors to the motors. Thankfully, we can represent analog information as a digital signal using a technique called pulse width modulation (PWM). Most modern sensors, motor drivers, and actuators rely on PWM. 13
  • 14. 7.3.1 How does it work? Imagine you have a light switch with two possible states: ON and OFF. The lights are too bright when turned ON, but there’s no way to make them dimmer without turning them completely OFF. If you flick the light switch ON and OFF very quickly — faster than human hands can move — you can control the brightness of the room in gradients. The longer you leave the light switch ON before turning it OFF (and remember, you’re still flicking the switch faster than humanly possible) the brighter the lights appear to be. The longer you leave the lights OFF before turning them back on, the dimmer the room becomes. You are using digital inputs to simulate analog outputs. The microcontroller does something similar. Every few milliseconds, the Arduino sends a 5V “pulse” of electricity to the motors. The greater the sensor’s signal, the longer the pulse lasts relative to the milliseconds-long interval. The longer the pulse lasts, the longer the motors stay ON, and the faster the robot moves. For example, let’s say the interval is two milliseconds long. A 5V analog signal will produce a pulse that lasts the entire two milliseconds; if the signal is sustained, your robot will eventually reach top speed. A 2.5V analog signal will produce a 1 millisecond long pulse, which puts the robot at half-speed. A 0V signal doesn’t produce any pulse at all, so the robot will decelerate to a halt. Unlike a light switch, your robot’s motors cannot instantly change speeds. They need time to accelerate or decelerate to the desired pace. Keep this in mind while programming your Arduino’s PWM. Appendix E shows the difference between PWMs and analog implementation in Arduino code. 8 Conclusion We hope this guide was a useful introduction to Sumobots. Below you’ll find the appendix, where we put most of our charts, diagrams, and extra pieces of information. If you have any questions this guide couldn’t answer, just talk to your mentors or send an email to Vinay Yuvashankar at yuvashv@mcmaster.ca. Good Luck! 14
  • 15. A Arduino Anatomy This picture, with all its parts and pins, might seem complicated to someone who’s never used a microcontroller before. Don’t worry — it’s not as hard as it looks. And to prove it, we made a chart for easy reference! Parts are listed clockwise from “External Power Supply” to “Reset Pin.” Figure 3: The Arduino 15
  • 16. Port Function External power supply Plug for the battery that powers the Arduino and sensors. Use a separate power supply for the motors. Analog reference pin You probably won’t use this pin. Provides a reference voltage for Analog inputs. Default is 5 V, but can be changed. Digital ground Ground wires for digital inputs and all outputs must terminate here. Digital I/O pins Digital inputs and all outputs are connected here. 12 pins available for digital inputs and outputs, numbered 2-13. Serial out (TX) Uses serial communication to send data to a computer or other device Serial in (RX) Uses serial communication to receive data from said device Reset button Erases all programming embedded on the Ar- duino. Don’t push it by accident! In-circuit serial programmer You probably won’t use this pin. Allows you to burn sketches onto the Arduino board through an external programmer instead of the boot- loader (which loads the OS). ATMega328 microcontroller This is the processor. Contains 32 KB of mem- ory. Analog in pins Connection point for sensors that take Analog readings. 6 pins are available for Analog in- puts. Voltage in You probably won’t use this pin. An alterna- tive to the Arduino’s external power supply. Ground pins Connection point for ground wires from Analog inputs. There are two ports. It doesn’t matter which one you use. 5 Volt power pin This pin has 5 V (relative to the ground). Sen- sors and motors that require 5 V or Vcc should be wired to this pin. 3.3 Volt power pin This pin has 3.3 V (relative to the ground). Sensors and motors that require 3.3 V or Vcc should be wired to this pin. Reset pin Will reset the Arduino if it receives a positive voltage 16
  • 17. B The CAD Checklist • Ensure design is within competition constraints • Ensure that all sensors have been considered (IR and Distance) – Ensure that all sensors can be wired – Ensure that sensors are able to see the environment • Ensure that Arduinos and supporting wires are in a secure place • Ensure that Batteries are at an easily accessible place – Ensure that all components (Sensors, Actuators and Arduinos) can be powered from the battery • Ensure Motors are at the correct place – Ensure that motors can touch the ground and move the robot 17
  • 18. C Hooking Up Sensors and H-Bridges Figure 4: The Arduino http://bildr.org/2011/03/various-proximity-sensors-arduino/ has a great tutorial on hooking up sensors to the arduino. 18
  • 19. D Sample SumoBot Code // Declare pins f o r the right motor . const int motor pin1 = 5; const int motor pin2 = 6; // Declare pins f o r the l e f t motor . const int motor pin3 = 10; const int motor pin4 = 11; // Declare pins f o r p h o t o r e s i s t o r s and the IR sensor . const int IRSens = 0; const int PHOTO1 = 1; const int PHOTO2 = 2; const int PHOTO3 = 3; const int PHOTO4 = 4; // Declare p h o t o r e s i s t o r s cut−o f f values f o r black−white detection . // This i s what you came up with a f t e r t e s t i n g : int InitVal1 = 120; int InitVal2 = 50; int InitVal3 = 270; int InitVal4 = 190; // Step 2: Set up your ports void setup () { // Data t r a v e l s through the s e r i a l data stream at the 9600 band . S e r i a l . begin (9600); // Set up motor pins . pinMode ( motor pin1 , OUTPUT) ; . // Set up sensor pins . pinMode (PHOTO1, INPUT) ; . . . } // Step 3: Writing functions // Helpful as these examples may be , // y o u l l probably have to write other functions on your own . // This next function i s a debugging tool that // prints sensor readings f o r your own sake . //The Arduino d o e s n t actually use checkSens () to check the sensors . 19
  • 20. void checkSens () { S e r i a l . print (” Distance : ” ) ; S e r i a l . print ( analogRead ( 0 ) ) ; S e r i a l . print (” tPhoto 1: ” ) ; S e r i a l . print ( analogRead (PHOTO1) ) ; S e r i a l . print (” tPhoto 2: ” ) ; S e r i a l . print ( analogRead (PHOTO2) ) ; S e r i a l . print (” tPhoto 3: ” ) ; S e r i a l . print ( analogRead (PHOTO3) ) ; S e r i a l . print (” tPhoto 4: ” ) ; S e r i a l . println ( analogRead (PHOTO4) ) ; } // This function t e l l s the motors to move forward : void forward () { analogWrite ( motor pin1 , 0 ) ; analogWrite ( motor pin2 , 1 5 0 ) ; analogWrite ( motor pin3 , 1 5 0 ) ; analogWrite ( motor pin4 , 0 ) ; } // This function stops a l l motors : void halt () { AnalogWrite ( motor pin1 , 0 ) ; AnalogWrite ( motor pin2 , 0 ) ; AnalogWrite ( motor pin3 , 0 ) ; AnalogWrite ( motor pin4 , 0 ) ; } // Step 4: The main code //Your main code w i l l be much longer than the provided example , //but i t should give you an idea of where to s t a r t : void loop () { checkSens ( ) ; //Get readings from the sensors that can be stored as v a r i a b l e s . unsigned int read1 = analogRead (PHOTO1) ; unsigned int read2 = analogRead (PHOTO2) ; unsigned int read3 = analogRead (PHOTO3) ; unsigned int read4 = analogRead (PHOTO4) ; unsigned int thing = analogRead ( IRSens ) ; // Decision−making code : i f ( ( read1 > InitVal1 ) && ( read2 > InitVal2 )) { // I f both front sensors detect white : halt ( ) ; } 20
  • 21. e l s e { forward ;} } Put together , the code looks l i k e t h i s : // Declare pins f o r the right motor . const int motor pin1 = 5; const int motor pin2 = 6; // Declare pins f o r l e f t motor const int motor pin3 = 10; const int motor pin4 = 11; // Declare pins f o r p h o t o r e s i s t o r s and the IR sensor . const int IRSens = 0; const int PHOTO1 = 1; const int PHOTO2 = 2; const int PHOTO3 = 3; const int PHOTO4 = 4; // Declare p h o t o r e s i s t o r s cut−o f f values f o r black−white detection . // This i s what you came up with a f t e r t e s t i n g : int InitVal1 = 120; int InitVal2 = 50; int InitVal3 = 270; int InitVal4 = 190; //Get readings from the sensors that can be stored as v a r i a b l e s : unsigned int read1 ; unsigned int read2 ; unsigned int read3 ; unsigned int read4 ; unsigned int thing ; void setup () { // Data t r a v e l s through the s e r i a l data stream at the 9600 band . S e r i a l . begin (9600); // Set up motor pins . pinMode ( motor pin1 , OUTPUT) ; . // Set up sensor pins . pinMode (PHOTO1, INPUT) ; . . . 21
  • 22. } // Tells you what the sensors see . // D o e s n t make the Arduino check the sensors . void checkSens () { S e r i a l . print (” Distance : ” ) ; S e r i a l . print ( analogRead ( 0 ) ) ; S e r i a l . print (” tPhoto 1: ” ) ; S e r i a l . print ( analogRead (PHOTO1) ) ; S e r i a l . print (” tPhoto 2: ” ) ; S e r i a l . print ( analogRead (PHOTO2) ) ; S e r i a l . print (” tPhoto 3: ” ) ; S e r i a l . print ( analogRead (PHOTO3) ) ; S e r i a l . print (” tPhoto 4: ” ) ; S e r i a l . println ( analogRead (PHOTO4) ) ; } // Tells the motors to move forward : void forward () { analogWrite ( motor pin1 , 0 ) ; analogWrite ( motor pin2 , 1 5 0 ) ; analogWrite ( motor pin3 , 1 5 0 ) ; analogWrite ( motor pin4 , 0 ) ; } // Stops a l l motors : void halt () { AnalogWrite ( motor pin1 , 0 ) ; AnalogWrite ( motor pin2 , 0 ) ; AnalogWrite ( motor pin3 , 0 ) ; AnalogWrite ( motor pin4 , 0 ) ; } void loop () { checkSens ( ) ; //Get readings from the sensors that can be stored as v a r i a b l e s : read1 = analogRead (PHOTO1) ; read2 = analogRead (PHOTO2) ; read3 = analogRead (PHOTO3) ; read4 = analogRead (PHOTO4) ; thing = analogRead ( IRSens ) ; // Decision−making code : i f ( ( read1 > InitVal1 ) && ( read2 > InitVal2 )) { // I f both front sensors detect white : halt ( ) ; } 22
  • 23. e l s e { forward ;} } 23
  • 24. E PMWs in Arduinos PWM signals make coding much easier. With PWM, you don’t have to worry about remapping input values to match output values. PWM signals are represented in 8 bits, so values range between 0 and 255, with 0 representing 0V and 255 representing 5V. The code needed to read and write digital signals is similar to the code needed for analog signals; the only difference is the syntax, which is described below: E.1 Analog // First , map the pins . const int analogInPin = A0; // Analog input const int analogOutPin = 9; // Analog output // Define other v a r i a b l e s : int InputValue = 0; int OutputValue = 0; void setup () { S e r i a l . begin (9600); } void loop () { // Tell i t how to read the analog input value : ImputValue = analogRead ( analogInPin ) ; // Do a l l necessary c a l c u l a t i o n s and r e s c a l e // the values so they f a l l between 0 and 255. OutputValue = map( InputValue , 0 , 1023 , 0 , 255); // Change the analog output value . analogWrite ( analogOutPin , OutputValue ) ; } E.2 PWM // First , map the pins . cons t i n t digitalInputPin = 10; // D i g i t a l Input const int digitalOutPin = 9; // D i g i t a l Output // Define other v a r i a b l e s : int InputValue = 0; int OutputValue = 0; 24
  • 25. void setup () { S e r i a l . begin (9600); pinMode ( digitalInputPin , OUTPUT) ; pinMode ( digitalOutputPin , INPUT) ; } void loop () { // Tell i t how to read the d i g i t a l input value : InputValue = digitalRead ( digitalInputPin ) ; // It isn ’ t necessary to r e s c a l e d i g i t a l values , // because they already f a l l between 0 and // 255. OutputValue = map( InputValue , 0 , 255 , 0 , 255); // Output the necessary d i g i t a l value . digitalWrite ( digitalOutputPin , OutputValue ) } 25