1 / 89

Introduction to Microcontrollers

Introduction to Microcontrollers. And all that whirrs, clicks, and beeps. Instructors. Ms. Hinterlong Lucas Sturnfield Brian Baker Thomas Houlahan. Sponsors. Houlahan’s Tavern and Grill. Programming Languages. .NET, Java, C++, Python…? Assembly?. what Micros can do. Electronics.

rivka
Download Presentation

Introduction to 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. Introduction to Microcontrollers And all that whirrs, clicks, and beeps

  2. Instructors • Ms. Hinterlong • Lucas Sturnfield • Brian Baker • Thomas Houlahan

  3. Sponsors • Houlahan’s Tavern and Grill

  4. Programming Languages • .NET, Java, C++, Python…? Assembly?

  5. what Micros can do

  6. Electronics • Electron juggling and shuffling • (some kinds of shuffling are more impressive than others)

  7. Outline • Today • Basic electronics • Digital electronics • Tuesday • Programming a microcontroller • Start projects • Wednesday • Projects • Thursday • Projects • Friday • Projects and presentations

  8. Basic Electronics

  9. Basic Electronics - Circuits

  10. Circuit Diagrams http://www.fancon.cz/slave-flash-trigger/slave-flash-en.html

  11. Wire and Elements Some elements Elements wired together

  12. Branches and Nodes

  13. Branches and Nodes

  14. Branches and Nodes

  15. Voltage and Current • Voltage • Potential energy per unit charge • Measured in Volts = Joules per Coulomb • Water analog: pressure • Measured between nodes

  16. Voltage and Current • Current • Flow of electrons • Measured in Amperes (Amps) = Coulombs per Second • Water analog: flow rate • Measured through an branch (through an element)

  17. Ohm’s Law: V = I * R • Voltage across the element = Va – Vb • Resistor has resistance R1, measured in Ohms • Current through resistor is i_R1 • Va-Vb = R1 * i_R1

  18. Power: P = V * I • Power used by any branch is equal to the voltage across the branch multiplied by the current through that branch • Units: Joules / Coulomb * Coulomb / Second = Joules / Second = Watts

  19. KVL and KCL • Kirchoff’s Voltage Law • The sum of voltages around any loop equals zero

  20. KVL and KCL • Define a ground node to be zero volts • Now, each node has a voltage

  21. KVL and KCL • Kirchoff’s Current Law • The sum of currents entering a node equals zero • (a lot like mass conservation)

  22. Breadboards • Internal connections • Power rails

  23. Multimeters – Measuring Voltage • Multimeter must connect to circuit differently to measure voltage or current • To measure voltage, set multimeter to Voltage setting, and place leads in parallel with branch of interest

  24. Multimeters – Measuring Current • To measure current, set multimeter to Current setting, and place leads in series with branch of interest

  25. Series and Parallel Resistance

  26. Diodes and LEDs • Water analog: Check valve – only lets current flow one way • Either ON or OFF • On • Anode-cathod voltage is fixed value, no matter what current (0.7 V) • Off • Current is zero, no matter what voltage • LEDs emit light when ON

  27. LEDs and Current Limiting Resistors

  28. Recap • Voltage is potential energy (pressure) • Current is flow of electrons (flow rate) • Voltage is measured between nodes, or with respect to ground • Current is measured through branches • V=IR • P=IV

  29. Voltage isn’t always Constant • Speakers are driven by a voltage signal; settings the voltage sets the position of the speaker diaphragm

  30. Sensors and analog out • Some sensors vary an output voltage; the voltage corresponds to a sensor value • Maxbotix ultrasonic sensor outputs voltage corresponding to distance

  31. RF - radio • Radio uses Electromagnetic waves • Voltage on antenna varies • Waveform carries data

  32. Power: DC vs AC DC AC • Direct Current • Batteries, wall warts • Time-constant voltage • Current flows one way • Alternating Current • Electrical outlets • Time-varying voltage • Current flows different ways at different times • Transfers power great distances with low line loss

  33. AC to DC http://hyperphysics.phy-astr.gsu.edu LM7805 Volage regulator - takes ~9V DC, makes 5V DC

  34. Capacitor • Stores energy • Resists change in voltage • Electrolytic are polarized, have stripe on minus end • Capacitance is measured in Farads (typically, micro Farads) Electrolytic capacitor Ceramic capacitor

  35. Transistor • Considered by many to be greatest invention of the 20th century • Transistor as amplifier (radio) • Transistor as switch

  36. Digital Electronics 0110100001100101011011000110110001101111001000000111011101101111011100100110110001100100 (hello world)

  37. 1 and 0 • Digital logic doesn’t use analog voltages – only ‘high’ and ‘low’ have meaning • Typically 5V and 0V • Sometimes 3.3V and 0V • Computer processor • High is 1, Low is 0

  38. Microcontroller • Programmable Chip • Same idea as PC, but on much smaller scale

  39. Black Box • Black box does stuff to inputs to get outputs • Typically don’t want to care what happens inside black box; just need to know how to give it input, and what output to expect

  40. Black Box • Need to know where to put toast • Need to know to be careful getting toast; it’s hot • Need to know that ‘ding’ means toast is done • Ding is an output! • Power, timer setting, lever are all inputs

  41. Computer vs Microcontroller Computer Microcontroller • Inputs • Keyboard • Mouse • Microphone • Outputs • Monitor • Speakers • Black box • Program is written on the computer • Inputs • Voltage on pins • Outputs • Voltage on pins • Black box • Program is written on a computer and downloaded to the chip

  42. Why Microcontrollers? • Low cost for a lot of processing • Low power (can run on batteries) • If power is well managed, can run for years on a 9V! • Small • Can communicate with PCs to do complex processing with real world effects

  43. Blinky LED in a Breadboard • Breadboard stuff • PICS are already programmed • Remember: Electrolytic caps are polarized; stripe goes to lower voltage • When you apply power, LED should blink

  44. PCB • Haha! jk jk we have awesome pcb. • Let’s solder: • Soldering irons get HOT: don’t burn yourself • Tinning things: put a little solder on both pieces that you’ll connect, THEN connect them • Sockets are done you get to do caps and 7805 • With sockets, we don’t apply heat to a chip. Also, if the chip gets fried, we can pull it and put a new one in • Test with Blinky LED again

  45. Introduction to Microcontrollers

  46. Programming a PIC Making machines Think

  47. Architecture • Memory • Variables – ‘registers’ – all 1 byte big • F register • Declare you own • Special ones, like PORTD and TRISB • Working register – the accumulator – your ‘hands’ • Instructions • Processor only does ONE thing at time – moves from one instruction to the next • Each instruction has an opcode (action) and parameters • i.e., movfw PORTA

  48. Comments prefixed with semilcolons Compiler info Config bits Constants Variables – declared two different ways Config & Variables

  49. ORG declares a place in code memory 0x000 is restart 0x004 is interrupt (ignore interrupt for now) Now every line is a comment, label, or instruction nop – do nothing goto [label] – jumps to a named label Beginning of Code

  50. bcf and bsf – bit modification Special f registers and bank bits Moving through accumulator PORT and TRIS control pins ADCON1 and analog Initialization

More Related