1 / 51

Microcontrollers

Microcontrollers. by Andy Zwirko – K1RA Tom Zeltwanger – KG3V Eric Nystrom – W4EON. Overview. What are microcontrollers? Microcontrollers vs. microprocessors Where are microcontrollers used? Popular microcontrollers & vendors Programming microcontrollers

garnet
Télécharger la présentation

Microcontrollers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microcontrollers by Andy Zwirko – K1RA Tom Zeltwanger – KG3V Eric Nystrom – W4EON

  2. Overview • What are microcontrollers? • Microcontrollers vs. microprocessors • Where are microcontrollers used? • Popular microcontrollers & vendors • Programming microcontrollers • Microcontroller projects (Eric, Tom, Andy)

  3. What is a Microcontroller? • An embedded, low power (uW/nW) computer that usually runs a dedicated task • An interrupt driven device providing real time, predictable responses to events • A self contained device with no external address and data buses

  4. What is a Microcontroller? • A microcontroller (µC, uC or MCU) is a single integrated circuit that contains the four major parts of every computer system • A device optimized for control applications

  5. What is in a Microcontroller? • All computers have a CPU (central processing unit) that executes programs

  6. What is in a Microcontroller? • A computer has some type of memory where it can store variables and instructions or steps • Memory may be RAM, ROM, (E)EPROM, Flash

  7. What is in a Microcontroller? • Computers have a clock or oscillator that determine the speed of program execution

  8. What is in a Microcontroller? • Computers have various input and output (I/O) capabilities to support various peripherals.

  9. What is in a Microcontroller? • Microcontroller range from 8 – 40+ pin packages • Extra pins provide analog and digital I/O options • 8, 16, 32 & 64 bit instructions & data controllers

  10. Where To Use a Microcontroller? • We need to flash an LED or light 3 times • Manually you would have to push button 3 times

  11. Where To Use a Microcontroller? • A microcontroller would allow sensing the button • The uC and its program could then flash the LED based on its system clock and pgm timer

  12. Where To Find Microcontrollers? • Microcontroller are found everywhere! • uC’s are considered embedded systems

  13. Microcontrollers in Ham Radio

  14. Popular Microcontrollers • Early day (1970’s/80’s) • Intel 8048 • Intel 8051 • Zilog Z8 • Motorola 68HC05

  15. Popular Microcontrollers • Current day • Microchip PIC / PICAXE • Amtel AVR / ATmega • Parallax BASIC Stamp

  16. Microchip PIC 16F628 Specs • Programmable Intelligent Controller • 8-bit CMOS processor • 4 MHz internal oscillator • 35 instructions • Single cycle execution (RISC). • 200ns instruction execution • Non-volatile memory: • Flash program memory (3.5K bytes) • EEPROM data memory (128 bytes) • Volatile memory • RAM data memory (224 bytes)

  17. Microchip PIC 16F628 Specs • 1 digital USART (async. RX/TX) • 16 I/O pins w/ individual direction ctrl • 1 Capture/Compare 16-bit • 1 PWM peripheral 10-bit • 2x 8-bit & 1x 16-bit timers (48 KHz) • 2 Comparators (int. or ext. reference) • Programmable voltage reference • Voltage operation 2 to 5.5 VDC • 100 nA @ 2 VDC standby • 120 uA @ 1MHz & 2 VDC

  18. Microchip PIC 16F628 Pin Out • PIC pins and associated functions • Some are dual purpose

  19. C Source File Assembly Language File C Compiler/Linker Assembler/Linker Device Programmer Programming Languages for the PIC

  20. PIC Instruction Set W – The W register (or accumulator) is used as temp storage for many instructions f – “f” represents a user defined variable or system memory location k – “k” represents a literal number or a defined constant d – The value or “d” (0 or 1) determines where the numerical results is stored W (d=0) or f (d=1) b – “b” represents a particular bit in a 8-bit memory location (7,6,5,4,3,2,1,0)

  21. Programming the PIC (S/W) • MPLAB Integrated Development Environment (IDE) • Assembly for free, C compilers cost $$$

  22. Programming the PIC (H/W) • Hardware programmer and associated pins

  23. PIC Circuit and Program • Simple circuit and program that blinks an LED on pin 6 (RB0) of a PIC16F628

  24. PIC Kits • PICKit2 - $50 • www.microchip.com • PICEL-III - $65 • www.kangaus.com • PIC LAB - $120 • www.apogeekits.com

  25. Atmel AVR ATmega168 Specs • Advanced Virtual RISC • 8-bit core • 16 MHz clock • Single cycle instruction • 100 instructions • Hardware Multiplier • Flash: 16 Kbytes w/ Boot Code • EEPROM: 512 bytes • SRAM: 1Kbytes

  26. Atmel AVR ATmega168 Specs • 32 registers • 2x 8-bit timers • 16-bit timer • Real Time Clock w/ oscillator • 3x PWM channels • 8x channel ADC 10-bit • Two wire serial interface • Master/Slave SPI Serial Interface • Program Serial USART • Watchdog Timer • Analog Comparator • 23x I/O lines • 24x external interrupts • On-chip debugging through JTAG • Simple programming (LPT port, 4 resistors & AVRDUDE) • 1.8-5.5 VDC / 0.5uA – 3.6mA AVR program cable

  27. Atmel AVR ATmega168 Pin Out • AVR pins and associated functions • Some are dual purpose

  28. ATMega168 Instruction Set Arithmetic ADD Rd, RrADC Rd, RrADIW Rd+1:Rd, K6SUB Rd, RrSUBI Rd, K8SBC Rd, RrSBCI Rd, K8SBIW Rd+1:Rd, K6INC RdDEC RdAND Rd, RrANDI Rd, K8OR Rd, RrORI Rd, K8EOR Rd, Rr Arithmetic COM RdNEG RdCP Rd, RrCPC Rd, RrCPI Rd, K8SWAP RdLSR RdROR RdASR Rd MUL Rd, RrMULS Rd, RrMULSU Rd, RrFMUL Rd, RrFMULS Rd, RrFMULSU Rd, Rr Bit & Other BSET sBCLR sSBI A, bCBI A, bBST Rd, bBLD Rd, bNOPBREAKSLEEPWDR Transfer MOV Rd, RrMOVW Rd+1:Rd, Rr+1:RrIN Rd, AOUT A, RrPUSH RrPOP RrLDI Rd, K8LDS Rd, K16LD Rd, XLD Rd, -XLD Rd, X+LDD Rd, Y+K6LD Rd, -YLD Rd, Y+LDD Rd, Z+K6LD Rd, -ZLD Rd, Z+ Transfer STS K16, RrST X, RrST -X, RrST X+, RrSTD Y+K6, RrST -Y, RrST Y+, RrSTD Z+K6, RrST -Z, RrST Z+, RrLPMLPM Rd, ZLPM Rd, Z+ELPMELPM Rd, ZELPM Rd, Z+SPM Jump RJMP K12IJMPEIJMPJMP K22 Branch CPSE Rd, RrSBRC Rr, bSBRS Rr, bSBIC A, bSBIS A, bBRBC s, K7BRBS s, K7 Call RCALL K12ICALLEICALLCALL K22RETRETI ATmega has multiplication hardware, 32 registers, pointer registers (X,Y,Z), register addressing, I/O ports, access read-only data in program memory, conditional branches

  29. Programming the AVR • AVR Studio 5, supports C, Pascal, Basic, free • GNU gcc support, avr-gcc, WinAVR

  30. AVR ATmega Kits • STK300 - $130 • www.microcontrollershop.com • ATMEGADEVBRD - $40 • www.futurlec.com • Arduino Uno - $30 • www.sparkfun.com

  31. Arduino (ATmega based) • The 555 of the 21st century • Open Source Hardware • Open architecture for expansion • Shield add-ons: • USB, ethernet, wireless/XBee, motor, MIDI, BT, LCD • Open Source Software Development Tools • Integrated Development Environment • Rich library sets for supporting peripherals I/O • Linux, MacOSX and Windows support

  32. Arduino Instruction Set

  33. Programming the Arduino

  34. FARA Member Microcontroller Projects • Tom KG3V – CWlink • Eric W4EON – Antenna Measurements • Andy K1RA – WSPR Beacon

  35. CWlinkAn embedded CW Project by Tom Zeltwanger KG3V Based on the Arduino Board

  36. CWlink Objectives • Learn about Arduino boards and development • Demonstrate useful Ham Arduino App • Start by sending canned CW text • Upgrade to accept hand-keyed CW for record/playback (preserve “fist”) • Long Term - Untethered rig operation for CW using a Keyer (vs. keyboard)

  37. Arduino Duemilanove Board • Microcontroller ATmega168 • Clock Speed 16 MHz • Operating Voltage 5V • Input Voltage 7-12V • Digital I/O Pins 14 • 6 provide PWM output • Analog Input Pins 6 • DC Current per I/O Pin 40 mA • DC Current for 3.3V Pin 50 mA • Flash Memory 16 KB • 2 KB used by boot loader • SRAM 1 KB • EEPROM 512 bytes

  38. CWlink Architecture Rig Arduino Board Serial Output Serial – Wireless Link Serial Input Keyer

  39. Cwlink Keyer State Diagram Power Up Init Cal Failed (loop) Init Success Cal Cal Success Mode Switch Change Record 5 Sec Timeout Playback Mode Switch Change

  40. PIC, DDS & Return Loss BridgeAn Antenna Measurement Project by Eric Nystrom W4EON Based on the PIC 16F1827

  41. Signal Generator for Antenna Analyzer • PIC 16F1827 • 18 pin device • 32 MHz • Accurate internal clock so no crystal needed • Pins used • 3 pins to control DDS80 • 2 pins for Serial IO • 1 pin for AD converter • 3 pins for in circuit programming

  42. Analyzer Development • Development Tools • CCS C compiler • CCS ICD 64 programmer (in circuit) • Code • 2 Files • 600 source lines • Reused code from other projects • Only minor modifications for this project • Resources: • ROM used: 1830 words (45%) • RAM used: 52 (14%) • PIC code functions • Serial Interface • Set frequency of DDS • Read AD converter

  43. Architecture Diagram • About 8 hours of development time. • Code for analysis and plotting is contained in a PC program written in Java.

  44. Lessons Learned • The bridge is a wideband device. The bridge measures what the antenna is receiving as well as the component from the signal generator. Measurement differs from day to night.

  45. Weak Signal Propagation Reporter(WSPR) 160m to 6mBeacon Board Project by Andy Zwirko K1RA Based on the PICEL-III Board

  46. PICEL-III Development Board • PIC Programmer for 18-pin PICs via PC USB Port made by AA0ZZ • Hardware components:  • PIC 16F628A • 2x16 line LCD (with backlight) • Rotary encoder • Three general purpose pushbuttons • Three LEDs • Speaker with driver • Stereo jack for CW paddle input • Stereo jack with transistor driver to key TX • Transistor conditioner for converting low-level signals for PIC input (frequency counter) detection • Multi-purpose BNC connector for signal I/O • Expansion port for AmQRP DDS-30/60

  47. AmQRP DDS-60 VFO • Analog Devices AD9851 DDS • 0-60 MHz programmable oscillator • 5th order elliptic filter • harmonics down 40db • Adjustable RF-amp • 10-40 mW • 8 pin header

  48. WSPR Beacon Code • AA0ZZ created signal generator program for PICEL-III (0-60 MHz) • W3PM modified AA0ZZ program • modulate signal generator with WSPR “whisper” encoding scheme TX-only • ~2700 lines of code w/ comments • WSPR signal conveys call sign, Maidenhead grid locator and power level • Example: KW4VA FM18 17 • Forward Error Correction (FEC) is employed • Modulation scheme narrow-band 4-FSK modulation.

  49. KW4VA Beacon DX Last 24 Hours • Stations spotting / hearing WSPR beacon in the last 24 hours (30/40m) • KW4VA beacon running 20 mW and attic antenna fed with 300 ohm feed line

  50. KW4VA WSPR Top 20 Best DX • Best DX copying / spotting KW4VA WSPR beacon over the last 30 days

More Related