Professional Documents
Culture Documents
A Practical Approach
Ernesto Arroyo earroyo@media.mit.edu
What is a Microcontroller?
Mini-Computer
Microprocessor
Why Important?
Embedded Inside:
Billions of units
iSphere
Talking Trivet
WaterBot
EyeR
Spatula
Spatula
PIC16F88
2-5.5v 18 Pins
13 I/O pins
www.microchip.com
I/O
Programming Languages
ASM
We will this
ASM Code
C Code
Compilers Inefficiency
/* pulses pin PORTB<3> eight times */ 0000: 0001: 0002: 0003: 0004: movlw movwf bsf bcf decfsz 0x8 0x20 0x6,0x3 0x6,0x3 0x20
/* pulses pin PORTB<3> eight times */
0005: 0006: 0007: 0008: 0009: 000A: 000B: 000C: 000D: 000E: 000F: 0010: 0011: 0012: 0013: CLRF MOVF SUBLW BTFSS GOTO BSF BCF BCF BSF BSF BCF BCF BCF INCF GOTO 21 21,W 07 03,0 014 03,5 06,3 03,5 06,3 03,5 06,3 03,5 06,3 21,F 006
Our Code
IRX Board
PIC16F84 RS-232 Serial Port Visible LED Infrared LED Infrared Detector 8 I/O Available Prototyping Area
http://www.ccsinfo.com/
Free
http://www.microchip.com
4.
MPLAB C or ASM
2. 3.
CCS PCM
5.
Power it Up
Connect 9V Battery
6.
7.
Repeat step 1
Tips
Programming
Debugging
Flash LED at start up for 500 mSec or longer Program all unused I/O pins to be outputs
Make sure the PIC is inserted properly and pin 1 facing the resistor Verify you have power Check the oscillator
Hands on
Make an led flash out a pattern LED / Photdiode pair to measure something a. variables and values b. calibration phase 4. make a context aware something: ideas? sunshine alarm headlight alarm finger bend back slouch measurer curve into a paint program (button and bendy black tube) door stop release when light turned out.