Summer 2007 EE100 EE43 Lab 9 EECS 100 43 Lab 9 PIC Input Output I O 1 Objective In this lab you will simply hook up the output from the strain gauge circuit you designed the previous week to the PIC microcontroller 2 Equipment a Breadboard b Wire cutters c Wires d Oscilloscope e Function Generator f Power supply g PICDEM 2 Plus demo board h MPLAB ICD 2 Incircuit Debugger i MPLAB IDE installed on lab computer1 j Various connectors for power supply function generator and oscilloscope k YOUR STRAIN GAUGE CIRCUIT 3 Theory a Downloading the sample project In this section you download the digital code to your microcontroller board Since you did not cover digital systems in lecture all the code is already done for you All you need to do is uncomment the A D code for interfacing the strain gauge 1 Download the StrainGauge project folder from the EE100 labs homepage the same project you used for lab 8 Save this to your U network drive DO NOT SAVE THIS ONTO YOUR DESKTOP FILES SAVED ONTO YOUR DESKTOP ARE AUTOMATICALLY DELETED WHEN YOU LOG OFF 2 Navigate to your folder and double click on window similar to figure 1 will pop up 1 icon A Note The microcontroller programming tools are installed in 140 Cory ONLY for ease of maintenance University of California Berkeley Department of EECS Summer 2007 EE100 EE43 Lab 9 Figure 1 MPLAB IDE has opened your Strain Gauge project 3 Now double click on main c in the StrainGaugeInterface mcw window The main program should pop up Look through it Find the line that displays VOLTMETER Replace this with STRAIN READING 4 Next you need to comment out the voltmeter reading code These are the first two lines after void main void line The default code is shown below You should be able to use this code to figure out how to comment out those lines void main void TRISA 0xFF Configure AN0 as input This is default ADCON0 0x41 configure ADC to receive signal from AN0 5 Uncomment the lines for interfacing an external signal in this case your sensor reading to your PIC board These are the lines immediately after the lines you commented out in 4 above TRISE 0x02 ADCON0 0x59 configure ADC to receive signal from AN6 RE1 6 You should debug the program before downloading it to the board To do this Click on Debugger Select Tool Make sure MPLAB ICD 2 is selected Refer to figure 2 University of California Berkeley Department of EECS Summer 2007 EE100 EE43 Lab 9 Figure 2 Make sure MPLAB ICD 2 is selected as the debugger 7 The debugger should ask you to download an operating system to the board Defaults are OK for everything Before you connect to the board MAKE SURE THE BOARD IS POWERED ON AND CONNECTED TO THE ICD2 DEBUGGER MAKE SURE THE DEBUGGER IS CONNECTED TO THE COMPUTER check with a TA Next connect to the board Debugger Connect 8 Build your program Select Project Build All 9 Program the board with your code Debugger Program 10 Run the program Debugger Run 11 If all goes well you should see the LCD screen display your strain gauge reading 12 If you are satisfied that your program is working you can permanently download code to EEPROM2 First halt debug mode Debugger Halt 13 Select Debugger Select Tool None You cannot use the programmer and the debugger at the same time 14 You pretty much repeat the same process for programming as debugging Select Programmer Select Tool MPLAB ICD 2 15 Select Programmer Connect 16 Select Programmer Program 2 EEPROM Electrically Erasable Programmable Read Only Memory University of California Berkeley Department of EECS Summer 2007 EE100 EE43 Lab 9 17 Select Programmer Release from Reset 18 Power off the board and power on again Your code will start running again University of California Berkeley Department of EECS Summer 2007 EE100 EE43 4 PRELAB Lab 9 NAME SECTION Please turn in INDIVIDUAL COPIES of the prelab They are due 10 MINUTES after start of lab NO EXCEPTIONS a TASK 1 THOROUGHLY READ THIS DOCUMENT YES THIS PRELAB IS A GIMME PRELAB COMPLETE TA CHECKOFF University of California Berkeley Department of EECS Summer 2007 EE100 EE43 5 REPORT Lab 9 NAME S SECTION a TASK 1 PROJECT COMPLETE TA Checkoff TURN IN ONE REPORT PER GROUP AT THE END OF YOUR LAB SESSION THERE IS NO TAKE HOME REPORT 6 REVISION HISTORY Date Author Summer 2007 Bharathwaj Muthuswamy University of California Berkeley Revision Comments Typed up source documentation organized lab report typed up solutions Department of EECS
View Full Document