Difference between revisions of "ME 333 Introduction to Mechatronics (Archive Winter 2012)"

From Mech
Jump to navigationJump to search
 
(295 intermediate revisions by 4 users not shown)
Line 1: Line 1:
'''Winter Quarter 2011'''
'''Winter Quarter 2012'''


(Here is an [[ME 333 Introduction to Mechatronics (Archive Winter 2011)|Archive of Winter 2011]])
* Instructor: Prof. Kevin Lynch, kmlynch at northwestern.edu

* TA: Nelson Rosa, nelsonrosa2013 at u.northwestern.edu
'''First day of class is Thursday Jan 5!'''
* Mechatronics Lab Coordinator: Nick Marchuk, nick.marchuk at gmail.com
* Class Hours: T Th, 12:30-1:50 Tech LR5
* Section 20: Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5
* Office Hours for Nick Marchuk: daily, 4-5 PM, Mechatronics Lab, Ford B100
* Section 21: Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5
* TAs: Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu
* Office Hours for Kevin Lynch: TTh 4-5 PM, Tech B221
* Circuits Q&A Session: Thurs Jan 6, 5 PM, location TBA
* Circuits Review Session: Mon Jan 9, 7 PM, Prof. Lynch, Tech L221; Wed Jan 11, 7 PM, Prof. Marchuk, Tech L221
* C Peer Instruction Sessions, 7-8:30 PM, Seeley-Mudd Engineering Library Room 230
** Thurs Jan 12
** Tues Jan 17
** Wed Jan 18
* '''Final demo''' (in lieu of final exam): Monday March 12 3-5 PM and Wed March 14 9-11 AM in LR5.
* Office Hours:
** Mon 4-6 PM: Jarvis Schultz, Mechatronics Lab, Ford B100
** Tues 2-3 PM: Prof. Lynch, B221
** Wed 3-5 PM: Nelson Rosa, Mechatronics Lab, Ford B100
**Thurs 3-4 PM: Prof. Lynch, B221
** Fri 3-4 PM: Prof. Marchuk, Mechatronics Lab, Ford B100
** Mon-Fri 4-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100


== Checklist to Complete Before the First Day of Class ==

Attendance at the first day of class (Thursday Jan 5) is mandatory. By the first day of class, you should:

* Be able to solve circuit problems similar to those on the practice problem set and last year's quiz at the bottom of [[ME_333_Circuits_Review_Material|this page]]. Be prepared for a quiz on this material in the second week of class. We will only spend one class period reviewing this material.
* Have a laptop with at least 2 USB ports. Any operating system is fine. One port will be used to program and communicate with your PIC microcontroller, and the other will be used for your portable oscilloscope.
* Buy your class kit [http://it.mccormick.northwestern.edu/matlab/student_license/login.php '''here''']. If you already have the oscilloscope and multimeter from this year's ME 233 offering, you should choose "ME 333 (w/o ME 233 equipment)" for the price of $75. If you do not have the oscilloscope and multimeter, you should choose "ME 333 (w/ ME 233 equipment)" for the price of $135. You will not be able to start the course until you have completed the purchase of your kit. If you decide to drop the course, you will be refunded the purchase price upon return of all the equipment in working shape.
* '''If you are not already comfortable with the C language, or if you do not already have a C compiler installed on your laptop, this step is recommended before the first day of class. This will give you a headstart on learning C. If you don't complete this before the first day of class, you will need to do it before the second class.''' Download and install the GCC GNU compiler collection and the Netbeans IDE (Integrated Development Environment) following the instructions [[Installing_a_C_Compiler_and_IDE|here]]. Verify that you can compile and run the sample programs at the end of that page. Read the comments in invest.c to find references to the [[Media:CrashCourseinC.pdf|Crash Course in C document]] and answer the questions to learn more about C. '''If you have problems installing a C compiler and running the programs, then you can still get a headstart before the first class by focusing on reading the C programs and the Crash Course in C manual to understand how they work.'''
<!-- * Download and install software described on [[NU32v2: Software to Install|this page]]. -->

== Student Contract ==

By signing up for this course, you agree to complete the checklist above before the course starts. You understand that learning from classmates is encouraged, up to the stage of conceptualizing solutions. You understand that copying assignment solutions and program code plagiarism is not tolerated. You will report instances of code plagiarism you are aware of. Code plagiarism includes, but is not limited to:

* Allowing another student to copy your code.
* Copying another student's code, in whole or in part.
* Transforming copied sections of code to try to disguise their origin.
* Borrowing code from others not in the course, e.g., code found on the internet, without attribution. Borrowing code found on the internet is acceptable if the source is clearly indicated in your code comments.

On our part (faculty and TAs), we commit to do our best to provide you a curriculum and set of experimental materials to get you up to speed on sophisticated mechatronics integration as quickly and efficiently as possible, while giving you a foundation in concepts needed to go further in future projects and courses.

== Prerequisite ==

ME 233 Electronics Design or similar (EECS 221, 225) is required. You will be expected to analyze circuits with resistors, capacitors, inductors, diodes, transistors, and op-amps on the first day of class. There will be a quiz on this material on the third day of class, but you are on your own to prepare for it, apart from one review class and some night review sessions. To see if you have the right background, or if you will need to freshen up before the quarter starts, do the practice problem set and the 2011 quiz on [[ME_333_Circuits_Review_Material|this page]].


== Reading ==
== Reading ==
Line 13: Line 51:
Required:
Required:


* [[Media:EssentialC.pdf|Essential C]]: A brief introduction to the C programming language
* [[Media:CrashCourseinC.pdf|A Crash Course in C]]: A brief introduction to the C programming language
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (254 pages, 5 MB pdf)
([[Media:EssentialC.pdf|Essential C]] is also a very nice intro to C)
* handouts associated with individual classes
* wiki info on [[Microchip PICs]]
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (256 pages, 5 MB pdf)
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2612 PIC32 Family Reference Manual, by chapter.] Lots of useful and detailed information on the PIC32 architecture and how the peripherals work, including detailed description of their SFRs. Only certain parts of certain chapters will be assigned.
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2612 PIC32 Family Reference Manual, by chapter.] Lots of useful and detailed information on the PIC32 architecture and how the peripherals work, including detailed description of their SFRs. Only certain parts of certain chapters will be assigned.
* The old version of the [[Media:61132B_PIC32ReferenceManual.pdf|PIC32 Family Reference Manual]] has many more pages than the chapter-by-chapter version linked above. It includes quite a lot of example code. '''Be warned though, Microchip was not very careful when writing the sample code; some of it contains syntax errors, or values in registers that are incorrect.''' Even with this being the case, this is still a very useful document.
* PIC32MX Peripheral Library (included as a .chm file under "doc" with your C32 compiler installation)
* PIC32MX Peripheral Library (included as a .chm file under "Program Files\Microchip\MPLAB C32\doc" with your C32 compiler installation)


Useful, but not required:
Useful, but not required:


* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&s=books&qid=1294091438&sr=8-1-spell Programming 32-bit MIcrocontrollers in C: Exploring the PIC32] by Lucio Di Jasio. This is an easy to read and informative exploration of the PIC32.
* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&s=books&qid=1294091438&sr=8-1-spell Programming 32-bit Microcontrollers in C: Exploring the PIC32] by Lucio Di Jasio. This is an easy to read and informative exploration of the PIC32.
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under "doc" of your C32 compiler installation
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under "doc" of your C32 compiler installation
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]], and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&ie=UTF8&qid=1294091625&sr=1-1 C Programming Language] reference book by Kernighan and Ritchie
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]] of "The C Book," and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&ie=UTF8&qid=1294091625&sr=1-1 C Programming Language] reference book by Kernighan and Ritchie

== Grading ==

Grades will be approximately 40% quizzes and 60% assignments (including the final project). We will have short quizzes once a week at the beginning of class covering material on the previous assignment. Bring a sheet of paper you can turn in with your quiz answers. (Your lowest quiz score and homework score will be dropped.) We will have a final project and demo in lieu of a final exam.

All quizzes and assignments have equal weight, regardless of how many points they are graded out of. If one homework is graded out of 20 points, and the next out of 40, the formula for calculating your grade for these two assignments would be 0.5*(score1/20) + 0.5*(score2/40).

== Homework Submission ==
All homework will be submitted on Blackboard. Here are a few guidelines/ tips associated with homework submissions:
* We expect the required files for each assignment to be compressed together in a zip file (no rar files).
* When asked to submit C code for a given programming assignment, we are only concerned with receiving the relevant source files i.e. all *.c and *.h files. We do not want entire NetBeans/MPLAB X projects or executables/object files.
* When writing your responses, please follow any instructions on how to write your response. For example, if we ask for a snippet of code, please do not submit your entire C program with header files and a main routine. We typically are only expecting a few lines of code that solves the problem.
* When submitting written responses, we prefer PDF files, but will accept word documents (.doc, .docx), .txt, and .rtf files.
* It helps both us and you if you format your code nicely. Clean looking code is easier for us to grade and easier for you to debug. Both NetBeans and MPLAB X (as well as other good editors) have tools for auto-formatting code. For example, highlighting a region and hitting Alt+Shift+f (Linux and Windows) will format that region according to your local formatting preferences.
* When you compile your code (by clicking the hammer in NetBeans/MPLAB X), the output window in the IDE shows any compiler warnings. Pay attention to these! They are there for a reason. You should be able to eventually get your code to produce no warnings. Often if a piece of code is not working, the warnings will give a clue as to why. Note that in "project properties" in both IDEs, it is possible to generate "Additional warnings." This tells your compiler to be more strict about the rules of C. The better you adhere to these rules, the more likely it is that your code will compile.


