Introduction To Microcontrollers: Jerry Spring VE6TL
Introduction To Microcontrollers: Jerry Spring VE6TL
Jerry Spring VE6TL
Outline
• Introduction ‐ History
• Microcontroller vs Microprocessor
• What are the choices?
• What can I do with a microcontroller?
• What do I need to buy?
• What do I need to learn?
• Ham radio projects
But first… a little digital humour
Why do electronic engineers
always confuse Halloween
and Christmas?
Because 31 Oct = 25 Dec
Homebrewing – A Bit of History
Many
homemade
parts
High
Voltage
Big
1940s – 50s
Kit Building– 1960s
No
homemade
parts
Low Voltage
Smaller
Tinkering – 1970s
Computers
All the rage
Mini to
Micro
IC Technology
The Boolean Age – 1980s
Everything
Digital
New Chip
technologies
Architecture ‐
using discreet
components
Homebrewing – 1990s – 2000s
Old and New
technologies
Big and
Small
components
Is this the
way to
attract new
hams to the
hobby?
Post 2002 ‐ Microcontrollers
Emphasis on
creativity
Programming
skills
essential
No soldering
– plug and
play
Attracting
wider
audience
2010 – Arduino – Starter Kit
Emphasis on
ease of use
Internet user
groups and
tutorials
Numerous
“shields”
IoT
A step back…
Why Should I Care about MCUs?
These things are
EVERYWHERE!
*Courtesy of Atmel Corp.
Impact of IoT
“The market for MCUs used in connected cars, wearable electronics,
building automation and other IoT applications is expected to grow at an
overall compound annual growth rate (CAGR) of 11 percent, from $1.7
billion in 2014 to $2.8 billion in 2019.” ‐ IHS
Microprocessor vs Microcontroller
Microprocessor Microcontroller
• Multipurpose • Single Purpose
• Connects to external circuits such as • Internal memory
memory, graphics, i/o ports, etc. on mother • Non‐volatile memory (permanent once
board written)
• Has O/S (Windows, Linux, etc.) • Built‐in peripherals
• Volatile memory (reboot when power lost) • Come in different sizes
• Requires PS, Keyboard, Mouse, Display, etc. • Usually does not have O/S
Microcontroller Peripherals
Four Main Types – Built‐in
1. TIMERS
• Counters
• Real Time
• Pulse Width Modulation (PWM)
2. ANALOGUE
• A/D Converter
3. Digital
• I/O Ports
• LCD Control
4. Communications
• Serial (RS‐232)
• USB
• Ethernet
• I2C
• Others
What are the choices?
• TinyAVR
• PIC‐EL III
• PICAXE
• Basic Stamp
• Texas Instruments MSP430
• ARDUINO
• ESP8266
• Many more
Tiny AVR Microcontroller
First Project: Two Switches to toggle two LEDs
PIC‐EL III BOARD
PICAXE Starter Pack ‐ $60
Basic Stamp ‐ $49
• First released in 1992
• Programmed in PBASIC
• Available add‐on “carrier boards”
• 20 MHz Clock = 4,000 PBASIC Instructions/sec
• EEPROM 2 KB (~500 PBASIC Instructions)
• I/O Pins: 16 + 2 dedicated serial
• Current Draw (5 VDC): 3mA Run, 50 uA Sleep
• Source/Sink Current per I/O: 20 mA/25mA
• PBASIC Commands: 42
• Package: 24‐pin DIP
• Dimensions: 1.2” X 0.63” X 0.15”
• Made by Parallax Inc. (California)
• Get Started Kit: $79.99
Texas Instruments Launchpad MSP430
Raspberry Pi
Arduino
What are the Main Differences?
$55 Shipped Free to Canada
Arduino – Sensors Galore!
$55 Shipped Free to Canada
Arduino – The Collection
Tutorial 5
Tutorial 8
Arduino – Online Tutorials
Topics
• Getting Started
• Turning LEDs on/off with pushbuttons
• Analogue Inputs
• Motors and Transistors
• Serial Communication and Processing
• I2C and Processing
• SPI Interfaces
• Wireless Communication
• Interrupts and Hardware
• SD Cards and Data Logging
• RFID Cards
• Liquid Crystal Displays (LCD)
• Lasers
• Robotics
Arduino – First Projects
Arduino – Sample Program
//Turning on LED when switch closed
int switch; // Declares switch an integer variable
void setup() // Required for each program
{
pinMode(10, OUTPUT); // Set pin 10 to output for LED
pinMode(11, INPUT); // Set pin 11 to input to read switch
digitalWrite(11,HIGH); // Turn on internal pull up resistor
}
void loop() // Repeat what is inside loop
{
switch = digitalRead(11); // Store the value of the switch (high or low)
if(switch == 0)
digitalWrite(10,HIGH); //turn on LED // If the switch is pressed (Low=0), LED on
else
digitalWrite(10,LOW); //turn LED off // Otherwise, turn the switch off
} // End of loop()
Arduino – HF Antenna Switch
Reads band data from rig and automatically selects antenna – KC8GRQ
Arduino Rotator Controller for EME – G4HSK
• Yaesu G‐5500 rotator with elevation and azimuth control
• Interface includes Arduino Uno, switching board, LCD
interface, 2X20 LCD module, PstRotator Software
Homebrew Switching Board All modules wired together
Arduino – Radio Artisan K3NG
Website dedicated to Ham Radio Arduino projects
Current Projects:
• Arduino controlled beacon
• CW Keyer
• Rotator controller
• Antenna tuner
• Downloadable sketches
• Diagrams and photos
• Discussion forums
• Resource links
Arduino – QRP Transceiver! M0XPD
Arduino – Ham Radio Reference
Arduino – The Future
ESP8266MOD (NodeMCU)
Arduino and WiFi on a chip for about $10 CDN
Faster, Smaller, Cheaper, More storage, More accurate
32‐bit RISC CPU: Tensilica Xtensa LX106 running at 80 MHz*
64 KB of instruction RAM, 96 KB of data RAM
External QSPI flash ‐ 512 KB to 4 MB* (up to 16 MB is supported)
IEEE 802.11 b/g/n Wi‐Fi
Integrated TR switch, balun, LNA, power amplifier and matching network
WEP or WPA/WPA2 authentication, or open networks
16 GPIO pins
SPI, I²C,
I²S interfaces with DMA (sharing pins with GPIO)
UART on dedicated pins, plus a transmit‐only UART can be enabled on GPIO2
1 10‐bit ADC
* Both the CPU and flash clock speeds can be doubled by overclocking on some
devices. CPU can be run at 160 MHz and flash can be sped up from 40 MHz to
80 MHz. Success varies chip to chip.
Ham Radio ‐ Projects
Projects:
• APRS Data Logger
• QRSS Beacon
• Multimode Transmitter Shield
• High Voltage, High Frequency, and High Temperature Data Logger
• Receive‐Only, Low‐Power APRS iGate
• PICAXE Keyer and CW Beacon Keyer
• Solar Tracker
• Nanokeyer
• Handheld Radio Talk Timer
• APRS Messenger
• DTMF Controlled SSTV Camera
• APRS Display
• Waterfall
• SWR Scanner
…and more projects using the Arduino, PICAXE, and ATtiny
microcontrollers
Recommended Reading
Shunt‐fed Tower Project
John True, W4OQ – May 1975 Ham Radio Magazine
Shunt‐fed Tower Project – Tower Unit Schematic
Shunt‐fed Tower Project – Tower Unit Device
Reset
5V – 3V Reg
Stepper Motor
Controller
nRF24L01 XCVR
328P MCU 16MHz XTAL
Shunt‐fed Tower Project – Shack Unit Schematic
Shunt‐fed Tower Project – Shack Unit Device
Shunt‐fed Tower Project – Final Configuration
The Rebel by TenTec ‐ Arduino‐based QRP Transceiver
Summary
• Microcontrollers such as the Arduino are leading a revolution in
new applications, including amateur radio
• Microcontrollers are inexpensive, safe to use (no high voltages),
and ubiquitous
• Other inexpensive hardware, such as the Raspberry Pi, Beaglebone
Black, etc. provide complementary platforms that can lead to new
technologies – Examples include prosthetic limbs, robotics, quad
copters, high altitude balloon measurements, home brew
satellites, etc.
• The technology continues to evolve by getting smaller, faster,
lighter, smarter, and using less energy.