The AVR Microcontroller

The AVR Microcontroller

An Introduction to Microcontrollers and Software Design Name _____________________ MRGS Technology Electronics Available online from www.techideas.co.nz B. Collis - Mount Roskill Grammar School 2003-2009 This work is licensed under the Creative Commons Attribution-Non-commercial-Share Alike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0 . The licensor permits others to copy, distribute and transmit the work. In return, licensees may not use the work for commercial purposes — unless they get the licensor's permission. The licensor permits others to distribute derivative works only under a license identical to the one that governs the licensor's work. Table of Contents Introduction to Microcontroller Electronics .......................................................................4 Computers and Microcontrollers ..............................................................................5 What exactly is a Microcontroller .............................................................................6 What you do when learning to program ...........................................................................7 Achievement Objectives from the NZ Curriculum ....................................................8 Hardware - The AVR Microcontroller ...............................................................................9 Power Supplies........................................................................................................9 AVR Programming.................................................................................................10 Breadboard ............................................................................................................10 Simple AVR circuit .................................................................................................11 Circuit description ..................................................................................................12 AVR programming cable........................................................................................12 Introduction to writing programs using Bascom-AVR IDE..............................................13 Reading and Writing using flowcharts....................................................................14 Input and Output Control........................................................................................15 Sending Morse code..............................................................................................16 Microcontroller ports: write a Knightrider program using 8 LED’s ..........................17 Multiple LEDs - Traffic lights exercise ....................................................................18 Multiple LEDs - 7 Segment Displays......................................................................19 Different types of switches .....................................................................................20 First input device – a single push button switch.....................................................21 BASCOM and AVR Assignment ............................................................................23 Words you need to be able to use correctly when talking about programming ......24 A Bit about Numbers..............................................................................................25 Programming Codes of Practice ....................................................................................26 Programming Template .........................................................................................27 Variables................................................................................................................28 The BASCOM-AVR Simulator................................................................................29 Control statements – IF THEN.......................................................................................31 Connecting and programming multiple switches....................................................31 Reading multiple switches in software ...................................................................32 Using flowcharts to help solve problems................................................................33 Using IF-THEN to control which parts of a program happen..................................37 Debounce ..............................................................................................................36 More Interfacing.............................................................................................................38 Analogue to Digital Conversion..............................................................................39 Reading an LDR’s values in Bascom.....................................................................41 Temperature measurement using the LM35 ..........................................................43 Keypad Interfacing.................................................................................................44 Alternative keypad interface...................................................................................44 Controlling high power loads (outputs)...................................................................45 Parallel Data Communications...............................................................................46 LCDs (Liquid Crystal Displays) ..............................................................................47 Connecting an LCD to a 40pin AVR.......................................................................48 Don’t delay.............................................................................................................51 Programs as solutions: understanding algorithms and flowcharts .................................54 Planning Sequence for an AVR project..................................................................54 One Page Brief ......................................................................................................55 One Page Brief ......................................................................................................56 Algorithm Development Worksheet........................................................................57 Example Brief.........................................................................................................58 Algorithm Planning Example..................................................................................59 Example Brief.........................................................................................................60 ii Algorithm Development Example...........................................................................61 Glue Gun Timer Flowchart.....................................................................................62 Multiplication Algorithms ........................................................................................64 Algorithm exercises................................................................................................68 LCD programming exercises..................................................................................69 LCD programming exercises..................................................................................69 Scrolling Message Assignment..............................................................................70 Strings Assignment................................................................................................71 ASCII Character Table...........................................................................................73 ASCII Assignment..................................................................................................74 Time.......................................................................................................................77 Sounding Off..........................................................................................................81 System and Software Design.........................................................................................84 Understanding how simple systems work ..............................................................84 Problem Decomposition Example..........................................................................85 Statecharts.............................................................................................................87 Token Game – Statechart Design Example...........................................................90 Serial Communications ..................................................................................................95 RS 232 Serial Communications .............................................................................97 Serial IO using Inkey() .........................................................................................102 Introduction to I2C................................................................................................103 Real Time Clocks.................................................................................................105 DS1307 RTC........................................................................................................107 Arrays ..........................................................................................................................112 Computer Programming detail .....................................................................................115 AVR Internals – how the microcontroller works....................................................116

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    150 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us