Microcontrollers • What is a Microcontroller • Characteristics • Basic Stamp 2 – the controller in the Boe Bot • Setting up • Developmental Software • Hardware • Sample First Programs • ASCII • DEBUG using ASCII What is a Microcontroller • Characteristics • How many microcontrollers did you use today? What else?? ______________ ______________ • They are embedded in many common devices we use every day • Some other examples: • Handheld games • Digital watches • ???????????????????? • How do microcontrollers differ from PC μProcessors • μProcessors use external circuitry to interface to non-computer devices (aka, Input/Output – I/O devices) What is a Microcontroller • Characteristics • How do microcontrollers differ from PC μProcessors (μP) • Microcontrollers have circuitry to interface and control noncomputer devices • The heart of both is a small computer on a chip • Major Components • Every system based upon a μP or microcontroller contains at least: • Arithmetic Logic Unit (ALU) –On Microcontroller • Memory Unit- Some or all on the Microcontroller • Control Unit –On Microcontroller • Input Unit –On Microcontroller • Output Unit –On Microcontroller Micro Controller Focused View of a Typical System Block Diagram What is a Microcontroller • Characteristics • Major Components • Interconnection of these is shown on the previous slide • Arrows indicate direction of data, info, and control signal flow • Large arrows indicate data or information flow • Smaller arrows indicate the flow of control signals • Logic Unit (ALU) –On Microcontroller • Area of the machine that performs • Arithmetic operations and logical operations • Memory Unit • The memory stores information in groups called bytes • The stored bytes can contain instructions (program) of the µC or data • Input Unit • Consists of all the devices that collect/take eternal information for input to the system What is a Microcontroller • Characteristics • Major Components • Shares pins with Output • Output Unit • Consists of all the devices that are used to transfer information from the system to the “outside” • Shares pins with Input • Basic Stamp 2 – the controller module in this class • First Basic Stamp module was introduced in 1992 • Over 3 million sold • The Stamp 2 is a later model than the on introduced in 1992 • Basic Module components • Micro controller chip (PIC16C57 on Basic Stamp 2) • Internal memory (RAM and EEPROM) What is a Microcontroller • Basic Stamp 2 • Basic Module components • 5 volt regulator • TTL levels • 0 – 5V • Set of basic commands • Math • I/O port control • Programming • Simplified custom version of BASIC – PBASIC • Speed • 4000 PBASIC instructions per second What is a Microcontroller • Basic Stamp 2 • Pin-outs • Pins 1 -24 • Critical Items • Sink/ Source limits on pins 5-20 • VDD on pin 21 • Pin 24 – VIN limits • System ground on Pin 23 What is a Microcontroller • Basic Stamp 2 • Embedded Computer Systems • Modules such as the BASIC Stamp 2 are correctly called this • Sometimes just “Embedded System” • However, they are most commonly called microcontrollers • Carrier Board used to hold the BASIC Stamp 2 on the Boe Bot Overview of Microcontroller LAB • Key Aspects • Software • Hardware • Software Setup • BASIC Stamp Editor • You will use it on most of the Hand-On parts of the course • Characteristics • Aids the writing of PBASIC programs to control the Boe Bot • Allows simple downloading of these programs to the Boe Bot • It can them run autonomously • Also displays messages sent from the Boe Bot Getting Setup for the Course • Software Setup • BASIC Stamp Editor • Characteristics • Free from Parallax for use with their products Desktop Icon • Should be installed on your computer w/desktop Icon • Click on it and open it First Programs • Overview • The BASIC Stamp and computer Communicate over the connecting USB or Serial cable • Stream of ones and zeros flow each way • First Program • The following program is shown in BASIC Stamp Editor First Programs • First Program • Program continued • Some lines are typed and some are entered by selecting a button Clicking on this button will automatically place '{$STAMP BS2} at the beginning of your program. • After entering the program Save it • Select File then Save Clicking on this button will automatically place '{$PBASIC 2.5} at the beginning of your program. First Programs • First Program • Program continued • How thee program works • First 2 lines are comments • For human reading • Note the apostrophe • The net two lines are comments and Complier directives • The DEBUG command tells the Stamp to send the message • Formatters • Code word that changes how a Stamp message is displayed • DEC causes the display of a decimal value • Control Characters • CR causes a Carriage return on the line below the characters that are before it in the message ASCII • American Standard Code for Information Interchange • Most microcontrollers and μPs use this code to represent each keyboard character and function • ASCII codes 32 – 126 represent printed characters and symbols • ASCII codes below 32 correspond to different functions or are spare • Some of the functions are: • cursor up, down, right, left, etc • space • Delete • Etc. • Machine and human versions of the codes • Letter “a” ASCII code is 61 in machine readable form 00111101 • Reference page : http://www.asciitable.com/ ASCII • Bits and Bytes • Most microcontrollers and μPs smallest unit of memory used is a Byte • A Byte consists of 8 bits • A Bit is the smallest unit of information • Each bit is either on or off (Logic 1 or 0) • ASCII only use 7 of the 8 bits in a Byte • DEBUG using ASCII • Sample Program ASCII • DEBUG using ASCII • How it works • Each letter in the DEBUG command corresponds to one ASCII code symbol that appeared in the Debug Terminal. DEBUG 66,65,83,73,67,32,83,116,97,109,112,32,50 • 66 is the ASCII code for capital “B”, 65 is the code for capital “A” and so on. 32 is the code for a space between characters. • Notice that each code number was separated with a comma. • The commas allow the one instance of DEBUG to execute each symbol as a separate command. • This is much easier to type than 12 separate DEBUG commands.