Difference between revisions of "ME 333 Lab 5"
Matt Turpin (talk | contribs) |
Matt Turpin (talk | contribs) |
||
Line 5: | Line 5: | ||
You are welcome to change the structure of your page to something other than these headings only if necessary to improve the clarity of the page. Don't erase the '''Original Assignment''' section. |
You are welcome to change the structure of your page to something other than these headings only if necessary to improve the clarity of the page. Don't erase the '''Original Assignment''' section. |
||
Every topic that uses interrupts to implement a function should report how long it takes the interrupt to complete the service routine. One way to do this is to set a digital output pin "high" at the beginning of the interrupt service routine, then set it low at the end. Then look at this digital output on an oscilloscope. If the interrupt routine is occurring every 1 ms, then you should see a pulse every 1 ms, and the duration of the pulse tells you approximately how much time it takes your ISR to execute. If you don't clearly see a pulse of less than 1 ms every 1 ms, then your ISR may be taking more than its allotted time, and you need to either increase the time between ISR calls or decrease the complexity of your code in the ISR. '''Remember that bitwise operations such as &, |, >>, or << are fast, math operations on unsigned integers are slower, math operations on signed integers are slower still, math operations on floats are slower still, and trigonometric and other complex functions are very slow.''' If you have two different ISRs, say one at 1 ms intervals and another at 13 ms intervals, use a different pin to time each and display the two channels simultaneously on your oscilloscope to understand the timing. |
Every topic that uses interrupts to implement a function should report how long it takes the interrupt to complete the service routine. One way to do this is to set a digital output pin "high" at the beginning of the interrupt service routine, then set it low at the end. Then look at this digital output on an oscilloscope. If the interrupt routine is occurring every 1 ms, then you should see a pulse every 1 ms, and the duration of the pulse tells you approximately how much time it takes your ISR to execute. If you don't clearly see a pulse of less than 1 ms every 1 ms, then your ISR may be taking more than its allotted time, and you need to either increase the time between ISR calls or decrease the complexity of your code in the ISR. '''Remember that bitwise operations such as &, |, !, >>, or << are fast, math operations on unsigned integers are slower, math operations on signed integers are slower still, math operations on floats are slower still, and trigonometric and other complex functions are very slow.''' If you have two different ISRs, say one at 1 ms intervals and another at 13 ms intervals (for example), use a different pin to time each and display the two channels simultaneously on your oscilloscope to understand the timing. |
||
Your lab will be graded on functionality (how well you have completed the objective) and the usefulness of your wiki page (how clearly it is written and documented with images or other supporting material). If you use figures or information you found elsewhere on the web, give a citation (link) to the original source. '''Do not use copyrighted work!''' |
Your lab will be graded on functionality (how well you have completed the objective) and the usefulness of your wiki page (how clearly it is written and documented with images or other supporting material). If you use figures or information you found elsewhere on the web, give a citation (link) to the original source. '''Do not use copyrighted work!''' |
Revision as of 15:10, 29 January 2008
In Lab 5, you will create your own wiki page describing some useful PIC-related function. Good resources include this mechatronics wiki itself (some of these functions may be partially documented), the PIC C compiler website and sample code that comes with the compiler, the two manuals with the PIC C compiler, application notes at the Microchip website, and just general google searches on the topic.
Each page should have four headings: Original Assignment, Overview, Circuit, and Code. See the Example Writeup: Analog Input for an example. The Original Assignment indicates what you were assigned to do, and will eventually be erased from the final page. The Overview is your rewritten version that clearly indicates what the page is about (to future students accessing the page) and should also include links to other good web sources of information on this topic, the Circuit shows a professional-looking circuit diagram including part numbers and where they can be obtained (and, where helpful, a photo of a neatly wired implementation of the circuit), and Code gives a listing of the liberally commented code, which should otherwise be as simple as possible (do not have extraneous lines of code that don't relate directly to the objective of the page). You may also wish to add a Further Reading section at the end of the page, with links to other useful sites on the topic. If not, you should make sure that your Overview has these links.
You are welcome to change the structure of your page to something other than these headings only if necessary to improve the clarity of the page. Don't erase the Original Assignment section.
Every topic that uses interrupts to implement a function should report how long it takes the interrupt to complete the service routine. One way to do this is to set a digital output pin "high" at the beginning of the interrupt service routine, then set it low at the end. Then look at this digital output on an oscilloscope. If the interrupt routine is occurring every 1 ms, then you should see a pulse every 1 ms, and the duration of the pulse tells you approximately how much time it takes your ISR to execute. If you don't clearly see a pulse of less than 1 ms every 1 ms, then your ISR may be taking more than its allotted time, and you need to either increase the time between ISR calls or decrease the complexity of your code in the ISR. Remember that bitwise operations such as &, |, !, >>, or << are fast, math operations on unsigned integers are slower, math operations on signed integers are slower still, math operations on floats are slower still, and trigonometric and other complex functions are very slow. If you have two different ISRs, say one at 1 ms intervals and another at 13 ms intervals (for example), use a different pin to time each and display the two channels simultaneously on your oscilloscope to understand the timing.
Your lab will be graded on functionality (how well you have completed the objective) and the usefulness of your wiki page (how clearly it is written and documented with images or other supporting material). If you use figures or information you found elsewhere on the web, give a citation (link) to the original source. Do not use copyrighted work!
Lab 5 assignments:
- Team 22: IR communication between PICs
- Team 23: Zigbee communication between PICs
- Team 14: SPI communication between PICs
- Team 25: I2C communication between PICs
- Team 26: Serial communication with Matlab
- Team 15: Microphones
- Team 12: Ambient light color sensing
- Team 13: Controlling a seven segment display
- Team 21: Storing constant data in program memory
- Team 11: Efficient computation of trigonometric functions
- Team 24: Stepper motor control with the PIC
Future: