Difference between revisions of "ME 333 Lab 5"
NickMarchuk (talk | contribs) |
|||
(99 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
'''(Note: When you link to a page on this wiki, use an internal link such as [[Main Page | this]], generated by <nowiki>[[Main Page | this]]</nowiki>, instead of an external link such as [http://hades.mech.northwestern.edu/wiki this], generated by <nowiki>[http://hades.mech.northwestern.edu/wiki this]</nowiki>. This is so the link will continue to work even if the wiki is moved to another server.)''' |
|||
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 [http://www.ccsinfo.com|PIC C compiler website] and sample code that comes with the compiler, the two manuals with the PIC C compiler, application notes at the [http://www.microchip.com|Microchip website], and just general google searches on the topic. |
|||
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) and the [[Introduction_to_the_PIC32#Further_Reading | Further Reading section of the PIC32 introduction page]]. |
|||
Each page should have four headings: Original Assignment, Objective, Circuit, and Code. See the [[Example Writeup]] for an example. The Original Assignment indicates what you were assigned to do, and will eventually be erased from the final page. The Objective is your rewritten version that clearly indicates what the page is about (to future students accessing the page), the Circuit shows a professional-looking black and white circuit diagram as well as 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). |
|||
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 I will eventually erase it 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 the four headings if necessary to improve the clarity of the page, but don't erase the Original Assignment. |
|||
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. |
|||
The MPLAB simulator is another powerful way to confirm your timing. You can experiment with it, or use DiJasio's [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096 Programming 32-bit Microcontrollers in C: Exploring the PIC32] (see also a [http://www.scribd.com/doc/16601628/Programming-32bit-Microcontrollers-in-C pdf version]) to learn more about it. |
|||
* [[Example Writeup]] |
|||
* [[IR communication between PICs]] |
|||
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!''' |
|||
* [[Zigbee communication between PICs]] |
|||
* [[I2C communication between PICs]] |
|||
=== Drawing Circuit Schematics === |
|||
* [[Serial communication with Matlab]] |
|||
* [[Sound: Microphones]] |
|||
You can create circuit schematics using [[PCB Artist]] or almost any drawing program, with the pain of creating your own circuit elements. Note that we want schematics, not a PCB layout, for this assignment. The final file should be an image file. |
|||
* [[Light: Ambient light color sensing]] |
|||
* [[Actuators: Speakers]] |
|||
<!-- |
|||
* [[Actuators: Piezoactuators]] |
|||
You can find a number of free schematic drawing programs, including Express PCB and PCB123, [http://www.freebyte.com/cad/cad.htm#electricalsystems here], including printed circuit board (PCB) layout. For this assignment, we just want '''schematics''', not PCB layouts, and they should be captured as images. Prof. Peshkin recommends trying [http://my.ece.ucsb.edu/bobsclass/2C/Simulation/circuit_maker.htm CircuitMaker], which is no longer supported but runs fine under Windows XP. [http://www.cadsoftusa.com/freeware.htm Eagle] runs under Windows, MacOS, and Linux. |
|||
* [[Controlling a seven segment display]] |
|||
* [[Distance: Ultrasonic ranging]] |
|||
Other circuit drawing software: |
|||
* [[Storing constant data in program memory]] |
|||
*Microsoft Word (Draw symbols using the shapes and wires with the flowchart connectors. You can find an example [http://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15251-s04/Site/Materials/Directions/circuits/ here].) |
|||
* [[Efficient computation of trigonometric functions]] |
|||
*[http://opencircuitdesign.com/xcircuit/ XCircuit]: Open source software that runs on Windows, Unix, and UNIX/X11 based Macs. |
|||
*Microsoft Visio: Not recommended, but it might do for simple circuits. |
|||
*[http://www.engr.uky.edu/~cathey/pspice061301.html PSpice Student]: Similar to Circuitmaker. |
|||
--> |
|||
=== Lab 5 Assignments === |
|||
* [[Example Writeup: Analog Input]] |
|||
Possible Lab 5 assignments: |
|||
* [[PIC32MX: Parallel LCD]]: Optimize the LCD code for the fastest possible communication |
|||
* [[PIC32MX: Input Capture]] |
|||
* [[PIC32MX: Change Notification]] |
|||
* Test Microchip example applications (e.g., interfacing with a 320x240 QVGA screen) |
|||
* FTDI chip high-speed parallel data transfer |
|||
* [[Wireless PIC bootloading]] |
|||
* [[Interfacing with a garage door opener]] |
|||
* [[Strain gauges]] |
|||
* [[Interfacing an IR remote control]] |
|||
* [[CAN bus]] |
|||
* [[RF communication]] |
|||
* [[Barcode scanning]] |
|||
* [[Adding external RAM to your PIC]] |
|||
---- |
|||
'''From 2010:''' |
|||
* Team 25: PIC32MX: I2C External RAM'''*!*''' and [[PIC32MX: SPI External RAM]] |
|||
* Team 12: [[PIC32MX: I2C DAC]] and PIC32MX: SPI DAC'''*!*''' |
|||
* Team 22: [[PIC32MX: I2C EEPROM]] and [[PIC32MX: SPI EEPROM]] |
|||
* Team 21: [[PIC32MX: I2C Communication between PIC32s]] and [[PIC32MX: SPI Communication between PIC32s]] |
|||
* Team 24: PIC32MX: High-speed Wireless Communication'''*!*''' (PIC-PIC or PIC-PC; see, for example, http://www.sparkfun.com/commerce/product_info.php?products_id=691) |
|||
* Team 27: [[PIC32MX: USB Communication with a PC]] |
|||
* Team 11: PIC32MX: Interfacing to a Secure Digital (SD) Flash Card'''*!*''' |
|||
* Team 15: [[PIC32MX: XBee Wireless Round-trip Latency]] |
|||
* Team 23: [[PIC32MX: FFT of Analog Input]] |
|||
* Team 13: [[PIC32MX: Benchmarking Mathematical Operations]] |
|||
* Team 26: [[PIC32MX: Interfacing with Force Sensors from a Scale]] |
|||
* Team 14: [[PIC32MX: Driving a Stepper Motor]] |
|||
'''*!* Denotes code that does not work''' |
|||
'''From 2009:''' |
|||
* Team 23: [[Ultrasonic ranging]] |
|||
* Team 13: [[Driving a piezo speaker with a PIC]] |
|||
* Team 14: [[Reading RFID tags]] |
|||
* Team 24: [[Data logging with an EEPROM]] |
|||
* Team 12: [[Fingertip laser light sensor]] |
|||
* Team 22: [[Audio recording and playback]] |
|||
* Team 16: [[Interfacing with a Secure Digital (SD) card]] |
|||
* Team 11: [[Interfacing with a touchscreen]] |
|||
* Team 15: [[Interfacing with a mouse]] |
|||
* Team 25: [[Characterizing the response of a solenoid]] |
|||
* Team 26: [[SPI communication between PICs]] <-- get this working |
|||
* Team 21: [[IR communication between PICs]] <-- get this working |
|||
'''From 2008:''' |
|||
* Team 22: [[IR communication between PICs]] |
|||
* Team 23: [[XBee radio 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: [[PIC computation time benchmarks]] |
|||
* Team 24: [[Stepper motor control with the PIC]] |
|||
* Team 25: [[Global Positioning System]] |
Latest revision as of 15:41, 1 March 2010
(Note: When you link to a page on this wiki, use an internal link such as this, generated by [[Main Page | this]], instead of an external link such as this, generated by [http://hades.mech.northwestern.edu/wiki this]. This is so the link will continue to work even if the wiki is moved to another server.)
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) and the Further Reading section of the PIC32 introduction page.
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 I will eventually erase it 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.
The MPLAB simulator is another powerful way to confirm your timing. You can experiment with it, or use DiJasio's Programming 32-bit Microcontrollers in C: Exploring the PIC32 (see also a pdf version) to learn more about it.
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!
Drawing Circuit Schematics
You can create circuit schematics using PCB Artist or almost any drawing program, with the pain of creating your own circuit elements. Note that we want schematics, not a PCB layout, for this assignment. The final file should be an image file.
Lab 5 Assignments
Possible Lab 5 assignments:
- PIC32MX: Parallel LCD: Optimize the LCD code for the fastest possible communication
- PIC32MX: Input Capture
- PIC32MX: Change Notification
- Test Microchip example applications (e.g., interfacing with a 320x240 QVGA screen)
- FTDI chip high-speed parallel data transfer
- Wireless PIC bootloading
- Interfacing with a garage door opener
- Strain gauges
- Interfacing an IR remote control
- CAN bus
- RF communication
- Barcode scanning
- Adding external RAM to your PIC
From 2010:
- Team 25: PIC32MX: I2C External RAM*!* and PIC32MX: SPI External RAM
- Team 12: PIC32MX: I2C DAC and PIC32MX: SPI DAC*!*
- Team 22: PIC32MX: I2C EEPROM and PIC32MX: SPI EEPROM
- Team 21: PIC32MX: I2C Communication between PIC32s and PIC32MX: SPI Communication between PIC32s
- Team 24: PIC32MX: High-speed Wireless Communication*!* (PIC-PIC or PIC-PC; see, for example, http://www.sparkfun.com/commerce/product_info.php?products_id=691)
- Team 27: PIC32MX: USB Communication with a PC
- Team 11: PIC32MX: Interfacing to a Secure Digital (SD) Flash Card*!*
- Team 15: PIC32MX: XBee Wireless Round-trip Latency
- Team 23: PIC32MX: FFT of Analog Input
- Team 13: PIC32MX: Benchmarking Mathematical Operations
- Team 26: PIC32MX: Interfacing with Force Sensors from a Scale
- Team 14: PIC32MX: Driving a Stepper Motor
*!* Denotes code that does not work
From 2009:
- Team 23: Ultrasonic ranging
- Team 13: Driving a piezo speaker with a PIC
- Team 14: Reading RFID tags
- Team 24: Data logging with an EEPROM
- Team 12: Fingertip laser light sensor
- Team 22: Audio recording and playback
- Team 16: Interfacing with a Secure Digital (SD) card
- Team 11: Interfacing with a touchscreen
- Team 15: Interfacing with a mouse
- Team 25: Characterizing the response of a solenoid
- Team 26: SPI communication between PICs <-- get this working
- Team 21: IR communication between PICs <-- get this working
From 2008:
- Team 22: IR communication between PICs
- Team 23: XBee radio 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: PIC computation time benchmarks
- Team 24: Stepper motor control with the PIC
- Team 25: Global Positioning System