












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A microcontroller is a one-chip computer. In a single package, it has the computing core and memory (or various types) needed to store and run small programs.
Typology: Study notes
1 / 20
This page cannot be seen from the preview
Don't miss anything!













A microcontroller is a one-chip computer. In a single package, it has the
computing core and memory (or various types) needed to store and run
small programs. There will be connections for power (obviously) and a
serial communications channel for moving program information onto
the controller and receiving information from the program.
In addition a microcontroller has a number of other input and output
connections.
voltage on the input is “high” or “low”, which correspond to logic
level 1 and logic level 0. The low voltage is usually 0 V and the high
either 3.3 V or 5 V, depending on the particular controller.
either a high or low voltage to activate (or de-activate) components
attached to the output.
attached to the input. The voltage must be between 0 and 5 V,
typically.
Other connections
external component. (Not all controllers have these.)
signal where the ratio of the high time to the low time can be varied.
PWM is usually produced by digital output pin. PWM can be used
as a “fake” analog output for controllers that do not have real analog
outputs.
Many of the pins are multi-purpose and can configured to do different
jobs. For example, a digital pin can be configured to be either an input
or an output. The analog output pins can be set up to work in a digital
fashion if needed.
These various input / output connections provide an interface between
the digital core and the outside world, allowing for measurement of
external effects and allowing for the microcontroller to make changes in
response to external stimuli.
A key concept in beginning to design and use micro controllers in
embedded systems is understanding the difference between analog and
digital signals.
Analog - a continuously varying energy or quantity of material. Much of
how we interact with the surrounding physical world is analog in nature
quantities to analog voltages or currents. (Microphones, photosensors,
temperature sensors, etc.) Just like the physical quantity, the voltage or
current is defined at every point in time. Detecting an analog voltage or
current requires requires precisely measuring the volts or amps at a
particular time. A reasonable example of an signal is a sine wave.
(Although there isn’t much information in a pure sine wave.)
Digital - The signal is either high or low (on/off or true/false or 0 /1).
There are not many digital signals in the physical world. However, in
terms of encoding information into signals, digital is much more robust.
There is more leeway in interpreting whether a voltage is high or low.
“High” means simply being “high enough” — above some threshold
level. “Low” means simply being “low enough” — below some
threshold level. Interpreting the information from a digital signal is less
susceptible to errors because the voltages don’t have to be known
precisely.
The systems that we have developed to collect information work best by
collecting the analog information from the surrounding physical
environment, converting it digital form, processing the information
digitally, and then converting back to analog (if needed).
controller was the PIC1650 in 1976. (The company at that time was
General Instruments. Microchip was spun out as a separate company
in the late 1980s.) PIC originally stood for Peripheral Instrumentation
Controller. Microchip sells more than 1 billion microcontrollers per
year.
microcontroller market. Their major product line is the AVR family of
controllers. Earlier this year Atmel was bought by Microchip.
engineer Jack Kilby was one of the co-inventors of the integrated
circuit. The MSP430 is one of their primary microcontroller products.
ARM is separate microcontroller architecture owned by ARM Holdings
(from Great Britain) that is licensed by many companies. It is used in all
smartphones and finds increasing use elsewhere.
There are literally hundreds of microcontrollers available from the
various companies. The differ on the number of bits (8, 16, 32, 64),
memory (a few kilobytes to 1 gigabyte), clock speed (10s of kilohertz to
1 gigahertz), price (a few cents to 10s of dollars) and the number of
inputs and outputs (3 or 4 up to 100 or more).
Start with 1 example - the Atmega328 from Atmel. (This is what is in the
most popular Arduino.)
What used to be needed to get started? (In the “old” days.)
power supply, a clock oscillator crystal, a serial communications
connection, and physical connections for all of the digital and analog
pins. Typically, this is provided by a prototyping platform available
from the microcontroller supplier. Of course, developers can also
build their own prototype hardware, but this is usually not an
effective use of resources.
controller must be written on a regular computer (Windows/MacOS/
Linux) and then transferred to the controller. Typically, the IDE is not
particularly user friendly — some prior software experience is
probably needed. Also, a special hardware dongle (a programmer) is
needed for the transfer.
Upshot: Developing embedded systems is only for “professionals”.
Hobbyists or “makers” need not apply.
In 2005, a group at the Interactive Design Institute Ivrea in Ivrea, Italy
put together a hardware / software platform that would make it much
easier to build embedded systems prototypes. (The titular leader of the
group was — and still is — Massimo Banzi, although there were four
other founders.) They named the platform Arduino , after a bar that they
frequented. They were focusing on making a system on which students
and hobbyists could learn easily and would affordable to non-
professionals. Their efforts unleashed the current “maker” movement.
There have been several iterations on the basic platform over the years.
The current standard hardware arrangement is the Arduino Uno.
Ethernet WiFi Bluetooth
Touch display Motor
Windows / Mac / Linux).
us!) There some special commands for defining the operation of I/O
and for receiving/sending information to those pins.
on the computer to the controller. (No hardware dongle!) The USB
interface also conveniently provides power when connected to a
computer.
and receiving information from the controller. (serial monitor)
not intended to be tethered to the host computer indefinitely. But
when developing the software, it is important to be able to “see” what
is happening with the program.
An Arduino program (sketch) is slightly different from our typical C
program. In a microcontroller, there is no main function. Instead there
are two separate functions — one called setup() and a second called
loop() runs in a continuous loop.
flow starts at the top and progresses through to the last line. (If there
are any loops, they behave according to the conditionals like we
would expect.) As the name implies, the purpose of setup is to define
variables, set the function of the pins, and take care of any
preliminary housekeeping. When setup() is complete, program flow
passes to loop().
through to the last line. But, as the name implies, the program goes
back to the first line of loop and runs again. And again and again.
Forever. (Or until the power is removed.) It is as there is an implied
while loop whose conditional is always true.
Once you have downloaded the Arduino software and installed it*.
When you launch it, you will get a blank, generic program. The setup
and loop functions are empty.
*MacOS does not have Java installed by default. When you try to run
the Arduino IDE for the first time, you will be asked if you want install
Java. Follow the instructions to do so.
There are many example programs that you can use to help in learning
the various commands. The simplest is a program called “Blink” that
will make one of the light-emitting diodes on the board blink on and off.
Choose it from the menu.
Note: A bunch of
comments at the top of
the program have been
removed to save space.
Inside setup(): The pin
mode command defines
the pin connected to the
built-in LED (also known
as pin 13) to be a digital
output.
Inside loop(): The first command sets the voltage of the LED pin to the
high value (5V), turning on the LED. The second command is a 1 s
(1000 ms) delay. (Basically, do nothing for 1 second.) The third
command sets the voltage of the LED to the LOW value (0 V), turning
off the LED. Then there is another 1000 ms delay. Then everything
repeats — the LED will repeatedly blink on and off.