== Approximate Syllabus ==
== Approximate Syllabus ==
Line 28: Line 85:
ME 333 focuses on three topics: (1) general C programming; (2) Microchip PIC microcontroller architecture and C programming specific to the PIC (e.g., using the PIC's peripherals, such as analog inputs, digital I/O, counters/timers, comm ports, etc.); and (3) interfacing the PIC to sensors and actuators, some theory of sensor and actuator operation, and interface circuitry and signal processing.
ME 333 focuses on three topics: (1) general C programming; (2) Microchip PIC microcontroller architecture and C programming specific to the PIC (e.g., using the PIC's peripherals, such as analog inputs, digital I/O, counters/timers, comm ports, etc.); and (3) interfacing the PIC to sensors and actuators, some theory of sensor and actuator operation, and interface circuitry and signal processing.


You will bring your laptop to each class. As the quarter progresses, we will be handing out other equipment that you will need to bring to class, such as the [[NU32v2: Introduction to the PIC32|NU32v2 development board]] that breaks out the [http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en545660 PIC32MX795F512L] microcontroller.
You will bring your laptop to each class. As the quarter progresses, we will be handing out other equipment that you will need to bring to class, such as the [[NU32: Introduction to the PIC32|NU32 development board]] that breaks out the [http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en545660 PIC32MX795F512L] microcontroller.

Most days we will begin class with a short quiz. Bring a sheet of paper you can turn in with your answer.


Topics we will cover include:
Topics we will cover include:
Line 47: Line 102:
* communication by SPI, I2C, and RS-232
* communication by SPI, I2C, and RS-232


[[ME333 Sample Code|'''Sample Code for ME 333''']]
== Important Information: Changes to ME 333 for Winter 2011 ==


By class (note: DS = Data Sheet, RM = Reference Manual):
* ME 333 will be taught differently in 2011 than it has been in recent years. In particular, there will be no lab groups and no large final projects. Each student will be issued a PIC microcontroller and electronics, sensors, and actuators needed to complete the programming and interface assignments on his/her own. Every student will do a significant amount of programming. An example of an assignment is to write PIC software to control a motor based on encoder feedback.
* You need a laptop for this course. You will need to bring it to class. (There are some similarities to ME 233.)
* ME 333 assumes some familiarity with circuits, e.g., transistors and op amps. ME 233 is good preparation. EECS 221 or 225 should suffice, too.


'''Class 1''' (Th 1/5)
If you are signed up for ME 333 and this does not sound like a course you want to take (e.g., you don't want to do a lot of programming), please unregister. If you would like to be on the waiting list, send me an email, kmlynch at northwestern.edu. If you are already on the waiting list (you received a mail from me) but would like to be off the waiting list, or if you don't have experience with circuits, please let me know, and I will take you off the waiting list.
: '''Quiz''': None.
: '''Topic''': Course overview. Circuits review.
: '''Reading''': Practice problem set and quiz on [[ME_333_Circuits_Review_Material|this page]], as well as background reading as needed.
: '''Assignment out''': If you do not already have a C compiler, install a C compiler following the instructions [[Installing_a_C_Compiler_and_IDE|here]]. For all students: compile and run the tutorial code [[Installing_a_C_Compiler_and_IDE#Tutorial_Sample_Code|here]] and begin to understand it.


'''Class 2''' (T 1/10)
== Checklist to Complete Before the First Day of Class ==
: '''Quiz''': None.
: '''Topic''': Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling and linking).
: '''Reading''': [[Media:invest.c|Sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).


'''Class 3''' (Th 1/12)
Attendance at the first day of class is mandatory. If you will be unable to make the first day of class, please give up your seat in ME 333 now (unregister or email Prof. Lynch to be taken off the waitlist) so that another student can have it. By the first day of class, you should:
: '''Quiz''': Circuits. ([[Media:ME333_Quiz1_2012_Solutions.pdf|Solutions]]; high score 45/46, average 33.4, stdev 7.8)
: '''Topic''': Introduction to C (syntax). We will compile and run programs together in this class, so bring your laptop with your installed C compiler and IDE.
: '''Reading''': Continue with [[Media:invest.c|sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).
: '''Assignment 1 out''': '''Problems 1-6 and 9''' of [[Media:CrashCourseinC.pdf|A Crash Course in C]] (v0.2 of Thurs, Jan 12). Due by electronic submission by 11 AM Thurs 1/19. Solutions to problems 1-6 must be typed. Place these solutions, plus your .c file from the programming assignment (problem 9), in a .zip file and submit the zip file through [https://courses.northwestern.edu/webapps/login/ Blackboard]. The name of your zip file should be Lastname_Firstname_a1.zip. You will also demonstrate your program in class on Thurs 1/19. For full credit, you must follow these instructions exactly.


'''Class 4''' (T 1/17)
* Be able to solve circuit problems similar to those on the practice problem set at the bottom of [[ME_333_Circuits_Review_Material|this page]]. Be prepared for a short quiz on this material on the second day of class.
: '''Topic''': Introduction to C (syntax).
* Have a laptop with at least 2 USB ports running a Windows operating system (see FAQ below on using running Windows on a Mac). One port will be used to program and communicate with your PIC microcontroller, and the other will be used for your portable oscilloscope.
: '''Reading''':
* Download and install the Microchip software described on [[Getting_Started_with_MPLAB | this page]]. This free software will allow you to program your PIC microcontroller. '''Update, January 3, 2011:''' Here is information for [[Installing MPLAB X Beta 4]], a cross-platform integrated development environment (IDE). This release is still missing some functionality as compared to Windows-only MPLAB 8.x, especially with respect to the simulator and debugger.
: '''Assignment out''':
* Download and install [http://www.processing.org/download/ Processing], free software that will allow you to develop GUIs and communicate with your PIC microcontroller. (Make sure you download the Windows version, so you can program your PIC and interact with it through Processing under the same OS.)
* Download and install the "setup executable" version of the [http://www.ftdichip.com/Drivers/VCP.htm FTDI drivers] to allow your PC to communicate with your microcontroller through a serial port. (You can ignore the bug fix release.)
* Download and save [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY], a free terminal program (putty.exe) that will allow you to communicate with your microcontroller through the serial port. (You don't need to run PuTTY now, and can click "Cancel" if you happen to run it.)
* Make sure your laptop has Matlab installed.


'''Class 5''' (Th 1/19)
On the first day of class, January 4, you should come to class with your laptop, ready to use all of the software mentioned above, since we will use it on the first day of class. If you are unable to meet the checklist (and downloading and installing the software may take you an hour, so plan ahead), you will be asked to drop the course to make space for someone else.
: '''Assignment 1 due''': Handed out on Thurs 1/12. [[Media:Assignment1Solutions.pdf|Solutions]] ([[Media:lightbulbs.c|lightbulbs.c]]) (ave score: 16.4/20, stdev 4.2)
: '''Topic''': The PIC32 microcontroller hardware.
: '''Reading''': [[Media:PIC32Chapters.pdf|PIC 32 hardware handout]], Data Sheet, Reference Manual
: '''Assignment 2 out''': Complete the questions at the end of the reading. Solutions must be submitted by blackboard at [https://courses.northwestern.edu/webapps/login/ Blackboard] by 11 AM Thurs 1/26. The name of your zip file should be Lastname_Firstname_a2.zip. You will also demo your NUscope and PIC32 in class on 1/26.


'''Class 6''' (T 1/24)
== Student Contract ==
: '''Quiz''': On the topic of Assignment 1, particularly Section 1.1 and Sections 1.2.5-1.2.8 of the CCC document [[Media:Quiz_2_soln.pdf|(Solutions)]]. (ave score: 5.6/7, stdev 1.8)
: '''Topic''': virtual and physical memory, NU32 board, beginning PIC32 programming, digital I/O SFRs
: '''Reading''': [[Media:PIC32_Ref_Man_Sec_12_IO_Ports.pdf|PIC32 Family Reference Manual Section 12, I/O Ports]]. This version is clearer than the current version on Microchip's website. We will discuss [[Media:Simple_pic2.c|this simple PIC program]]. Also, [[NU32: A Detailed Look at Programming the PIC32 on the NU32]].


'''Class 7''' (Th 1/26)
By signing up for this course, you agree to complete the checklist above before the course starts. You understand that ME 333 is being revised extensively, and there will be some uncertainties as the curriculum and equipment are ironed out. You understand that learning from classmates is encouraged, up to the stage of conceptualizing solutions. You understand that copying assignment solutions and program code plagiarism is not tolerated. You will report instances of code plagiarism you are aware of. Code plagiarism includes, but is not limited to:
: '''Assignment 2 due''': Handed out on Thurs 1/19. [[Media:Assignment2Solutions.pdf|Solutions]] (ave score: 21.8/25; stdev 4.8)
: '''Topic''': Continue analyzing the Simple_pic.c program.
: '''Reading''': Continued from previous class.
: '''Assignment 3 out''': [[Media:Assignment3v2.pdf|Investigating the PIC C32 Tool Suite (v2)]]


'''Class 8''' (T 1/31)
* Allowing another student to copy your code.
: '''Quiz''': On the topic of Assignment 2. [[Media:ME333_2012_quiz3_solns.c|Solutions; average 6.93/8, stdev 1.63]]
* Copying another student's code, in whole or in part.
: '''Topic''': CPU: core timer and and interrupts.
* Transforming copied sections of code to try to disguise their origin.
: '''Reading''': A reading on [[Media:PIC32Chapters.pdf|PIC32 software and interrupts]] and some [[Media:core_timer_tester.c|code for working with the core timer and interrupts]].
* Borrowing code from others not in the course, e.g., code found on the internet, without attribution. Borrowing code found on the internet is acceptable if the source is clearly indicated in your code comments.


'''Class 9''' (Th 2/2)
On our part (faculty and TA), we commit to do our best to provide you a curriculum and set of experimental materials to get you up to speed on sophisticated mechatronics integration as quickly and efficiently as possible, while giving you a foundation in concepts needed to go further in future projects and courses.
: '''Assignment 3 due''': Handed out on Thurs 1/26. [[Media:Assignment3Solutions.pdf|Solutions]], ave: 27.7/33, stdev 7.8
: '''Topic''': Interrupts, cont.
: '''Reading''': Updated version of [[Media:PIC32Chapters.pdf|PIC32 software and interrupts]] (the section on interrupts has been completed), [[Media:SampleCode6-1.c|sample code 6.1]], [[Media:SampleCode6-2.c|sample code 6.2]]
: '''Assignment 4 out''': [[Media:HW4_Interrupts_and_Programming.zip|Assignment 4 on Interrupts]] The assignment is described in the pdf included with the zip file. Solutions must be uploaded to [https://courses.northwestern.edu/webapps/login/ Blackboard] by Thursday, February 9 at 11:00AM.


'''Class 10''' (T 2/7)
== Prerequisite ==
: '''Quiz''': On the topic of Assignment 3. [[Media:ME333_2012_quiz4_solns2.c|Solutions; average 4.67/6, stdev 1.37]]
: '''Topic''': Digital I/O, counter/timers, and output compare (PWM).
: '''Reading''': [[Media:PIC32Chapters.pdf|Chapters on digital input and output, timers, and output compare]].


'''Class 11''' (Th 2/9)
ME 233 Analog and Digital Electronics or similar (EECS 221, 225) is required. You will be expected to analyze circuits with resistors, capacitors, inductors, diodes, transistors, and op-amps on the first day of class. There will be a quiz on this material on the second day of class, but you are on your own to prepare for it. To see if you have the right background, or if you will need to freshen up before the quarter starts, do the practice problem set on [[ME_333_Circuits_Review_Material|this page]].
: '''Assignment 4 due''': Handed out on Thurs 2/2. [[Media:Assignment4Solutionsv2.zip|Solutions]]
: '''Topic''': RC LPF (and its Bode plot) of PWM for analog output; analog input; LED and phototransistor pairs; PID control and integer math; analog input example.
: '''Reading''': [[Media:PIC32Chapters.pdf|Chapter on analog input]].


'''Class 12''' (T 2/14)
: '''Quiz''': On the topic of Assignment 4. [[Media:ME333_2012_quiz5_solns.txt|Solutions]] (average 5.57/7, stdev 2.0)
: '''Topic''': Sensors, op amp circuits for signal conditioning.
: '''Reading''': [[Sensor Overview]], [[Rotary Encoder]], [[Operational Amplifiers (Op-Amps)|wiki page on op amps]], [http://en.wikipedia.org/wiki/Operational_amplifier_applications wikipedia page on op amps]
: '''Assignment 5 out''': [[Media:ME333_winter2012_Assignment5.pdf|Simple real-time control with the PIC32]] Note that if you do not get the entire assignment done, you can turn in screenshots from your NUScope demonstrating the tasks that you did accomplish. If you do this, in the filenames, clearly indicate which section the image corresponds to.


'''Class 13''' (Th 2/16)
== FAQ ==
: '''Topic''': DSP: digital filtering, FIR, IIR, FFT, iFFT.
: '''Reading''': [http://www.falstad.com/dfilter/directions.html A cool digital filter applet]. Background material (not required): [http://www.dspguide.com/pdfbook.htm Chapters 14-17, on FIR filters, of this pdf book], and these wikipedia pages on [http://en.wikipedia.org/wiki/Low-pass_filter low-pass filters], [http://en.wikipedia.org/wiki/Fir_filter FIR filters], [http://en.wikipedia.org/wiki/Iir_filter IIR filters], and [http://en.wikipedia.org/wiki/Fast_fourier_transform FFT].


'''Class 14''' (T 2/21)
Q: Do I need to know the C language to take this course?
: '''Assignment 5 due''': Handed out on Tues 2/14. [[Media:Assignment5Solutions.pdf|Solutions]] ([[Media:MyProjectCode.zip|MyProject Code]])
: '''Topic''': DSP (continued).
: '''Reading''': [[Media:PIC32Chapters.pdf|Chapter 11 on DSP]].
: '''Assignment 6 out''': [[Media:Asst6.zip|Introduction to Digital Filtering with the PIC32]].


'''Class 15''' (Th 2/23)
A: No. If you already know C, there is still plenty else in this course for you. If you already know C, know how to use microcontrollers for real-time control, and have a good understanding how common sensors and actuators work and how to interface to them, this course may not be for you. Consider taking ME 433 Advanced Mechatronics in the spring quarter.
: '''Quiz''': On the topic of Assignment 5. [[Media:ME333_2012_quiz6_solns.txt|Solutions]] (average 5.5/7, stdev 1.65)
: '''Topic''': Brushed DC motor theory.
: '''Reading''': [[Media:PIC32Chapters.pdf|Chapter 12 on brushed DC motors]].


'''Class 16''' (T 2/28)
: '''Assignment 6 due''': Handed out on Tues 2/21.
: '''Topic''': In-class DC motor characterization.
: '''Reading''': [[Media:PIC32Chapters.pdf|Chapter 12 on brushed DC motors]].
: '''Assignment 7 out''': Motor characterization and the three problems at the end of Chapter 12.


'''Class 17''' (Th 3/1)
Q: Is there any independent project at all?
: '''Quiz''': On the topic of Assignment 6. You should be able to recognize the magnitude responses of the different kinds of filters, understand the impulse response of an FIR filter, understand the axes of a filter magnitude response, and understand the axes of the FFT magnitude plot (e.g., Nyquist frequency and the frequency spacing between components). [[Media:ME333_2012_quiz7_solns.txt|Solutions]] (average score 5.8/7, stdev 1.56)
: '''Topic''': DC motor control.
: '''Reading''': [[Media:PIC32Chapters.pdf|Chapter 14 on DC motor control]] (updated 3/1/2012).


'''Class 18''' (T 3/6)
A: There is no large independent project. There may be a small two-week project at the end of the course, but there will be no machining. For a significant project, do a quarter-long project in ME 433 Advanced Mechatronics, offered in the spring quarter. ME 333 is good preparation for ME 433.
: '''Assignment 7 due''': Handed out on Tues 2/28. [[Media:MotorDataSheet.pdf|Solutions]]
: '''Quiz''': On the topic of Assignment 7. You should know Chapter 12.1-12.4. [[Media:ME333_2012_quiz8_solns.txt|Solutions]] (average 5.0/8, stdev 2.1)
: '''Topic''': Work on final demo. You should have built three circuits as indicated in email (H-bridge, current sensor, encoder reading) before class.
: '''Final demo assignment''': Demos on 3/12 and 3/14. [[Media:FinalProjectV2.zip|Final ProjectV2]] ('''Version 2.0 of the code should allow you to open port 0 from the TerminalV2 executable. Follow the steps in this pdf to test your setup: [[Media:TestingTerminalV2.pdf|TestingTerminalV2.pdf]]. If you are having problems with TerminalV2, please contact the TAs ASAP.''')


'''Class 19''' (Th 3/8)
: '''Topic''': Time permitting: steppers and RC servos; gearing, inertia and torque, motor sizing and selection.
: '''Reading''': [[Media:PIC32Chapters.pdf|Chapter 15 on steppers and RC servos]], [[Media:PIC32Chapters.pdf|Chapter 13 on gearing and motor sizing]].


'''Final Demo''': Monday 3/12, 3-5 PM and Wednesday 3/14, 9-11 AM. See email to sign up for a time.
Q: Do I need a PC laptop, or is a Mac fine? Any other requirements?


== FAQ ==
A: You need a laptop with 2 USB ports, and you need to be able to run a Windows OS. The Microchip MPLAB Integrated Development Environment runs only on Windows operating systems:


Q: Do I need to know the C language to take this course?
[http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469 http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469]


A: No. But if you already know C, there is still plenty else in this course for you. If you already know C, know how to use microcontrollers for real-time control, and have a good understanding how common sensors and actuators work and how to interface to them, this course may not be for you. Consider taking ME 433 Advanced Mechatronics in the spring quarter.
I use a Mac with VirtualBox (free) to run Windows (which you have to pay for). You can get a full version of Windows 7 Pro using the Microsoft Student Deal for $64.95; see


[http://www.it.northwestern.edu/software/microsoft/ http://www.it.northwestern.edu/software/microsoft/]


Q: Is there an independent project?
[http://www.microsoft.com/student/en/us/software/windows/default.aspx http://www.microsoft.com/student/en/us/software/windows/default.aspx]


A: There is no large independent project. There will be an individual two-week project at the end of the course, but there will be no machining. For a significant project, do a quarter-long project in ME 433 Advanced Mechatronics, offered in the spring quarter. ME 333 is good preparation for ME 433.
You can get a wide variety of Windows software by becoming a student member of the IEEE for $32; see

[http://www.ieee.org/membership_services/membership/students/students_software.html http://www.ieee.org/membership_services/membership/students/students_software.html]




Q: What kind of laptop do I need?


A: You need a laptop with at least 2 USB ports. Any operating system is fine.


== ME 333 Winter 2010 (obsolete) ==
== ME 333 Winter 2010 (obsolete) ==
Line 136: Line 246:
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]



[[NU32v2: A Detailed Look at Programming the PIC32]]

Latest revision as of 20:20, 27 November 2012

Winter Quarter 2012

(Here is an Archive of Winter 2011)

First day of class is Thursday Jan 5!

  • Section 20: Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5
  • Section 21: Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5
  • TAs: Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu
  • Circuits Review Session: Mon Jan 9, 7 PM, Prof. Lynch, Tech L221; Wed Jan 11, 7 PM, Prof. Marchuk, Tech L221
  • C Peer Instruction Sessions, 7-8:30 PM, Seeley-Mudd Engineering Library Room 230
    • Thurs Jan 12
    • Tues Jan 17
    • Wed Jan 18
  • Final demo (in lieu of final exam): Monday March 12 3-5 PM and Wed March 14 9-11 AM in LR5.
  • Office Hours:
    • Mon 4-6 PM: Jarvis Schultz, Mechatronics Lab, Ford B100
    • Tues 2-3 PM: Prof. Lynch, B221
    • Wed 3-5 PM: Nelson Rosa, Mechatronics Lab, Ford B100
    • Thurs 3-4 PM: Prof. Lynch, B221
    • Fri 3-4 PM: Prof. Marchuk, Mechatronics Lab, Ford B100
    • Mon-Fri 4-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100


Checklist to Complete Before the First Day of Class

Attendance at the first day of class (Thursday Jan 5) is mandatory. By the first day of class, you should:

  • Be able to solve circuit problems similar to those on the practice problem set and last year's quiz at the bottom of this page. Be prepared for a quiz on this material in the second week of class. We will only spend one class period reviewing this material.
  • Have a laptop with at least 2 USB ports. Any operating system is fine. One port will be used to program and communicate with your PIC microcontroller, and the other will be used for your portable oscilloscope.
  • Buy your class kit here. If you already have the oscilloscope and multimeter from this year's ME 233 offering, you should choose "ME 333 (w/o ME 233 equipment)" for the price of $75. If you do not have the oscilloscope and multimeter, you should choose "ME 333 (w/ ME 233 equipment)" for the price of $135. You will not be able to start the course until you have completed the purchase of your kit. If you decide to drop the course, you will be refunded the purchase price upon return of all the equipment in working shape.
  • If you are not already comfortable with the C language, or if you do not already have a C compiler installed on your laptop, this step is recommended before the first day of class. This will give you a headstart on learning C. If you don't complete this before the first day of class, you will need to do it before the second class. Download and install the GCC GNU compiler collection and the Netbeans IDE (Integrated Development Environment) following the instructions here. Verify that you can compile and run the sample programs at the end of that page. Read the comments in invest.c to find references to the Crash Course in C document and answer the questions to learn more about C. If you have problems installing a C compiler and running the programs, then you can still get a headstart before the first class by focusing on reading the C programs and the Crash Course in C manual to understand how they work.

Student Contract

By signing up for this course, you agree to complete the checklist above before the course starts. You understand that learning from classmates is encouraged, up to the stage of conceptualizing solutions. You understand that copying assignment solutions and program code plagiarism is not tolerated. You will report instances of code plagiarism you are aware of. Code plagiarism includes, but is not limited to:

  • Allowing another student to copy your code.
  • Copying another student's code, in whole or in part.
  • Transforming copied sections of code to try to disguise their origin.
  • Borrowing code from others not in the course, e.g., code found on the internet, without attribution. Borrowing code found on the internet is acceptable if the source is clearly indicated in your code comments.

On our part (faculty and TAs), we commit to do our best to provide you a curriculum and set of experimental materials to get you up to speed on sophisticated mechatronics integration as quickly and efficiently as possible, while giving you a foundation in concepts needed to go further in future projects and courses.

Prerequisite

ME 233 Electronics Design or similar (EECS 221, 225) is required. You will be expected to analyze circuits with resistors, capacitors, inductors, diodes, transistors, and op-amps on the first day of class. There will be a quiz on this material on the third day of class, but you are on your own to prepare for it, apart from one review class and some night review sessions. To see if you have the right background, or if you will need to freshen up before the quarter starts, do the practice problem set and the 2011 quiz on this page.

Reading

Required:

(Essential C is also a very nice intro to C)

  • handouts associated with individual classes
  • wiki info on Microchip PICs
  • PIC32 Data Sheet (256 pages, 5 MB pdf)
  • PIC32 Family Reference Manual, by chapter. Lots of useful and detailed information on the PIC32 architecture and how the peripherals work, including detailed description of their SFRs. Only certain parts of certain chapters will be assigned.
  • The old version of the PIC32 Family Reference Manual has many more pages than the chapter-by-chapter version linked above. It includes quite a lot of example code. Be warned though, Microchip was not very careful when writing the sample code; some of it contains syntax errors, or values in registers that are incorrect. Even with this being the case, this is still a very useful document.
  • PIC32MX Peripheral Library (included as a .chm file under "Program Files\Microchip\MPLAB C32\doc" with your C32 compiler installation)

Useful, but not required:

Grading

Grades will be approximately 40% quizzes and 60% assignments (including the final project). We will have short quizzes once a week at the beginning of class covering material on the previous assignment. Bring a sheet of paper you can turn in with your quiz answers. (Your lowest quiz score and homework score will be dropped.) We will have a final project and demo in lieu of a final exam.

All quizzes and assignments have equal weight, regardless of how many points they are graded out of. If one homework is graded out of 20 points, and the next out of 40, the formula for calculating your grade for these two assignments would be 0.5*(score1/20) + 0.5*(score2/40).

Homework Submission

All homework will be submitted on Blackboard. Here are a few guidelines/ tips associated with homework submissions:

  • We expect the required files for each assignment to be compressed together in a zip file (no rar files).
  • When asked to submit C code for a given programming assignment, we are only concerned with receiving the relevant source files i.e. all *.c and *.h files. We do not want entire NetBeans/MPLAB X projects or executables/object files.
  • When writing your responses, please follow any instructions on how to write your response. For example, if we ask for a snippet of code, please do not submit your entire C program with header files and a main routine. We typically are only expecting a few lines of code that solves the problem.
  • When submitting written responses, we prefer PDF files, but will accept word documents (.doc, .docx), .txt, and .rtf files.
  • It helps both us and you if you format your code nicely. Clean looking code is easier for us to grade and easier for you to debug. Both NetBeans and MPLAB X (as well as other good editors) have tools for auto-formatting code. For example, highlighting a region and hitting Alt+Shift+f (Linux and Windows) will format that region according to your local formatting preferences.
  • When you compile your code (by clicking the hammer in NetBeans/MPLAB X), the output window in the IDE shows any compiler warnings. Pay attention to these! They are there for a reason. You should be able to eventually get your code to produce no warnings. Often if a piece of code is not working, the warnings will give a clue as to why. Note that in "project properties" in both IDEs, it is possible to generate "Additional warnings." This tells your compiler to be more strict about the rules of C. The better you adhere to these rules, the more likely it is that your code will compile.

Approximate Syllabus

ME 333 focuses on three topics: (1) general C programming; (2) Microchip PIC microcontroller architecture and C programming specific to the PIC (e.g., using the PIC's peripherals, such as analog inputs, digital I/O, counters/timers, comm ports, etc.); and (3) interfacing the PIC to sensors and actuators, some theory of sensor and actuator operation, and interface circuitry and signal processing.

You will bring your laptop to each class. As the quarter progresses, we will be handing out other equipment that you will need to bring to class, such as the NU32 development board that breaks out the PIC32MX795F512L microcontroller.

Topics we will cover include:

  • introduction to C programming (here's a simple tutorial C program)
  • quiz on circuits
  • introduction to the PIC32 hardware, and programming the PIC32 in C
  • digital I/O
  • counters/timers and interrupts
  • analog input
  • sensor smorgasbord
  • digital signal processing: filters and FFTs
  • analog output and pulse-width modulation
  • brushed permanent magnet DC motors: theory and control
  • stepper motors and RC servo motors
  • communication by SPI, I2C, and RS-232

Sample Code for ME 333

By class (note: DS = Data Sheet, RM = Reference Manual):

Class 1 (Th 1/5)

Quiz: None.
Topic: Course overview. Circuits review.
Reading: Practice problem set and quiz on this page, as well as background reading as needed.
Assignment out: If you do not already have a C compiler, install a C compiler following the instructions here. For all students: compile and run the tutorial code here and begin to understand it.

Class 2 (T 1/10)

Quiz: None.
Topic: Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling and linking).
Reading: Sample program, A Crash Course in C (section numbers referenced in program comments).

Class 3 (Th 1/12)

Quiz: Circuits. (Solutions; high score 45/46, average 33.4, stdev 7.8)
Topic: Introduction to C (syntax). We will compile and run programs together in this class, so bring your laptop with your installed C compiler and IDE.
Reading: Continue with sample program, A Crash Course in C (section numbers referenced in program comments).
Assignment 1 out: Problems 1-6 and 9 of A Crash Course in C (v0.2 of Thurs, Jan 12). Due by electronic submission by 11 AM Thurs 1/19. Solutions to problems 1-6 must be typed. Place these solutions, plus your .c file from the programming assignment (problem 9), in a .zip file and submit the zip file through Blackboard. The name of your zip file should be Lastname_Firstname_a1.zip. You will also demonstrate your program in class on Thurs 1/19. For full credit, you must follow these instructions exactly.

Class 4 (T 1/17)

Topic: Introduction to C (syntax).
Reading:
Assignment out:

Class 5 (Th 1/19)

Assignment 1 due: Handed out on Thurs 1/12. Solutions (lightbulbs.c) (ave score: 16.4/20, stdev 4.2)
Topic: The PIC32 microcontroller hardware.
Reading: PIC 32 hardware handout, Data Sheet, Reference Manual
Assignment 2 out: Complete the questions at the end of the reading. Solutions must be submitted by blackboard at Blackboard by 11 AM Thurs 1/26. The name of your zip file should be Lastname_Firstname_a2.zip. You will also demo your NUscope and PIC32 in class on 1/26.

Class 6 (T 1/24)

Quiz: On the topic of Assignment 1, particularly Section 1.1 and Sections 1.2.5-1.2.8 of the CCC document (Solutions). (ave score: 5.6/7, stdev 1.8)
Topic: virtual and physical memory, NU32 board, beginning PIC32 programming, digital I/O SFRs
Reading: PIC32 Family Reference Manual Section 12, I/O Ports. This version is clearer than the current version on Microchip's website. We will discuss this simple PIC program. Also, NU32: A Detailed Look at Programming the PIC32 on the NU32.

Class 7 (Th 1/26)

Assignment 2 due: Handed out on Thurs 1/19. Solutions (ave score: 21.8/25; stdev 4.8)
Topic: Continue analyzing the Simple_pic.c program.
Reading: Continued from previous class.
Assignment 3 out: Investigating the PIC C32 Tool Suite (v2)

Class 8 (T 1/31)

Quiz: On the topic of Assignment 2. Solutions; average 6.93/8, stdev 1.63
Topic: CPU: core timer and and interrupts.
Reading: A reading on PIC32 software and interrupts and some code for working with the core timer and interrupts.

Class 9 (Th 2/2)

Assignment 3 due: Handed out on Thurs 1/26. Solutions, ave: 27.7/33, stdev 7.8
Topic: Interrupts, cont.
Reading: Updated version of PIC32 software and interrupts (the section on interrupts has been completed), sample code 6.1, sample code 6.2
Assignment 4 out: Assignment 4 on Interrupts The assignment is described in the pdf included with the zip file. Solutions must be uploaded to Blackboard by Thursday, February 9 at 11:00AM.

Class 10 (T 2/7)

Quiz: On the topic of Assignment 3. Solutions; average 4.67/6, stdev 1.37
Topic: Digital I/O, counter/timers, and output compare (PWM).
Reading: Chapters on digital input and output, timers, and output compare.

Class 11 (Th 2/9)

Assignment 4 due: Handed out on Thurs 2/2. Solutions
Topic: RC LPF (and its Bode plot) of PWM for analog output; analog input; LED and phototransistor pairs; PID control and integer math; analog input example.
Reading: Chapter on analog input.

Class 12 (T 2/14)

Quiz: On the topic of Assignment 4. Solutions (average 5.57/7, stdev 2.0)
Topic: Sensors, op amp circuits for signal conditioning.
Reading: Sensor Overview, Rotary Encoder, wiki page on op amps, wikipedia page on op amps
Assignment 5 out: Simple real-time control with the PIC32 Note that if you do not get the entire assignment done, you can turn in screenshots from your NUScope demonstrating the tasks that you did accomplish. If you do this, in the filenames, clearly indicate which section the image corresponds to.

Class 13 (Th 2/16)

Topic: DSP: digital filtering, FIR, IIR, FFT, iFFT.
Reading: A cool digital filter applet. Background material (not required): Chapters 14-17, on FIR filters, of this pdf book, and these wikipedia pages on low-pass filters, FIR filters, IIR filters, and FFT.

Class 14 (T 2/21)

Assignment 5 due: Handed out on Tues 2/14. Solutions (MyProject Code)
Topic: DSP (continued).
Reading: Chapter 11 on DSP.
Assignment 6 out: Introduction to Digital Filtering with the PIC32.

Class 15 (Th 2/23)

Quiz: On the topic of Assignment 5. Solutions (average 5.5/7, stdev 1.65)
Topic: Brushed DC motor theory.
Reading: Chapter 12 on brushed DC motors.

Class 16 (T 2/28)

Assignment 6 due: Handed out on Tues 2/21.
Topic: In-class DC motor characterization.
Reading: Chapter 12 on brushed DC motors.
Assignment 7 out: Motor characterization and the three problems at the end of Chapter 12.

Class 17 (Th 3/1)

Quiz: On the topic of Assignment 6. You should be able to recognize the magnitude responses of the different kinds of filters, understand the impulse response of an FIR filter, understand the axes of a filter magnitude response, and understand the axes of the FFT magnitude plot (e.g., Nyquist frequency and the frequency spacing between components). Solutions (average score 5.8/7, stdev 1.56)
Topic: DC motor control.
Reading: Chapter 14 on DC motor control (updated 3/1/2012).

Class 18 (T 3/6)

Assignment 7 due: Handed out on Tues 2/28. Solutions
Quiz: On the topic of Assignment 7. You should know Chapter 12.1-12.4. Solutions (average 5.0/8, stdev 2.1)
Topic: Work on final demo. You should have built three circuits as indicated in email (H-bridge, current sensor, encoder reading) before class.
Final demo assignment: Demos on 3/12 and 3/14. Final ProjectV2 (Version 2.0 of the code should allow you to open port 0 from the TerminalV2 executable. Follow the steps in this pdf to test your setup: TestingTerminalV2.pdf. If you are having problems with TerminalV2, please contact the TAs ASAP.)

Class 19 (Th 3/8)

Topic: Time permitting: steppers and RC servos; gearing, inertia and torque, motor sizing and selection.
Reading: Chapter 15 on steppers and RC servos, Chapter 13 on gearing and motor sizing.

Final Demo: Monday 3/12, 3-5 PM and Wednesday 3/14, 9-11 AM. See email to sign up for a time.

FAQ

Q: Do I need to know the C language to take this course?

A: No. But if you already know C, there is still plenty else in this course for you. If you already know C, know how to use microcontrollers for real-time control, and have a good understanding how common sensors and actuators work and how to interface to them, this course may not be for you. Consider taking ME 433 Advanced Mechatronics in the spring quarter.


Q: Is there an independent project?

A: There is no large independent project. There will be an individual two-week project at the end of the course, but there will be no machining. For a significant project, do a quarter-long project in ME 433 Advanced Mechatronics, offered in the spring quarter. ME 333 is good preparation for ME 433.


Q: What kind of laptop do I need?

A: You need a laptop with at least 2 USB ports. Any operating system is fine.

ME 333 Winter 2010 (obsolete)


NU32v2: A Detailed Look at Programming the PIC32