This document provides instructions for downloading and installing MPLAB IDE and C18 compiler software, setting up a project file in MPLAB, programming a PIC microcontroller, connecting an oscilloscope to view output, and some troubleshooting tips. Students are directed to download ZIP files from a course website, run setup files, choose installation options, set the correct device and compiler in their MPLAB project, add and build a sample C file, program their PIC microcontroller, and connect an oscilloscope to view output pin responses. Tips are provided for resolving issues connecting or programming devices or seeing unexpected output.
This document provides instructions for downloading and installing MPLAB IDE and C18 compiler software, setting up a project file in MPLAB, programming a PIC microcontroller, connecting an oscilloscope to view output, and some troubleshooting tips. Students are directed to download ZIP files from a course website, run setup files, choose installation options, set the correct device and compiler in their MPLAB project, add and build a sample C file, program their PIC microcontroller, and connect an oscilloscope to view output pin responses. Tips are provided for resolving issues connecting or programming devices or seeing unexpected output.
This document provides instructions for downloading and installing MPLAB IDE and C18 compiler software, setting up a project file in MPLAB, programming a PIC microcontroller, connecting an oscilloscope to view output, and some troubleshooting tips. Students are directed to download ZIP files from a course website, run setup files, choose installation options, set the correct device and compiler in their MPLAB project, add and build a sample C file, program their PIC microcontroller, and connect an oscilloscope to view output pin responses. Tips are provided for resolving issues connecting or programming devices or seeing unexpected output.
This document provides instructions for downloading and installing MPLAB IDE and C18 compiler software, setting up a project file in MPLAB, programming a PIC microcontroller, connecting an oscilloscope to view output, and some troubleshooting tips. Students are directed to download ZIP files from a course website, run setup files, choose installation options, set the correct device and compiler in their MPLAB project, add and build a sample C file, program their PIC microcontroller, and connect an oscilloscope to view output pin responses. Tips are provided for resolving issues connecting or programming devices or seeing unexpected output.
Downloading and Installing MPLAB IDE v8.89 1. The .zip file is located on the BME361 course website http://www.ele.uri.edu/courses/bme360/ under the C programming listing 2. Download and open the zip file and click the setup.exe to start the install 3. Choose the complete install
4. Continue to click through the prompts until it starts installing files
5. Once it is finished installing, it will give you the option to view documentation. Close the window unless there is something you really want to read.
6. Now download C18 compiler from the BME361 website and install it. Just keep clicking next until it starts installing the files. When it is finished you will see this:
7. All the software is installed. Now set up a project file based on the Sample program on the website. Download the C code and put it into a folder where you will keep your lab work for the semester. Launch the MPLAB IDE
8. After you launch the IDE, select the PROJECT WIZARD and follow the steps.
9. Make sure you select the correct microchip (Device). We are using the 18F452.
10. Now set up the C18 compiler by selecting Microchip C18 Toolsuite from the drop down list.
11. It is important that you go through each of the Toolsuite Contents and make sure the path location is correct for each of the components. In the picture above, MPASM Assembler is located in C:\Program Files (x86) Each of the others will be located in the mplabc18\v3.44 folder as well. Just match the executable in the folder with the component.
12. You are now ready to make your project. Browse to the folder you created for your lab work (where you downloaded the C file) and create a name for your project.
13. Now add the C file to the project and youre all done!
14. Double-click the source C file and a new window will appear with the source file displayed.
15. Verify that you can build the project. Project->Build All.
16. If you did everything correctly, you should see BUILD SUCCEEDED!
17. You can now program your microcontroller.
7
Constructing your Circuit and Connecting the Programmer
A schematic for the circuit is shown below:
*Note: Before connecting the PIC, plug in the battery and test to make sure the correct voltages are visible at the appropriate locations. A clear sign that the wrong voltage is being supplied to the PIC is the D/A converter will heat up very rapidly. Supplying the wrong voltage to the PIC can permanently damage it, so continually check voltages throughout your use to prevent this from happening.
Assuming you have built the circuit correctly, connect your 9V battery again. You can now connect the programmer to the circuit. While in the workspace check to see that in the Output window the MPLAB ICD 2 has successfully connected:
8 When you are ready to program the PIC microcontroller, connect your 9V battery to the circuit and save your workspace. Then select the down-latch from the various tabs located at the top of the workspace, and then Build . If programming has succeeded, the output window will validate it by saying BUILD SUCCEEDED.
To disconnect the programmer using the workspace, select the up-latch from the various tabs located at the top of the workspace. You can now disconnect the battery, and unplug the MPLAB ICD 2 Programmer from the circuit.
Troubleshooting Programmer
Here are a few tips to help you if you encounter problems in programming your PIC, or even just compiling your source code:
You cannot connect to the MPLAB ICD 2 (USB):
1. Make sure your battery is plugged in correctly, and has at least 8.2V. 2. Check to see that the connector pins are oriented in the correct direction (test this by reversing orientation of the connector pins). 3. Unplug the USB extension from the computer and reinsert, try connecting again. 4. Go to Programmer >> Settings >> Power, and make sure that the power target circuit is coming from the battery, not the programmer itself by unselecting the box:
9
5. In Programmer >> Settings >> Communication, make sure that the USB device is selected for the Communication Port.
You are connected to the device, but are unable to successfully compile your source code:
1. In the output window, there will be at least one Error Message (blue text). You can double-click on the word Error which will direct you to the exact line where the error occurs. After fixing each error, re-compile and debug until no more errors are shown. 2. If this does not work, save the C-file, remove it from the project window, and add it again to the project. When you double-click on the file, make sure the correct version of your source file 10 opens up in a new window. If not, an older version of the source file has been trying to compile while youve been making changes to the newer version.
You are connected, and the source code compiles, but programming still fails:
1. Check to make sure your PIC is not reversed on your breadboard, if it is, immediately disconnect the battery to prevent damaging the PIC and/or your breadboard. 2. Try replacing the PIC with a new one. In the case that this works, the PIC you were using is damaged. 3. Review your breadboard for loose connections, short circuits, broken components, and overheating. 4. Try replacing components with new ones in the case that some are broken or are not working properly. This is especially relevant to the 7805 5V regulator because if this component does not work properly, you can potentially damage your PIC and breadboard when it overheats. 5. As a last resort, rewire your breadboard in a new location (i.e. lower right-hand corner) to avoid defects or bad connections.
In order to view the results of your program on an oscilloscope, you must connect a D/A (Digital to Analog) converter chip. Notice that pin 2 of the PIC is the output pin, and can be directly connected to the oscilloscope. The schematic for the circuit is shown below:
Your circuit programmed successfully, but you are not receiving the correct (or any) response from the output pin:
11 1. Check to make sure your battery is plugged in and has enough voltage (at least 8.2V). If you notice that your batterys voltage is dropping quickly during use, check your breadboard connections to find the source of the batterys drainage. 2. Make sure that the up-latch in the MPLAB workspace is selected, which will disconnect the ICD 2 connector from the circuit and allow the output to be seen. 3. Disconnect and reconnect the cables from the oscilloscope to ensure they are connected properly, and perform a probe calibration which is located on the oscilloscope. 4. You should also make sure that the probe tips are not damaged or oxidized, and replace them if they are. 5. Check and recheck your source code. Even if compilation and programming succeed, your code may not work as expected. Review for infinite loops, faulty switch-statements, and unused variables. Just because your program compiles does not mean it will do what you want it to do.
Microprocessors and Microcontrollers Anna University Important Questions 2 Marks and 16 Marks Questions - Repeated Questions in Anna University Question Papers From All 5 Units ...