Faculty Of Engineering
Mechanical Engineering
ME 425
Microcontroller Structure
Dr. Laith Sawaqed
UNDERGRADUATE PROGRAM
Fall Semester
2016
What is a Microcontroller?
www.mikroe.com/chapters/view/1
A small computer on a single chip
containing a processor, memory, and input/output
Typically "embedded" inside some device that they control
A microcontroller is often small and low cost.
Faculty Of Engineering 2
Mechanical Engineering
Microcontroller Internal Structure
http://www.electronicshub.org/pic-microcontroller-architecture/
Faculty Of Engineering 3
Mechanical Engineering
What is a Microcontroller?
Faculty Of Engineering 4
Mechanical Engineering
What is a Development Board?
A printed circuit board designed
to facilitate work with a particular
microcontroller.
Typical components include:
power circuit
programming interface
basic input; usually buttons and LEDs
I/O pins
Faculty Of Engineering 5
Mechanical Engineering
Why Arduino?
Easy to use platform
Ease of programming
Simple USB interface
Modifiable IDE
Many shields available
Faculty Of Engineering 6
Mechanical Engineering
The Many Flavors of Arduino:
Many Flavors of Arduino
Arduino Uno
Arduino Leonardo
Arduino LilyPad
Arduino Mega
Arduino Nano
Arduino Mini
Arduino Mini Pro
Arduino BT
Faculty Of Engineering 7
Mechanical Engineering
Arduino-like Systems:
Cortino (ARM)
Xduino (ARM)
LeafLabs Maple (ARM)
BeagleBoard (Linux)
Wiring Board (Arduino predecessor)
ChipKit Uno32/Max32
Faculty Of Engineering 8
Mechanical Engineering
Arduino Add-ons (Shields):
TFT Touch Screen
Data logger
Motor/Servo shield
Ethernet shield
Audio wave shield
Cellular/GSM shield
WiFi shield
Proto-shield
...many more
Faculty Of Engineering 9
Mechanical Engineering
Components of the Arduino:
ATMega168/328
16MHz crystal/filtering
capacitors
Onboard power
regulators
FTDI USB <-> Serial
Chip
Hardware
Faculty Of Engineering 10
Mechanical Engineering
Where to Get an Arduino
Board:
Purchase from online
vendor (available
worldwide)
Sparkfun
Adafruit
DFRobot
... or build your own
PC board
Solderless breadboard http://itp.nyu.edu/physcomp/Tutorials/ArduinoBreadboard
Faculty Of Engineering 11
Mechanical Engineering
Schematic
Faculty Of Engineering 12
Mechanical Engineering
Necessary parts for any circuit
ATMega168/328
The brain of the
Arduino
Program is loaded onto
the chip
Runs main loop until
power is removed
Thats it! All other parts
are optional!
Faculty Of Engineering 13
Mechanical Engineering
Optional parts: Timing
16Mhz Crystal
The heartbeat of the
ATMega chip
Speed of crystal
determines chip speed
Possible to
over/underclock
depending on application
ATMega series has
onboard oscillator; less
precise
Faculty Of Engineering 14
Mechanical Engineering
Power Supply
5 Volt and 3.3 Volt
Regulators
Filtering capacitors
Automatic switching
between external and
USB Power
Leave it out if you have
a filtered 5 Volt power
supply
Faculty Of Engineering 15
Mechanical Engineering
FTDI USB Chip
Allows your Arduino to
communicate with your
computer over a simple
USB link
Abstraction
Only necessary for
communicating with
USB
Faculty Of Engineering 16
Mechanical Engineering
Hardware
Circuit Board
Headers
USB port
Sockets
All optional, use them
if you need them
Faculty Of Engineering 17
Mechanical Engineering
The Arduino Development Board
Input voltage: 7-12 V (USB, DC plug, or Vin)
Max output current per pin: 40 mA
Faculty Of Engineering 18
Mechanical Engineering
The Arduino Microcontroller:
Atmel ARV Atmega 328
Faculty Of Engineering 19
Mechanical Engineering
How to work with Arduino?
Faculty Of Engineering 20 www.todbot.com/blog/bionicarduino
Mechanical Engineering
Two methods of using the
Arduino
Working with the Prototyping with the
Arduino to solve a Arduino to solve a need
problem Preparing a product for
Temporary solution market
One time only Mass production
Faculty Of Engineering 21
Mechanical Engineering
Phases of Circuit Design
Arduino Approach Stand-alone approach
Idea Idea
Sketch Sketch
Read datasheets Read datasheets
Gather materials Gather materials
Prototype Prototype
Testing Testing
Optional ----------------> Refining
Testing
Release to manufacture
Faculty Of Engineering 22
Mechanical Engineering
Getting Started
Check out: http://arduino.cc/en/Guide/HomePage
1. Download & install the Arduino environment (Integrated
Development Environment = IDE)
2. Connect the board to your computer via the UBS cable
3. If needed, install the drivers (not needed in lab)
4. Launch the Arduino IDE
5. Select your board
6. Select your serial port
7. Open the blink example
8. Upload the program
Faculty Of Engineering 23
Mechanical Engineering
Try It: Connect the USB Cable
www.todbot.com/blog/bionicarduino
Faculty Of Engineering 24
Mechanical Engineering
Elements of the Arduino IDE:
Text editor
syntax and keyword
Coloring
Automatic indentation
Programming shortcuts
Compiler
Hardware Interface
Uploading programs
Communicating with
Arduino via USB
See: http://arduino.cc/en/Guide/Environment for more information
Faculty Of Engineering 25
Mechanical Engineering
Elements of the Arduino IDE:
Text editor
syntax and keyword
Coloring
Automatic indentation
Programming shortcuts
Compiler
Hardware Interface
Uploading programs
Communicating with
Arduino via USB
See: http://arduino.cc/en/Guide/Environment for more information
Faculty Of Engineering 26
Mechanical Engineering
Select Serial Port and Board:
Faculty Of Engineering 27
Mechanical Engineering
Status Messages:
www.todbot.com/blog/bionicarduino
Faculty Of Engineering 28
Mechanical Engineering
Using the Arduino IDE:
Faculty Of Engineering 29
Mechanical Engineering
Arduino Reference:
Faculty Of Engineering 30
Mechanical Engineering
Arduino Sketch Structure:
Faculty Of Engineering 31
Mechanical Engineering
Uploading and Running the
Blink Sketch:
Compile, then upload the program
Congratulations! you are now blinkers!
Faculty Of Engineering 32
Mechanical Engineering
www.todbot.com/blog/bionicarduino
Faculty Of Engineering 33
Mechanical Engineering
Creating and Saving a Sketch:
Now connect your own LED
http://www.wikipedia.org/ Notes:
Resistor is needed to limit current
Resistor and LED may be interchanged (but
polarity of LED is important)
Pin 13 is special: has built-in resistor and LED
Change program and upload
Faculty Of Engineering 34
Mechanical Engineering
Creating and Saving a Sketch:
Using the Breadboard
Faculty Of Engineering 35
Mechanical Engineering
Creating and Saving a Sketch:
Now connect your own LED
Faculty Of Engineering 36
Mechanical Engineering
Assignment # 2:
Change the blink rate
how fast can the LED blink (before you can no
longer perceive the blinking?)
How would you make the LED dimmer?
(...without changing the resistor?)
Faculty Of Engineering 37
Mechanical Engineering