Você está na página 1de 34

Microcontrollers

TOBIAS P. TUMBUAN
Nowadays
It is on your
Washing machine
Microwave
Mobile phone
ECU, etc.
Content
Microcontroller and microprocessor, Ch 1
Microcontroller Components, Ch 2
Processor
Memory
Digital I/O
Analog I/O

Programing Arduino

BOOK FOR ARDUINO


Microcontroller and
microprocessor

Arduino Microcontroller
Subject on microcontroller
The subject of microcontroller can be viewed from some perspective:
Hardware > Electrical engineering Function and how to use it

Flip-flop synchronous counter circuit

Application (Arduino) > Practicum


Microcontroller - Hardware
Sources: Schuler and McNamee, Industrial Electronics and Robotics, 1986
Characteristic of digital circuit, Ch. 11
Latches and flip-flops
Counter and register
Multiplexer and decoder
Memory
Microprocessor, Ch. 12
Addressing
Instruction set
Subroutines and interrupts Assembly language
System design
Support
Data Conversion, communication and storage, Ch. 13
DAC
ADC
Communication standard
Disk and tape storage
Microcontroller
It consists of:
Processor core
arithmetic logic unit, control unit and register
Memory
Program memory
Data memory
Interrupt controller
Useful to interrupting the normal program flow in case of important events.
Timer/counter
2 3 timer / counter. Useful to timestamp events and count the event.
Digital and analog IO
Interface
At least 1 serial interface for download the program and communicating with PC in general
Watchdog time
Reset the controller in case of crashes
Debugging unit
Processor core
ALU
o Performing computation
o Status register
o Zero : the result of operation is zero
Boolean o Negative: The result is negative
algebra o Overflow:
overflow
the operation produced an

o Carry: The operation produced a carry


o It different within processor

Register file
Accumulator arithmetic / logic
Index register addressing mode
Stack pointer
Storing address and possibly register
content during subroutine or
interrupt.
Processor core 2.
Control unit
Determine which operation should be
executed next and configure the data path
accordingly (Instruction register)
Instruction
CISC (Complex Instruction Set Computer)
RISC (Reduced Instruction Set Computer)
Architecture
Von Neuman: Program and data are stored together and accessed through the same bus. It may
generate conflict

Harvard Architecture: data and program are in separate memories and separate bus. It requires
more hardware.
Launchpad vs Arduino
Memory
Memory Types:
Register file scratch pad (small size), internal
Data memory large, external
Instruction memory large external
Memory - FYI
Memory
Volatile > Needs power to retain (hold) the data
Parameter SRAM DRAM
Method Flip-Flop Capacitor
Hardware 6 transistor 1 transistor + 1 capacitor
Chip size (=storage) Large Small

Non volatile > Needs no power to retain the data


Parameter ROM PROM EPROM EEPROM EEPROM -
flash
Data generation From By user
manufacture By user By user By user
Dies fuse
Erasable
Method of
N/A N/A By UV Electrically Electrically
erasing
Erasing byte N/A N/A N/A Byte by byte Bulk data
Picture

ROM on BIOS EEPROM


(Computer Motherboard)

EPROM

EEPROM flash memory


Digital IO
Pins can be input only, output only, or bidirectional (Typical)
Its based on Data Direction Register (DDR)
Digital Input
Sampling process is based on system clock.

To reduce the effect of undefined voltage, apply Schmidt trigger.

V > Vhi Stateout = True


V < Vlo Stateout = False

It will not change in


undefined area.
Digital Input
Noise cancellation: The controller samples the pin for k times. The
state will be change if all k samples were equal.
To diminish problem due to floating input (the pin out is connect to
nothing), apply pull up resistor. It can be enabled.

Pull up resistor

Pin 13 is hard to be an internal input. It has a resistor and LED. Enabling the
pull up resistor will generate error. Please read:
https://www.arduino.cc/en/Tutorial/DigitalPins
Digital Output
Current sink and current source is up to 20 mA.
Give an attention to short circuit possibility.
Set the value before setting the pin. So that it has no possibility to
have floating output. Please ensure the problem may be risen due to
the existence of pull up resistor.

Direct Load Gain some current from transistor


Digital output
Arduino 5V
Line

1N4004

Arduino output
2N2222L L
1k O O
Arduino GND A A
D D

Line GND
Driving a relay, dont forget to put the fly wheel diode.
Digital Output

LOAD

Driving an optoisolator
Analog Input ADC
Comparator
Analog Input ADC
Successive Approximation
Analog input

DIGITAL SYSTEM

Quantization

Discretization
Analog input
Analog Output DAC
Summing Amplifier
Analog Output DAC
R2R Ladder
PWM Output
PWM Output
top: top value frequency of PWM
cmp: compare value duty cycle

To remove glitch, controller must hold the


value until zero is reach before update the
CMP
Vout
PWM Output


=
Typical:
R = 3.9K
C = 0.1uF
PWM Output
PWM Output H bridge
Advanced topic
Interrupt, counter and timer
(Its OK as long as you can employ it.)
Communication interfaces
(For mechatronics student, I suggest to understand (at least read) this
topic.)
The Arduino
Studying Arduino
To start studying Arduino, the following book might be very helpful.
http://www.me.umn.edu/courses/me2011/arduino/arduinoGuide.pdf
A more comprehensive (if not difficult) project might be seen on
http://www.maerivoet.org/website/software/arduino/manuals/arduino
/arduino-cookbook.pdf
If you do not understand the function, you may see the hand book
provided by Arduino.
https://playground.arduino.cc/uploads/Main/arduino_notebook_v1-
1.pdf
For PID freak
http://blog.solutions-cubed.com/pid-motor-control-with-an-arduino/

Você também pode gostar