<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://hades.mech.northwestern.edu//api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JarvisSchultz</id>
	<title>Mech - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://hades.mech.northwestern.edu//api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JarvisSchultz"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php/Special:Contributions/JarvisSchultz"/>
	<updated>2026-04-22T04:13:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.9</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=V-REP_Introduction&amp;diff=24048</id>
		<title>V-REP Introduction</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=V-REP_Introduction&amp;diff=24048"/>
		<updated>2016-10-26T19:56:46Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Switching Between Scenes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== V-REP Introduction ==&lt;br /&gt;
&lt;br /&gt;
On [http://www.coppeliarobotics.com/index.html V-REP&amp;#039;s homepage] the program is described as&lt;br /&gt;
&lt;br /&gt;
   ...the Swiss army knife among robot simulators: you won&amp;#039;t find a simulator with more functions, features, or more elaborate APIs.&lt;br /&gt;
&lt;br /&gt;
V-REP&amp;#039;s strength comes from several features:&lt;br /&gt;
&lt;br /&gt;
# V-REP provides a unified framework combining many powerful internal and external libraries that are often useful for robotics simulations. This includes dynamic simulation engines, forward/inverse kinematics tools, collision detection libraries, vision sensor simulations, path planning, GUI development tools, and built-in models of many common robots.&lt;br /&gt;
# V-REP is highly extensible. V-REP developers provide an API that allows one to write custom plugins that add new features. You can embed [https://en.wikipedia.org/wiki/Lua_(programming_language) Lua] scripts directly into a simulation scene that, for example, process simulated sensor data, run control algorithms, implement user interfaces, or even send data to a physical robot. They also provide a remote API that allows one to develop standalone applications in many programming languages that are able to pass data in and out of a running V-REP simulation.&lt;br /&gt;
# V-REP is cross-platform, mostly open-source, and provides a free educational license.&lt;br /&gt;
&lt;br /&gt;
The purpose of this page is not to teach you how to use V-REP. Rather it is to&lt;br /&gt;
describe demonstration scenes that have been developed to help&lt;br /&gt;
visualize robot arm kinematics. If you are interested in learning more about&lt;br /&gt;
V-REP, check out the [[#Useful Resources|Useful Resources]] section below.&lt;br /&gt;
&lt;br /&gt;
== Demonstration V-REP Scenes ==&lt;br /&gt;
&lt;br /&gt;
To run either of the scenes below, the first step will be to [http://www.coppeliarobotics.com/downloads.html download V-REP] for your operating system. You should download the latest Non-limited EDUCATIONAL version. Next you will have to install V-REP. On Windows, you simply have an EXE that installs V-REP. On a Mac, you first need to unzip the download. The directory that is produced by unzipping the download contains a &amp;lt;code&amp;gt;vrep.app&amp;lt;/code&amp;gt; directory that should allow you start V-REP through normal mechanisms, e.g., Finder/Spotlight/Launchpad. On Linux, you will need to extract the compressed tar archive (e.g., using a command like &amp;lt;code&amp;gt;tar xvf V-REP_PRO_EDU_V3_3_2_64_Linux.tar.gz&amp;lt;/code&amp;gt;). Then you need to change directories into the V-REP source directory and run the &amp;lt;code&amp;gt;vrep.sh&amp;lt;/code&amp;gt; shell script.&lt;br /&gt;
&lt;br /&gt;
Once V-REP is open you will want to run one of the scenes below. To run either of them, you first run V-REP, then you click &amp;lt;code&amp;gt;File-&amp;gt;Open scene...&amp;lt;/code&amp;gt; and open one of the ttt files that are linked below. Then click either the &amp;#039;&amp;#039;Play&amp;#039;&amp;#039; button from the top toolbar or click &amp;lt;code&amp;gt;Simulation-&amp;gt;Start simulation&amp;lt;/code&amp;gt; and a GUI should pop up. Clicking the &amp;#039;&amp;#039;Stop&amp;#039;&amp;#039; button or &amp;lt;code&amp;gt;Simulation-&amp;gt;Stop simulation&amp;lt;/code&amp;gt; will close the GUI and stop the simulation.&lt;br /&gt;
&lt;br /&gt;
The scenes below are implemented similarly. They both feature a simulation of a kinematically-controlled, non-respondable [https://www.universal-robots.com/products/ur5-robot/ UR5 robot] from [https://www.universal-robots.com/ Universal Robots]. &amp;#039;&amp;#039;Kinematically controlled&amp;#039;&amp;#039; means that all dynamics (inertias, torques, friction, etc.) of the system are neglected. We can specify a set of joint angles and the simulation is capable of instantaneously &amp;quot;teleporting&amp;quot; the robot to be at the new set of joint angles. &amp;#039;&amp;#039;Non-respondable&amp;#039;&amp;#039; means that the links of the robot are not capable of interacting with the world or each other through collisions. In other words, we can put the robot in configurations that result in self-collisions, but the simulation will ignore the collisions. The physical UR5 robot features 6 joints each with 720 degrees of rotation, and this simulated robot has the same joints and limits. The model of the UR5 in each of the scenes was created by importing a URDF from the ROS-Industrial [https://github.com/ros-industrial/universal_robot/tree/indigo-devel/ur_description/urdf ur5_description package].&lt;br /&gt;
&lt;br /&gt;
In each scene, there is a single Lua script called a [http://www.coppeliarobotics.com/helpFiles/en/childScripts.htm Non-threaded child script]. When the scene is first run, there is a function that is called that sets up the GUI and creates variables that are going to be needed later on in the simulation. Then during every step of the simulation the [http://www.coppeliarobotics.com/helpFiles/en/mainScript.htm main script], which is part of every V-REP scene, runs an &amp;quot;actuation&amp;quot; function from the child script. This actuation function is responsible for processing all of the changes to the GUI since the last time it was called (buttons clicked, label updates, etc.), and for sending joint commands to the simulated robot. Technically, there is also a &amp;quot;sensing&amp;quot; function in the child script that gets called by the main script, but in each of these demos, the sensing function is empty. The GUIs are both built with V-REP&amp;#039;s [http://www.coppeliarobotics.com/helpFiles/en/customUIPlugin.htm Qt-based custom UI framework].&lt;br /&gt;
&lt;br /&gt;
=== Scene 1:  Interactive UR5 ===&lt;br /&gt;
&lt;br /&gt;
In this demo, the GUI features two tabs. One tab lets you drag sliders to modify the joint angles of each joint, and the other tab allows you to specify comma-separated angles for all 6 joints in an editable text box and ask for the &amp;lt;math&amp;gt;SE(3)&amp;lt;/math&amp;gt; transformation from the base frame to the end-effector frame. (&amp;#039;&amp;#039;&amp;#039;Note&amp;#039;&amp;#039;&amp;#039;:  You have to click the &amp;quot;Calculate SE(3) Transform&amp;quot; button to see the transformation.)  The frames attached to the base and end-effector are persistently displayed (x-axis in red, y-axis in green, z-axis in blue). Note that all angles are specified in radians.&lt;br /&gt;
&lt;br /&gt;
* Download the ttt scene file here: [[Media:UR5_imported_interactive.ttt]]&lt;br /&gt;
&lt;br /&gt;
=== Scene 2:  CSV Animation UR5 ===&lt;br /&gt;
&lt;br /&gt;
This demo allows you to specify a CSV file containing a trajectory of joint angles, and then animate this trajectory. Each column of the CSV file is the joint angle through time for one of the joints (first column is joint 1, last column is joint 6). In other words, a single row of the CSV file represents a complete configuration of the robot at a particular time. The assumed timestep between rows is equal to the timestep that V-REP uses for simulation; the default is 0.05 seconds. Note that will need to provide a complete path to your CSV file. Alternatively, you may be able to provide a relative path, but you&amp;#039;ll need to figure out what V-REP uses as its base directory on your OS. On Linux, this directory is the root directory of the V-REP source code. If you figure out this directory, you could also move your CSV files to be in this directory and just reference them by name without specifying the path at all.  A typical path on the Mac is something like &amp;lt;code&amp;gt;/Users/kevin/yourdirectoryname/example.csv&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
* Download the ttt scene file here: [[Media:UR5_imported_csvplayer.ttt]]&lt;br /&gt;
* Download an example csv file here: [[Media:UR5_example_jointstates.csv]]&lt;br /&gt;
&lt;br /&gt;
=== Switching Between Scenes ===&lt;br /&gt;
&lt;br /&gt;
Press the &amp;#039;&amp;#039;Stop&amp;#039;&amp;#039; button to stop the simulation of the current scene, then choose &amp;lt;code&amp;gt;File&amp;gt;Open scene...&amp;lt;/code&amp;gt;.  You can also use &amp;lt;code&amp;gt;File&amp;gt;Open recent scene&amp;lt;/code&amp;gt; to switch to a scene you previously loaded.  Then you press the &amp;#039;&amp;#039;Play&amp;#039;&amp;#039; button to run the scene. Alternatively, stop the simulation and then press the &amp;lt;code&amp;gt;Scenes&amp;lt;/code&amp;gt; button in the top toolbar to see which scenes are currently open and select one to be in the foreground. The scene selector toolbar button may also be used to switch between opened scenes. Read more [http://www.coppeliarobotics.com/helpFiles/en/scenes.htm here]&lt;br /&gt;
&lt;br /&gt;
=== Exploring Other Scenes ===&lt;br /&gt;
&lt;br /&gt;
You are encouraged to explore some of the (quite impressive) scenes that come pre-loaded with V-REP.  You can find these scenes in the &amp;lt;code&amp;gt;scenes&amp;lt;/code&amp;gt; directory under the V-REP directory.  Running and studying these can be a great way to learn more about the V-REP capabilities and to understand how to put together more complex scenes.&lt;br /&gt;
&lt;br /&gt;
== Useful Resources ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.coppeliarobotics.com/v-repOverviewPresentation.pdf V-REP Overview Presentation]&lt;br /&gt;
* [http://www.coppeliarobotics.com/videos.html V-REP Videos Page]&lt;br /&gt;
* [http://www.coppeliarobotics.com/helpFiles/en/tutorials.htm V-REP Tutorial Series]&lt;br /&gt;
* [http://www.coppeliarobotics.com/features.html Overview of V-REP Features]&lt;br /&gt;
* [http://www.coppeliarobotics.com/helpFiles/en/apiOverview.htm V-REP API Documentation] These are all functions that can either be called directly from a custom C/C++ plugin or through a Lua embedded script.&lt;br /&gt;
* [http://www.coppeliarobotics.com/helpFiles/en/remoteApiOverview.htm Remote API Documentation] The Remote API is how V-REP enables scripts and programs written in other languages (MATLAB, Java, Python, etc.) to interact with a V-REP simulation&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Ur5_example_jointstates.csv&amp;diff=24021</id>
		<title>File:Ur5 example jointstates.csv</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Ur5_example_jointstates.csv&amp;diff=24021"/>
		<updated>2016-10-26T17:24:52Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Ur5_imported_csvplayer.ttt&amp;diff=24020</id>
		<title>File:Ur5 imported csvplayer.ttt</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Ur5_imported_csvplayer.ttt&amp;diff=24020"/>
		<updated>2016-10-26T17:24:08Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Ur5_imported_interactive.ttt&amp;diff=24017</id>
		<title>File:Ur5 imported interactive.ttt</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Ur5_imported_interactive.ttt&amp;diff=24017"/>
		<updated>2016-10-26T17:20:54Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=V-rep-intro&amp;diff=24012</id>
		<title>V-rep-intro</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=V-rep-intro&amp;diff=24012"/>
		<updated>2016-10-26T17:02:05Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: moved V-rep-intro to V-Rep Introduction&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[V-Rep Introduction]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:FinalDemo.zip&amp;diff=21198</id>
		<title>File:FinalDemo.zip</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:FinalDemo.zip&amp;diff=21198"/>
		<updated>2012-03-06T07:40:48Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: uploaded a new version of &amp;quot;Image:FinalDemo.zip&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21197</id>
		<title>ME 333 Introduction to Mechatronics (Archive Winter 2012)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21197"/>
		<updated>2012-03-06T07:31:48Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Approximate Syllabus */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Winter Quarter 2012&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
(Here is an [[ME 333 Introduction to Mechatronics (Archive Winter 2011)|Archive of Winter 2011]])&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;First day of class is Thursday Jan 5!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Section 20:  Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5&lt;br /&gt;
* Section 21:  Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5&lt;br /&gt;
* TAs:  Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu&lt;br /&gt;
* Circuits Review Session:  Mon Jan 9, 7 PM, Prof. Lynch, Tech L221; Wed Jan 11, 7 PM, Prof. Marchuk, Tech L221&lt;br /&gt;
* C Peer Instruction Sessions, 7-8:30 PM, Seeley-Mudd Engineering Library Room 230&lt;br /&gt;
** Thurs Jan 12&lt;br /&gt;
** Tues Jan 17&lt;br /&gt;
** Wed Jan 18&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Final demo&amp;#039;&amp;#039;&amp;#039; (in lieu of final exam):  11-12:20 section Wed March 14 9-11 AM; 12:30-1:50 section Monday March 12 3-5 PM&lt;br /&gt;
* Office Hours:  &lt;br /&gt;
** Mon 4-6 PM:  Jarvis Schultz, Mechatronics Lab, Ford B100&lt;br /&gt;
** Tues 2-3 PM:  Prof. Lynch, B221&lt;br /&gt;
** Wed 3-5 PM:  Nelson Rosa, Mechatronics Lab, Ford B100&lt;br /&gt;
**Thurs 3-4 PM:  Prof. Lynch, B221&lt;br /&gt;
** Fri 3-4 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
** Mon-Fri 4-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Checklist to Complete Before the First Day of Class ==&lt;br /&gt;
&lt;br /&gt;
Attendance at the first day of class (Thursday Jan 5) is mandatory.  By the first day of class, you should:&lt;br /&gt;
&lt;br /&gt;
* Be able to solve circuit problems similar to those on the practice problem set and last year&amp;#039;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.&lt;br /&gt;
* 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.  &lt;br /&gt;
* Buy your class kit [http://it.mccormick.northwestern.edu/matlab/student_license/login.php &amp;#039;&amp;#039;&amp;#039;here&amp;#039;&amp;#039;&amp;#039;].  If you already have the oscilloscope and multimeter from this year&amp;#039;s ME 233 offering, you should choose &amp;quot;ME 333 (w/o ME 233 equipment)&amp;quot; for the price of $75.  If you do not have the oscilloscope and multimeter, you should choose &amp;quot;ME 333 (w/ ME 233 equipment)&amp;quot; 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.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;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&amp;#039;t complete this before the first day of class, you will need to do it before the second class.&amp;#039;&amp;#039;&amp;#039;  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. &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;!-- * Download and install software described on [[NU32v2: Software to Install|this page]].  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Student Contract ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* Allowing another student to copy your code.&lt;br /&gt;
* Copying another student&amp;#039;s code, in whole or in part.&lt;br /&gt;
* Transforming copied sections of code to try to disguise their origin.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
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]].&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
&lt;br /&gt;
* [[Media:CrashCourseinC.pdf|A Crash Course in C]]:  A brief introduction to the C programming language &lt;br /&gt;
([[Media:EssentialC.pdf|Essential C]] is also a very nice intro to C)&lt;br /&gt;
* handouts associated with individual classes&lt;br /&gt;
* wiki info on [[Microchip PICs]]&lt;br /&gt;
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (256 pages, 5 MB pdf)&lt;br /&gt;
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;amp;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.&lt;br /&gt;
* 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.  &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;  Even with this being the case, this is still a very useful document.&lt;br /&gt;
* PIC32MX Peripheral Library (included as a .chm file under &amp;quot;Program Files\Microchip\MPLAB C32\doc&amp;quot; with your C32 compiler installation)&lt;br /&gt;
&lt;br /&gt;
Useful, but not required:&lt;br /&gt;
&lt;br /&gt;
* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1294091438&amp;amp;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.&lt;br /&gt;
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under &amp;quot;doc&amp;quot; of your C32 compiler installation&lt;br /&gt;
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]] of &amp;quot;The C Book,&amp;quot; and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1294091625&amp;amp;sr=1-1 C Programming Language] reference book by Kernighan and Ritchie&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
== Homework Submission ==&lt;br /&gt;
All homework will be submitted on Blackboard.  Here are a few guidelines/ tips associated with homework submissions:&lt;br /&gt;
* We expect the required files for each assignment to be compressed together in a zip file (no rar files).&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* When submitting written responses, we prefer PDF files, but will accept word documents (.doc, .docx), .txt, and .rtf files.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 &amp;quot;project properties&amp;quot; in both IDEs, it is possible to generate &amp;quot;Additional warnings.&amp;quot;  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.&lt;br /&gt;
&lt;br /&gt;
== Approximate Syllabus ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Topics we will cover include:&lt;br /&gt;
&lt;br /&gt;
* introduction to C programming (here&amp;#039;s a [[Media:invest.c|simple tutorial C program]])&lt;br /&gt;
* quiz on circuits&lt;br /&gt;
* introduction to the PIC32 hardware, and programming the PIC32 in C&lt;br /&gt;
* digital I/O&lt;br /&gt;
* counters/timers and interrupts&lt;br /&gt;
* analog input&lt;br /&gt;
* sensor smorgasbord&lt;br /&gt;
* digital signal processing:  filters and FFTs&lt;br /&gt;
* analog output and pulse-width modulation&lt;br /&gt;
* brushed permanent magnet DC motors:  theory and control&lt;br /&gt;
* stepper motors and RC servo motors&lt;br /&gt;
* communication by SPI, I2C, and RS-232&lt;br /&gt;
&lt;br /&gt;
[[ME333 Sample Code|&amp;#039;&amp;#039;&amp;#039;Sample Code for ME 333&amp;#039;&amp;#039;&amp;#039;]] &lt;br /&gt;
&lt;br /&gt;
By class (note:  DS = Data Sheet, RM = Reference Manual):&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 1&amp;#039;&amp;#039;&amp;#039; (Th 1/5)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Course overview.  Circuits review.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Practice problem set and quiz on [[ME_333_Circuits_Review_Material|this page]], as well as background reading as needed.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 2&amp;#039;&amp;#039;&amp;#039; (T 1/10)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling and linking).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:invest.c|Sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 3&amp;#039;&amp;#039;&amp;#039; (Th 1/12)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  Circuits.  ([[Media:ME333_Quiz1_2012_Solutions.pdf|Solutions]]; high score 45/46, average 33.4, stdev 7.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continue with [[Media:invest.c|sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 out&amp;#039;&amp;#039;&amp;#039;:  &amp;#039;&amp;#039;&amp;#039;Problems 1-6 and 9&amp;#039;&amp;#039;&amp;#039; 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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 4&amp;#039;&amp;#039;&amp;#039; (T 1/17)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (syntax).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 5&amp;#039;&amp;#039;&amp;#039; (Th 1/19)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/12. [[Media:Assignment1Solutions.pdf|Solutions]] ([[Media:lightbulbs.c|lightbulbs.c]]) (ave score:  16.4/20, stdev 4.2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  The PIC32 microcontroller hardware.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|PIC 32 hardware handout]], Data Sheet, Reference Manual&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 6&amp;#039;&amp;#039;&amp;#039; (T 1/24)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: 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)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  virtual and physical memory, NU32 board, beginning PIC32 programming, digital I/O SFRs&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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&amp;#039;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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 7&amp;#039;&amp;#039;&amp;#039; (Th 1/26)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/19. [[Media:Assignment2Solutions.pdf|Solutions]] (ave score:  21.8/25; stdev 4.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Continue analyzing the Simple_pic.c program.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 out&amp;#039;&amp;#039;&amp;#039;: [[Media:Assignment3v2.pdf|Investigating the PIC C32 Tool Suite (v2)]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 8&amp;#039;&amp;#039;&amp;#039; (T 1/31)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 2.  [[Media:ME333_2012_quiz3_solns.c|Solutions; average 6.93/8, stdev 1.63]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: CPU:  core timer and and interrupts.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 9&amp;#039;&amp;#039;&amp;#039; (Th 2/2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 1/26. [[Media:Assignment3Solutions.pdf|Solutions]], ave: 27.7/33, stdev 7.8&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: Interrupts, cont.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 out&amp;#039;&amp;#039;&amp;#039;: [[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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 10&amp;#039;&amp;#039;&amp;#039; (T 2/7)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 3.  [[Media:ME333_2012_quiz4_solns2.c|Solutions; average 4.67/6, stdev 1.37]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Digital I/O, counter/timers, and output compare (PWM).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapters on digital input and output, timers, and output compare]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 11&amp;#039;&amp;#039;&amp;#039; (Th 2/9)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/2. [[Media:Assignment4Solutionsv2.zip|Solutions]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: 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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapter on analog input]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 12&amp;#039;&amp;#039;&amp;#039; (T 2/14)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 4.  [[Media:ME333_2012_quiz5_solns.txt|Solutions]] (average 5.57/7, stdev 2.0)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Sensors, op amp circuits for signal conditioning.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 out&amp;#039;&amp;#039;&amp;#039;: [[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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 13&amp;#039;&amp;#039;&amp;#039; (Th 2/16)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DSP:  digital filtering, FIR, IIR, FFT, iFFT.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [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].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 14&amp;#039;&amp;#039;&amp;#039; (T 2/21)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Tues 2/14. [[Media:Assignment5Solutions.pdf|Solutions]] ([[Media:MyProjectCode.zip|MyProject Code]])&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DSP (continued).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapter 11 on DSP]].&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 out&amp;#039;&amp;#039;&amp;#039;:  [[Media:Asst6.zip|Introduction to Digital Filtering with the PIC32]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 15&amp;#039;&amp;#039;&amp;#039; (Th 2/23)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 5.  [[Media:ME333_2012_quiz6_solns.txt|Solutions]] (average 5.5/7, stdev 1.65)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Brushed DC motor theory.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapter 12 on brushed DC motors]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 16&amp;#039;&amp;#039;&amp;#039; (T 2/28)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Tues 2/21.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  In-class DC motor characterization.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:   [[Media:PIC32Chapters.pdf|Chapter 12 on brushed DC motors]].&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 out&amp;#039;&amp;#039;&amp;#039;:  Motor characterization and the three problems at the end of Chapter 12.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 17&amp;#039;&amp;#039;&amp;#039; (Th 3/1)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  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)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DC motor control.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapter 14 on DC motor control]] (updated 3/1/2012).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 18&amp;#039;&amp;#039;&amp;#039; (T 3/6)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Tues 2/28.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  On the topic of Assignment 7.  You should know Chapter 12.1-12.4. &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Work on final demo.  You should have built three circuits as indicated in email (H-bridge, current sensor, encoder reading) before class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Final demo assignment&amp;#039;&amp;#039;&amp;#039;:  Demos on 3/12 and 3/14. [[Media:FinalDemo.zip|Final Project Assignment and Starter Code]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 19&amp;#039;&amp;#039;&amp;#039; (Th 3/8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Time permitting:  steppers and RC servos; gearing, inertia and torque, motor sizing and selection.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[Media:PIC32Chapters.pdf|Chapter 15 on steppers and RC servos]], [[Media:PIC32Chapters.pdf|Chapter 13 on gearing and motor sizing]]. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Final Demo&amp;#039;&amp;#039;&amp;#039;:  Monday 3/12, 3-5 PM, for 12:30-1:50 section; Wednesday 3/14, 9-11 AM, for 11:00-12:20 section.  You can attend either demo session, but if everyone comes on Wednesday, we won&amp;#039;t have enough room to accommodate everyone.&lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
&lt;br /&gt;
Q: Do I need to know the C language to take this course?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: Is there an independent project?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: What kind of laptop do I need?&lt;br /&gt;
&lt;br /&gt;
A: You need a laptop with at least 2 USB ports.  Any operating system is fine.&lt;br /&gt;
&lt;br /&gt;
== ME 333 Winter 2010 (obsolete) ==&lt;br /&gt;
&lt;br /&gt;
* [[ME 333 Circuits Review Material]]&lt;br /&gt;
* [http://www.youtube.com/NUmechatronics NUmechatronics youtube channel]&lt;br /&gt;
* [[ME 333 final projects]]&lt;br /&gt;
* [[PCB Artist]]&lt;br /&gt;
* [[ME 333 Suggested Final Projects]]&lt;br /&gt;
* [[ME 333 end of course schedule]]&lt;br /&gt;
* [[ME 333 Lab Kits]]&lt;br /&gt;
* [[Processing]] (software allowing you to create GUIs on your PC and interface through your USB port)&lt;br /&gt;
* Labs from Winter 2010&lt;br /&gt;
** [[Getting Started with PIC32|ME 333 Lab 1:  Getting started with the PIC32]]&lt;br /&gt;
** [[ME 333 Lab 2]]&lt;br /&gt;
** [http://lims.mech.northwestern.edu/~lynch/courses/ME333/PIClabs/lab3/lab3.html ME 333 Lab 3]&lt;br /&gt;
** [[ME 333 Lab 4]]&lt;br /&gt;
** [[ME 333 Lab 5]]&lt;br /&gt;
* Ungraded study problems (be sure to attempt to solve the problems before looking at the solutions!)&lt;br /&gt;
** [[ME 333 Circuits Review Material]]&lt;br /&gt;
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]&lt;br /&gt;
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[NU32v2:  A Detailed Look at Programming the PIC32]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:FinalDemo.zip&amp;diff=21196</id>
		<title>File:FinalDemo.zip</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:FinalDemo.zip&amp;diff=21196"/>
		<updated>2012-03-06T07:30:40Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: uploaded a new version of &amp;quot;Image:FinalDemo.zip&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME333_Sample_Code&amp;diff=21118</id>
		<title>ME333 Sample Code</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME333_Sample_Code&amp;diff=21118"/>
		<updated>2012-02-23T17:42:41Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Simple PIC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:simplePIC.c|simplePIC.c]]: Flashes LEDs on the NU32 unless the USER button is pressed.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;NU32 library, header file, procdefs, and terminal comm test&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:NU32.c|NU32.c]]: NU32 board library.&lt;br /&gt;
* [[Media:NU32.h|NU32.h]]: NU32 header file.&lt;br /&gt;
* [[Media:procdefs.ld|procdefs.ld]]:  Linker file for NU32.&lt;br /&gt;
* [[Media:NU32_serial_comm.c|NU32_serial_comm.c]]:  Serial communication test with the terminal.&lt;br /&gt;
* [[Media:NU32_serial_plot.c|NU32_serial_plot.c]]:  Plot data with serial communication in NU32_Utility.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Analog to digital&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:ADC_Read2.c|ADC_Read2.c]]:  Reads two analog inputs repetitively and prints the results to the user&amp;#039;s terminal.&lt;br /&gt;
* [[Media:ADC_Read2_LCD.c|ADC_Read2_LCD.c]]  Reads two analog inputs repetitively and prints the results to the LCD.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Digital I/O&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:DIGIO_sfrs.c|DIGIO_sfrs.c]]:  Digital I/O and change notification using SFR manipulation.&lt;br /&gt;
* [[Media:DIGI0_plib.c|DIGIO_plib.c]]: Digital I/O and change notification using the peripheral library.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Interrupts&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:INT_core_timer.c|INT_core_timer.c]]:  Interrupt on core timer period match.&lt;br /&gt;
* [[Media:INT_ext_int.c|INT_ext_int.c]]:  Interrupt on rising edge of external interrupt line INT0. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;LCD code&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:LCD.c|LCD.c]]:  LCD library.&lt;br /&gt;
* [[Media:LCD.h|LCD.h]]:  LCD header file.&lt;br /&gt;
* [[Media:LCDtest.c|LCDtest.c]]:  Test program for LCD library.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Output compare (PWM)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:OC_PWM_nolib.c|OC_PWM_nolib.c]]:  Set up PWM by setting SFRs.&lt;br /&gt;
* [[Media:OC_PWM_lib.c|OC_PWM_lib.c]]:  Set up PWM using peripheral library functions.&lt;br /&gt;
* [[Media:OC_square_wave.c|OC_square_wave.c]]:  Alternate between two different PWM duty cycles at 1 Hz.  PWM is at 100 kHz and can be low-pass filtered to get a square wave analog output.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Counter/timer&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:TMR_16bit.c|TMR_16bit.c]]: Set up a 16-bit timer to count the PBCLK.&lt;br /&gt;
* [[Media:TMR_16bit_external_clocks.c|TMR_16bit_external_clocks.c]]:  Count two external clock sources, such as the A and B channel from a motor encoder.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DSP and FFT&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:DSP_sample_square_wave.zip|DSP_sample_square_wave.zip]]: Examples of FIR and FFT in both MATLAB and on the PIC32.&lt;br /&gt;
* [[Media:DSP_mips32_fft.zip|DSP_mips32_fft.zip]]: Example of using the Q31 mips library for FFT. Contains a C source file and a header file.&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:DSP_mips32_fft.zip&amp;diff=21117</id>
		<title>File:DSP mips32 fft.zip</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:DSP_mips32_fft.zip&amp;diff=21117"/>
		<updated>2012-02-23T17:41:32Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: Small sample source and header file showing an example of using the mips32_fft library.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Small sample source and header file showing an example of using the mips32_fft library.&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME333_Sample_Code&amp;diff=21114</id>
		<title>ME333 Sample Code</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME333_Sample_Code&amp;diff=21114"/>
		<updated>2012-02-23T04:37:53Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Simple PIC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:simplePIC.c|simplePIC.c]]: Flashes LEDs on the NU32 unless the USER button is pressed.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;NU32 library, header file, procdefs, and terminal comm test&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:NU32.c|NU32.c]]: NU32 board library.&lt;br /&gt;
* [[Media:NU32.h|NU32.h]]: NU32 header file.&lt;br /&gt;
* [[Media:procdefs.ld|procdefs.ld]]:  Linker file for NU32.&lt;br /&gt;
* [[Media:NU32_serial_comm.c|NU32_serial_comm.c]]:  Serial communication test with the terminal.&lt;br /&gt;
* [[Media:NU32_serial_plot.c|NU32_serial_plot.c]]:  Plot data with serial communication in NU32_Utility.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Analog to digital&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:ADC_Read2.c|ADC_Read2.c]]:  Reads two analog inputs repetitively and prints the results to the user&amp;#039;s terminal.&lt;br /&gt;
* [[Media:ADC_Read2_LCD.c|ADC_Read2_LCD.c]]  Reads two analog inputs repetitively and prints the results to the LCD.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Digital I/O&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:DIGIO_sfrs.c|DIGIO_sfrs.c]]:  Digital I/O and change notification using SFR manipulation.&lt;br /&gt;
* [[Media:DIGI0_plib.c|DIGIO_plib.c]]: Digital I/O and change notification using the peripheral library.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Interrupts&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:INT_core_timer.c|INT_core_timer.c]]:  Interrupt on core timer period match.&lt;br /&gt;
* [[Media:INT_ext_int.c|INT_ext_int.c]]:  Interrupt on rising edge of external interrupt line INT0. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;LCD code&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:LCD.c|LCD.c]]:  LCD library.&lt;br /&gt;
* [[Media:LCD.h|LCD.h]]:  LCD header file.&lt;br /&gt;
* [[Media:LCDtest.c|LCDtest.c]]:  Test program for LCD library.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Output compare (PWM)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:OC_PWM_nolib.c|OC_PWM_nolib.c]]:  Set up PWM by setting SFRs.&lt;br /&gt;
* [[Media:OC_PWM_lib.c|OC_PWM_lib.c]]:  Set up PWM using peripheral library functions.&lt;br /&gt;
* [[Media:OC_square_wave.c|OC_square_wave.c]]:  Alternate between two different PWM duty cycles at 1 Hz.  PWM is at 100 kHz and can be low-pass filtered to get a square wave analog output.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Counter/timer&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[Media:TMR_16bit.c|TMR_16bit.c]]: Set up a 16-bit timer to count the PBCLK.&lt;br /&gt;
* [[Media:TMR_16bit_external_clocks.c|TMR_16bit_external_clocks.c]]:  Count two external clock sources, such as the A and B channel from a motor encoder.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DSP and FFT&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:DSP_sample_square_wave.zip|DSP_sample_square_wave.zip]]: Examples of FIR and FFT in both MATLAB and on the PIC32.&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:DSP_sample_square_wave.zip&amp;diff=21113</id>
		<title>File:DSP sample square wave.zip</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:DSP_sample_square_wave.zip&amp;diff=21113"/>
		<updated>2012-02-23T04:35:25Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: A zip file containing some MATLAB code and some C code that demonstrates the use of the mips fixed-point library for DSP and FFT.  MATLAB is used to generate a header file containing a square wave, and the coefficients of a high-order FIR.  The FIR coeffi&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A zip file containing some MATLAB code and some C code that demonstrates the use of the mips fixed-point library for DSP and FFT.  MATLAB is used to generate a header file containing a square wave, and the coefficients of a high-order FIR.  The FIR coefficients are used to filter the square wave using the mips library, and the results are sent to the PIC via UART1.  MATLAB then generates plots comparing the PIC results and its own results.&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:ME333_winter2012_Assignment5.pdf&amp;diff=21070</id>
		<title>File:ME333 winter2012 Assignment5.pdf</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:ME333_winter2012_Assignment5.pdf&amp;diff=21070"/>
		<updated>2012-02-14T17:14:07Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: uploaded a new version of &amp;quot;Image:ME333 winter2012 Assignment5.pdf&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21069</id>
		<title>ME 333 Introduction to Mechatronics (Archive Winter 2012)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21069"/>
		<updated>2012-02-14T17:07:43Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Approximate Syllabus */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Winter Quarter 2012&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
(Here is an [[ME 333 Introduction to Mechatronics (Archive Winter 2011)|Archive of Winter 2011]])&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;First day of class is Thursday Jan 5!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Section 20:  Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5&lt;br /&gt;
* Section 21:  Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5&lt;br /&gt;
* TAs:  Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu&lt;br /&gt;
* Circuits Review Session:  Mon Jan 9, 7 PM, Prof. Lynch, Tech L221; Wed Jan 11, 7 PM, Prof. Marchuk, Tech L221&lt;br /&gt;
* C Peer Instruction Sessions, 7-8:30 PM, Seeley-Mudd Engineering Library Room 230&lt;br /&gt;
** Thurs Jan 12&lt;br /&gt;
** Tues Jan 17&lt;br /&gt;
** Wed Jan 18&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Final demo&amp;#039;&amp;#039;&amp;#039; (in lieu of final exam):  11-12:20 section Wed March 14 9-11 AM; 12:30-1:50 section Monday March 12 3-5 PM&lt;br /&gt;
* Office Hours:  &lt;br /&gt;
** Mon 4-6 PM:  Jarvis Schultz, Mechatronics Lab, Ford B100&lt;br /&gt;
** Tues 2-3 PM:  Prof. Lynch, B221&lt;br /&gt;
** Wed 3-5 PM:  Nelson Rosa, Mechatronics Lab, Ford B100&lt;br /&gt;
**Thurs 3-4 PM:  Prof. Lynch, B221&lt;br /&gt;
** Fri 3-4 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
** Mon-Fri 4-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Checklist to Complete Before the First Day of Class ==&lt;br /&gt;
&lt;br /&gt;
Attendance at the first day of class (Thursday Jan 5) is mandatory.  By the first day of class, you should:&lt;br /&gt;
&lt;br /&gt;
* Be able to solve circuit problems similar to those on the practice problem set and last year&amp;#039;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.&lt;br /&gt;
* 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.  &lt;br /&gt;
* Buy your class kit [http://it.mccormick.northwestern.edu/matlab/student_license/login.php &amp;#039;&amp;#039;&amp;#039;here&amp;#039;&amp;#039;&amp;#039;].  If you already have the oscilloscope and multimeter from this year&amp;#039;s ME 233 offering, you should choose &amp;quot;ME 333 (w/o ME 233 equipment)&amp;quot; for the price of $75.  If you do not have the oscilloscope and multimeter, you should choose &amp;quot;ME 333 (w/ ME 233 equipment)&amp;quot; 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.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;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&amp;#039;t complete this before the first day of class, you will need to do it before the second class.&amp;#039;&amp;#039;&amp;#039;  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. &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;!-- * Download and install software described on [[NU32v2: Software to Install|this page]].  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Student Contract ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* Allowing another student to copy your code.&lt;br /&gt;
* Copying another student&amp;#039;s code, in whole or in part.&lt;br /&gt;
* Transforming copied sections of code to try to disguise their origin.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
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]].&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
&lt;br /&gt;
* [[Media:CrashCourseinC.pdf|A Crash Course in C]]:  A brief introduction to the C programming language &lt;br /&gt;
([[Media:EssentialC.pdf|Essential C]] is also a very nice intro to C)&lt;br /&gt;
* handouts associated with individual classes&lt;br /&gt;
* wiki info on [[Microchip PICs]]&lt;br /&gt;
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (256 pages, 5 MB pdf)&lt;br /&gt;
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;amp;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.&lt;br /&gt;
* 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.  &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;  Even with this being the case, this is still a very useful document.&lt;br /&gt;
* PIC32MX Peripheral Library (included as a .chm file under &amp;quot;Program Files\Microchip\MPLAB C32\doc&amp;quot; with your C32 compiler installation)&lt;br /&gt;
&lt;br /&gt;
Useful, but not required:&lt;br /&gt;
&lt;br /&gt;
* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1294091438&amp;amp;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.&lt;br /&gt;
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under &amp;quot;doc&amp;quot; of your C32 compiler installation&lt;br /&gt;
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]] of &amp;quot;The C Book,&amp;quot; and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1294091625&amp;amp;sr=1-1 C Programming Language] reference book by Kernighan and Ritchie&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
== Homework Submission ==&lt;br /&gt;
All homework will be submitted on Blackboard.  Here are a few guidelines/ tips associated with homework submissions:&lt;br /&gt;
* We expect the required files for each assignment to be compressed together in a zip file (no rar files).&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* When submitting written responses, we prefer PDF files, but will accept word documents (.doc, .docx), .txt, and .rtf files.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 &amp;quot;project properties&amp;quot; in both IDEs, it is possible to generate &amp;quot;Additional warnings.&amp;quot;  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.&lt;br /&gt;
&lt;br /&gt;
== Approximate Syllabus ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Topics we will cover include:&lt;br /&gt;
&lt;br /&gt;
* introduction to C programming (here&amp;#039;s a [[Media:invest.c|simple tutorial C program]])&lt;br /&gt;
* quiz on circuits&lt;br /&gt;
* introduction to the PIC32 hardware, and programming the PIC32 in C&lt;br /&gt;
* digital I/O&lt;br /&gt;
* counters/timers and interrupts&lt;br /&gt;
* analog input&lt;br /&gt;
* sensor smorgasbord&lt;br /&gt;
* digital signal processing:  filters and FFTs&lt;br /&gt;
* analog output and pulse-width modulation&lt;br /&gt;
* brushed permanent magnet DC motors:  theory and control&lt;br /&gt;
* stepper motors and RC servo motors&lt;br /&gt;
* communication by SPI, I2C, and RS-232&lt;br /&gt;
&lt;br /&gt;
[[ME333 Sample Code|Sample Code for ME 333]] &lt;br /&gt;
&lt;br /&gt;
By class (note:  DS = Data Sheet, RM = Reference Manual):&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 1&amp;#039;&amp;#039;&amp;#039; (Th 1/5)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Course overview.  Circuits review.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Practice problem set and quiz on [[ME_333_Circuits_Review_Material|this page]], as well as background reading as needed.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 2&amp;#039;&amp;#039;&amp;#039; (T 1/10)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling and linking).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:invest.c|Sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 3&amp;#039;&amp;#039;&amp;#039; (Th 1/12)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  Circuits.  ([[Media:ME333_Quiz1_2012_Solutions.pdf|Solutions]]; high score 45/46, average 33.4, stdev 7.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continue with [[Media:invest.c|sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 out&amp;#039;&amp;#039;&amp;#039;:  &amp;#039;&amp;#039;&amp;#039;Problems 1-6 and 9&amp;#039;&amp;#039;&amp;#039; 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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 4&amp;#039;&amp;#039;&amp;#039; (T 1/17)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (syntax).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 5&amp;#039;&amp;#039;&amp;#039; (Th 1/19)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/12. [[Media:Assignment1Solutions.pdf|Solutions]] ([[Media:lightbulbs.c|lightbulbs.c]]) (ave score:  16.4/20, stdev 4.2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  The PIC32 microcontroller hardware.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|PIC 32 hardware handout]], Data Sheet, Reference Manual&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 6&amp;#039;&amp;#039;&amp;#039; (T 1/24)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: 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)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  virtual and physical memory, NU32 board, beginning PIC32 programming, digital I/O SFRs&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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&amp;#039;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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 7&amp;#039;&amp;#039;&amp;#039; (Th 1/26)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/19. [[Media:Assignment2Solutions.pdf|Solutions]] (ave score:  21.8/25; stdev 4.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Continue analyzing the Simple_pic.c program.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 out&amp;#039;&amp;#039;&amp;#039;: [[Media:Assignment3v2.pdf|Investigating the PIC C32 Tool Suite (v2)]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 8&amp;#039;&amp;#039;&amp;#039; (T 1/31)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 2.  [[Media:ME333_2012_quiz3_solns.c|Solutions; average 6.93/8, stdev 1.63]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: CPU:  core timer and and interrupts.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 9&amp;#039;&amp;#039;&amp;#039; (Th 2/2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 1/26. [[Media:Assignment3Solutions.pdf|Solutions]], ave: 27.7/33, stdev 7.8&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: Interrupts, cont.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 out&amp;#039;&amp;#039;&amp;#039;: [[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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 10&amp;#039;&amp;#039;&amp;#039; (T 2/7)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 3.  [[Media:ME333_2012_quiz4_solns2.c|Solutions; average 4.67/6, stdev 1.37]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Digital I/O, counter/timers, and output compare (PWM).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapters on digital input and output, timers, and output compare]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 11&amp;#039;&amp;#039;&amp;#039; (Th 2/9)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/2. [[Media:Assignment4Solutionsv2.zip|Solutions]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: 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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapter on analog input]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 12&amp;#039;&amp;#039;&amp;#039; (T 2/14)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 4.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Sensors, op amp circuits for signal conditioning.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 out&amp;#039;&amp;#039;&amp;#039;: [[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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 13&amp;#039;&amp;#039;&amp;#039; (Th 2/16)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DSP:  digital filtering, FIR, IIR, FFT, iFFT.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [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].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 14&amp;#039;&amp;#039;&amp;#039; (T 2/21)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Tues 2/14.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Brushed DC motor theory.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[Brushed DC Motor Theory]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 out&amp;#039;&amp;#039;&amp;#039;:  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 15&amp;#039;&amp;#039;&amp;#039; (Th 2/23)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 5.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DC motors.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 16&amp;#039;&amp;#039;&amp;#039; (T 2/28)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Tues 2/21.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Gearing, inertia and torque, motor sizing and selection&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Choosing a Motor and Gearing Combination]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 out&amp;#039;&amp;#039;&amp;#039;: &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 17&amp;#039;&amp;#039;&amp;#039; (Th 3/1)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  On the topic of Assignment 6.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Stepper motors and RC servo motors.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  From previous versions of the NU32 board:  [[PIC32MX: Driving a Stepper Motor]], [[PIC32MX: Servo Control]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 18&amp;#039;&amp;#039;&amp;#039; (T 3/6)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Tues 2/28.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Serial communication.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Final demo assignment&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 19&amp;#039;&amp;#039;&amp;#039; (Th 3/8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;&amp;#039;:  On the topic of Assignment 7.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Wrapup.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Final Demo&amp;#039;&amp;#039;&amp;#039;:  Monday 3/12, 3-5 PM, for 12:30-1:50 section; Wednesday 3/14, 9-11 AM, for 11:00-12:20 section.  You can attend either demo session, but if everyone comes on Wednesday, we won&amp;#039;t have enough room to accommodate everyone.&lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
&lt;br /&gt;
Q: Do I need to know the C language to take this course?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: Is there an independent project?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: What kind of laptop do I need?&lt;br /&gt;
&lt;br /&gt;
A: You need a laptop with at least 2 USB ports.  Any operating system is fine.&lt;br /&gt;
&lt;br /&gt;
== ME 333 Winter 2010 (obsolete) ==&lt;br /&gt;
&lt;br /&gt;
* [[ME 333 Circuits Review Material]]&lt;br /&gt;
* [http://www.youtube.com/NUmechatronics NUmechatronics youtube channel]&lt;br /&gt;
* [[ME 333 final projects]]&lt;br /&gt;
* [[PCB Artist]]&lt;br /&gt;
* [[ME 333 Suggested Final Projects]]&lt;br /&gt;
* [[ME 333 end of course schedule]]&lt;br /&gt;
* [[ME 333 Lab Kits]]&lt;br /&gt;
* [[Processing]] (software allowing you to create GUIs on your PC and interface through your USB port)&lt;br /&gt;
* Labs from Winter 2010&lt;br /&gt;
** [[Getting Started with PIC32|ME 333 Lab 1:  Getting started with the PIC32]]&lt;br /&gt;
** [[ME 333 Lab 2]]&lt;br /&gt;
** [http://lims.mech.northwestern.edu/~lynch/courses/ME333/PIClabs/lab3/lab3.html ME 333 Lab 3]&lt;br /&gt;
** [[ME 333 Lab 4]]&lt;br /&gt;
** [[ME 333 Lab 5]]&lt;br /&gt;
* Ungraded study problems (be sure to attempt to solve the problems before looking at the solutions!)&lt;br /&gt;
** [[ME 333 Circuits Review Material]]&lt;br /&gt;
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]&lt;br /&gt;
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[NU32v2:  A Detailed Look at Programming the PIC32]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:ME333_winter2012_Assignment5.pdf&amp;diff=21066</id>
		<title>File:ME333 winter2012 Assignment5.pdf</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:ME333_winter2012_Assignment5.pdf&amp;diff=21066"/>
		<updated>2012-02-14T16:54:07Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: uploaded a new version of &amp;quot;Image:ME333 winter2012 Assignment5.pdf&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21065</id>
		<title>ME 333 Introduction to Mechatronics (Archive Winter 2012)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21065"/>
		<updated>2012-02-14T16:35:39Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Approximate Syllabus */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Winter Quarter 2012&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
(Here is an [[ME 333 Introduction to Mechatronics (Archive Winter 2011)|Archive of Winter 2011]])&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;First day of class is Thursday Jan 5!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Section 20:  Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5&lt;br /&gt;
* Section 21:  Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5&lt;br /&gt;
* TAs:  Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu&lt;br /&gt;
* Circuits Review Session:  Mon Jan 9, 7 PM, Prof. Lynch, Tech L221; Wed Jan 11, 7 PM, Prof. Marchuk, Tech L221&lt;br /&gt;
* C Peer Instruction Sessions, 7-8:30 PM, Seeley-Mudd Engineering Library Room 230&lt;br /&gt;
** Thurs Jan 12&lt;br /&gt;
** Tues Jan 17&lt;br /&gt;
** Wed Jan 18&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Final demo&amp;#039;&amp;#039;&amp;#039; (in lieu of final exam):  11-12:20 section Wed March 14 9-11 AM; 12:30-1:50 section Monday March 12 3-5 PM&lt;br /&gt;
* Office Hours:  &lt;br /&gt;
** Mon 4-6 PM:  Jarvis Schultz, Mechatronics Lab, Ford B100&lt;br /&gt;
** Tues 2-3 PM:  Prof. Lynch, B221&lt;br /&gt;
** Wed 3-5 PM:  Nelson Rosa, Mechatronics Lab, Ford B100&lt;br /&gt;
**Thurs 3-4 PM:  Prof. Lynch, B221&lt;br /&gt;
** Fri 3-4 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
** Mon-Fri 4-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Checklist to Complete Before the First Day of Class ==&lt;br /&gt;
&lt;br /&gt;
Attendance at the first day of class (Thursday Jan 5) is mandatory.  By the first day of class, you should:&lt;br /&gt;
&lt;br /&gt;
* Be able to solve circuit problems similar to those on the practice problem set and last year&amp;#039;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.&lt;br /&gt;
* 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.  &lt;br /&gt;
* Buy your class kit [http://it.mccormick.northwestern.edu/matlab/student_license/login.php &amp;#039;&amp;#039;&amp;#039;here&amp;#039;&amp;#039;&amp;#039;].  If you already have the oscilloscope and multimeter from this year&amp;#039;s ME 233 offering, you should choose &amp;quot;ME 333 (w/o ME 233 equipment)&amp;quot; for the price of $75.  If you do not have the oscilloscope and multimeter, you should choose &amp;quot;ME 333 (w/ ME 233 equipment)&amp;quot; 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.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;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&amp;#039;t complete this before the first day of class, you will need to do it before the second class.&amp;#039;&amp;#039;&amp;#039;  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. &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;!-- * Download and install software described on [[NU32v2: Software to Install|this page]].  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Student Contract ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* Allowing another student to copy your code.&lt;br /&gt;
* Copying another student&amp;#039;s code, in whole or in part.&lt;br /&gt;
* Transforming copied sections of code to try to disguise their origin.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
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]].&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
&lt;br /&gt;
* [[Media:CrashCourseinC.pdf|A Crash Course in C]]:  A brief introduction to the C programming language &lt;br /&gt;
([[Media:EssentialC.pdf|Essential C]] is also a very nice intro to C)&lt;br /&gt;
* handouts associated with individual classes&lt;br /&gt;
* wiki info on [[Microchip PICs]]&lt;br /&gt;
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (256 pages, 5 MB pdf)&lt;br /&gt;
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;amp;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.&lt;br /&gt;
* 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.  &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;  Even with this being the case, this is still a very useful document.&lt;br /&gt;
* PIC32MX Peripheral Library (included as a .chm file under &amp;quot;Program Files\Microchip\MPLAB C32\doc&amp;quot; with your C32 compiler installation)&lt;br /&gt;
&lt;br /&gt;
Useful, but not required:&lt;br /&gt;
&lt;br /&gt;
* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1294091438&amp;amp;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.&lt;br /&gt;
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under &amp;quot;doc&amp;quot; of your C32 compiler installation&lt;br /&gt;
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]] of &amp;quot;The C Book,&amp;quot; and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1294091625&amp;amp;sr=1-1 C Programming Language] reference book by Kernighan and Ritchie&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
== Homework Submission ==&lt;br /&gt;
All homework will be submitted on Blackboard.  Here are a few guidelines/ tips associated with homework submissions:&lt;br /&gt;
* We expect the required files for each assignment to be compressed together in a zip file (no rar files).&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* When submitting written responses, we prefer PDF files, but will accept word documents (.doc, .docx), .txt, and .rtf files.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 &amp;quot;project properties&amp;quot; in both IDEs, it is possible to generate &amp;quot;Additional warnings.&amp;quot;  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.&lt;br /&gt;
&lt;br /&gt;
== Approximate Syllabus ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Topics we will cover include:&lt;br /&gt;
&lt;br /&gt;
* introduction to C programming (here&amp;#039;s a [[Media:invest.c|simple tutorial C program]])&lt;br /&gt;
* quiz on circuits&lt;br /&gt;
* introduction to the PIC32 hardware, and programming the PIC32 in C&lt;br /&gt;
* digital I/O&lt;br /&gt;
* counters/timers and interrupts&lt;br /&gt;
* analog input&lt;br /&gt;
* sensor smorgasbord&lt;br /&gt;
* digital signal processing:  filters and FFTs&lt;br /&gt;
* analog output and pulse-width modulation&lt;br /&gt;
* brushed permanent magnet DC motors:  theory and control&lt;br /&gt;
* stepper motors and RC servo motors&lt;br /&gt;
* communication by SPI, I2C, and RS-232&lt;br /&gt;
&lt;br /&gt;
[[ME333 Sample Code|Sample Code for ME 333]] &lt;br /&gt;
&lt;br /&gt;
By class (note:  DS = Data Sheet, RM = Reference Manual):&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 1&amp;#039;&amp;#039;&amp;#039; (Th 1/5)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Course overview.  Circuits review.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Practice problem set and quiz on [[ME_333_Circuits_Review_Material|this page]], as well as background reading as needed.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 2&amp;#039;&amp;#039;&amp;#039; (T 1/10)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling and linking).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:invest.c|Sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 3&amp;#039;&amp;#039;&amp;#039; (Th 1/12)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  Circuits.  ([[Media:ME333_Quiz1_2012_Solutions.pdf|Solutions]]; high score 45/46, average 33.4, stdev 7.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continue with [[Media:invest.c|sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 out&amp;#039;&amp;#039;&amp;#039;:  &amp;#039;&amp;#039;&amp;#039;Problems 1-6 and 9&amp;#039;&amp;#039;&amp;#039; 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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 4&amp;#039;&amp;#039;&amp;#039; (T 1/17)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (syntax).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 5&amp;#039;&amp;#039;&amp;#039; (Th 1/19)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/12. [[Media:Assignment1Solutions.pdf|Solutions]] ([[Media:lightbulbs.c|lightbulbs.c]]) (ave score:  16.4/20, stdev 4.2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  The PIC32 microcontroller hardware.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|PIC 32 hardware handout]], Data Sheet, Reference Manual&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 6&amp;#039;&amp;#039;&amp;#039; (T 1/24)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: 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)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  virtual and physical memory, NU32 board, beginning PIC32 programming, digital I/O SFRs&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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&amp;#039;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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 7&amp;#039;&amp;#039;&amp;#039; (Th 1/26)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/19. [[Media:Assignment2Solutions.pdf|Solutions]] (ave score:  21.8/25; stdev 4.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Continue analyzing the Simple_pic.c program.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 out&amp;#039;&amp;#039;&amp;#039;: [[Media:Assignment3v2.pdf|Investigating the PIC C32 Tool Suite (v2)]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 8&amp;#039;&amp;#039;&amp;#039; (T 1/31)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 2.  [[Media:ME333_2012_quiz3_solns.c|Solutions; average 6.93/8, stdev 1.63]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: CPU:  core timer and and interrupts.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 9&amp;#039;&amp;#039;&amp;#039; (Th 2/2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 1/26. [[Media:Assignment3Solutions.pdf|Solutions]], ave: 27.7/33, stdev 7.8&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: Interrupts, cont.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 out&amp;#039;&amp;#039;&amp;#039;: [[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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 10&amp;#039;&amp;#039;&amp;#039; (T 2/7)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 3.  [[Media:ME333_2012_quiz4_solns2.c|Solutions; average 4.67/6, stdev 1.37]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Digital I/O, counter/timers, and output compare (PWM).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapters on digital input and output, timers, and output compare]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 11&amp;#039;&amp;#039;&amp;#039; (Th 2/9)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/2. [[Media:Assignment4Solutionsv2.zip|Solutions]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: 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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapter on analog input]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 12&amp;#039;&amp;#039;&amp;#039; (T 2/14)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 4.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Sensors, op amp circuits for signal conditioning.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 out&amp;#039;&amp;#039;&amp;#039;: [[Media:ME333_winter2012_Assignment5.pdf|Simple real-time control with the PIC32]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 13&amp;#039;&amp;#039;&amp;#039; (Th 2/16)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DSP:  digital filtering, FFT, iFFT.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [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].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 14&amp;#039;&amp;#039;&amp;#039; (T 2/21)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/9.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Brushed DC motor theory.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[Brushed DC Motor Theory]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 out&amp;#039;&amp;#039;&amp;#039;:  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 15&amp;#039;&amp;#039;&amp;#039; (Th 2/23)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 5.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DC motors.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 16&amp;#039;&amp;#039;&amp;#039; (T 2/28)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Tues 2/21.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Gearing, inertia and torque, motor sizing and selection&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Choosing a Motor and Gearing Combination]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 out&amp;#039;&amp;#039;&amp;#039;: &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 17&amp;#039;&amp;#039;&amp;#039; (Th 3/1)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  On the topic of Assignment 6.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Stepper motors and RC servo motors.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  From previous versions of the NU32 board:  [[PIC32MX: Driving a Stepper Motor]], [[PIC32MX: Servo Control]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 18&amp;#039;&amp;#039;&amp;#039; (T 3/6)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Tues 2/28.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Serial communication.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Final demo assignment&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 19&amp;#039;&amp;#039;&amp;#039; (Th 3/8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;&amp;#039;:  On the topic of Assignment 7.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Wrapup.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Final Demo&amp;#039;&amp;#039;&amp;#039;:  Monday 3/12, 3-5 PM, for 12:30-1:50 section; Wednesday 3/14, 9-11 AM, for 11:00-12:20 section.  You can attend either demo session, but if everyone comes on Wednesday, we won&amp;#039;t have enough room to accommodate everyone.&lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
&lt;br /&gt;
Q: Do I need to know the C language to take this course?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: Is there an independent project?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: What kind of laptop do I need?&lt;br /&gt;
&lt;br /&gt;
A: You need a laptop with at least 2 USB ports.  Any operating system is fine.&lt;br /&gt;
&lt;br /&gt;
== ME 333 Winter 2010 (obsolete) ==&lt;br /&gt;
&lt;br /&gt;
* [[ME 333 Circuits Review Material]]&lt;br /&gt;
* [http://www.youtube.com/NUmechatronics NUmechatronics youtube channel]&lt;br /&gt;
* [[ME 333 final projects]]&lt;br /&gt;
* [[PCB Artist]]&lt;br /&gt;
* [[ME 333 Suggested Final Projects]]&lt;br /&gt;
* [[ME 333 end of course schedule]]&lt;br /&gt;
* [[ME 333 Lab Kits]]&lt;br /&gt;
* [[Processing]] (software allowing you to create GUIs on your PC and interface through your USB port)&lt;br /&gt;
* Labs from Winter 2010&lt;br /&gt;
** [[Getting Started with PIC32|ME 333 Lab 1:  Getting started with the PIC32]]&lt;br /&gt;
** [[ME 333 Lab 2]]&lt;br /&gt;
** [http://lims.mech.northwestern.edu/~lynch/courses/ME333/PIClabs/lab3/lab3.html ME 333 Lab 3]&lt;br /&gt;
** [[ME 333 Lab 4]]&lt;br /&gt;
** [[ME 333 Lab 5]]&lt;br /&gt;
* Ungraded study problems (be sure to attempt to solve the problems before looking at the solutions!)&lt;br /&gt;
** [[ME 333 Circuits Review Material]]&lt;br /&gt;
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]&lt;br /&gt;
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[NU32v2:  A Detailed Look at Programming the PIC32]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:ME333_winter2012_Assignment5.pdf&amp;diff=21064</id>
		<title>File:ME333 winter2012 Assignment5.pdf</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:ME333_winter2012_Assignment5.pdf&amp;diff=21064"/>
		<updated>2012-02-14T16:33:12Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21045</id>
		<title>ME 333 Introduction to Mechatronics (Archive Winter 2012)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21045"/>
		<updated>2012-02-09T17:36:26Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Reading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Winter Quarter 2012&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
(Here is an [[ME 333 Introduction to Mechatronics (Archive Winter 2011)|Archive of Winter 2011]])&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;First day of class is Thursday Jan 5!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Section 20:  Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5&lt;br /&gt;
* Section 21:  Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5&lt;br /&gt;
* TAs:  Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu&lt;br /&gt;
* Circuits Review Session:  Mon Jan 9, 7 PM, Prof. Lynch, Tech L221; Wed Jan 11, 7 PM, Prof. Marchuk, Tech L221&lt;br /&gt;
* C Peer Instruction Sessions, 7-8:30 PM, Seeley-Mudd Engineering Library Room 230&lt;br /&gt;
** Thurs Jan 12&lt;br /&gt;
** Tues Jan 17&lt;br /&gt;
** Wed Jan 18&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Final demo&amp;#039;&amp;#039;&amp;#039; (in lieu of final exam):  11-12:20 section Wed March 14 9-11 AM; 12:30-1:50 section Monday March 12 3-5 PM&lt;br /&gt;
* Office Hours:  &lt;br /&gt;
** Mon 4-6 PM:  Jarvis Schultz, Mechatronics Lab, Ford B100&lt;br /&gt;
** Tues 2-3 PM:  Prof. Lynch, B221&lt;br /&gt;
** Wed 3-5 PM:  Nelson Rosa, Mechatronics Lab, Ford B100&lt;br /&gt;
**Thurs 3-4 PM:  Prof. Lynch, B221&lt;br /&gt;
** Fri 3-4 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
** Mon-Fri 4-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Checklist to Complete Before the First Day of Class ==&lt;br /&gt;
&lt;br /&gt;
Attendance at the first day of class (Thursday Jan 5) is mandatory.  By the first day of class, you should:&lt;br /&gt;
&lt;br /&gt;
* Be able to solve circuit problems similar to those on the practice problem set and last year&amp;#039;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.&lt;br /&gt;
* 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.  &lt;br /&gt;
* Buy your class kit [http://it.mccormick.northwestern.edu/matlab/student_license/login.php &amp;#039;&amp;#039;&amp;#039;here&amp;#039;&amp;#039;&amp;#039;].  If you already have the oscilloscope and multimeter from this year&amp;#039;s ME 233 offering, you should choose &amp;quot;ME 333 (w/o ME 233 equipment)&amp;quot; for the price of $75.  If you do not have the oscilloscope and multimeter, you should choose &amp;quot;ME 333 (w/ ME 233 equipment)&amp;quot; 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.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;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&amp;#039;t complete this before the first day of class, you will need to do it before the second class.&amp;#039;&amp;#039;&amp;#039;  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. &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;!-- * Download and install software described on [[NU32v2: Software to Install|this page]].  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Student Contract ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* Allowing another student to copy your code.&lt;br /&gt;
* Copying another student&amp;#039;s code, in whole or in part.&lt;br /&gt;
* Transforming copied sections of code to try to disguise their origin.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
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]].&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
&lt;br /&gt;
* [[Media:CrashCourseinC.pdf|A Crash Course in C]]:  A brief introduction to the C programming language &lt;br /&gt;
([[Media:EssentialC.pdf|Essential C]] is also a very nice intro to C)&lt;br /&gt;
* handouts associated with individual classes&lt;br /&gt;
* wiki info on [[Microchip PICs]]&lt;br /&gt;
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (256 pages, 5 MB pdf)&lt;br /&gt;
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;amp;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.&lt;br /&gt;
* 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.  &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;  Even with this being the case, this is still a very useful document.&lt;br /&gt;
* PIC32MX Peripheral Library (included as a .chm file under &amp;quot;Program Files\Microchip\MPLAB C32\doc&amp;quot; with your C32 compiler installation)&lt;br /&gt;
&lt;br /&gt;
Useful, but not required:&lt;br /&gt;
&lt;br /&gt;
* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1294091438&amp;amp;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.&lt;br /&gt;
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under &amp;quot;doc&amp;quot; of your C32 compiler installation&lt;br /&gt;
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]] of &amp;quot;The C Book,&amp;quot; and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1294091625&amp;amp;sr=1-1 C Programming Language] reference book by Kernighan and Ritchie&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
== Homework Submission ==&lt;br /&gt;
All homework will be submitted on Blackboard.  Here are a few guidelines/ tips associated with homework submissions:&lt;br /&gt;
* We expect the required files for each assignment to be compressed together in a zip file (no rar files).&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* When submitting written responses, we prefer PDF files, but will accept word documents (.doc, .docx), .txt, and .rtf files.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 &amp;quot;project properties&amp;quot; in both IDEs, it is possible to generate &amp;quot;Additional warnings.&amp;quot;  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.&lt;br /&gt;
&lt;br /&gt;
== Approximate Syllabus ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Topics we will cover include:&lt;br /&gt;
&lt;br /&gt;
* introduction to C programming (here&amp;#039;s a [[Media:invest.c|simple tutorial C program]])&lt;br /&gt;
* quiz on circuits&lt;br /&gt;
* introduction to the PIC32 hardware, and programming the PIC32 in C&lt;br /&gt;
* digital I/O&lt;br /&gt;
* counters/timers and interrupts&lt;br /&gt;
* analog input&lt;br /&gt;
* sensor smorgasbord&lt;br /&gt;
* digital signal processing:  filters and FFTs&lt;br /&gt;
* analog output and pulse-width modulation&lt;br /&gt;
* brushed permanent magnet DC motors:  theory and control&lt;br /&gt;
* stepper motors and RC servo motors&lt;br /&gt;
* communication by SPI, I2C, and RS-232&lt;br /&gt;
&lt;br /&gt;
[[ME333 Sample Code|Sample Code for ME 333]] &lt;br /&gt;
&lt;br /&gt;
By class (note:  DS = Data Sheet, RM = Reference Manual):&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 1&amp;#039;&amp;#039;&amp;#039; (Th 1/5)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Course overview.  Circuits review.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Practice problem set and quiz on [[ME_333_Circuits_Review_Material|this page]], as well as background reading as needed.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 2&amp;#039;&amp;#039;&amp;#039; (T 1/10)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling and linking).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:invest.c|Sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 3&amp;#039;&amp;#039;&amp;#039; (Th 1/12)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  Circuits.  ([[Media:ME333_Quiz1_2012_Solutions.pdf|Solutions]]; high score 45/46, average 33.4, stdev 7.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continue with [[Media:invest.c|sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 out&amp;#039;&amp;#039;&amp;#039;:  &amp;#039;&amp;#039;&amp;#039;Problems 1-6 and 9&amp;#039;&amp;#039;&amp;#039; 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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 4&amp;#039;&amp;#039;&amp;#039; (T 1/17)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (syntax).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 5&amp;#039;&amp;#039;&amp;#039; (Th 1/19)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/12. [[Media:Assignment1Solutions.pdf|Solutions]] ([[Media:lightbulbs.c|lightbulbs.c]]) (ave score:  16.4/20, stdev 4.2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  The PIC32 microcontroller hardware.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|PIC 32 hardware handout]], Data Sheet, Reference Manual&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 6&amp;#039;&amp;#039;&amp;#039; (T 1/24)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: 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)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  virtual and physical memory, NU32 board, beginning PIC32 programming, digital I/O SFRs&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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&amp;#039;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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 7&amp;#039;&amp;#039;&amp;#039; (Th 1/26)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/19. [[Media:Assignment2Solutions.pdf|Solutions]] (ave score:  21.8/25; stdev 4.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Continue analyzing the Simple_pic.c program.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 out&amp;#039;&amp;#039;&amp;#039;: [[Media:Assignment3v2.pdf|Investigating the PIC C32 Tool Suite (v2)]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 8&amp;#039;&amp;#039;&amp;#039; (T 1/31)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 2.  [[Media:ME333_2012_quiz3_solns.c|Solutions; average 6.93/8, stdev 1.63]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: CPU:  core timer and and interrupts.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 9&amp;#039;&amp;#039;&amp;#039; (Th 2/2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 1/26. [[Media:Assignment3Solutions.pdf|Solutions]], ave: 27.7/33, stdev 7.8&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: Interrupts, cont.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 out&amp;#039;&amp;#039;&amp;#039;: [[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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 10&amp;#039;&amp;#039;&amp;#039; (T 2/7)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 3.  [[Media:ME333_2012_quiz4_solns2.c|Solutions; average 4.67/6, stdev 1.37]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Digital I/O, counter/timers, and output compare (PWM).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapters on digital input and output, timers, and output compare]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 11&amp;#039;&amp;#039;&amp;#039; (Th 2/9)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/2.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: 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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapter on analog input]].&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 12&amp;#039;&amp;#039;&amp;#039; (T 2/14)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 4.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  [[Sensor Overview|Sensors]], op amp circuits for signal conditioning.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[Sensor Overview]], [[Rotary Encoder]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 13&amp;#039;&amp;#039;&amp;#039; (Th 2/16)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/9.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DSP:  digital filtering, FFT, iFFT.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 out&amp;#039;&amp;#039;&amp;#039;:  [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].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 14&amp;#039;&amp;#039;&amp;#039; (T 2/21)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 5.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Brushed DC motor theory.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[Brushed DC Motor Theory]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 15&amp;#039;&amp;#039;&amp;#039; (Th 2/23)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/16.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DC motors.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 16&amp;#039;&amp;#039;&amp;#039; (T 2/28)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 6&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Gearing, inertia and torque, motor sizing and selection&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Choosing a Motor and Gearing Combination]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 17&amp;#039;&amp;#039;&amp;#039; (Th 3/1)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Stepper motors and RC servo motors.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  From previous versions of the NU32 board:  [[PIC32MX: Driving a Stepper Motor]], [[PIC32MX: Servo Control]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 18&amp;#039;&amp;#039;&amp;#039; (T 3/6)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: yes&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Serial communication.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 19&amp;#039;&amp;#039;&amp;#039; (Th 3/8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Final Demo&amp;#039;&amp;#039;&amp;#039;:  Monday 3/12, 3-5 PM, for 12:30-1:50 section; Wednesday 3/14, 9-11 AM, for 11:00-12:20 section&lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
&lt;br /&gt;
Q: Do I need to know the C language to take this course?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: Is there an independent project?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: What kind of laptop do I need?&lt;br /&gt;
&lt;br /&gt;
A: You need a laptop with at least 2 USB ports.  Any operating system is fine.&lt;br /&gt;
&lt;br /&gt;
== ME 333 Winter 2010 (obsolete) ==&lt;br /&gt;
&lt;br /&gt;
* [[ME 333 Circuits Review Material]]&lt;br /&gt;
* [http://www.youtube.com/NUmechatronics NUmechatronics youtube channel]&lt;br /&gt;
* [[ME 333 final projects]]&lt;br /&gt;
* [[PCB Artist]]&lt;br /&gt;
* [[ME 333 Suggested Final Projects]]&lt;br /&gt;
* [[ME 333 end of course schedule]]&lt;br /&gt;
* [[ME 333 Lab Kits]]&lt;br /&gt;
* [[Processing]] (software allowing you to create GUIs on your PC and interface through your USB port)&lt;br /&gt;
* Labs from Winter 2010&lt;br /&gt;
** [[Getting Started with PIC32|ME 333 Lab 1:  Getting started with the PIC32]]&lt;br /&gt;
** [[ME 333 Lab 2]]&lt;br /&gt;
** [http://lims.mech.northwestern.edu/~lynch/courses/ME333/PIClabs/lab3/lab3.html ME 333 Lab 3]&lt;br /&gt;
** [[ME 333 Lab 4]]&lt;br /&gt;
** [[ME 333 Lab 5]]&lt;br /&gt;
* Ungraded study problems (be sure to attempt to solve the problems before looking at the solutions!)&lt;br /&gt;
** [[ME 333 Circuits Review Material]]&lt;br /&gt;
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]&lt;br /&gt;
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[NU32v2:  A Detailed Look at Programming the PIC32]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21044</id>
		<title>ME 333 Introduction to Mechatronics (Archive Winter 2012)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21044"/>
		<updated>2012-02-09T17:35:57Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Reading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Winter Quarter 2012&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
(Here is an [[ME 333 Introduction to Mechatronics (Archive Winter 2011)|Archive of Winter 2011]])&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;First day of class is Thursday Jan 5!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Section 20:  Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5&lt;br /&gt;
* Section 21:  Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5&lt;br /&gt;
* TAs:  Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu&lt;br /&gt;
* Circuits Review Session:  Mon Jan 9, 7 PM, Prof. Lynch, Tech L221; Wed Jan 11, 7 PM, Prof. Marchuk, Tech L221&lt;br /&gt;
* C Peer Instruction Sessions, 7-8:30 PM, Seeley-Mudd Engineering Library Room 230&lt;br /&gt;
** Thurs Jan 12&lt;br /&gt;
** Tues Jan 17&lt;br /&gt;
** Wed Jan 18&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Final demo&amp;#039;&amp;#039;&amp;#039; (in lieu of final exam):  11-12:20 section Wed March 14 9-11 AM; 12:30-1:50 section Monday March 12 3-5 PM&lt;br /&gt;
* Office Hours:  &lt;br /&gt;
** Mon 4-6 PM:  Jarvis Schultz, Mechatronics Lab, Ford B100&lt;br /&gt;
** Tues 2-3 PM:  Prof. Lynch, B221&lt;br /&gt;
** Wed 3-5 PM:  Nelson Rosa, Mechatronics Lab, Ford B100&lt;br /&gt;
**Thurs 3-4 PM:  Prof. Lynch, B221&lt;br /&gt;
** Fri 3-4 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
** Mon-Fri 4-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Checklist to Complete Before the First Day of Class ==&lt;br /&gt;
&lt;br /&gt;
Attendance at the first day of class (Thursday Jan 5) is mandatory.  By the first day of class, you should:&lt;br /&gt;
&lt;br /&gt;
* Be able to solve circuit problems similar to those on the practice problem set and last year&amp;#039;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.&lt;br /&gt;
* 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.  &lt;br /&gt;
* Buy your class kit [http://it.mccormick.northwestern.edu/matlab/student_license/login.php &amp;#039;&amp;#039;&amp;#039;here&amp;#039;&amp;#039;&amp;#039;].  If you already have the oscilloscope and multimeter from this year&amp;#039;s ME 233 offering, you should choose &amp;quot;ME 333 (w/o ME 233 equipment)&amp;quot; for the price of $75.  If you do not have the oscilloscope and multimeter, you should choose &amp;quot;ME 333 (w/ ME 233 equipment)&amp;quot; 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.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;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&amp;#039;t complete this before the first day of class, you will need to do it before the second class.&amp;#039;&amp;#039;&amp;#039;  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. &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;!-- * Download and install software described on [[NU32v2: Software to Install|this page]].  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Student Contract ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* Allowing another student to copy your code.&lt;br /&gt;
* Copying another student&amp;#039;s code, in whole or in part.&lt;br /&gt;
* Transforming copied sections of code to try to disguise their origin.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
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]].&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
&lt;br /&gt;
* [[Media:CrashCourseinC.pdf|A Crash Course in C]]:  A brief introduction to the C programming language &lt;br /&gt;
([[Media:EssentialC.pdf|Essential C]] is also a very nice intro to C)&lt;br /&gt;
* handouts associated with individual classes&lt;br /&gt;
* wiki info on [[Microchip PICs]]&lt;br /&gt;
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (256 pages, 5 MB pdf)&lt;br /&gt;
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;amp;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.&lt;br /&gt;
* The old version of the [[Media:61132B_PIC32ReferenceManual.pdf|PIC32 Reference Manual]] has many more pages than the chapter-by-chapter version linked above.  It includes quite a lot of example code.  &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;  Even with this being the case, this is still a very useful document.&lt;br /&gt;
* PIC32MX Peripheral Library (included as a .chm file under &amp;quot;Program Files\Microchip\MPLAB C32\doc&amp;quot; with your C32 compiler installation)&lt;br /&gt;
&lt;br /&gt;
Useful, but not required:&lt;br /&gt;
&lt;br /&gt;
* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1294091438&amp;amp;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.&lt;br /&gt;
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under &amp;quot;doc&amp;quot; of your C32 compiler installation&lt;br /&gt;
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]] of &amp;quot;The C Book,&amp;quot; and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1294091625&amp;amp;sr=1-1 C Programming Language] reference book by Kernighan and Ritchie&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
== Homework Submission ==&lt;br /&gt;
All homework will be submitted on Blackboard.  Here are a few guidelines/ tips associated with homework submissions:&lt;br /&gt;
* We expect the required files for each assignment to be compressed together in a zip file (no rar files).&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* When submitting written responses, we prefer PDF files, but will accept word documents (.doc, .docx), .txt, and .rtf files.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 &amp;quot;project properties&amp;quot; in both IDEs, it is possible to generate &amp;quot;Additional warnings.&amp;quot;  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.&lt;br /&gt;
&lt;br /&gt;
== Approximate Syllabus ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Topics we will cover include:&lt;br /&gt;
&lt;br /&gt;
* introduction to C programming (here&amp;#039;s a [[Media:invest.c|simple tutorial C program]])&lt;br /&gt;
* quiz on circuits&lt;br /&gt;
* introduction to the PIC32 hardware, and programming the PIC32 in C&lt;br /&gt;
* digital I/O&lt;br /&gt;
* counters/timers and interrupts&lt;br /&gt;
* analog input&lt;br /&gt;
* sensor smorgasbord&lt;br /&gt;
* digital signal processing:  filters and FFTs&lt;br /&gt;
* analog output and pulse-width modulation&lt;br /&gt;
* brushed permanent magnet DC motors:  theory and control&lt;br /&gt;
* stepper motors and RC servo motors&lt;br /&gt;
* communication by SPI, I2C, and RS-232&lt;br /&gt;
&lt;br /&gt;
[[ME333 Sample Code|Sample Code for ME 333]] &lt;br /&gt;
&lt;br /&gt;
By class (note:  DS = Data Sheet, RM = Reference Manual):&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 1&amp;#039;&amp;#039;&amp;#039; (Th 1/5)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Course overview.  Circuits review.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Practice problem set and quiz on [[ME_333_Circuits_Review_Material|this page]], as well as background reading as needed.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 2&amp;#039;&amp;#039;&amp;#039; (T 1/10)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling and linking).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:invest.c|Sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 3&amp;#039;&amp;#039;&amp;#039; (Th 1/12)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  Circuits.  ([[Media:ME333_Quiz1_2012_Solutions.pdf|Solutions]]; high score 45/46, average 33.4, stdev 7.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continue with [[Media:invest.c|sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 out&amp;#039;&amp;#039;&amp;#039;:  &amp;#039;&amp;#039;&amp;#039;Problems 1-6 and 9&amp;#039;&amp;#039;&amp;#039; 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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 4&amp;#039;&amp;#039;&amp;#039; (T 1/17)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (syntax).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 5&amp;#039;&amp;#039;&amp;#039; (Th 1/19)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/12. [[Media:Assignment1Solutions.pdf|Solutions]] ([[Media:lightbulbs.c|lightbulbs.c]]) (ave score:  16.4/20, stdev 4.2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  The PIC32 microcontroller hardware.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|PIC 32 hardware handout]], Data Sheet, Reference Manual&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 6&amp;#039;&amp;#039;&amp;#039; (T 1/24)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: 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)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  virtual and physical memory, NU32 board, beginning PIC32 programming, digital I/O SFRs&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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&amp;#039;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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 7&amp;#039;&amp;#039;&amp;#039; (Th 1/26)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/19. [[Media:Assignment2Solutions.pdf|Solutions]] (ave score:  21.8/25; stdev 4.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Continue analyzing the Simple_pic.c program.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 out&amp;#039;&amp;#039;&amp;#039;: [[Media:Assignment3v2.pdf|Investigating the PIC C32 Tool Suite (v2)]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 8&amp;#039;&amp;#039;&amp;#039; (T 1/31)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 2.  [[Media:ME333_2012_quiz3_solns.c|Solutions; average 6.93/8, stdev 1.63]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: CPU:  core timer and and interrupts.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 9&amp;#039;&amp;#039;&amp;#039; (Th 2/2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 1/26. [[Media:Assignment3Solutions.pdf|Solutions]], ave: 27.7/33, stdev 7.8&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: Interrupts, cont.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 out&amp;#039;&amp;#039;&amp;#039;: [[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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 10&amp;#039;&amp;#039;&amp;#039; (T 2/7)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 3.  [[Media:ME333_2012_quiz4_solns2.c|Solutions; average 4.67/6, stdev 1.37]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Digital I/O, counter/timers, and output compare (PWM).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapters on digital input and output, timers, and output compare]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 11&amp;#039;&amp;#039;&amp;#039; (Th 2/9)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/2.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: 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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapter on analog input]].&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 12&amp;#039;&amp;#039;&amp;#039; (T 2/14)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 4.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  [[Sensor Overview|Sensors]], op amp circuits for signal conditioning.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[Sensor Overview]], [[Rotary Encoder]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 13&amp;#039;&amp;#039;&amp;#039; (Th 2/16)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/9.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DSP:  digital filtering, FFT, iFFT.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 out&amp;#039;&amp;#039;&amp;#039;:  [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].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 14&amp;#039;&amp;#039;&amp;#039; (T 2/21)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 5.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Brushed DC motor theory.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[Brushed DC Motor Theory]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 15&amp;#039;&amp;#039;&amp;#039; (Th 2/23)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/16.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DC motors.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 16&amp;#039;&amp;#039;&amp;#039; (T 2/28)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 6&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Gearing, inertia and torque, motor sizing and selection&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Choosing a Motor and Gearing Combination]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 17&amp;#039;&amp;#039;&amp;#039; (Th 3/1)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Stepper motors and RC servo motors.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  From previous versions of the NU32 board:  [[PIC32MX: Driving a Stepper Motor]], [[PIC32MX: Servo Control]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 18&amp;#039;&amp;#039;&amp;#039; (T 3/6)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: yes&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Serial communication.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 19&amp;#039;&amp;#039;&amp;#039; (Th 3/8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Final Demo&amp;#039;&amp;#039;&amp;#039;:  Monday 3/12, 3-5 PM, for 12:30-1:50 section; Wednesday 3/14, 9-11 AM, for 11:00-12:20 section&lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
&lt;br /&gt;
Q: Do I need to know the C language to take this course?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: Is there an independent project?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: What kind of laptop do I need?&lt;br /&gt;
&lt;br /&gt;
A: You need a laptop with at least 2 USB ports.  Any operating system is fine.&lt;br /&gt;
&lt;br /&gt;
== ME 333 Winter 2010 (obsolete) ==&lt;br /&gt;
&lt;br /&gt;
* [[ME 333 Circuits Review Material]]&lt;br /&gt;
* [http://www.youtube.com/NUmechatronics NUmechatronics youtube channel]&lt;br /&gt;
* [[ME 333 final projects]]&lt;br /&gt;
* [[PCB Artist]]&lt;br /&gt;
* [[ME 333 Suggested Final Projects]]&lt;br /&gt;
* [[ME 333 end of course schedule]]&lt;br /&gt;
* [[ME 333 Lab Kits]]&lt;br /&gt;
* [[Processing]] (software allowing you to create GUIs on your PC and interface through your USB port)&lt;br /&gt;
* Labs from Winter 2010&lt;br /&gt;
** [[Getting Started with PIC32|ME 333 Lab 1:  Getting started with the PIC32]]&lt;br /&gt;
** [[ME 333 Lab 2]]&lt;br /&gt;
** [http://lims.mech.northwestern.edu/~lynch/courses/ME333/PIClabs/lab3/lab3.html ME 333 Lab 3]&lt;br /&gt;
** [[ME 333 Lab 4]]&lt;br /&gt;
** [[ME 333 Lab 5]]&lt;br /&gt;
* Ungraded study problems (be sure to attempt to solve the problems before looking at the solutions!)&lt;br /&gt;
** [[ME 333 Circuits Review Material]]&lt;br /&gt;
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]&lt;br /&gt;
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[NU32v2:  A Detailed Look at Programming the PIC32]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21043</id>
		<title>ME 333 Introduction to Mechatronics (Archive Winter 2012)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=21043"/>
		<updated>2012-02-09T17:35:21Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Reading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Winter Quarter 2012&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
(Here is an [[ME 333 Introduction to Mechatronics (Archive Winter 2011)|Archive of Winter 2011]])&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;First day of class is Thursday Jan 5!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Section 20:  Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5&lt;br /&gt;
* Section 21:  Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5&lt;br /&gt;
* TAs:  Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu&lt;br /&gt;
* Circuits Review Session:  Mon Jan 9, 7 PM, Prof. Lynch, Tech L221; Wed Jan 11, 7 PM, Prof. Marchuk, Tech L221&lt;br /&gt;
* C Peer Instruction Sessions, 7-8:30 PM, Seeley-Mudd Engineering Library Room 230&lt;br /&gt;
** Thurs Jan 12&lt;br /&gt;
** Tues Jan 17&lt;br /&gt;
** Wed Jan 18&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Final demo&amp;#039;&amp;#039;&amp;#039; (in lieu of final exam):  11-12:20 section Wed March 14 9-11 AM; 12:30-1:50 section Monday March 12 3-5 PM&lt;br /&gt;
* Office Hours:  &lt;br /&gt;
** Mon 4-6 PM:  Jarvis Schultz, Mechatronics Lab, Ford B100&lt;br /&gt;
** Tues 2-3 PM:  Prof. Lynch, B221&lt;br /&gt;
** Wed 3-5 PM:  Nelson Rosa, Mechatronics Lab, Ford B100&lt;br /&gt;
**Thurs 3-4 PM:  Prof. Lynch, B221&lt;br /&gt;
** Fri 3-4 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
** Mon-Fri 4-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Checklist to Complete Before the First Day of Class ==&lt;br /&gt;
&lt;br /&gt;
Attendance at the first day of class (Thursday Jan 5) is mandatory.  By the first day of class, you should:&lt;br /&gt;
&lt;br /&gt;
* Be able to solve circuit problems similar to those on the practice problem set and last year&amp;#039;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.&lt;br /&gt;
* 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.  &lt;br /&gt;
* Buy your class kit [http://it.mccormick.northwestern.edu/matlab/student_license/login.php &amp;#039;&amp;#039;&amp;#039;here&amp;#039;&amp;#039;&amp;#039;].  If you already have the oscilloscope and multimeter from this year&amp;#039;s ME 233 offering, you should choose &amp;quot;ME 333 (w/o ME 233 equipment)&amp;quot; for the price of $75.  If you do not have the oscilloscope and multimeter, you should choose &amp;quot;ME 333 (w/ ME 233 equipment)&amp;quot; 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.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;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&amp;#039;t complete this before the first day of class, you will need to do it before the second class.&amp;#039;&amp;#039;&amp;#039;  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. &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;!-- * Download and install software described on [[NU32v2: Software to Install|this page]].  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Student Contract ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* Allowing another student to copy your code.&lt;br /&gt;
* Copying another student&amp;#039;s code, in whole or in part.&lt;br /&gt;
* Transforming copied sections of code to try to disguise their origin.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
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]].&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
&lt;br /&gt;
* [[Media:CrashCourseinC.pdf|A Crash Course in C]]:  A brief introduction to the C programming language &lt;br /&gt;
([[Media:EssentialC.pdf|Essential C]] is also a very nice intro to C)&lt;br /&gt;
* handouts associated with individual classes&lt;br /&gt;
* wiki info on [[Microchip PICs]]&lt;br /&gt;
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (256 pages, 5 MB pdf)&lt;br /&gt;
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;amp;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.&lt;br /&gt;
* The old version of the [[Media:61132B_PIC32ReferenceManual.pdf|PIC32 Reference Manual]] has many more pages than the chapter-by-chapter version linked above.  It includes a lot of example code as well.  &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;  Even with this being the case, this is still a very useful document.&lt;br /&gt;
* PIC32MX Peripheral Library (included as a .chm file under &amp;quot;Program Files\Microchip\MPLAB C32\doc&amp;quot; with your C32 compiler installation)&lt;br /&gt;
&lt;br /&gt;
Useful, but not required:&lt;br /&gt;
&lt;br /&gt;
* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1294091438&amp;amp;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.&lt;br /&gt;
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under &amp;quot;doc&amp;quot; of your C32 compiler installation&lt;br /&gt;
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]] of &amp;quot;The C Book,&amp;quot; and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1294091625&amp;amp;sr=1-1 C Programming Language] reference book by Kernighan and Ritchie&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
== Homework Submission ==&lt;br /&gt;
All homework will be submitted on Blackboard.  Here are a few guidelines/ tips associated with homework submissions:&lt;br /&gt;
* We expect the required files for each assignment to be compressed together in a zip file (no rar files).&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* When submitting written responses, we prefer PDF files, but will accept word documents (.doc, .docx), .txt, and .rtf files.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 &amp;quot;project properties&amp;quot; in both IDEs, it is possible to generate &amp;quot;Additional warnings.&amp;quot;  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.&lt;br /&gt;
&lt;br /&gt;
== Approximate Syllabus ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Topics we will cover include:&lt;br /&gt;
&lt;br /&gt;
* introduction to C programming (here&amp;#039;s a [[Media:invest.c|simple tutorial C program]])&lt;br /&gt;
* quiz on circuits&lt;br /&gt;
* introduction to the PIC32 hardware, and programming the PIC32 in C&lt;br /&gt;
* digital I/O&lt;br /&gt;
* counters/timers and interrupts&lt;br /&gt;
* analog input&lt;br /&gt;
* sensor smorgasbord&lt;br /&gt;
* digital signal processing:  filters and FFTs&lt;br /&gt;
* analog output and pulse-width modulation&lt;br /&gt;
* brushed permanent magnet DC motors:  theory and control&lt;br /&gt;
* stepper motors and RC servo motors&lt;br /&gt;
* communication by SPI, I2C, and RS-232&lt;br /&gt;
&lt;br /&gt;
[[ME333 Sample Code|Sample Code for ME 333]] &lt;br /&gt;
&lt;br /&gt;
By class (note:  DS = Data Sheet, RM = Reference Manual):&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 1&amp;#039;&amp;#039;&amp;#039; (Th 1/5)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Course overview.  Circuits review.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Practice problem set and quiz on [[ME_333_Circuits_Review_Material|this page]], as well as background reading as needed.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 2&amp;#039;&amp;#039;&amp;#039; (T 1/10)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling and linking).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:invest.c|Sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 3&amp;#039;&amp;#039;&amp;#039; (Th 1/12)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  Circuits.  ([[Media:ME333_Quiz1_2012_Solutions.pdf|Solutions]]; high score 45/46, average 33.4, stdev 7.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continue with [[Media:invest.c|sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 out&amp;#039;&amp;#039;&amp;#039;:  &amp;#039;&amp;#039;&amp;#039;Problems 1-6 and 9&amp;#039;&amp;#039;&amp;#039; 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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 4&amp;#039;&amp;#039;&amp;#039; (T 1/17)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (syntax).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 5&amp;#039;&amp;#039;&amp;#039; (Th 1/19)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/12. [[Media:Assignment1Solutions.pdf|Solutions]] ([[Media:lightbulbs.c|lightbulbs.c]]) (ave score:  16.4/20, stdev 4.2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  The PIC32 microcontroller hardware.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|PIC 32 hardware handout]], Data Sheet, Reference Manual&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 6&amp;#039;&amp;#039;&amp;#039; (T 1/24)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: 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)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  virtual and physical memory, NU32 board, beginning PIC32 programming, digital I/O SFRs&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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&amp;#039;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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 7&amp;#039;&amp;#039;&amp;#039; (Th 1/26)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/19. [[Media:Assignment2Solutions.pdf|Solutions]] (ave score:  21.8/25; stdev 4.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Continue analyzing the Simple_pic.c program.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 out&amp;#039;&amp;#039;&amp;#039;: [[Media:Assignment3v2.pdf|Investigating the PIC C32 Tool Suite (v2)]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 8&amp;#039;&amp;#039;&amp;#039; (T 1/31)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 2.  [[Media:ME333_2012_quiz3_solns.c|Solutions; average 6.93/8, stdev 1.63]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: CPU:  core timer and and interrupts.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 9&amp;#039;&amp;#039;&amp;#039; (Th 2/2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 1/26. [[Media:Assignment3Solutions.pdf|Solutions]], ave: 27.7/33, stdev 7.8&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: Interrupts, cont.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  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]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 out&amp;#039;&amp;#039;&amp;#039;: [[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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 10&amp;#039;&amp;#039;&amp;#039; (T 2/7)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 3.  [[Media:ME333_2012_quiz4_solns2.c|Solutions; average 4.67/6, stdev 1.37]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Digital I/O, counter/timers, and output compare (PWM).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapters on digital input and output, timers, and output compare]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 11&amp;#039;&amp;#039;&amp;#039; (Th 2/9)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/2.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: 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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32Chapters.pdf|Chapter on analog input]].&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 12&amp;#039;&amp;#039;&amp;#039; (T 2/14)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 4.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  [[Sensor Overview|Sensors]], op amp circuits for signal conditioning.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[Sensor Overview]], [[Rotary Encoder]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 13&amp;#039;&amp;#039;&amp;#039; (Th 2/16)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/9.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DSP:  digital filtering, FFT, iFFT.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 out&amp;#039;&amp;#039;&amp;#039;:  [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].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 14&amp;#039;&amp;#039;&amp;#039; (T 2/21)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 5.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Brushed DC motor theory.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[Brushed DC Motor Theory]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 15&amp;#039;&amp;#039;&amp;#039; (Th 2/23)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/16.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  DC motors.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 16&amp;#039;&amp;#039;&amp;#039; (T 2/28)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 6&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Gearing, inertia and torque, motor sizing and selection&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Choosing a Motor and Gearing Combination]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 17&amp;#039;&amp;#039;&amp;#039; (Th 3/1)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Stepper motors and RC servo motors.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  From previous versions of the NU32 board:  [[PIC32MX: Driving a Stepper Motor]], [[PIC32MX: Servo Control]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 18&amp;#039;&amp;#039;&amp;#039; (T 3/6)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: yes&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Serial communication.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 19&amp;#039;&amp;#039;&amp;#039; (Th 3/8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Final Demo&amp;#039;&amp;#039;&amp;#039;:  Monday 3/12, 3-5 PM, for 12:30-1:50 section; Wednesday 3/14, 9-11 AM, for 11:00-12:20 section&lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
&lt;br /&gt;
Q: Do I need to know the C language to take this course?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: Is there an independent project?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: What kind of laptop do I need?&lt;br /&gt;
&lt;br /&gt;
A: You need a laptop with at least 2 USB ports.  Any operating system is fine.&lt;br /&gt;
&lt;br /&gt;
== ME 333 Winter 2010 (obsolete) ==&lt;br /&gt;
&lt;br /&gt;
* [[ME 333 Circuits Review Material]]&lt;br /&gt;
* [http://www.youtube.com/NUmechatronics NUmechatronics youtube channel]&lt;br /&gt;
* [[ME 333 final projects]]&lt;br /&gt;
* [[PCB Artist]]&lt;br /&gt;
* [[ME 333 Suggested Final Projects]]&lt;br /&gt;
* [[ME 333 end of course schedule]]&lt;br /&gt;
* [[ME 333 Lab Kits]]&lt;br /&gt;
* [[Processing]] (software allowing you to create GUIs on your PC and interface through your USB port)&lt;br /&gt;
* Labs from Winter 2010&lt;br /&gt;
** [[Getting Started with PIC32|ME 333 Lab 1:  Getting started with the PIC32]]&lt;br /&gt;
** [[ME 333 Lab 2]]&lt;br /&gt;
** [http://lims.mech.northwestern.edu/~lynch/courses/ME333/PIClabs/lab3/lab3.html ME 333 Lab 3]&lt;br /&gt;
** [[ME 333 Lab 4]]&lt;br /&gt;
** [[ME 333 Lab 5]]&lt;br /&gt;
* Ungraded study problems (be sure to attempt to solve the problems before looking at the solutions!)&lt;br /&gt;
** [[ME 333 Circuits Review Material]]&lt;br /&gt;
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]&lt;br /&gt;
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[NU32v2:  A Detailed Look at Programming the PIC32]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32:_16x2_LCD&amp;diff=21001</id>
		<title>NU32: 16x2 LCD</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32:_16x2_LCD&amp;diff=21001"/>
		<updated>2012-02-08T17:33:50Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* LCD Hookup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:NU32_LCD.jpg|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Parallel LCD ==&lt;br /&gt;
&lt;br /&gt;
The popular HD44780 (and compatible chipsets) can be interfaced to the NU32 PIC32 board using 11 pins for easy character output to an LCD. This can be highly useful in either debugging or generating a more complex user interface for a PIC (or other microcontroller)-based device. &lt;br /&gt;
&lt;br /&gt;
This implementation of an HD44780 LCD uses 11 I/O on the PIC as output only, so it is not optimized for speed.&lt;br /&gt;
&lt;br /&gt;
== LCD Hookup ==&lt;br /&gt;
&lt;br /&gt;
The LCD uses the following connections with the NU32:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border = 1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;LCD Pin&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;PIC Pin&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;1 - VSS&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;GND&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;2 - VDD&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;+5V&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;3 - V0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~1.5k resistor to GND&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;4 - RS&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;G12&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;5 - RW&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;G13&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;6 - E&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;G15&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;7 - D0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;E0&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;8 - D1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;E1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;9 - D2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;E2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;10 - D3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;E3&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;11 - D4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;E4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;12 - D5&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;E5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;13 - D6&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;E6&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;14 - D7&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;E7&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;15 - A&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;100 ohm resistor to 3.3V&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;16 - K&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;GND&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The VEE pin on the LCD (labeled &amp;#039;A&amp;#039;) sets the contrast of the characters on the LCD. Create with a voltage around 1V using a 10k pot to get a nice contrast, or hook it to GND through a 1.5kOhm resistor, which also seems to work well.&lt;br /&gt;
&lt;br /&gt;
If you power the LCD but do not send it any commands, the top row should fill with boxes. Use this to set your contrast and check that your LCD works.&lt;br /&gt;
&lt;br /&gt;
The NU32 board is based on 3.3V logical outputs, which works fine for most LCDs, but this LCD must be supplied with 5V on VDD.&lt;br /&gt;
&lt;br /&gt;
== LCD Commands ==&lt;br /&gt;
&lt;br /&gt;
In the main.c file, before the main while loop, you must initialize the LCD&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
setupLCD();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The basic command used to write to the LCD is &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
LCDWriteString(&amp;quot;Hello World&amp;quot;, 1, 2);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
where 1 is the first row (options are 1 or 2), and 2 is the location to start in (options 1-16). There are only 16 characters per row, so don&amp;#039;t try to print a string with more than 16 characters!&lt;br /&gt;
&lt;br /&gt;
You can clear everything on the LCD by using&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
LCDClear(0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Write the contents of a variable using&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
sprintf(LCD_Out_Buffer,&amp;quot;k = %5.2f&amp;quot;, k);&lt;br /&gt;
LCDWriteString(LCD_Out_Buffer, 2, 1);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
LCD_Out_Buffer is a 16 element char array declared in LCD.h&lt;br /&gt;
Use sprintf just like in serial communication, but pay attention to the modifies to your variable.&lt;br /&gt;
In this case, k is a float, and we don&amp;#039;t want to print every character in the decimal number. %5.2f means use at least 5 characters (including the .) to represent the number, but only two decimals, so we should see 12.34, not 12.345, but we could see 123.45, and _1.23, where _ is really a blank space.&lt;br /&gt;
&lt;br /&gt;
== Files and Example Code ==&lt;br /&gt;
&lt;br /&gt;
Include the following h and c files to your project: [[Media:NU32LCD.zip|h and c files]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:HW4_Interrupts_and_Programming.zip&amp;diff=20992</id>
		<title>File:HW4 Interrupts and Programming.zip</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:HW4_Interrupts_and_Programming.zip&amp;diff=20992"/>
		<updated>2012-02-03T23:09:31Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: uploaded a new version of &amp;quot;Image:HW4 Interrupts and Programming.zip&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=20989</id>
		<title>ME 333 Introduction to Mechatronics (Archive Winter 2012)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=20989"/>
		<updated>2012-02-03T15:17:59Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Approximate Syllabus */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Winter Quarter 2012&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
(Here is an [[ME 333 Introduction to Mechatronics (Archive Winter 2011)|Archive of Winter 2011]])&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;First day of class is Thursday Jan 5!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Section 20:  Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5&lt;br /&gt;
* Section 21:  Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5&lt;br /&gt;
* TAs:  Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu&lt;br /&gt;
* Circuits Review Session:  Mon Jan 9, 7 PM, Prof. Lynch, Tech L221; Wed Jan 11, 7 PM, Prof. Marchuk, Tech L221&lt;br /&gt;
* C Peer Instruction Sessions, 7-8:30 PM, Seeley-Mudd Engineering Library Room 230&lt;br /&gt;
** Thurs Jan 12&lt;br /&gt;
** Tues Jan 17&lt;br /&gt;
** Wed Jan 18&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Final demo&amp;#039;&amp;#039;&amp;#039; (in lieu of final exam):  11-12:20 section Wed March 14 9-11 AM; 12:30-1:50 section Monday March 12 3-5 PM&lt;br /&gt;
* Office Hours:  &lt;br /&gt;
** Mon 4-6 PM:  Jarvis Schultz, Mechatronics Lab, Ford B100&lt;br /&gt;
** Tues 2-3 PM:  Prof. Lynch, B221&lt;br /&gt;
** Wed 3-5 PM:  Nelson Rosa, Mechatronics Lab, Ford B100&lt;br /&gt;
**Thurs 3-4 PM:  Prof. Lynch, B221&lt;br /&gt;
** Fri 3-4 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
** Mon-Fri 4-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Checklist to Complete Before the First Day of Class ==&lt;br /&gt;
&lt;br /&gt;
Attendance at the first day of class (Thursday Jan 5) is mandatory.  By the first day of class, you should:&lt;br /&gt;
&lt;br /&gt;
* Be able to solve circuit problems similar to those on the practice problem set and last year&amp;#039;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.&lt;br /&gt;
* 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.  &lt;br /&gt;
* Buy your class kit [http://it.mccormick.northwestern.edu/matlab/student_license/login.php &amp;#039;&amp;#039;&amp;#039;here&amp;#039;&amp;#039;&amp;#039;].  If you already have the oscilloscope and multimeter from this year&amp;#039;s ME 233 offering, you should choose &amp;quot;ME 333 (w/o ME 233 equipment)&amp;quot; for the price of $75.  If you do not have the oscilloscope and multimeter, you should choose &amp;quot;ME 333 (w/ ME 233 equipment)&amp;quot; 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.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;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&amp;#039;t complete this before the first day of class, you will need to do it before the second class.&amp;#039;&amp;#039;&amp;#039;  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. &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;!-- * Download and install software described on [[NU32v2: Software to Install|this page]].  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Student Contract ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* Allowing another student to copy your code.&lt;br /&gt;
* Copying another student&amp;#039;s code, in whole or in part.&lt;br /&gt;
* Transforming copied sections of code to try to disguise their origin.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
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]].&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
&lt;br /&gt;
* [[Media:CrashCourseinC.pdf|A Crash Course in C]]:  A brief introduction to the C programming language &lt;br /&gt;
([[Media:EssentialC.pdf|Essential C]] is also a very nice intro to C)&lt;br /&gt;
* handouts associated with individual classes&lt;br /&gt;
* wiki info on [[Microchip PICs]]&lt;br /&gt;
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (256 pages, 5 MB pdf)&lt;br /&gt;
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;amp;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.&lt;br /&gt;
* PIC32MX Peripheral Library (included as a .chm file under &amp;quot;Program Files\Microchip\MPLAB C32\doc&amp;quot; with your C32 compiler installation)&lt;br /&gt;
&lt;br /&gt;
Useful, but not required:&lt;br /&gt;
&lt;br /&gt;
* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1294091438&amp;amp;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.&lt;br /&gt;
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under &amp;quot;doc&amp;quot; of your C32 compiler installation&lt;br /&gt;
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]] of &amp;quot;The C Book,&amp;quot; and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1294091625&amp;amp;sr=1-1 C Programming Language] reference book by Kernighan and Ritchie&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
== Homework Submission ==&lt;br /&gt;
All homework will be submitted on Blackboard.  Here are a few guidelines/ tips associated with homework submissions:&lt;br /&gt;
* We expect the required files for each assignment to be compressed together in a zip file (no rar files).&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* When submitting written responses, we prefer PDF files, but will accept word documents (.doc, .docx), .txt, and .rtf files.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 &amp;quot;project properties&amp;quot; in both IDEs, it is possible to generate &amp;quot;Additional warnings.&amp;quot;  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.&lt;br /&gt;
&lt;br /&gt;
== Approximate Syllabus ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Topics we will cover include:&lt;br /&gt;
&lt;br /&gt;
* introduction to C programming (here&amp;#039;s a [[Media:invest.c|simple tutorial C program]])&lt;br /&gt;
* quiz on circuits&lt;br /&gt;
* introduction to the PIC32 hardware, and programming the PIC32 in C&lt;br /&gt;
* digital I/O&lt;br /&gt;
* counters/timers and interrupts&lt;br /&gt;
* analog input&lt;br /&gt;
* sensor smorgasbord&lt;br /&gt;
* digital signal processing:  filters and FFTs&lt;br /&gt;
* analog output and pulse-width modulation&lt;br /&gt;
* brushed permanent magnet DC motors:  theory and control&lt;br /&gt;
* stepper motors and RC servo motors&lt;br /&gt;
* communication by SPI, I2C, and RS-232&lt;br /&gt;
&lt;br /&gt;
By class (note:  DS = Data Sheet, RM = Reference Manual):&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 1&amp;#039;&amp;#039;&amp;#039; (Th 1/5)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Course overview.  Circuits review.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Practice problem set and quiz on [[ME_333_Circuits_Review_Material|this page]], as well as background reading as needed.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 2&amp;#039;&amp;#039;&amp;#039; (T 1/10)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling and linking).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:invest.c|Sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 3&amp;#039;&amp;#039;&amp;#039; (Th 1/12)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  Circuits.  ([[Media:ME333_Quiz1_2012_Solutions.pdf|Solutions]]; high score 45/46, average 33.4, stdev 7.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continue with [[Media:invest.c|sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 out&amp;#039;&amp;#039;&amp;#039;:  &amp;#039;&amp;#039;&amp;#039;Problems 1-6 and 9&amp;#039;&amp;#039;&amp;#039; 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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 4&amp;#039;&amp;#039;&amp;#039; (T 1/17)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (syntax).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 5&amp;#039;&amp;#039;&amp;#039; (Th 1/19)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/12. [[Media:Assignment1Solutions.pdf|Solutions]] ([[Media:lightbulbs.c|lightbulbs.c]]) (ave score:  16.4/20, stdev 4.2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  The PIC32 microcontroller hardware.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32hardware.pdf|PIC 32 hardware handout]], Data Sheet, Reference Manual&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 6&amp;#039;&amp;#039;&amp;#039; (T 1/24)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: 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)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  virtual and physical memory, NU32 board, beginning PIC32 programming, digital I/O SFRs&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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&amp;#039;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]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 7&amp;#039;&amp;#039;&amp;#039; (Th 1/26)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/19. [[Media:Assignment2Solutions.pdf|Solutions]] (ave score:  21.8/25; stdev 4.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Continue analyzing the Simple_pic.c program.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 out&amp;#039;&amp;#039;&amp;#039;: [[Media:Assignment3v2.pdf|Investigating the PIC C32 Tool Suite (v2)]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 8&amp;#039;&amp;#039;&amp;#039; (T 1/31)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 2.  [[Media:ME333_2012_quiz3_solns.c|Solutions]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: CPU:  core timer and and interrupts.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  A reading on [[Media:PIC32SoftwareAndInterrupts.pdf|PIC32 software and interrupts]] and some [[Media:core_timer_tester.c|code for working with the core timer and interrupts]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 9&amp;#039;&amp;#039;&amp;#039; (Th 2/2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 1/26.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;: Interrupts, cont.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Updated version of [[Media:PIC32SoftwareAndInterrupts.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]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 out&amp;#039;&amp;#039;&amp;#039;: [[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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 10&amp;#039;&amp;#039;&amp;#039; (T 2/7)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 3.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 11&amp;#039;&amp;#039;&amp;#039; (Th 2/9)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/2.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 12&amp;#039;&amp;#039;&amp;#039; (T 2/14)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 4.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 13&amp;#039;&amp;#039;&amp;#039; (Th 2/16)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/9.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 14&amp;#039;&amp;#039;&amp;#039; (T 2/21)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 5.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 15&amp;#039;&amp;#039;&amp;#039; (Th 2/23)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/16.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 16&amp;#039;&amp;#039;&amp;#039; (T 2/28)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 6&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 17&amp;#039;&amp;#039;&amp;#039; (Th 3/1)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 18&amp;#039;&amp;#039;&amp;#039; (T 3/6)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: yes&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 19&amp;#039;&amp;#039;&amp;#039; (Th 3/8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Final Demo&amp;#039;&amp;#039;&amp;#039;:  Monday 3/12, 3-5 PM, for 12:30-1:50 section; Wednesday 3/14, 9-11 AM, for 11:00-12:20 section&lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
&lt;br /&gt;
Q: Do I need to know the C language to take this course?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: Is there an independent project?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: What kind of laptop do I need?&lt;br /&gt;
&lt;br /&gt;
A: You need a laptop with at least 2 USB ports.  Any operating system is fine.&lt;br /&gt;
&lt;br /&gt;
== ME 333 Winter 2010 (obsolete) ==&lt;br /&gt;
&lt;br /&gt;
* [[ME 333 Circuits Review Material]]&lt;br /&gt;
* [http://www.youtube.com/NUmechatronics NUmechatronics youtube channel]&lt;br /&gt;
* [[ME 333 final projects]]&lt;br /&gt;
* [[PCB Artist]]&lt;br /&gt;
* [[ME 333 Suggested Final Projects]]&lt;br /&gt;
* [[ME 333 end of course schedule]]&lt;br /&gt;
* [[ME 333 Lab Kits]]&lt;br /&gt;
* [[Processing]] (software allowing you to create GUIs on your PC and interface through your USB port)&lt;br /&gt;
* Labs from Winter 2010&lt;br /&gt;
** [[Getting Started with PIC32|ME 333 Lab 1:  Getting started with the PIC32]]&lt;br /&gt;
** [[ME 333 Lab 2]]&lt;br /&gt;
** [http://lims.mech.northwestern.edu/~lynch/courses/ME333/PIClabs/lab3/lab3.html ME 333 Lab 3]&lt;br /&gt;
** [[ME 333 Lab 4]]&lt;br /&gt;
** [[ME 333 Lab 5]]&lt;br /&gt;
* Ungraded study problems (be sure to attempt to solve the problems before looking at the solutions!)&lt;br /&gt;
** [[ME 333 Circuits Review Material]]&lt;br /&gt;
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]&lt;br /&gt;
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[NU32v2:  A Detailed Look at Programming the PIC32]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:HW4_Interrupts_and_Programming.zip&amp;diff=20988</id>
		<title>File:HW4 Interrupts and Programming.zip</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:HW4_Interrupts_and_Programming.zip&amp;diff=20988"/>
		<updated>2012-02-03T15:17:14Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: uploaded a new version of &amp;quot;Image:HW4 Interrupts and Programming.zip&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:HW4_Interrupts_and_Programming.zip&amp;diff=20987</id>
		<title>File:HW4 Interrupts and Programming.zip</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:HW4_Interrupts_and_Programming.zip&amp;diff=20987"/>
		<updated>2012-02-03T15:10:35Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Core_timer_tester.c&amp;diff=20962</id>
		<title>File:Core timer tester.c</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Core_timer_tester.c&amp;diff=20962"/>
		<updated>2012-01-31T17:09:46Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: uploaded a new version of &amp;quot;Image:Core timer tester.c&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Core_timer_tester.c&amp;diff=20961</id>
		<title>File:Core timer tester.c</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Core_timer_tester.c&amp;diff=20961"/>
		<updated>2012-01-31T17:04:03Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: uploaded a new version of &amp;quot;Image:Core timer tester.c&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=20916</id>
		<title>ME 333 Introduction to Mechatronics (Archive Winter 2012)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=20916"/>
		<updated>2012-01-24T17:42:10Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Homework Submission */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Winter Quarter 2012&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
(Here is an [[ME 333 Introduction to Mechatronics (Archive Winter 2011)|Archive of Winter 2011]])&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;First day of class is Thursday Jan 5!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Section 20:  Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5&lt;br /&gt;
* Section 21:  Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5&lt;br /&gt;
* TAs:  Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu&lt;br /&gt;
* Circuits Review Session:  Mon Jan 9, 7 PM, Prof. Lynch, Tech L221; Wed Jan 11, 7 PM, Prof. Marchuk, Tech L221&lt;br /&gt;
* C Peer Instruction Sessions, 7-8:30 PM, Seeley-Mudd Engineering Library Room 230&lt;br /&gt;
** Thurs Jan 12&lt;br /&gt;
** Tues Jan 17&lt;br /&gt;
** Wed Jan 18&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Final demo&amp;#039;&amp;#039;&amp;#039; (in lieu of final exam):  11-12:20 section Wed March 14 9-11 AM; 12:30-1:50 section Monday March 12 3-5 PM&lt;br /&gt;
* Office Hours:  &lt;br /&gt;
** Mon 4-6 PM:  Jarvis Schultz, Mechatronics Lab, Ford B100&lt;br /&gt;
** Tues 2-3 PM:  Prof. Lynch, B221&lt;br /&gt;
** Wed 3-5 PM:  Nelson Rosa, Mechatronics Lab, Ford B100&lt;br /&gt;
**Thurs 3-4 PM:  Prof. Lynch, B221&lt;br /&gt;
** Fri 3-4 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
** Mon-Fri 4-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Checklist to Complete Before the First Day of Class ==&lt;br /&gt;
&lt;br /&gt;
Attendance at the first day of class (Thursday Jan 5) is mandatory.  By the first day of class, you should:&lt;br /&gt;
&lt;br /&gt;
* Be able to solve circuit problems similar to those on the practice problem set and last year&amp;#039;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.&lt;br /&gt;
* 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.  &lt;br /&gt;
* Buy your class kit [http://it.mccormick.northwestern.edu/matlab/student_license/login.php &amp;#039;&amp;#039;&amp;#039;here&amp;#039;&amp;#039;&amp;#039;].  If you already have the oscilloscope and multimeter from this year&amp;#039;s ME 233 offering, you should choose &amp;quot;ME 333 (w/o ME 233 equipment)&amp;quot; for the price of $75.  If you do not have the oscilloscope and multimeter, you should choose &amp;quot;ME 333 (w/ ME 233 equipment)&amp;quot; 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.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;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&amp;#039;t complete this before the first day of class, you will need to do it before the second class.&amp;#039;&amp;#039;&amp;#039;  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. &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;!-- * Download and install software described on [[NU32v2: Software to Install|this page]].  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Student Contract ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* Allowing another student to copy your code.&lt;br /&gt;
* Copying another student&amp;#039;s code, in whole or in part.&lt;br /&gt;
* Transforming copied sections of code to try to disguise their origin.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
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]].&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
&lt;br /&gt;
* [[Media:CrashCourseinC.pdf|A Crash Course in C]]:  A brief introduction to the C programming language &lt;br /&gt;
([[Media:EssentialC.pdf|Essential C]] is also a very nice intro to C)&lt;br /&gt;
* handouts associated with individual classes&lt;br /&gt;
* wiki info on [[Microchip PICs]]&lt;br /&gt;
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (256 pages, 5 MB pdf)&lt;br /&gt;
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;amp;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.&lt;br /&gt;
* PIC32MX Peripheral Library (included as a .chm file under &amp;quot;Program Files\Microchip\MPLAB C32\doc&amp;quot; with your C32 compiler installation)&lt;br /&gt;
&lt;br /&gt;
Useful, but not required:&lt;br /&gt;
&lt;br /&gt;
* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1294091438&amp;amp;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.&lt;br /&gt;
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under &amp;quot;doc&amp;quot; of your C32 compiler installation&lt;br /&gt;
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]] of &amp;quot;The C Book,&amp;quot; and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1294091625&amp;amp;sr=1-1 C Programming Language] reference book by Kernighan and Ritchie&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
Grades will be approximately 40% quizzes and 60% assignments.  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 demo in lieu of a final exam.&lt;br /&gt;
&lt;br /&gt;
== Homework Submission ==&lt;br /&gt;
All homework will be submitted on Blackboard.  Here are a few guidelines/ tips associated with homework submissions:&lt;br /&gt;
* We expect the required files for each assignment to be compressed together in a zip file (no rar files).&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 &amp;quot;project properties&amp;quot; in both IDEs, it is possible to generate &amp;quot;Additional warnings.&amp;quot;  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.&lt;br /&gt;
&lt;br /&gt;
== Approximate Syllabus ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Topics we will cover include:&lt;br /&gt;
&lt;br /&gt;
* introduction to C programming (here&amp;#039;s a [[Media:invest.c|simple tutorial C program]])&lt;br /&gt;
* quiz on circuits&lt;br /&gt;
* introduction to the PIC32 hardware, and programming the PIC32 in C&lt;br /&gt;
* digital I/O&lt;br /&gt;
* counters/timers and interrupts&lt;br /&gt;
* analog input&lt;br /&gt;
* sensor smorgasbord&lt;br /&gt;
* digital signal processing:  filters and FFTs&lt;br /&gt;
* analog output and pulse-width modulation&lt;br /&gt;
* brushed permanent magnet DC motors:  theory and control&lt;br /&gt;
* stepper motors and RC servo motors&lt;br /&gt;
* communication by SPI, I2C, and RS-232&lt;br /&gt;
&lt;br /&gt;
By class (note:  DS = Data Sheet, RM = Reference Manual):&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 1&amp;#039;&amp;#039;&amp;#039; (Th 1/5)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Course overview.  Circuits review.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Practice problem set and quiz on [[ME_333_Circuits_Review_Material|this page]], as well as background reading as needed.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 2&amp;#039;&amp;#039;&amp;#039; (T 1/10)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling and linking).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:invest.c|Sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 3&amp;#039;&amp;#039;&amp;#039; (Th 1/12)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  Circuits.  ([[Media:ME333_Quiz1_2012_Solutions.pdf|Solutions]]; high score 45/46, average 33.4, stdev 7.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continue with [[Media:invest.c|sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 out&amp;#039;&amp;#039;&amp;#039;:  &amp;#039;&amp;#039;&amp;#039;Problems 1-6 and 9&amp;#039;&amp;#039;&amp;#039; 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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 4&amp;#039;&amp;#039;&amp;#039; (T 1/17)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (syntax).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 5&amp;#039;&amp;#039;&amp;#039; (Th 1/19)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/12. [[Media:Assignment1Solutions.pdf|Solutions]] ([[Media:lightbulbs.c|lightbulbs.c]])&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  The PIC32 microcontroller hardware.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32hardware.pdf|PIC 32 hardware handout]], Data Sheet, Reference Manual&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 6&amp;#039;&amp;#039;&amp;#039; (T 1/24)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 1, particularly Section 1.1 and Sections 1.2.5-1.2.8 of the CCC document.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  virtual and physical memory, NU32 board, beginning PIC32 programming, digital I/O SFRs&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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&amp;#039;s website.  We will discuss [[Media:simple_pic.c|this simple PIC program]].  Also, [[NU32: A Detailed Look at Programming the PIC32 on the NU32]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 7&amp;#039;&amp;#039;&amp;#039; (Th 1/26)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/19.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 8&amp;#039;&amp;#039;&amp;#039; (T 1/31)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 2.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 9&amp;#039;&amp;#039;&amp;#039; (Th 2/2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 1/26.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 10&amp;#039;&amp;#039;&amp;#039; (T 2/7)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 3.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 11&amp;#039;&amp;#039;&amp;#039; (Th 2/9)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/2.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 12&amp;#039;&amp;#039;&amp;#039; (T 2/14)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 4.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 13&amp;#039;&amp;#039;&amp;#039; (Th 2/16)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/9.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 14&amp;#039;&amp;#039;&amp;#039; (T 2/21)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 5.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 15&amp;#039;&amp;#039;&amp;#039; (Th 2/23)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/16.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 16&amp;#039;&amp;#039;&amp;#039; (T 2/28)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 6&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 17&amp;#039;&amp;#039;&amp;#039; (Th 3/1)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 18&amp;#039;&amp;#039;&amp;#039; (T 3/6)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: yes&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 19&amp;#039;&amp;#039;&amp;#039; (Th 3/8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Final Demo&amp;#039;&amp;#039;&amp;#039;:  Monday 3/12, 3-5 PM, for 12:30-1:50 section; Wednesday 3/14, 9-11 AM, for 11:00-12:20 section&lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
&lt;br /&gt;
Q: Do I need to know the C language to take this course?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: Is there an independent project?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: What kind of laptop do I need?&lt;br /&gt;
&lt;br /&gt;
A: You need a laptop with at least 2 USB ports.  Any operating system is fine.&lt;br /&gt;
&lt;br /&gt;
== ME 333 Winter 2010 (obsolete) ==&lt;br /&gt;
&lt;br /&gt;
* [[ME 333 Circuits Review Material]]&lt;br /&gt;
* [http://www.youtube.com/NUmechatronics NUmechatronics youtube channel]&lt;br /&gt;
* [[ME 333 final projects]]&lt;br /&gt;
* [[PCB Artist]]&lt;br /&gt;
* [[ME 333 Suggested Final Projects]]&lt;br /&gt;
* [[ME 333 end of course schedule]]&lt;br /&gt;
* [[ME 333 Lab Kits]]&lt;br /&gt;
* [[Processing]] (software allowing you to create GUIs on your PC and interface through your USB port)&lt;br /&gt;
* Labs from Winter 2010&lt;br /&gt;
** [[Getting Started with PIC32|ME 333 Lab 1:  Getting started with the PIC32]]&lt;br /&gt;
** [[ME 333 Lab 2]]&lt;br /&gt;
** [http://lims.mech.northwestern.edu/~lynch/courses/ME333/PIClabs/lab3/lab3.html ME 333 Lab 3]&lt;br /&gt;
** [[ME 333 Lab 4]]&lt;br /&gt;
** [[ME 333 Lab 5]]&lt;br /&gt;
* Ungraded study problems (be sure to attempt to solve the problems before looking at the solutions!)&lt;br /&gt;
** [[ME 333 Circuits Review Material]]&lt;br /&gt;
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]&lt;br /&gt;
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[NU32v2:  A Detailed Look at Programming the PIC32]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=20915</id>
		<title>ME 333 Introduction to Mechatronics (Archive Winter 2012)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=20915"/>
		<updated>2012-01-24T17:31:15Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Winter Quarter 2012&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
(Here is an [[ME 333 Introduction to Mechatronics (Archive Winter 2011)|Archive of Winter 2011]])&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;First day of class is Thursday Jan 5!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Section 20:  Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5&lt;br /&gt;
* Section 21:  Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5&lt;br /&gt;
* TAs:  Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu&lt;br /&gt;
* Circuits Review Session:  Mon Jan 9, 7 PM, Prof. Lynch, Tech L221; Wed Jan 11, 7 PM, Prof. Marchuk, Tech L221&lt;br /&gt;
* C Peer Instruction Sessions, 7-8:30 PM, Seeley-Mudd Engineering Library Room 230&lt;br /&gt;
** Thurs Jan 12&lt;br /&gt;
** Tues Jan 17&lt;br /&gt;
** Wed Jan 18&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Final demo&amp;#039;&amp;#039;&amp;#039; (in lieu of final exam):  11-12:20 section Wed March 14 9-11 AM; 12:30-1:50 section Monday March 12 3-5 PM&lt;br /&gt;
* Office Hours:  &lt;br /&gt;
** Mon 4-6 PM:  Jarvis Schultz, Mechatronics Lab, Ford B100&lt;br /&gt;
** Tues 2-3 PM:  Prof. Lynch, B221&lt;br /&gt;
** Wed 3-5 PM:  Nelson Rosa, Mechatronics Lab, Ford B100&lt;br /&gt;
**Thurs 3-4 PM:  Prof. Lynch, B221&lt;br /&gt;
** Fri 3-4 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
** Mon-Fri 4-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Checklist to Complete Before the First Day of Class ==&lt;br /&gt;
&lt;br /&gt;
Attendance at the first day of class (Thursday Jan 5) is mandatory.  By the first day of class, you should:&lt;br /&gt;
&lt;br /&gt;
* Be able to solve circuit problems similar to those on the practice problem set and last year&amp;#039;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.&lt;br /&gt;
* 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.  &lt;br /&gt;
* Buy your class kit [http://it.mccormick.northwestern.edu/matlab/student_license/login.php &amp;#039;&amp;#039;&amp;#039;here&amp;#039;&amp;#039;&amp;#039;].  If you already have the oscilloscope and multimeter from this year&amp;#039;s ME 233 offering, you should choose &amp;quot;ME 333 (w/o ME 233 equipment)&amp;quot; for the price of $75.  If you do not have the oscilloscope and multimeter, you should choose &amp;quot;ME 333 (w/ ME 233 equipment)&amp;quot; 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.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;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&amp;#039;t complete this before the first day of class, you will need to do it before the second class.&amp;#039;&amp;#039;&amp;#039;  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. &amp;#039;&amp;#039;&amp;#039;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.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;!-- * Download and install software described on [[NU32v2: Software to Install|this page]].  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Student Contract ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* Allowing another student to copy your code.&lt;br /&gt;
* Copying another student&amp;#039;s code, in whole or in part.&lt;br /&gt;
* Transforming copied sections of code to try to disguise their origin.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
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]].&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
&lt;br /&gt;
* [[Media:CrashCourseinC.pdf|A Crash Course in C]]:  A brief introduction to the C programming language &lt;br /&gt;
([[Media:EssentialC.pdf|Essential C]] is also a very nice intro to C)&lt;br /&gt;
* handouts associated with individual classes&lt;br /&gt;
* wiki info on [[Microchip PICs]]&lt;br /&gt;
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (256 pages, 5 MB pdf)&lt;br /&gt;
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;amp;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.&lt;br /&gt;
* PIC32MX Peripheral Library (included as a .chm file under &amp;quot;Program Files\Microchip\MPLAB C32\doc&amp;quot; with your C32 compiler installation)&lt;br /&gt;
&lt;br /&gt;
Useful, but not required:&lt;br /&gt;
&lt;br /&gt;
* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1294091438&amp;amp;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.&lt;br /&gt;
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under &amp;quot;doc&amp;quot; of your C32 compiler installation&lt;br /&gt;
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]] of &amp;quot;The C Book,&amp;quot; and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1294091625&amp;amp;sr=1-1 C Programming Language] reference book by Kernighan and Ritchie&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
Grades will be approximately 40% quizzes and 60% assignments.  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 demo in lieu of a final exam.&lt;br /&gt;
&lt;br /&gt;
== Homework Submission ==&lt;br /&gt;
All homework will be submitted on Blackboard.  Here are a few guidelines/ tips associated with homework submissions:&lt;br /&gt;
* We expect the required files for each assignment to be compressed together in a zip file (no rar files).&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 Ctrl+Shift+f (Linux and Windows) will format that region according to your local formatting preferences.&lt;br /&gt;
* 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 &amp;quot;project properties&amp;quot; in both IDEs, it is possible to generate &amp;quot;Additional warnings.&amp;quot;  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.&lt;br /&gt;
&lt;br /&gt;
== Approximate Syllabus ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Topics we will cover include:&lt;br /&gt;
&lt;br /&gt;
* introduction to C programming (here&amp;#039;s a [[Media:invest.c|simple tutorial C program]])&lt;br /&gt;
* quiz on circuits&lt;br /&gt;
* introduction to the PIC32 hardware, and programming the PIC32 in C&lt;br /&gt;
* digital I/O&lt;br /&gt;
* counters/timers and interrupts&lt;br /&gt;
* analog input&lt;br /&gt;
* sensor smorgasbord&lt;br /&gt;
* digital signal processing:  filters and FFTs&lt;br /&gt;
* analog output and pulse-width modulation&lt;br /&gt;
* brushed permanent magnet DC motors:  theory and control&lt;br /&gt;
* stepper motors and RC servo motors&lt;br /&gt;
* communication by SPI, I2C, and RS-232&lt;br /&gt;
&lt;br /&gt;
By class (note:  DS = Data Sheet, RM = Reference Manual):&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 1&amp;#039;&amp;#039;&amp;#039; (Th 1/5)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Course overview.  Circuits review.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Practice problem set and quiz on [[ME_333_Circuits_Review_Material|this page]], as well as background reading as needed.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 2&amp;#039;&amp;#039;&amp;#039; (T 1/10)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling and linking).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:invest.c|Sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 3&amp;#039;&amp;#039;&amp;#039; (Th 1/12)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  Circuits.  ([[Media:ME333_Quiz1_2012_Solutions.pdf|Solutions]]; high score 45/46, average 33.4, stdev 7.8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continue with [[Media:invest.c|sample program]], [[Media:CrashCourseinC.pdf|A Crash Course in C]] (section numbers referenced in program comments).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 out&amp;#039;&amp;#039;&amp;#039;:  &amp;#039;&amp;#039;&amp;#039;Problems 1-6 and 9&amp;#039;&amp;#039;&amp;#039; 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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 4&amp;#039;&amp;#039;&amp;#039; (T 1/17)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (syntax).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 5&amp;#039;&amp;#039;&amp;#039; (Th 1/19)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/12. [[Media:Assignment1Solutions.pdf|Solutions]] ([[Media:lightbulbs.c|lightbulbs.c]])&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  The PIC32 microcontroller hardware.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:PIC32hardware.pdf|PIC 32 hardware handout]], Data Sheet, Reference Manual&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 out&amp;#039;&amp;#039;&amp;#039;:  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.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 6&amp;#039;&amp;#039;&amp;#039; (T 1/24)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 1, particularly Section 1.1 and Sections 1.2.5-1.2.8 of the CCC document.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  virtual and physical memory, NU32 board, beginning PIC32 programming, digital I/O SFRs&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;: [[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&amp;#039;s website.  We will discuss [[Media:simple_pic.c|this simple PIC program]].  Also, [[NU32: A Detailed Look at Programming the PIC32 on the NU32]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 7&amp;#039;&amp;#039;&amp;#039; (Th 1/26)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 due&amp;#039;&amp;#039;&amp;#039;:  Handed out on Thurs 1/19.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Continued from previous class.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 8&amp;#039;&amp;#039;&amp;#039; (T 1/31)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 2.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 9&amp;#039;&amp;#039;&amp;#039; (Th 2/2)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 1/26.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 10&amp;#039;&amp;#039;&amp;#039; (T 2/7)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 3.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 11&amp;#039;&amp;#039;&amp;#039; (Th 2/9)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/2.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 12&amp;#039;&amp;#039;&amp;#039; (T 2/14)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 4.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 13&amp;#039;&amp;#039;&amp;#039; (Th 2/16)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/9.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 14&amp;#039;&amp;#039;&amp;#039; (T 2/21)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 5.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 15&amp;#039;&amp;#039;&amp;#039; (Th 2/23)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 due&amp;#039;&amp;#039;&amp;#039;: Handed out on Thurs 2/16.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 out&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 16&amp;#039;&amp;#039;&amp;#039; (T 2/28)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: On the topic of Assignment 6&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 17&amp;#039;&amp;#039;&amp;#039; (Th 3/1)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 18&amp;#039;&amp;#039;&amp;#039; (T 3/6)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;: yes&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 19&amp;#039;&amp;#039;&amp;#039; (Th 3/8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Final Demo&amp;#039;&amp;#039;&amp;#039;:  Monday 3/12, 3-5 PM, for 12:30-1:50 section; Wednesday 3/14, 9-11 AM, for 11:00-12:20 section&lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
&lt;br /&gt;
Q: Do I need to know the C language to take this course?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: Is there an independent project?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: What kind of laptop do I need?&lt;br /&gt;
&lt;br /&gt;
A: You need a laptop with at least 2 USB ports.  Any operating system is fine.&lt;br /&gt;
&lt;br /&gt;
== ME 333 Winter 2010 (obsolete) ==&lt;br /&gt;
&lt;br /&gt;
* [[ME 333 Circuits Review Material]]&lt;br /&gt;
* [http://www.youtube.com/NUmechatronics NUmechatronics youtube channel]&lt;br /&gt;
* [[ME 333 final projects]]&lt;br /&gt;
* [[PCB Artist]]&lt;br /&gt;
* [[ME 333 Suggested Final Projects]]&lt;br /&gt;
* [[ME 333 end of course schedule]]&lt;br /&gt;
* [[ME 333 Lab Kits]]&lt;br /&gt;
* [[Processing]] (software allowing you to create GUIs on your PC and interface through your USB port)&lt;br /&gt;
* Labs from Winter 2010&lt;br /&gt;
** [[Getting Started with PIC32|ME 333 Lab 1:  Getting started with the PIC32]]&lt;br /&gt;
** [[ME 333 Lab 2]]&lt;br /&gt;
** [http://lims.mech.northwestern.edu/~lynch/courses/ME333/PIClabs/lab3/lab3.html ME 333 Lab 3]&lt;br /&gt;
** [[ME 333 Lab 4]]&lt;br /&gt;
** [[ME 333 Lab 5]]&lt;br /&gt;
* Ungraded study problems (be sure to attempt to solve the problems before looking at the solutions!)&lt;br /&gt;
** [[ME 333 Circuits Review Material]]&lt;br /&gt;
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]&lt;br /&gt;
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[NU32v2:  A Detailed Look at Programming the PIC32]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32:_Serial_Communication_with_the_PC&amp;diff=20914</id>
		<title>NU32: Serial Communication with the PC</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32:_Serial_Communication_with_the_PC&amp;diff=20914"/>
		<updated>2012-01-24T16:32:42Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Python */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The NU32 has the ability to talk directly with a computer over a virtual serial port connection.  This ability can be used to debug code, transfer data, and interact with the microcontroller using a computer. &lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The NU32 uses an on board [http://www.ftdichip.com/Products/ICs/FT2232H.htm FT2232H] chip from FTDI to convert [http://en.wikipedia.org/wiki/RS-232 RS-232 TTL serial communication] to USB.  Using drivers from FTDI, the communication can be opened by any program that can access a [http://en.wikipedia.org/wiki/Serial_port virtual serial port].  On the NU32, sample code has been created to enable the UART module on the PIC32.  Using this code you can write strings to the computer, and generate an interrupt when characters are received. On the computer, several programs that can access the serial connection are discussed, including Processing, MATLAB, Python, and terminal programs.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
The FT2232H chip is hardwired the to UART1 (F2 and F8, for general communication) and UART4 (D14 and D15, for bootloading) modules on the PIC32MX795F512L.  The Receive (RX) pins, F2 and D14, and Transmit (TX) pins, F8 and D15, are also brought out to the sides of the NU32 board.  &amp;#039;&amp;#039;&amp;#039;They should not be used as general IO.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Serial communication is asynchronous, it does not use an external clock signal to know when to read individual bits. Instead, the sender and receiver decide beforehand what frequency to transmit data. This frequency is called the baud rate and must match on both the NU32 and computer for the data to be interpreted correctly.&lt;br /&gt;
&lt;br /&gt;
The NU32 uses the UART1 and UART4 modules at 115200 baud, as does the sample code below.&lt;br /&gt;
&lt;br /&gt;
== Library Functions ==&lt;br /&gt;
[[Media:NU32_serial_example.zip | This code]] contains functions to read characters and write strings over the serial port. It uses the same header files as &amp;quot;Hello World&amp;quot;.&lt;br /&gt;
*NU32.c contains the functions to initialize the LEDs and USER button on the NU32 board, and to initialize the UART modules.  &lt;br /&gt;
*NU32.h contains function prototypes for the .c file.&lt;br /&gt;
**&amp;#039;&amp;#039;&amp;#039;You do not need to modify these files to use serial communication.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The functions that control the serial communication are:&lt;br /&gt;
*void initSerialNU32(void) - enables UART1 and UART4 at 115200 baud with an interrupt at priority level 2 and 3&lt;br /&gt;
*void WriteString(UART_MODULE, const char *) - call with UART1 and the character array you wish to send&lt;br /&gt;
*void PutCharacter(UART_MODULE, const char) - writes an individual character to the computer when the module is able to, called by WriteString()&lt;br /&gt;
&lt;br /&gt;
NU32_serial_example.c in the .zip file above demonstrates how to use the functions.&lt;br /&gt;
&lt;br /&gt;
== Sample Code ==&lt;br /&gt;
&lt;br /&gt;
To initialize the serial communication, call initSerialNU32():&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  initSerialNU32();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To write a string to the computer, use WriteString(UART1, charArray). The special characters &amp;#039;\r&amp;#039; and &amp;#039;\n&amp;#039; are carriage return and newline. Using them together puts the cursor on the next line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  WriteString(UART1, &amp;quot;\r\nHello World!\r\n&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To write a string with the value of a variable in it, use sprintf(RS232_Out_Buffer,charArray) and WriteString(UART1, charArray). RS232_Out_Buffer is declared in NU32.h as a char array with 32 elements.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sprintf(RS232_Out_Buffer, &amp;quot;the value of i is: %d\r\n&amp;quot;, i);&lt;br /&gt;
  WriteString(UART3, RS232_Out_Buffer);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To receive characters in an interrupt, use this interrupt service routine (ISR): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void __ISR(_UART_1_VECTOR, ipl2) IntUart1Handler(void) {&lt;br /&gt;
  // Is this an RX interrupt?&lt;br /&gt;
  if(INTGetFlag(INT_SOURCE_UART_RX(UART1))){&lt;br /&gt;
    char data = UARTGetDataByte(UART1);&lt;br /&gt;
&lt;br /&gt;
    // now do something with data&lt;br /&gt;
&lt;br /&gt;
    // Clear the RX interrupt Flag&lt;br /&gt;
    INTClearFlag(INT_SOURCE_UART_RX(UART1)); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // If the interrupt was on TX (ignore it)&lt;br /&gt;
  if(INTGetFlag(INT_SOURCE_UART_TX(UART1))) {&lt;br /&gt;
    INTClearFlag(INT_SOURCE_UART_TX(UART1));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NU32_serial_example.c initializes the serial communication, and then waits until it receives the character &amp;#039;a&amp;#039; from the computer. When it gets an &amp;#039;a&amp;#039;, it replies back with numbers 0 through 9, each on their own line, and then waits for another &amp;#039;a&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//////LIBRARIES&lt;br /&gt;
#include &amp;lt;plib.h&amp;gt; // for PIC specific functions&lt;br /&gt;
#include &amp;quot;NU32.h&amp;quot; // for NU32 board specific functions&lt;br /&gt;
&lt;br /&gt;
//////GLOBAL VARIABLES&lt;br /&gt;
&lt;br /&gt;
//////FUNCTION PROTOTYPES&lt;br /&gt;
&lt;br /&gt;
//////MAIN&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    startup(); // from NU32.c, maximizes performance&lt;br /&gt;
    initialize(); // from NU32.c, inits USER, L1 and L2, serial fns&lt;br /&gt;
&lt;br /&gt;
    // infinite loop&lt;br /&gt;
    while(1)&lt;br /&gt;
    {&lt;br /&gt;
        // nothing, do everything in the UART1 ISR&lt;br /&gt;
    }&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////FUNCTIONS&lt;br /&gt;
&lt;br /&gt;
//////ISRs&lt;br /&gt;
// interrupt when the NU32 gets a character from the computer&lt;br /&gt;
void __ISR(_UART_1_VECTOR, ipl2) IntUart1Handler(void)&lt;br /&gt;
{&lt;br /&gt;
    int i = 0;&lt;br /&gt;
&lt;br /&gt;
    // Is this an RX interrupt?&lt;br /&gt;
    if(INTGetFlag(INT_SOURCE_UART_RX(UART1)))&lt;br /&gt;
    {&lt;br /&gt;
        // read the byte&lt;br /&gt;
        char data = UARTGetDataByte(UART1);&lt;br /&gt;
&lt;br /&gt;
        // if the byte is an &amp;#039;a&amp;#039;, send back 0-9&lt;br /&gt;
        if (data == &amp;#039;a&amp;#039;) {&lt;br /&gt;
            for (i=0; i&amp;lt;10; i++) {&lt;br /&gt;
                sprintf(RS232_Out_Buffer,&amp;quot;%d\r\n&amp;quot;, i);&lt;br /&gt;
                WriteString(UART1, RS232_Out_Buffer);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // Clear the RX interrupt Flag&lt;br /&gt;
        INTClearFlag(INT_SOURCE_UART_RX(UART1));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // We don&amp;#039;t care about TX interrupt&lt;br /&gt;
    if(INTGetFlag(INT_SOURCE_UART_TX(UART1)))&lt;br /&gt;
    {&lt;br /&gt;
        INTClearFlag(INT_SOURCE_UART_TX(UART1));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Communicating with NU32_Utility ==&lt;br /&gt;
The right hand side of the NU32_Utility program is a debugger that will display any character received from the &amp;#039;Debug&amp;#039; port, and will send any characters in the text entry using &amp;#039;Send&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Compile the code and put it on your NU32. Send an &amp;#039;a&amp;#039; with the debugger and you should see the following:&lt;br /&gt;
&lt;br /&gt;
[[Image:NU32_utility_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Communicating with a Terminal Program ==&lt;br /&gt;
The NU32_Utility debugger is based on a more traditional [http://en.wikipedia.org/wiki/Terminal_emulator Terminal emulator] program. Terminal programs let you choose the baud rate, flow control, and many other aspects of serial communication, and let you view the incoming bytes as ASCII text or hex bytes. A Terminal program is useful when you want to see hidden characters that the NU32_Utility can not display.&lt;br /&gt;
&lt;br /&gt;
On Windows, you can use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] or [http://realterm.sourceforge.net/index.html#downloads_Download RealTerm].&lt;br /&gt;
&lt;br /&gt;
On a MAC, you can use [http://www.iterm2.com/#/section/home iTerm2].&lt;br /&gt;
&lt;br /&gt;
In Linux people commonly use [https://help.ubuntu.com/community/Minicom minicom] or [https://fedorahosted.org/gtkterm/ gtkterm].&lt;br /&gt;
&lt;br /&gt;
When you use a Terminal program, make sure that you know the communication port name and baud before opening the program. &amp;#039;&amp;#039;&amp;#039;Also be sure that the port is not already open in another program. A port can only be open in one place at a time!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The Terminal programs vary in use, but for example, launch Putty.exe. Set up your communication by:&lt;br /&gt;
*Selecting the &amp;#039;Serial&amp;#039; radio button&lt;br /&gt;
&lt;br /&gt;
Select the &amp;#039;Serial&amp;#039; branch in the tree on the bottom left.&lt;br /&gt;
*Enter the name of your COM port in &amp;#039;Serial line to connect to&amp;#039;&lt;br /&gt;
*Enter 115200 in &amp;#039;Speed (baud)&amp;#039;&lt;br /&gt;
*Change &amp;#039;Flow control&amp;#039; from &amp;#039;XON/XOFF&amp;#039; to &amp;#039;None&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Go back to the &amp;#039;Session&amp;#039; screen by selecting the &amp;#039;Session&amp;#039; in the top left of the tree.&lt;br /&gt;
*Name your settings in &amp;#039;Saved Sessions&amp;#039; and click &amp;#039;Save&amp;#039;&lt;br /&gt;
*Click the &amp;#039;Open&amp;#039; button&lt;br /&gt;
&lt;br /&gt;
Type an &amp;#039;a&amp;#039;. Notice you do not get to see what you typed in! In this case it would be the responsibility of the NU32 to echo back any characters it receives so that you can verify what was typed in.&lt;br /&gt;
&lt;br /&gt;
[[Image:PuTTY_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Processing ==&lt;br /&gt;
[http://processing.org/ Processing] is a free IDE that is easy to use, makes nice graphics, and easily performs serial communication. The NU32_Utility was written in Processing.&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;See the [[Processing]] page for more specific information on Processing.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following code is a simple Processing sketch that will open a serial port, print any characters received to the Debug window, and send an &amp;#039;a&amp;#039; if a key on the keyboard is pressed and released:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Based on the SimpleRead example&lt;br /&gt;
import processing.serial.*;&lt;br /&gt;
&lt;br /&gt;
Serial myPort;  // Create object from Serial class&lt;br /&gt;
&lt;br /&gt;
// setup() runs first but only once, use it to initialize things&lt;br /&gt;
void setup() &lt;br /&gt;
{&lt;br /&gt;
  size(200, 200); // the size of the Processing window in pixels&lt;br /&gt;
  background(255); // Set background to white&lt;br /&gt;
  println(Serial.list()); // print all of the serial ports that&lt;br /&gt;
                          // are available, you need to know what&lt;br /&gt;
                          // port to open in the next line&lt;br /&gt;
  // guess which port to open, if you get it wrong rerun the progam&lt;br /&gt;
  // after changing which port you open&lt;br /&gt;
  String portName = Serial.list()[1];&lt;br /&gt;
  myPort = new Serial(this, portName, 115200); // open the port&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// draw runs at 30fps (default)&lt;br /&gt;
void draw()&lt;br /&gt;
{&lt;br /&gt;
  if ( myPort.available() &amp;gt; 0) {  // If data is available,&lt;br /&gt;
    println(myPort.read()); // read it and store it in val&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if a key is pressed, on release send an &amp;#039;a&amp;#039;&lt;br /&gt;
void keyReleased() {&lt;br /&gt;
  myPort.write(&amp;#039;a&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following is output in the Debug window:&lt;br /&gt;
[[Image:Processing_serial_ex1.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What is that? Note that there are 30 characters. Processing has printed the decimal value of each character received!&lt;br /&gt;
&lt;br /&gt;
Try something else- Processing has the ability to check for incoming characters in parallel to running code in the Draw() routine:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Based on the SimpleRead example&lt;br /&gt;
import processing.serial.*;&lt;br /&gt;
&lt;br /&gt;
Serial myPort;  // Create object from Serial class&lt;br /&gt;
&lt;br /&gt;
// setup() runs first but only once, use it to initialize things&lt;br /&gt;
void setup() &lt;br /&gt;
{&lt;br /&gt;
  size(200, 200); // the size of the Processing window in pixels&lt;br /&gt;
  background(255); // Set background to white&lt;br /&gt;
  println(Serial.list()); // print all of the serial ports that&lt;br /&gt;
                          // are available, you need to know what&lt;br /&gt;
                          // port to open in the next line&lt;br /&gt;
  // guess which port to open, if you get it wrong rerun the progam&lt;br /&gt;
  // after changing which port you open&lt;br /&gt;
  String portName = Serial.list()[1];&lt;br /&gt;
  myPort = new Serial(this, portName, 115200); // open the port&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// draw runs at 30fps (default)&lt;br /&gt;
void draw()&lt;br /&gt;
{&lt;br /&gt;
  // nothing, do it in the serialEvent&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void serialEvent(Serial thisPort) {&lt;br /&gt;
  // read a byte from the port:&lt;br /&gt;
  int inByte = thisPort.read();&lt;br /&gt;
  println((char)inByte);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if a key is pressed, on release send an &amp;#039;a&amp;#039;&lt;br /&gt;
void keyReleased() {&lt;br /&gt;
  myPort.write(&amp;#039;a&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Processing_serial_ex2.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  int inByte = thisPort.read();&lt;br /&gt;
  println((char)inByte);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
shows the actual ASCII values for the numbers, but the &amp;#039;\r&amp;#039; and &amp;#039;\n&amp;#039; are not displayed! This is why it is sometimes nice to use the Terminal emulator.&lt;br /&gt;
&lt;br /&gt;
== MATLAB ==&lt;br /&gt;
MATLAB can open a serial port and send and receive data as well. This is useful when you need to plot data, perform a complicated mathematical function, or error check a function that you wrote in C to the function in MATLAB.&lt;br /&gt;
&lt;br /&gt;
To open a port in MATLAB, be sure to check if ports were not closed correctly, then try to open them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    % check to see if any ports are open&lt;br /&gt;
    % matlab is easily hung up if &lt;br /&gt;
    % the port is already open&lt;br /&gt;
    if ~isempty(instrfind)&lt;br /&gt;
        fclose(instrfind);&lt;br /&gt;
        delete(instrfind);&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % open up the port&lt;br /&gt;
    COM = serial(&amp;#039;COM14&amp;#039;);&lt;br /&gt;
    set(COM,&amp;#039;BaudRate&amp;#039;,115200);&lt;br /&gt;
    set(COM,&amp;#039;OutputBufferSize&amp;#039;,100);&lt;br /&gt;
    % set how long to wait when&lt;br /&gt;
    % doing fscanf&lt;br /&gt;
    set(COM,&amp;#039;Timeout&amp;#039;,20);&lt;br /&gt;
    fopen(COM);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To send data:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    fwrite(COM,&amp;#039;a&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To receive data:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    reading = fscanf(COM,&amp;#039;%i&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put together, the code looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    % clear the screen and memory&lt;br /&gt;
    clc;&lt;br /&gt;
    clear;&lt;br /&gt;
&lt;br /&gt;
    % check to see if any ports are open&lt;br /&gt;
    % matlab is easily hung up if &lt;br /&gt;
    % the port is already open&lt;br /&gt;
    if ~isempty(instrfind)&lt;br /&gt;
        fclose(instrfind);&lt;br /&gt;
        delete(instrfind);&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % open up the port&lt;br /&gt;
    COM = serial(&amp;#039;COM14&amp;#039;);&lt;br /&gt;
    set(COM,&amp;#039;BaudRate&amp;#039;,115200);&lt;br /&gt;
    set(COM,&amp;#039;OutputBufferSize&amp;#039;,100);&lt;br /&gt;
    % set how long to wait when&lt;br /&gt;
    % doing fscanf&lt;br /&gt;
    set(COM,&amp;#039;Timeout&amp;#039;,20);&lt;br /&gt;
    fopen(COM);&lt;br /&gt;
      &lt;br /&gt;
    % send an &amp;#039;a&amp;#039;&lt;br /&gt;
    fwrite(COM,&amp;#039;a&amp;#039;);&lt;br /&gt;
    % print to the screen &lt;br /&gt;
    % that we sent an &amp;#039;a&amp;#039;&lt;br /&gt;
    disp(&amp;#039;sent a&amp;#039;);&lt;br /&gt;
    &lt;br /&gt;
    % we know to expect 10 numbers&lt;br /&gt;
    i = 0;&lt;br /&gt;
    while (i&amp;lt;10)&lt;br /&gt;
        % read the number and print&lt;br /&gt;
        % to the screen&lt;br /&gt;
        reading = fscanf(COM,&amp;#039;%i&amp;#039;);&lt;br /&gt;
        disp(num2str(reading));&lt;br /&gt;
        i = i+1;&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % be sure to close the port&lt;br /&gt;
    fclose(COM);&lt;br /&gt;
    disp(&amp;#039;done&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result looks like:&lt;br /&gt;
[[Image:Matlab_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Python ==&lt;br /&gt;
For those familiar with Python, its [http://pyserial.sf.net/ serial library] can provide several useful, platform-independent functions for interfacing with the NU32 board.  The latest installation comes with a terminal emulator written in Python called [http://pyserial.sourceforge.net/examples.html#miniterm miniterm] (source code [http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/serial/tools/miniterm.py here]).  To run miniterm with the NU32 you would run a command on the command line similar to &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  python miniterm.py -p COM7 -b 115200 -e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the argument after the &amp;quot;-p&amp;quot; will be different depending on which port the NU32 is attached to on your computer.  On a MAC it would be something like &amp;quot;/DEV/TTY.USBSERIAL-000030FDA&amp;quot; and in Linux it might be &amp;quot;/dev/ttyUSB0&amp;quot;.  Also note that the &amp;quot;-e&amp;quot; argument is for turning on local echo.  In other words, when you hit a key it will show up in the output window.&lt;br /&gt;
&lt;br /&gt;
The following is a piece of sample Python code that replicates the other serial examples from above:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
## First we import the system module&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
## First thing that we need to do is import the serial library:&lt;br /&gt;
try:&lt;br /&gt;
    import serial&lt;br /&gt;
except ImportError:&lt;br /&gt;
    print &amp;quot;[FATAL] Serial library not found&amp;quot;&lt;br /&gt;
    sys.exit(0)&lt;br /&gt;
    &lt;br /&gt;
## open comm port&lt;br /&gt;
com = serial.Serial(&amp;#039;COM7&amp;#039;,baudrate=115200)&lt;br /&gt;
&lt;br /&gt;
## send &amp;#039;a&amp;#039; character&lt;br /&gt;
com.write(&amp;#039;a&amp;#039;)&lt;br /&gt;
print &amp;quot;sent &amp;#039;a&amp;#039;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
## read in values sent by PIC&lt;br /&gt;
data = com.read(30) ## we read 30 characters because Python counts the&lt;br /&gt;
                    ## \n and \r as characters&lt;br /&gt;
print &amp;quot;Incoming data:&amp;quot;&lt;br /&gt;
print data&lt;br /&gt;
&lt;br /&gt;
## close serial port:&lt;br /&gt;
com.close()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== More Information ==&lt;br /&gt;
&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32:_Serial_Communication_with_the_PC&amp;diff=20912</id>
		<title>NU32: Serial Communication with the PC</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32:_Serial_Communication_with_the_PC&amp;diff=20912"/>
		<updated>2012-01-24T16:09:02Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Python */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The NU32 has the ability to talk directly with a computer over a virtual serial port connection.  This ability can be used to debug code, transfer data, and interact with the microcontroller using a computer. &lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The NU32 uses an on board [http://www.ftdichip.com/Products/ICs/FT2232H.htm FT2232H] chip from FTDI to convert [http://en.wikipedia.org/wiki/RS-232 RS-232 TTL serial communication] to USB.  Using drivers from FTDI, the communication can be opened by any program that can access a [http://en.wikipedia.org/wiki/Serial_port virtual serial port].  On the NU32, sample code has been created to enable the UART module on the PIC32.  Using this code you can write strings to the computer, and generate an interrupt when characters are received. On the computer, several programs that can access the serial connection are discussed, including Processing, MATLAB, Python, and terminal programs.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
The FT2232H chip is hardwired the to UART1 (F2 and F8, for general communication) and UART4 (D14 and D15, for bootloading) modules on the PIC32MX795F512L.  The Receive (RX) pins, F2 and D14, and Transmit (TX) pins, F8 and D15, are also brought out to the sides of the NU32 board.  &amp;#039;&amp;#039;&amp;#039;They should not be used as general IO.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Serial communication is asynchronous, it does not use an external clock signal to know when to read individual bits. Instead, the sender and receiver decide beforehand what frequency to transmit data. This frequency is called the baud rate and must match on both the NU32 and computer for the data to be interpreted correctly.&lt;br /&gt;
&lt;br /&gt;
The NU32 uses the UART1 and UART4 modules at 115200 baud, as does the sample code below.&lt;br /&gt;
&lt;br /&gt;
== Library Functions ==&lt;br /&gt;
[[Media:NU32_serial_example.zip | This code]] contains functions to read characters and write strings over the serial port. It uses the same header files as &amp;quot;Hello World&amp;quot;.&lt;br /&gt;
*NU32.c contains the functions to initialize the LEDs and USER button on the NU32 board, and to initialize the UART modules.  &lt;br /&gt;
*NU32.h contains function prototypes for the .c file.&lt;br /&gt;
**&amp;#039;&amp;#039;&amp;#039;You do not need to modify these files to use serial communication.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The functions that control the serial communication are:&lt;br /&gt;
*void initSerialNU32(void) - enables UART1 and UART4 at 115200 baud with an interrupt at priority level 2 and 3&lt;br /&gt;
*void WriteString(UART_MODULE, const char *) - call with UART1 and the character array you wish to send&lt;br /&gt;
*void PutCharacter(UART_MODULE, const char) - writes an individual character to the computer when the module is able to, called by WriteString()&lt;br /&gt;
&lt;br /&gt;
NU32_serial_example.c in the .zip file above demonstrates how to use the functions.&lt;br /&gt;
&lt;br /&gt;
== Sample Code ==&lt;br /&gt;
&lt;br /&gt;
To initialize the serial communication, call initSerialNU32():&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  initSerialNU32();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To write a string to the computer, use WriteString(UART1, charArray). The special characters &amp;#039;\r&amp;#039; and &amp;#039;\n&amp;#039; are carriage return and newline. Using them together puts the cursor on the next line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  WriteString(UART1, &amp;quot;\r\nHello World!\r\n&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To write a string with the value of a variable in it, use sprintf(RS232_Out_Buffer,charArray) and WriteString(UART1, charArray). RS232_Out_Buffer is declared in NU32.h as a char array with 32 elements.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sprintf(RS232_Out_Buffer, &amp;quot;the value of i is: %d\r\n&amp;quot;, i);&lt;br /&gt;
  WriteString(UART3, RS232_Out_Buffer);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To receive characters in an interrupt, use this interrupt service routine (ISR): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void __ISR(_UART_1_VECTOR, ipl2) IntUart1Handler(void) {&lt;br /&gt;
  // Is this an RX interrupt?&lt;br /&gt;
  if(INTGetFlag(INT_SOURCE_UART_RX(UART1))){&lt;br /&gt;
    char data = UARTGetDataByte(UART1);&lt;br /&gt;
&lt;br /&gt;
    // now do something with data&lt;br /&gt;
&lt;br /&gt;
    // Clear the RX interrupt Flag&lt;br /&gt;
    INTClearFlag(INT_SOURCE_UART_RX(UART1)); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // If the interrupt was on TX (ignore it)&lt;br /&gt;
  if(INTGetFlag(INT_SOURCE_UART_TX(UART1))) {&lt;br /&gt;
    INTClearFlag(INT_SOURCE_UART_TX(UART1));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NU32_serial_example.c initializes the serial communication, and then waits until it receives the character &amp;#039;a&amp;#039; from the computer. When it gets an &amp;#039;a&amp;#039;, it replies back with numbers 0 through 9, each on their own line, and then waits for another &amp;#039;a&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//////LIBRARIES&lt;br /&gt;
#include &amp;lt;plib.h&amp;gt; // for PIC specific functions&lt;br /&gt;
#include &amp;quot;NU32.h&amp;quot; // for NU32 board specific functions&lt;br /&gt;
&lt;br /&gt;
//////GLOBAL VARIABLES&lt;br /&gt;
&lt;br /&gt;
//////FUNCTION PROTOTYPES&lt;br /&gt;
&lt;br /&gt;
//////MAIN&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    startup(); // from NU32.c, maximizes performance&lt;br /&gt;
    initialize(); // from NU32.c, inits USER, L1 and L2, serial fns&lt;br /&gt;
&lt;br /&gt;
    // infinite loop&lt;br /&gt;
    while(1)&lt;br /&gt;
    {&lt;br /&gt;
        // nothing, do everything in the UART1 ISR&lt;br /&gt;
    }&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////FUNCTIONS&lt;br /&gt;
&lt;br /&gt;
//////ISRs&lt;br /&gt;
// interrupt when the NU32 gets a character from the computer&lt;br /&gt;
void __ISR(_UART_1_VECTOR, ipl2) IntUart1Handler(void)&lt;br /&gt;
{&lt;br /&gt;
    int i = 0;&lt;br /&gt;
&lt;br /&gt;
    // Is this an RX interrupt?&lt;br /&gt;
    if(INTGetFlag(INT_SOURCE_UART_RX(UART1)))&lt;br /&gt;
    {&lt;br /&gt;
        // read the byte&lt;br /&gt;
        char data = UARTGetDataByte(UART1);&lt;br /&gt;
&lt;br /&gt;
        // if the byte is an &amp;#039;a&amp;#039;, send back 0-9&lt;br /&gt;
        if (data == &amp;#039;a&amp;#039;) {&lt;br /&gt;
            for (i=0; i&amp;lt;10; i++) {&lt;br /&gt;
                sprintf(RS232_Out_Buffer,&amp;quot;%d\r\n&amp;quot;, i);&lt;br /&gt;
                WriteString(UART1, RS232_Out_Buffer);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // Clear the RX interrupt Flag&lt;br /&gt;
        INTClearFlag(INT_SOURCE_UART_RX(UART1));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // We don&amp;#039;t care about TX interrupt&lt;br /&gt;
    if(INTGetFlag(INT_SOURCE_UART_TX(UART1)))&lt;br /&gt;
    {&lt;br /&gt;
        INTClearFlag(INT_SOURCE_UART_TX(UART1));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Communicating with NU32_Utility ==&lt;br /&gt;
The right hand side of the NU32_Utility program is a debugger that will display any character received from the &amp;#039;Debug&amp;#039; port, and will send any characters in the text entry using &amp;#039;Send&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Compile the code and put it on your NU32. Send an &amp;#039;a&amp;#039; with the debugger and you should see the following:&lt;br /&gt;
&lt;br /&gt;
[[Image:NU32_utility_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Communicating with a Terminal Program ==&lt;br /&gt;
The NU32_Utility debugger is based on a more traditional [http://en.wikipedia.org/wiki/Terminal_emulator Terminal emulator] program. Terminal programs let you choose the baud rate, flow control, and many other aspects of serial communication, and let you view the incoming bytes as ASCII text or hex bytes. A Terminal program is useful when you want to see hidden characters that the NU32_Utility can not display.&lt;br /&gt;
&lt;br /&gt;
On Windows, you can use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] or [http://realterm.sourceforge.net/index.html#downloads_Download RealTerm].&lt;br /&gt;
&lt;br /&gt;
On a MAC, you can use [http://www.iterm2.com/#/section/home iTerm2].&lt;br /&gt;
&lt;br /&gt;
In Linux people commonly use [https://help.ubuntu.com/community/Minicom minicom] or [https://fedorahosted.org/gtkterm/ gtkterm].&lt;br /&gt;
&lt;br /&gt;
When you use a Terminal program, make sure that you know the communication port name and baud before opening the program. &amp;#039;&amp;#039;&amp;#039;Also be sure that the port is not already open in another program. A port can only be open in one place at a time!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The Terminal programs vary in use, but for example, launch Putty.exe. Set up your communication by:&lt;br /&gt;
*Selecting the &amp;#039;Serial&amp;#039; radio button&lt;br /&gt;
&lt;br /&gt;
Select the &amp;#039;Serial&amp;#039; branch in the tree on the bottom left.&lt;br /&gt;
*Enter the name of your COM port in &amp;#039;Serial line to connect to&amp;#039;&lt;br /&gt;
*Enter 115200 in &amp;#039;Speed (baud)&amp;#039;&lt;br /&gt;
*Change &amp;#039;Flow control&amp;#039; from &amp;#039;XON/XOFF&amp;#039; to &amp;#039;None&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Go back to the &amp;#039;Session&amp;#039; screen by selecting the &amp;#039;Session&amp;#039; in the top left of the tree.&lt;br /&gt;
*Name your settings in &amp;#039;Saved Sessions&amp;#039; and click &amp;#039;Save&amp;#039;&lt;br /&gt;
*Click the &amp;#039;Open&amp;#039; button&lt;br /&gt;
&lt;br /&gt;
Type an &amp;#039;a&amp;#039;. Notice you do not get to see what you typed in! In this case it would be the responsibility of the NU32 to echo back any characters it receives so that you can verify what was typed in.&lt;br /&gt;
&lt;br /&gt;
[[Image:PuTTY_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Processing ==&lt;br /&gt;
[http://processing.org/ Processing] is a free IDE that is easy to use, makes nice graphics, and easily performs serial communication. The NU32_Utility was written in Processing.&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;See the [[Processing]] page for more specific information on Processing.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following code is a simple Processing sketch that will open a serial port, print any characters received to the Debug window, and send an &amp;#039;a&amp;#039; if a key on the keyboard is pressed and released:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Based on the SimpleRead example&lt;br /&gt;
import processing.serial.*;&lt;br /&gt;
&lt;br /&gt;
Serial myPort;  // Create object from Serial class&lt;br /&gt;
&lt;br /&gt;
// setup() runs first but only once, use it to initialize things&lt;br /&gt;
void setup() &lt;br /&gt;
{&lt;br /&gt;
  size(200, 200); // the size of the Processing window in pixels&lt;br /&gt;
  background(255); // Set background to white&lt;br /&gt;
  println(Serial.list()); // print all of the serial ports that&lt;br /&gt;
                          // are available, you need to know what&lt;br /&gt;
                          // port to open in the next line&lt;br /&gt;
  // guess which port to open, if you get it wrong rerun the progam&lt;br /&gt;
  // after changing which port you open&lt;br /&gt;
  String portName = Serial.list()[1];&lt;br /&gt;
  myPort = new Serial(this, portName, 115200); // open the port&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// draw runs at 30fps (default)&lt;br /&gt;
void draw()&lt;br /&gt;
{&lt;br /&gt;
  if ( myPort.available() &amp;gt; 0) {  // If data is available,&lt;br /&gt;
    println(myPort.read()); // read it and store it in val&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if a key is pressed, on release send an &amp;#039;a&amp;#039;&lt;br /&gt;
void keyReleased() {&lt;br /&gt;
  myPort.write(&amp;#039;a&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following is output in the Debug window:&lt;br /&gt;
[[Image:Processing_serial_ex1.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What is that? Note that there are 30 characters. Processing has printed the decimal value of each character received!&lt;br /&gt;
&lt;br /&gt;
Try something else- Processing has the ability to check for incoming characters in parallel to running code in the Draw() routine:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Based on the SimpleRead example&lt;br /&gt;
import processing.serial.*;&lt;br /&gt;
&lt;br /&gt;
Serial myPort;  // Create object from Serial class&lt;br /&gt;
&lt;br /&gt;
// setup() runs first but only once, use it to initialize things&lt;br /&gt;
void setup() &lt;br /&gt;
{&lt;br /&gt;
  size(200, 200); // the size of the Processing window in pixels&lt;br /&gt;
  background(255); // Set background to white&lt;br /&gt;
  println(Serial.list()); // print all of the serial ports that&lt;br /&gt;
                          // are available, you need to know what&lt;br /&gt;
                          // port to open in the next line&lt;br /&gt;
  // guess which port to open, if you get it wrong rerun the progam&lt;br /&gt;
  // after changing which port you open&lt;br /&gt;
  String portName = Serial.list()[1];&lt;br /&gt;
  myPort = new Serial(this, portName, 115200); // open the port&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// draw runs at 30fps (default)&lt;br /&gt;
void draw()&lt;br /&gt;
{&lt;br /&gt;
  // nothing, do it in the serialEvent&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void serialEvent(Serial thisPort) {&lt;br /&gt;
  // read a byte from the port:&lt;br /&gt;
  int inByte = thisPort.read();&lt;br /&gt;
  println((char)inByte);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if a key is pressed, on release send an &amp;#039;a&amp;#039;&lt;br /&gt;
void keyReleased() {&lt;br /&gt;
  myPort.write(&amp;#039;a&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Processing_serial_ex2.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  int inByte = thisPort.read();&lt;br /&gt;
  println((char)inByte);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
shows the actual ASCII values for the numbers, but the &amp;#039;\r&amp;#039; and &amp;#039;\n&amp;#039; are not displayed! This is why it is sometimes nice to use the Terminal emulator.&lt;br /&gt;
&lt;br /&gt;
== MATLAB ==&lt;br /&gt;
MATLAB can open a serial port and send and receive data as well. This is useful when you need to plot data, perform a complicated mathematical function, or error check a function that you wrote in C to the function in MATLAB.&lt;br /&gt;
&lt;br /&gt;
To open a port in MATLAB, be sure to check if ports were not closed correctly, then try to open them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    % check to see if any ports are open&lt;br /&gt;
    % matlab is easily hung up if &lt;br /&gt;
    % the port is already open&lt;br /&gt;
    if ~isempty(instrfind)&lt;br /&gt;
        fclose(instrfind);&lt;br /&gt;
        delete(instrfind);&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % open up the port&lt;br /&gt;
    COM = serial(&amp;#039;COM14&amp;#039;);&lt;br /&gt;
    set(COM,&amp;#039;BaudRate&amp;#039;,115200);&lt;br /&gt;
    set(COM,&amp;#039;OutputBufferSize&amp;#039;,100);&lt;br /&gt;
    % set how long to wait when&lt;br /&gt;
    % doing fscanf&lt;br /&gt;
    set(COM,&amp;#039;Timeout&amp;#039;,20);&lt;br /&gt;
    fopen(COM);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To send data:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    fwrite(COM,&amp;#039;a&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To receive data:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    reading = fscanf(COM,&amp;#039;%i&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put together, the code looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    % clear the screen and memory&lt;br /&gt;
    clc;&lt;br /&gt;
    clear;&lt;br /&gt;
&lt;br /&gt;
    % check to see if any ports are open&lt;br /&gt;
    % matlab is easily hung up if &lt;br /&gt;
    % the port is already open&lt;br /&gt;
    if ~isempty(instrfind)&lt;br /&gt;
        fclose(instrfind);&lt;br /&gt;
        delete(instrfind);&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % open up the port&lt;br /&gt;
    COM = serial(&amp;#039;COM14&amp;#039;);&lt;br /&gt;
    set(COM,&amp;#039;BaudRate&amp;#039;,115200);&lt;br /&gt;
    set(COM,&amp;#039;OutputBufferSize&amp;#039;,100);&lt;br /&gt;
    % set how long to wait when&lt;br /&gt;
    % doing fscanf&lt;br /&gt;
    set(COM,&amp;#039;Timeout&amp;#039;,20);&lt;br /&gt;
    fopen(COM);&lt;br /&gt;
      &lt;br /&gt;
    % send an &amp;#039;a&amp;#039;&lt;br /&gt;
    fwrite(COM,&amp;#039;a&amp;#039;);&lt;br /&gt;
    % print to the screen &lt;br /&gt;
    % that we sent an &amp;#039;a&amp;#039;&lt;br /&gt;
    disp(&amp;#039;sent a&amp;#039;);&lt;br /&gt;
    &lt;br /&gt;
    % we know to expect 10 numbers&lt;br /&gt;
    i = 0;&lt;br /&gt;
    while (i&amp;lt;10)&lt;br /&gt;
        % read the number and print&lt;br /&gt;
        % to the screen&lt;br /&gt;
        reading = fscanf(COM,&amp;#039;%i&amp;#039;);&lt;br /&gt;
        disp(num2str(reading));&lt;br /&gt;
        i = i+1;&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % be sure to close the port&lt;br /&gt;
    fclose(COM);&lt;br /&gt;
    disp(&amp;#039;done&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result looks like:&lt;br /&gt;
[[Image:Matlab_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Python ==&lt;br /&gt;
For those familiar with Python, its [http://pyserial.sf.net/ serial library] can provide several useful, platform-independent functions for interfacing with the NU32 board.  The latest installation comes with a terminal emulator written in Python called [http://pyserial.sourceforge.net/examples.html#miniterm miniterm] (source code [http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/serial/tools/miniterm.py here]).  To run miniterm with the NU32 you would run a command on the command line similar to &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  python miniterm.py -p COM7 -b 115200 -e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the argument after the &amp;quot;-p&amp;quot; will be different depending on which port the NU32 is attached to on your computer.  On a MAC it would be something like &amp;quot;/DEV/TTY.USBSERIAL-000030FDA&amp;quot; and in Linux it might be &amp;quot;/dev/ttyUSB0&amp;quot;.  Also note that the &amp;quot;-e&amp;quot; argument is for turning on local echo.  In other words, when you hit a key it will show up in the output window.&lt;br /&gt;
&lt;br /&gt;
== More Information ==&lt;br /&gt;
&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32:_Serial_Communication_with_the_PC&amp;diff=20911</id>
		<title>NU32: Serial Communication with the PC</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32:_Serial_Communication_with_the_PC&amp;diff=20911"/>
		<updated>2012-01-24T15:54:09Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* MATLAB */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The NU32 has the ability to talk directly with a computer over a virtual serial port connection.  This ability can be used to debug code, transfer data, and interact with the microcontroller using a computer. &lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The NU32 uses an on board [http://www.ftdichip.com/Products/ICs/FT2232H.htm FT2232H] chip from FTDI to convert [http://en.wikipedia.org/wiki/RS-232 RS-232 TTL serial communication] to USB.  Using drivers from FTDI, the communication can be opened by any program that can access a [http://en.wikipedia.org/wiki/Serial_port virtual serial port].  On the NU32, sample code has been created to enable the UART module on the PIC32.  Using this code you can write strings to the computer, and generate an interrupt when characters are received. On the computer, several programs that can access the serial connection are discussed, including Processing, MATLAB, Python, and terminal programs.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
The FT2232H chip is hardwired the to UART1 (F2 and F8, for general communication) and UART4 (D14 and D15, for bootloading) modules on the PIC32MX795F512L.  The Receive (RX) pins, F2 and D14, and Transmit (TX) pins, F8 and D15, are also brought out to the sides of the NU32 board.  &amp;#039;&amp;#039;&amp;#039;They should not be used as general IO.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Serial communication is asynchronous, it does not use an external clock signal to know when to read individual bits. Instead, the sender and receiver decide beforehand what frequency to transmit data. This frequency is called the baud rate and must match on both the NU32 and computer for the data to be interpreted correctly.&lt;br /&gt;
&lt;br /&gt;
The NU32 uses the UART1 and UART4 modules at 115200 baud, as does the sample code below.&lt;br /&gt;
&lt;br /&gt;
== Library Functions ==&lt;br /&gt;
[[Media:NU32_serial_example.zip | This code]] contains functions to read characters and write strings over the serial port. It uses the same header files as &amp;quot;Hello World&amp;quot;.&lt;br /&gt;
*NU32.c contains the functions to initialize the LEDs and USER button on the NU32 board, and to initialize the UART modules.  &lt;br /&gt;
*NU32.h contains function prototypes for the .c file.&lt;br /&gt;
**&amp;#039;&amp;#039;&amp;#039;You do not need to modify these files to use serial communication.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The functions that control the serial communication are:&lt;br /&gt;
*void initSerialNU32(void) - enables UART1 and UART4 at 115200 baud with an interrupt at priority level 2 and 3&lt;br /&gt;
*void WriteString(UART_MODULE, const char *) - call with UART1 and the character array you wish to send&lt;br /&gt;
*void PutCharacter(UART_MODULE, const char) - writes an individual character to the computer when the module is able to, called by WriteString()&lt;br /&gt;
&lt;br /&gt;
NU32_serial_example.c in the .zip file above demonstrates how to use the functions.&lt;br /&gt;
&lt;br /&gt;
== Sample Code ==&lt;br /&gt;
&lt;br /&gt;
To initialize the serial communication, call initSerialNU32():&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  initSerialNU32();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To write a string to the computer, use WriteString(UART1, charArray). The special characters &amp;#039;\r&amp;#039; and &amp;#039;\n&amp;#039; are carriage return and newline. Using them together puts the cursor on the next line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  WriteString(UART1, &amp;quot;\r\nHello World!\r\n&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To write a string with the value of a variable in it, use sprintf(RS232_Out_Buffer,charArray) and WriteString(UART1, charArray). RS232_Out_Buffer is declared in NU32.h as a char array with 32 elements.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sprintf(RS232_Out_Buffer, &amp;quot;the value of i is: %d\r\n&amp;quot;, i);&lt;br /&gt;
  WriteString(UART3, RS232_Out_Buffer);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To receive characters in an interrupt, use this interrupt service routine (ISR): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void __ISR(_UART_1_VECTOR, ipl2) IntUart1Handler(void) {&lt;br /&gt;
  // Is this an RX interrupt?&lt;br /&gt;
  if(INTGetFlag(INT_SOURCE_UART_RX(UART1))){&lt;br /&gt;
    char data = UARTGetDataByte(UART1);&lt;br /&gt;
&lt;br /&gt;
    // now do something with data&lt;br /&gt;
&lt;br /&gt;
    // Clear the RX interrupt Flag&lt;br /&gt;
    INTClearFlag(INT_SOURCE_UART_RX(UART1)); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // If the interrupt was on TX (ignore it)&lt;br /&gt;
  if(INTGetFlag(INT_SOURCE_UART_TX(UART1))) {&lt;br /&gt;
    INTClearFlag(INT_SOURCE_UART_TX(UART1));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NU32_serial_example.c initializes the serial communication, and then waits until it receives the character &amp;#039;a&amp;#039; from the computer. When it gets an &amp;#039;a&amp;#039;, it replies back with numbers 0 through 9, each on their own line, and then waits for another &amp;#039;a&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//////LIBRARIES&lt;br /&gt;
#include &amp;lt;plib.h&amp;gt; // for PIC specific functions&lt;br /&gt;
#include &amp;quot;NU32.h&amp;quot; // for NU32 board specific functions&lt;br /&gt;
&lt;br /&gt;
//////GLOBAL VARIABLES&lt;br /&gt;
&lt;br /&gt;
//////FUNCTION PROTOTYPES&lt;br /&gt;
&lt;br /&gt;
//////MAIN&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    startup(); // from NU32.c, maximizes performance&lt;br /&gt;
    initialize(); // from NU32.c, inits USER, L1 and L2, serial fns&lt;br /&gt;
&lt;br /&gt;
    // infinite loop&lt;br /&gt;
    while(1)&lt;br /&gt;
    {&lt;br /&gt;
        // nothing, do everything in the UART1 ISR&lt;br /&gt;
    }&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////FUNCTIONS&lt;br /&gt;
&lt;br /&gt;
//////ISRs&lt;br /&gt;
// interrupt when the NU32 gets a character from the computer&lt;br /&gt;
void __ISR(_UART_1_VECTOR, ipl2) IntUart1Handler(void)&lt;br /&gt;
{&lt;br /&gt;
    int i = 0;&lt;br /&gt;
&lt;br /&gt;
    // Is this an RX interrupt?&lt;br /&gt;
    if(INTGetFlag(INT_SOURCE_UART_RX(UART1)))&lt;br /&gt;
    {&lt;br /&gt;
        // read the byte&lt;br /&gt;
        char data = UARTGetDataByte(UART1);&lt;br /&gt;
&lt;br /&gt;
        // if the byte is an &amp;#039;a&amp;#039;, send back 0-9&lt;br /&gt;
        if (data == &amp;#039;a&amp;#039;) {&lt;br /&gt;
            for (i=0; i&amp;lt;10; i++) {&lt;br /&gt;
                sprintf(RS232_Out_Buffer,&amp;quot;%d\r\n&amp;quot;, i);&lt;br /&gt;
                WriteString(UART1, RS232_Out_Buffer);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // Clear the RX interrupt Flag&lt;br /&gt;
        INTClearFlag(INT_SOURCE_UART_RX(UART1));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // We don&amp;#039;t care about TX interrupt&lt;br /&gt;
    if(INTGetFlag(INT_SOURCE_UART_TX(UART1)))&lt;br /&gt;
    {&lt;br /&gt;
        INTClearFlag(INT_SOURCE_UART_TX(UART1));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Communicating with NU32_Utility ==&lt;br /&gt;
The right hand side of the NU32_Utility program is a debugger that will display any character received from the &amp;#039;Debug&amp;#039; port, and will send any characters in the text entry using &amp;#039;Send&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Compile the code and put it on your NU32. Send an &amp;#039;a&amp;#039; with the debugger and you should see the following:&lt;br /&gt;
&lt;br /&gt;
[[Image:NU32_utility_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Communicating with a Terminal Program ==&lt;br /&gt;
The NU32_Utility debugger is based on a more traditional [http://en.wikipedia.org/wiki/Terminal_emulator Terminal emulator] program. Terminal programs let you choose the baud rate, flow control, and many other aspects of serial communication, and let you view the incoming bytes as ASCII text or hex bytes. A Terminal program is useful when you want to see hidden characters that the NU32_Utility can not display.&lt;br /&gt;
&lt;br /&gt;
On Windows, you can use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] or [http://realterm.sourceforge.net/index.html#downloads_Download RealTerm].&lt;br /&gt;
&lt;br /&gt;
On a MAC, you can use [http://www.iterm2.com/#/section/home iTerm2].&lt;br /&gt;
&lt;br /&gt;
In Linux people commonly use [https://help.ubuntu.com/community/Minicom minicom] or [https://fedorahosted.org/gtkterm/ gtkterm].&lt;br /&gt;
&lt;br /&gt;
When you use a Terminal program, make sure that you know the communication port name and baud before opening the program. &amp;#039;&amp;#039;&amp;#039;Also be sure that the port is not already open in another program. A port can only be open in one place at a time!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The Terminal programs vary in use, but for example, launch Putty.exe. Set up your communication by:&lt;br /&gt;
*Selecting the &amp;#039;Serial&amp;#039; radio button&lt;br /&gt;
&lt;br /&gt;
Select the &amp;#039;Serial&amp;#039; branch in the tree on the bottom left.&lt;br /&gt;
*Enter the name of your COM port in &amp;#039;Serial line to connect to&amp;#039;&lt;br /&gt;
*Enter 115200 in &amp;#039;Speed (baud)&amp;#039;&lt;br /&gt;
*Change &amp;#039;Flow control&amp;#039; from &amp;#039;XON/XOFF&amp;#039; to &amp;#039;None&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Go back to the &amp;#039;Session&amp;#039; screen by selecting the &amp;#039;Session&amp;#039; in the top left of the tree.&lt;br /&gt;
*Name your settings in &amp;#039;Saved Sessions&amp;#039; and click &amp;#039;Save&amp;#039;&lt;br /&gt;
*Click the &amp;#039;Open&amp;#039; button&lt;br /&gt;
&lt;br /&gt;
Type an &amp;#039;a&amp;#039;. Notice you do not get to see what you typed in! In this case it would be the responsibility of the NU32 to echo back any characters it receives so that you can verify what was typed in.&lt;br /&gt;
&lt;br /&gt;
[[Image:PuTTY_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Processing ==&lt;br /&gt;
[http://processing.org/ Processing] is a free IDE that is easy to use, makes nice graphics, and easily performs serial communication. The NU32_Utility was written in Processing.&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;See the [[Processing]] page for more specific information on Processing.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following code is a simple Processing sketch that will open a serial port, print any characters received to the Debug window, and send an &amp;#039;a&amp;#039; if a key on the keyboard is pressed and released:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Based on the SimpleRead example&lt;br /&gt;
import processing.serial.*;&lt;br /&gt;
&lt;br /&gt;
Serial myPort;  // Create object from Serial class&lt;br /&gt;
&lt;br /&gt;
// setup() runs first but only once, use it to initialize things&lt;br /&gt;
void setup() &lt;br /&gt;
{&lt;br /&gt;
  size(200, 200); // the size of the Processing window in pixels&lt;br /&gt;
  background(255); // Set background to white&lt;br /&gt;
  println(Serial.list()); // print all of the serial ports that&lt;br /&gt;
                          // are available, you need to know what&lt;br /&gt;
                          // port to open in the next line&lt;br /&gt;
  // guess which port to open, if you get it wrong rerun the progam&lt;br /&gt;
  // after changing which port you open&lt;br /&gt;
  String portName = Serial.list()[1];&lt;br /&gt;
  myPort = new Serial(this, portName, 115200); // open the port&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// draw runs at 30fps (default)&lt;br /&gt;
void draw()&lt;br /&gt;
{&lt;br /&gt;
  if ( myPort.available() &amp;gt; 0) {  // If data is available,&lt;br /&gt;
    println(myPort.read()); // read it and store it in val&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if a key is pressed, on release send an &amp;#039;a&amp;#039;&lt;br /&gt;
void keyReleased() {&lt;br /&gt;
  myPort.write(&amp;#039;a&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following is output in the Debug window:&lt;br /&gt;
[[Image:Processing_serial_ex1.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What is that? Note that there are 30 characters. Processing has printed the decimal value of each character received!&lt;br /&gt;
&lt;br /&gt;
Try something else- Processing has the ability to check for incoming characters in parallel to running code in the Draw() routine:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Based on the SimpleRead example&lt;br /&gt;
import processing.serial.*;&lt;br /&gt;
&lt;br /&gt;
Serial myPort;  // Create object from Serial class&lt;br /&gt;
&lt;br /&gt;
// setup() runs first but only once, use it to initialize things&lt;br /&gt;
void setup() &lt;br /&gt;
{&lt;br /&gt;
  size(200, 200); // the size of the Processing window in pixels&lt;br /&gt;
  background(255); // Set background to white&lt;br /&gt;
  println(Serial.list()); // print all of the serial ports that&lt;br /&gt;
                          // are available, you need to know what&lt;br /&gt;
                          // port to open in the next line&lt;br /&gt;
  // guess which port to open, if you get it wrong rerun the progam&lt;br /&gt;
  // after changing which port you open&lt;br /&gt;
  String portName = Serial.list()[1];&lt;br /&gt;
  myPort = new Serial(this, portName, 115200); // open the port&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// draw runs at 30fps (default)&lt;br /&gt;
void draw()&lt;br /&gt;
{&lt;br /&gt;
  // nothing, do it in the serialEvent&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void serialEvent(Serial thisPort) {&lt;br /&gt;
  // read a byte from the port:&lt;br /&gt;
  int inByte = thisPort.read();&lt;br /&gt;
  println((char)inByte);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if a key is pressed, on release send an &amp;#039;a&amp;#039;&lt;br /&gt;
void keyReleased() {&lt;br /&gt;
  myPort.write(&amp;#039;a&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Processing_serial_ex2.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  int inByte = thisPort.read();&lt;br /&gt;
  println((char)inByte);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
shows the actual ASCII values for the numbers, but the &amp;#039;\r&amp;#039; and &amp;#039;\n&amp;#039; are not displayed! This is why it is sometimes nice to use the Terminal emulator.&lt;br /&gt;
&lt;br /&gt;
== MATLAB ==&lt;br /&gt;
MATLAB can open a serial port and send and receive data as well. This is useful when you need to plot data, perform a complicated mathematical function, or error check a function that you wrote in C to the function in MATLAB.&lt;br /&gt;
&lt;br /&gt;
To open a port in MATLAB, be sure to check if ports were not closed correctly, then try to open them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    % check to see if any ports are open&lt;br /&gt;
    % matlab is easily hung up if &lt;br /&gt;
    % the port is already open&lt;br /&gt;
    if ~isempty(instrfind)&lt;br /&gt;
        fclose(instrfind);&lt;br /&gt;
        delete(instrfind);&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % open up the port&lt;br /&gt;
    COM = serial(&amp;#039;COM14&amp;#039;);&lt;br /&gt;
    set(COM,&amp;#039;BaudRate&amp;#039;,115200);&lt;br /&gt;
    set(COM,&amp;#039;OutputBufferSize&amp;#039;,100);&lt;br /&gt;
    % set how long to wait when&lt;br /&gt;
    % doing fscanf&lt;br /&gt;
    set(COM,&amp;#039;Timeout&amp;#039;,20);&lt;br /&gt;
    fopen(COM);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To send data:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    fwrite(COM,&amp;#039;a&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To receive data:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    reading = fscanf(COM,&amp;#039;%i&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put together, the code looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    % clear the screen and memory&lt;br /&gt;
    clc;&lt;br /&gt;
    clear;&lt;br /&gt;
&lt;br /&gt;
    % check to see if any ports are open&lt;br /&gt;
    % matlab is easily hung up if &lt;br /&gt;
    % the port is already open&lt;br /&gt;
    if ~isempty(instrfind)&lt;br /&gt;
        fclose(instrfind);&lt;br /&gt;
        delete(instrfind);&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % open up the port&lt;br /&gt;
    COM = serial(&amp;#039;COM14&amp;#039;);&lt;br /&gt;
    set(COM,&amp;#039;BaudRate&amp;#039;,115200);&lt;br /&gt;
    set(COM,&amp;#039;OutputBufferSize&amp;#039;,100);&lt;br /&gt;
    % set how long to wait when&lt;br /&gt;
    % doing fscanf&lt;br /&gt;
    set(COM,&amp;#039;Timeout&amp;#039;,20);&lt;br /&gt;
    fopen(COM);&lt;br /&gt;
      &lt;br /&gt;
    % send an &amp;#039;a&amp;#039;&lt;br /&gt;
    fwrite(COM,&amp;#039;a&amp;#039;);&lt;br /&gt;
    % print to the screen &lt;br /&gt;
    % that we sent an &amp;#039;a&amp;#039;&lt;br /&gt;
    disp(&amp;#039;sent a&amp;#039;);&lt;br /&gt;
    &lt;br /&gt;
    % we know to expect 10 numbers&lt;br /&gt;
    i = 0;&lt;br /&gt;
    while (i&amp;lt;10)&lt;br /&gt;
        % read the number and print&lt;br /&gt;
        % to the screen&lt;br /&gt;
        reading = fscanf(COM,&amp;#039;%i&amp;#039;);&lt;br /&gt;
        disp(num2str(reading));&lt;br /&gt;
        i = i+1;&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % be sure to close the port&lt;br /&gt;
    fclose(COM);&lt;br /&gt;
    disp(&amp;#039;done&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result looks like:&lt;br /&gt;
[[Image:Matlab_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Python ==&lt;br /&gt;
&lt;br /&gt;
== More Information ==&lt;br /&gt;
&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32:_Serial_Communication_with_the_PC&amp;diff=20910</id>
		<title>NU32: Serial Communication with the PC</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32:_Serial_Communication_with_the_PC&amp;diff=20910"/>
		<updated>2012-01-24T15:52:13Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The NU32 has the ability to talk directly with a computer over a virtual serial port connection.  This ability can be used to debug code, transfer data, and interact with the microcontroller using a computer. &lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The NU32 uses an on board [http://www.ftdichip.com/Products/ICs/FT2232H.htm FT2232H] chip from FTDI to convert [http://en.wikipedia.org/wiki/RS-232 RS-232 TTL serial communication] to USB.  Using drivers from FTDI, the communication can be opened by any program that can access a [http://en.wikipedia.org/wiki/Serial_port virtual serial port].  On the NU32, sample code has been created to enable the UART module on the PIC32.  Using this code you can write strings to the computer, and generate an interrupt when characters are received. On the computer, several programs that can access the serial connection are discussed, including Processing, MATLAB, Python, and terminal programs.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
The FT2232H chip is hardwired the to UART1 (F2 and F8, for general communication) and UART4 (D14 and D15, for bootloading) modules on the PIC32MX795F512L.  The Receive (RX) pins, F2 and D14, and Transmit (TX) pins, F8 and D15, are also brought out to the sides of the NU32 board.  &amp;#039;&amp;#039;&amp;#039;They should not be used as general IO.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Serial communication is asynchronous, it does not use an external clock signal to know when to read individual bits. Instead, the sender and receiver decide beforehand what frequency to transmit data. This frequency is called the baud rate and must match on both the NU32 and computer for the data to be interpreted correctly.&lt;br /&gt;
&lt;br /&gt;
The NU32 uses the UART1 and UART4 modules at 115200 baud, as does the sample code below.&lt;br /&gt;
&lt;br /&gt;
== Library Functions ==&lt;br /&gt;
[[Media:NU32_serial_example.zip | This code]] contains functions to read characters and write strings over the serial port. It uses the same header files as &amp;quot;Hello World&amp;quot;.&lt;br /&gt;
*NU32.c contains the functions to initialize the LEDs and USER button on the NU32 board, and to initialize the UART modules.  &lt;br /&gt;
*NU32.h contains function prototypes for the .c file.&lt;br /&gt;
**&amp;#039;&amp;#039;&amp;#039;You do not need to modify these files to use serial communication.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The functions that control the serial communication are:&lt;br /&gt;
*void initSerialNU32(void) - enables UART1 and UART4 at 115200 baud with an interrupt at priority level 2 and 3&lt;br /&gt;
*void WriteString(UART_MODULE, const char *) - call with UART1 and the character array you wish to send&lt;br /&gt;
*void PutCharacter(UART_MODULE, const char) - writes an individual character to the computer when the module is able to, called by WriteString()&lt;br /&gt;
&lt;br /&gt;
NU32_serial_example.c in the .zip file above demonstrates how to use the functions.&lt;br /&gt;
&lt;br /&gt;
== Sample Code ==&lt;br /&gt;
&lt;br /&gt;
To initialize the serial communication, call initSerialNU32():&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  initSerialNU32();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To write a string to the computer, use WriteString(UART1, charArray). The special characters &amp;#039;\r&amp;#039; and &amp;#039;\n&amp;#039; are carriage return and newline. Using them together puts the cursor on the next line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  WriteString(UART1, &amp;quot;\r\nHello World!\r\n&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To write a string with the value of a variable in it, use sprintf(RS232_Out_Buffer,charArray) and WriteString(UART1, charArray). RS232_Out_Buffer is declared in NU32.h as a char array with 32 elements.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sprintf(RS232_Out_Buffer, &amp;quot;the value of i is: %d\r\n&amp;quot;, i);&lt;br /&gt;
  WriteString(UART3, RS232_Out_Buffer);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To receive characters in an interrupt, use this interrupt service routine (ISR): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void __ISR(_UART_1_VECTOR, ipl2) IntUart1Handler(void) {&lt;br /&gt;
  // Is this an RX interrupt?&lt;br /&gt;
  if(INTGetFlag(INT_SOURCE_UART_RX(UART1))){&lt;br /&gt;
    char data = UARTGetDataByte(UART1);&lt;br /&gt;
&lt;br /&gt;
    // now do something with data&lt;br /&gt;
&lt;br /&gt;
    // Clear the RX interrupt Flag&lt;br /&gt;
    INTClearFlag(INT_SOURCE_UART_RX(UART1)); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // If the interrupt was on TX (ignore it)&lt;br /&gt;
  if(INTGetFlag(INT_SOURCE_UART_TX(UART1))) {&lt;br /&gt;
    INTClearFlag(INT_SOURCE_UART_TX(UART1));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NU32_serial_example.c initializes the serial communication, and then waits until it receives the character &amp;#039;a&amp;#039; from the computer. When it gets an &amp;#039;a&amp;#039;, it replies back with numbers 0 through 9, each on their own line, and then waits for another &amp;#039;a&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//////LIBRARIES&lt;br /&gt;
#include &amp;lt;plib.h&amp;gt; // for PIC specific functions&lt;br /&gt;
#include &amp;quot;NU32.h&amp;quot; // for NU32 board specific functions&lt;br /&gt;
&lt;br /&gt;
//////GLOBAL VARIABLES&lt;br /&gt;
&lt;br /&gt;
//////FUNCTION PROTOTYPES&lt;br /&gt;
&lt;br /&gt;
//////MAIN&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    startup(); // from NU32.c, maximizes performance&lt;br /&gt;
    initialize(); // from NU32.c, inits USER, L1 and L2, serial fns&lt;br /&gt;
&lt;br /&gt;
    // infinite loop&lt;br /&gt;
    while(1)&lt;br /&gt;
    {&lt;br /&gt;
        // nothing, do everything in the UART1 ISR&lt;br /&gt;
    }&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////FUNCTIONS&lt;br /&gt;
&lt;br /&gt;
//////ISRs&lt;br /&gt;
// interrupt when the NU32 gets a character from the computer&lt;br /&gt;
void __ISR(_UART_1_VECTOR, ipl2) IntUart1Handler(void)&lt;br /&gt;
{&lt;br /&gt;
    int i = 0;&lt;br /&gt;
&lt;br /&gt;
    // Is this an RX interrupt?&lt;br /&gt;
    if(INTGetFlag(INT_SOURCE_UART_RX(UART1)))&lt;br /&gt;
    {&lt;br /&gt;
        // read the byte&lt;br /&gt;
        char data = UARTGetDataByte(UART1);&lt;br /&gt;
&lt;br /&gt;
        // if the byte is an &amp;#039;a&amp;#039;, send back 0-9&lt;br /&gt;
        if (data == &amp;#039;a&amp;#039;) {&lt;br /&gt;
            for (i=0; i&amp;lt;10; i++) {&lt;br /&gt;
                sprintf(RS232_Out_Buffer,&amp;quot;%d\r\n&amp;quot;, i);&lt;br /&gt;
                WriteString(UART1, RS232_Out_Buffer);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // Clear the RX interrupt Flag&lt;br /&gt;
        INTClearFlag(INT_SOURCE_UART_RX(UART1));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // We don&amp;#039;t care about TX interrupt&lt;br /&gt;
    if(INTGetFlag(INT_SOURCE_UART_TX(UART1)))&lt;br /&gt;
    {&lt;br /&gt;
        INTClearFlag(INT_SOURCE_UART_TX(UART1));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Communicating with NU32_Utility ==&lt;br /&gt;
The right hand side of the NU32_Utility program is a debugger that will display any character received from the &amp;#039;Debug&amp;#039; port, and will send any characters in the text entry using &amp;#039;Send&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Compile the code and put it on your NU32. Send an &amp;#039;a&amp;#039; with the debugger and you should see the following:&lt;br /&gt;
&lt;br /&gt;
[[Image:NU32_utility_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Communicating with a Terminal Program ==&lt;br /&gt;
The NU32_Utility debugger is based on a more traditional [http://en.wikipedia.org/wiki/Terminal_emulator Terminal emulator] program. Terminal programs let you choose the baud rate, flow control, and many other aspects of serial communication, and let you view the incoming bytes as ASCII text or hex bytes. A Terminal program is useful when you want to see hidden characters that the NU32_Utility can not display.&lt;br /&gt;
&lt;br /&gt;
On Windows, you can use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] or [http://realterm.sourceforge.net/index.html#downloads_Download RealTerm].&lt;br /&gt;
&lt;br /&gt;
On a MAC, you can use [http://www.iterm2.com/#/section/home iTerm2].&lt;br /&gt;
&lt;br /&gt;
In Linux people commonly use [https://help.ubuntu.com/community/Minicom minicom] or [https://fedorahosted.org/gtkterm/ gtkterm].&lt;br /&gt;
&lt;br /&gt;
When you use a Terminal program, make sure that you know the communication port name and baud before opening the program. &amp;#039;&amp;#039;&amp;#039;Also be sure that the port is not already open in another program. A port can only be open in one place at a time!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The Terminal programs vary in use, but for example, launch Putty.exe. Set up your communication by:&lt;br /&gt;
*Selecting the &amp;#039;Serial&amp;#039; radio button&lt;br /&gt;
&lt;br /&gt;
Select the &amp;#039;Serial&amp;#039; branch in the tree on the bottom left.&lt;br /&gt;
*Enter the name of your COM port in &amp;#039;Serial line to connect to&amp;#039;&lt;br /&gt;
*Enter 115200 in &amp;#039;Speed (baud)&amp;#039;&lt;br /&gt;
*Change &amp;#039;Flow control&amp;#039; from &amp;#039;XON/XOFF&amp;#039; to &amp;#039;None&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Go back to the &amp;#039;Session&amp;#039; screen by selecting the &amp;#039;Session&amp;#039; in the top left of the tree.&lt;br /&gt;
*Name your settings in &amp;#039;Saved Sessions&amp;#039; and click &amp;#039;Save&amp;#039;&lt;br /&gt;
*Click the &amp;#039;Open&amp;#039; button&lt;br /&gt;
&lt;br /&gt;
Type an &amp;#039;a&amp;#039;. Notice you do not get to see what you typed in! In this case it would be the responsibility of the NU32 to echo back any characters it receives so that you can verify what was typed in.&lt;br /&gt;
&lt;br /&gt;
[[Image:PuTTY_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Processing ==&lt;br /&gt;
[http://processing.org/ Processing] is a free IDE that is easy to use, makes nice graphics, and easily performs serial communication. The NU32_Utility was written in Processing.&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;See the [[Processing]] page for more specific information on Processing.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following code is a simple Processing sketch that will open a serial port, print any characters received to the Debug window, and send an &amp;#039;a&amp;#039; if a key on the keyboard is pressed and released:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Based on the SimpleRead example&lt;br /&gt;
import processing.serial.*;&lt;br /&gt;
&lt;br /&gt;
Serial myPort;  // Create object from Serial class&lt;br /&gt;
&lt;br /&gt;
// setup() runs first but only once, use it to initialize things&lt;br /&gt;
void setup() &lt;br /&gt;
{&lt;br /&gt;
  size(200, 200); // the size of the Processing window in pixels&lt;br /&gt;
  background(255); // Set background to white&lt;br /&gt;
  println(Serial.list()); // print all of the serial ports that&lt;br /&gt;
                          // are available, you need to know what&lt;br /&gt;
                          // port to open in the next line&lt;br /&gt;
  // guess which port to open, if you get it wrong rerun the progam&lt;br /&gt;
  // after changing which port you open&lt;br /&gt;
  String portName = Serial.list()[1];&lt;br /&gt;
  myPort = new Serial(this, portName, 115200); // open the port&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// draw runs at 30fps (default)&lt;br /&gt;
void draw()&lt;br /&gt;
{&lt;br /&gt;
  if ( myPort.available() &amp;gt; 0) {  // If data is available,&lt;br /&gt;
    println(myPort.read()); // read it and store it in val&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if a key is pressed, on release send an &amp;#039;a&amp;#039;&lt;br /&gt;
void keyReleased() {&lt;br /&gt;
  myPort.write(&amp;#039;a&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following is output in the Debug window:&lt;br /&gt;
[[Image:Processing_serial_ex1.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What is that? Note that there are 30 characters. Processing has printed the decimal value of each character received!&lt;br /&gt;
&lt;br /&gt;
Try something else- Processing has the ability to check for incoming characters in parallel to running code in the Draw() routine:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Based on the SimpleRead example&lt;br /&gt;
import processing.serial.*;&lt;br /&gt;
&lt;br /&gt;
Serial myPort;  // Create object from Serial class&lt;br /&gt;
&lt;br /&gt;
// setup() runs first but only once, use it to initialize things&lt;br /&gt;
void setup() &lt;br /&gt;
{&lt;br /&gt;
  size(200, 200); // the size of the Processing window in pixels&lt;br /&gt;
  background(255); // Set background to white&lt;br /&gt;
  println(Serial.list()); // print all of the serial ports that&lt;br /&gt;
                          // are available, you need to know what&lt;br /&gt;
                          // port to open in the next line&lt;br /&gt;
  // guess which port to open, if you get it wrong rerun the progam&lt;br /&gt;
  // after changing which port you open&lt;br /&gt;
  String portName = Serial.list()[1];&lt;br /&gt;
  myPort = new Serial(this, portName, 115200); // open the port&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// draw runs at 30fps (default)&lt;br /&gt;
void draw()&lt;br /&gt;
{&lt;br /&gt;
  // nothing, do it in the serialEvent&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void serialEvent(Serial thisPort) {&lt;br /&gt;
  // read a byte from the port:&lt;br /&gt;
  int inByte = thisPort.read();&lt;br /&gt;
  println((char)inByte);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if a key is pressed, on release send an &amp;#039;a&amp;#039;&lt;br /&gt;
void keyReleased() {&lt;br /&gt;
  myPort.write(&amp;#039;a&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Processing_serial_ex2.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  int inByte = thisPort.read();&lt;br /&gt;
  println((char)inByte);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
shows the actual ASCII values for the numbers, but the &amp;#039;\r&amp;#039; and &amp;#039;\n&amp;#039; are not displayed! This is why it is sometimes nice to use the Terminal emulator.&lt;br /&gt;
&lt;br /&gt;
== MATLAB ==&lt;br /&gt;
MATLAB can open a serial port and send and receive data as well. This is useful when you need to plot data, perform a complicated mathematical function, or error check a function that you wrote in C to the function in MATLAB.&lt;br /&gt;
&lt;br /&gt;
To open a port in MATLAB, be sure to check if ports were not closed correctly, then try to open them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    % check to see if any ports are open&lt;br /&gt;
    % matlab is easily hung up if &lt;br /&gt;
    % the port is already open&lt;br /&gt;
    if ~isempty(instrfind)&lt;br /&gt;
        fclose(instrfind);&lt;br /&gt;
        delete(instrfind);&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % open up the port&lt;br /&gt;
    COM = serial(&amp;#039;COM14&amp;#039;);&lt;br /&gt;
    set(COM,&amp;#039;BaudRate&amp;#039;,115200);&lt;br /&gt;
    set(COM,&amp;#039;OutputBufferSize&amp;#039;,100);&lt;br /&gt;
    % set how long to wait when&lt;br /&gt;
    % doing fscanf&lt;br /&gt;
    set(COM,&amp;#039;Timeout&amp;#039;,20);&lt;br /&gt;
    fopen(COM);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To send data:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    fwrite(COM,&amp;#039;a&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To receive data:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    reading = fscanf(COM,&amp;#039;%i&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put together, the code looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    % clear the screen and memory&lt;br /&gt;
    clc;&lt;br /&gt;
    clear;&lt;br /&gt;
&lt;br /&gt;
    % check to see if any ports are open&lt;br /&gt;
    % matlab is easily hung up if &lt;br /&gt;
    % the port is already open&lt;br /&gt;
    if ~isempty(instrfind)&lt;br /&gt;
        fclose(instrfind);&lt;br /&gt;
        delete(instrfind);&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % open up the port&lt;br /&gt;
    COM = serial(&amp;#039;COM14&amp;#039;);&lt;br /&gt;
    set(COM,&amp;#039;BaudRate&amp;#039;,115200);&lt;br /&gt;
    set(COM,&amp;#039;OutputBufferSize&amp;#039;,100);&lt;br /&gt;
    % set how long to wait when&lt;br /&gt;
    % doing fscanf&lt;br /&gt;
    set(COM,&amp;#039;Timeout&amp;#039;,20);&lt;br /&gt;
    fopen(COM);&lt;br /&gt;
      &lt;br /&gt;
    % send an &amp;#039;a&amp;#039;&lt;br /&gt;
    fwrite(COM,&amp;#039;a&amp;#039;);&lt;br /&gt;
    % print to the screen &lt;br /&gt;
    % that we sent an &amp;#039;a&amp;#039;&lt;br /&gt;
    disp(&amp;#039;sent a&amp;#039;);&lt;br /&gt;
    &lt;br /&gt;
    % we know to expect 10 numbers&lt;br /&gt;
    i = 0;&lt;br /&gt;
    while (i&amp;lt;10)&lt;br /&gt;
        % read the number and print&lt;br /&gt;
        % to the screen&lt;br /&gt;
        reading = fscanf(COM,&amp;#039;%i&amp;#039;);&lt;br /&gt;
        disp(num2str(reading));&lt;br /&gt;
        i = i+1;&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % be sure to close the port&lt;br /&gt;
    fclose(COM);&lt;br /&gt;
    disp(&amp;#039;done&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result looks like:&lt;br /&gt;
[[Image:Matlab_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== More Information ==&lt;br /&gt;
&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32:_Serial_Communication_with_the_PC&amp;diff=20909</id>
		<title>NU32: Serial Communication with the PC</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32:_Serial_Communication_with_the_PC&amp;diff=20909"/>
		<updated>2012-01-24T15:48:02Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Communicating with a Terminal Program */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The NU32 has the ability to talk directly with a computer over a virtual serial port connection.  This ability can be used to debug code, transfer data, and interact with the microcontroller using a computer. &lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The NU32 uses an on board [http://www.ftdichip.com/Products/ICs/FT2232H.htm FT2232H] chip from FTDI to convert [http://en.wikipedia.org/wiki/RS-232 RS-232 TTL serial communication] to USB.  Using drivers from FTDI, the communication can be opened by any program that can access a [http://en.wikipedia.org/wiki/Serial_port virtual serial port].  On the NU32, sample code has been created to enable the UART module on the PIC32.  Using this code you can write strings to the computer, and generate an interrupt when characters are received. On the computer, several programs that can access the serial connection are discussed, including Processing, MATLAB, and terminal programs.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
The FT2232H chip is hardwired the to UART1 (F2 and F8, for general communication) and UART4 (D14 and D15, for bootloading) modules on the PIC32MX795F512L.  The Receive (RX) pins, F2 and D14, and Transmit (TX) pins, F8 and D15, are also brought out to the sides of the NU32 board.  &amp;#039;&amp;#039;&amp;#039;They should not be used as general IO.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Serial communication is asynchronous, it does not use an external clock signal to know when to read individual bits. Instead, the sender and receiver decide beforehand what frequency to transmit data. This frequency is called the baud rate and must match on both the NU32 and computer for the data to be interpreted correctly.&lt;br /&gt;
&lt;br /&gt;
The NU32 uses the UART1 and UART4 modules at 115200 baud, as does the sample code below.&lt;br /&gt;
&lt;br /&gt;
== Library Functions ==&lt;br /&gt;
[[Media:NU32_serial_example.zip | This code]] contains functions to read characters and write strings over the serial port. It uses the same header files as &amp;quot;Hello World&amp;quot;.&lt;br /&gt;
*NU32.c contains the functions to initialize the LEDs and USER button on the NU32 board, and to initialize the UART modules.  &lt;br /&gt;
*NU32.h contains function prototypes for the .c file.&lt;br /&gt;
**&amp;#039;&amp;#039;&amp;#039;You do not need to modify these files to use serial communication.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The functions that control the serial communication are:&lt;br /&gt;
*void initSerialNU32(void) - enables UART1 and UART4 at 115200 baud with an interrupt at priority level 2 and 3&lt;br /&gt;
*void WriteString(UART_MODULE, const char *) - call with UART1 and the character array you wish to send&lt;br /&gt;
*void PutCharacter(UART_MODULE, const char) - writes an individual character to the computer when the module is able to, called by WriteString()&lt;br /&gt;
&lt;br /&gt;
NU32_serial_example.c in the .zip file above demonstrates how to use the functions.&lt;br /&gt;
&lt;br /&gt;
== Sample Code ==&lt;br /&gt;
&lt;br /&gt;
To initialize the serial communication, call initSerialNU32():&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  initSerialNU32();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To write a string to the computer, use WriteString(UART1, charArray). The special characters &amp;#039;\r&amp;#039; and &amp;#039;\n&amp;#039; are carriage return and newline. Using them together puts the cursor on the next line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  WriteString(UART1, &amp;quot;\r\nHello World!\r\n&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To write a string with the value of a variable in it, use sprintf(RS232_Out_Buffer,charArray) and WriteString(UART1, charArray). RS232_Out_Buffer is declared in NU32.h as a char array with 32 elements.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sprintf(RS232_Out_Buffer, &amp;quot;the value of i is: %d\r\n&amp;quot;, i);&lt;br /&gt;
  WriteString(UART3, RS232_Out_Buffer);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To receive characters in an interrupt, use this interrupt service routine (ISR): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void __ISR(_UART_1_VECTOR, ipl2) IntUart1Handler(void) {&lt;br /&gt;
  // Is this an RX interrupt?&lt;br /&gt;
  if(INTGetFlag(INT_SOURCE_UART_RX(UART1))){&lt;br /&gt;
    char data = UARTGetDataByte(UART1);&lt;br /&gt;
&lt;br /&gt;
    // now do something with data&lt;br /&gt;
&lt;br /&gt;
    // Clear the RX interrupt Flag&lt;br /&gt;
    INTClearFlag(INT_SOURCE_UART_RX(UART1)); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // If the interrupt was on TX (ignore it)&lt;br /&gt;
  if(INTGetFlag(INT_SOURCE_UART_TX(UART1))) {&lt;br /&gt;
    INTClearFlag(INT_SOURCE_UART_TX(UART1));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NU32_serial_example.c initializes the serial communication, and then waits until it receives the character &amp;#039;a&amp;#039; from the computer. When it gets an &amp;#039;a&amp;#039;, it replies back with numbers 0 through 9, each on their own line, and then waits for another &amp;#039;a&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//////LIBRARIES&lt;br /&gt;
#include &amp;lt;plib.h&amp;gt; // for PIC specific functions&lt;br /&gt;
#include &amp;quot;NU32.h&amp;quot; // for NU32 board specific functions&lt;br /&gt;
&lt;br /&gt;
//////GLOBAL VARIABLES&lt;br /&gt;
&lt;br /&gt;
//////FUNCTION PROTOTYPES&lt;br /&gt;
&lt;br /&gt;
//////MAIN&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    startup(); // from NU32.c, maximizes performance&lt;br /&gt;
    initialize(); // from NU32.c, inits USER, L1 and L2, serial fns&lt;br /&gt;
&lt;br /&gt;
    // infinite loop&lt;br /&gt;
    while(1)&lt;br /&gt;
    {&lt;br /&gt;
        // nothing, do everything in the UART1 ISR&lt;br /&gt;
    }&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////FUNCTIONS&lt;br /&gt;
&lt;br /&gt;
//////ISRs&lt;br /&gt;
// interrupt when the NU32 gets a character from the computer&lt;br /&gt;
void __ISR(_UART_1_VECTOR, ipl2) IntUart1Handler(void)&lt;br /&gt;
{&lt;br /&gt;
    int i = 0;&lt;br /&gt;
&lt;br /&gt;
    // Is this an RX interrupt?&lt;br /&gt;
    if(INTGetFlag(INT_SOURCE_UART_RX(UART1)))&lt;br /&gt;
    {&lt;br /&gt;
        // read the byte&lt;br /&gt;
        char data = UARTGetDataByte(UART1);&lt;br /&gt;
&lt;br /&gt;
        // if the byte is an &amp;#039;a&amp;#039;, send back 0-9&lt;br /&gt;
        if (data == &amp;#039;a&amp;#039;) {&lt;br /&gt;
            for (i=0; i&amp;lt;10; i++) {&lt;br /&gt;
                sprintf(RS232_Out_Buffer,&amp;quot;%d\r\n&amp;quot;, i);&lt;br /&gt;
                WriteString(UART1, RS232_Out_Buffer);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // Clear the RX interrupt Flag&lt;br /&gt;
        INTClearFlag(INT_SOURCE_UART_RX(UART1));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // We don&amp;#039;t care about TX interrupt&lt;br /&gt;
    if(INTGetFlag(INT_SOURCE_UART_TX(UART1)))&lt;br /&gt;
    {&lt;br /&gt;
        INTClearFlag(INT_SOURCE_UART_TX(UART1));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Communicating with NU32_Utility ==&lt;br /&gt;
The right hand side of the NU32_Utility program is a debugger that will display any character received from the &amp;#039;Debug&amp;#039; port, and will send any characters in the text entry using &amp;#039;Send&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Compile the code and put it on your NU32. Send an &amp;#039;a&amp;#039; with the debugger and you should see the following:&lt;br /&gt;
&lt;br /&gt;
[[Image:NU32_utility_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Communicating with a Terminal Program ==&lt;br /&gt;
The NU32_Utility debugger is based on a more traditional [http://en.wikipedia.org/wiki/Terminal_emulator Terminal emulator] program. Terminal programs let you choose the baud rate, flow control, and many other aspects of serial communication, and let you view the incoming bytes as ASCII text or hex bytes. A Terminal program is useful when you want to see hidden characters that the NU32_Utility can not display.&lt;br /&gt;
&lt;br /&gt;
On Windows, you can use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] or [http://realterm.sourceforge.net/index.html#downloads_Download RealTerm].&lt;br /&gt;
&lt;br /&gt;
On a MAC, you can use [http://www.iterm2.com/#/section/home iTerm2].&lt;br /&gt;
&lt;br /&gt;
In Linux people commonly use [https://help.ubuntu.com/community/Minicom minicom] or [https://fedorahosted.org/gtkterm/ gtkterm].&lt;br /&gt;
&lt;br /&gt;
When you use a Terminal program, make sure that you know the communication port name and baud before opening the program. &amp;#039;&amp;#039;&amp;#039;Also be sure that the port is not already open in another program. A port can only be open in one place at a time!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The Terminal programs vary in use, but for example, launch Putty.exe. Set up your communication by:&lt;br /&gt;
*Selecting the &amp;#039;Serial&amp;#039; radio button&lt;br /&gt;
&lt;br /&gt;
Select the &amp;#039;Serial&amp;#039; branch in the tree on the bottom left.&lt;br /&gt;
*Enter the name of your COM port in &amp;#039;Serial line to connect to&amp;#039;&lt;br /&gt;
*Enter 115200 in &amp;#039;Speed (baud)&amp;#039;&lt;br /&gt;
*Change &amp;#039;Flow control&amp;#039; from &amp;#039;XON/XOFF&amp;#039; to &amp;#039;None&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Go back to the &amp;#039;Session&amp;#039; screen by selecting the &amp;#039;Session&amp;#039; in the top left of the tree.&lt;br /&gt;
*Name your settings in &amp;#039;Saved Sessions&amp;#039; and click &amp;#039;Save&amp;#039;&lt;br /&gt;
*Click the &amp;#039;Open&amp;#039; button&lt;br /&gt;
&lt;br /&gt;
Type an &amp;#039;a&amp;#039;. Notice you do not get to see what you typed in! In this case it would be the responsibility of the NU32 to echo back any characters it receives so that you can verify what was typed in.&lt;br /&gt;
&lt;br /&gt;
[[Image:PuTTY_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Processing ==&lt;br /&gt;
[http://processing.org/ Processing] is a free IDE that is easy to use, makes nice graphics, and easily performs serial communication. The NU32_Utility was written in Processing.&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;See the [[Processing]] page for more specific information on Processing.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following code is a simple Processing sketch that will open a serial port, print any characters received to the Debug window, and send an &amp;#039;a&amp;#039; if a key on the keyboard is pressed and released:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Based on the SimpleRead example&lt;br /&gt;
import processing.serial.*;&lt;br /&gt;
&lt;br /&gt;
Serial myPort;  // Create object from Serial class&lt;br /&gt;
&lt;br /&gt;
// setup() runs first but only once, use it to initialize things&lt;br /&gt;
void setup() &lt;br /&gt;
{&lt;br /&gt;
  size(200, 200); // the size of the Processing window in pixels&lt;br /&gt;
  background(255); // Set background to white&lt;br /&gt;
  println(Serial.list()); // print all of the serial ports that&lt;br /&gt;
                          // are available, you need to know what&lt;br /&gt;
                          // port to open in the next line&lt;br /&gt;
  // guess which port to open, if you get it wrong rerun the progam&lt;br /&gt;
  // after changing which port you open&lt;br /&gt;
  String portName = Serial.list()[1];&lt;br /&gt;
  myPort = new Serial(this, portName, 115200); // open the port&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// draw runs at 30fps (default)&lt;br /&gt;
void draw()&lt;br /&gt;
{&lt;br /&gt;
  if ( myPort.available() &amp;gt; 0) {  // If data is available,&lt;br /&gt;
    println(myPort.read()); // read it and store it in val&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if a key is pressed, on release send an &amp;#039;a&amp;#039;&lt;br /&gt;
void keyReleased() {&lt;br /&gt;
  myPort.write(&amp;#039;a&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following is output in the Debug window:&lt;br /&gt;
[[Image:Processing_serial_ex1.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What is that? Note that there are 30 characters. Processing has printed the decimal value of each character received!&lt;br /&gt;
&lt;br /&gt;
Try something else- Processing has the ability to check for incoming characters in parallel to running code in the Draw() routine:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Based on the SimpleRead example&lt;br /&gt;
import processing.serial.*;&lt;br /&gt;
&lt;br /&gt;
Serial myPort;  // Create object from Serial class&lt;br /&gt;
&lt;br /&gt;
// setup() runs first but only once, use it to initialize things&lt;br /&gt;
void setup() &lt;br /&gt;
{&lt;br /&gt;
  size(200, 200); // the size of the Processing window in pixels&lt;br /&gt;
  background(255); // Set background to white&lt;br /&gt;
  println(Serial.list()); // print all of the serial ports that&lt;br /&gt;
                          // are available, you need to know what&lt;br /&gt;
                          // port to open in the next line&lt;br /&gt;
  // guess which port to open, if you get it wrong rerun the progam&lt;br /&gt;
  // after changing which port you open&lt;br /&gt;
  String portName = Serial.list()[1];&lt;br /&gt;
  myPort = new Serial(this, portName, 115200); // open the port&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// draw runs at 30fps (default)&lt;br /&gt;
void draw()&lt;br /&gt;
{&lt;br /&gt;
  // nothing, do it in the serialEvent&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void serialEvent(Serial thisPort) {&lt;br /&gt;
  // read a byte from the port:&lt;br /&gt;
  int inByte = thisPort.read();&lt;br /&gt;
  println((char)inByte);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if a key is pressed, on release send an &amp;#039;a&amp;#039;&lt;br /&gt;
void keyReleased() {&lt;br /&gt;
  myPort.write(&amp;#039;a&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Processing_serial_ex2.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  int inByte = thisPort.read();&lt;br /&gt;
  println((char)inByte);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
shows the actual ASCII values for the numbers, but the &amp;#039;\r&amp;#039; and &amp;#039;\n&amp;#039; are not displayed! This is why it is sometimes nice to use the Terminal emulator.&lt;br /&gt;
&lt;br /&gt;
== MATLAB ==&lt;br /&gt;
MATLAB can open a serial port and send and receive data as well. This is useful when you need to plot data, perform a complicated mathematical function, or error check a function that you wrote in C to the function in MATLAB.&lt;br /&gt;
&lt;br /&gt;
To open a port in MATLAB, be sure to check if ports were not closed correctly, then try to open them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    % check to see if any ports are open&lt;br /&gt;
    % matlab is easily hung up if &lt;br /&gt;
    % the port is already open&lt;br /&gt;
    if ~isempty(instrfind)&lt;br /&gt;
        fclose(instrfind);&lt;br /&gt;
        delete(instrfind);&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % open up the port&lt;br /&gt;
    COM = serial(&amp;#039;COM14&amp;#039;);&lt;br /&gt;
    set(COM,&amp;#039;BaudRate&amp;#039;,115200);&lt;br /&gt;
    set(COM,&amp;#039;OutputBufferSize&amp;#039;,100);&lt;br /&gt;
    % set how long to wait when&lt;br /&gt;
    % doing fscanf&lt;br /&gt;
    set(COM,&amp;#039;Timeout&amp;#039;,20);&lt;br /&gt;
    fopen(COM);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To send data:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    fwrite(COM,&amp;#039;a&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To receive data:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    reading = fscanf(COM,&amp;#039;%i&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put together, the code looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    % clear the screen and memory&lt;br /&gt;
    clc;&lt;br /&gt;
    clear;&lt;br /&gt;
&lt;br /&gt;
    % check to see if any ports are open&lt;br /&gt;
    % matlab is easily hung up if &lt;br /&gt;
    % the port is already open&lt;br /&gt;
    if ~isempty(instrfind)&lt;br /&gt;
        fclose(instrfind);&lt;br /&gt;
        delete(instrfind);&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % open up the port&lt;br /&gt;
    COM = serial(&amp;#039;COM14&amp;#039;);&lt;br /&gt;
    set(COM,&amp;#039;BaudRate&amp;#039;,115200);&lt;br /&gt;
    set(COM,&amp;#039;OutputBufferSize&amp;#039;,100);&lt;br /&gt;
    % set how long to wait when&lt;br /&gt;
    % doing fscanf&lt;br /&gt;
    set(COM,&amp;#039;Timeout&amp;#039;,20);&lt;br /&gt;
    fopen(COM);&lt;br /&gt;
      &lt;br /&gt;
    % send an &amp;#039;a&amp;#039;&lt;br /&gt;
    fwrite(COM,&amp;#039;a&amp;#039;);&lt;br /&gt;
    % print to the screen &lt;br /&gt;
    % that we sent an &amp;#039;a&amp;#039;&lt;br /&gt;
    disp(&amp;#039;sent a&amp;#039;);&lt;br /&gt;
    &lt;br /&gt;
    % we know to expect 10 numbers&lt;br /&gt;
    i = 0;&lt;br /&gt;
    while (i&amp;lt;10)&lt;br /&gt;
        % read the number and print&lt;br /&gt;
        % to the screen&lt;br /&gt;
        reading = fscanf(COM,&amp;#039;%i&amp;#039;);&lt;br /&gt;
        disp(num2str(reading));&lt;br /&gt;
        i = i+1;&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    % be sure to close the port&lt;br /&gt;
    fclose(COM);&lt;br /&gt;
    disp(&amp;#039;done&amp;#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result looks like:&lt;br /&gt;
[[Image:Matlab_serial_ex.png|thumb|300 px|left]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== More Information ==&lt;br /&gt;
&lt;br /&gt;
NA&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20810</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20810"/>
		<updated>2012-01-12T18:49:42Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Setting up the IDE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
If you already have a C compiler you are comfortable with, you can ignore this page.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  If you run into any issues installing GCC, &lt;br /&gt;
check out NetBeans&amp;#039; instructions for each operating system. They have very thorough &lt;br /&gt;
directions that could definitely help to sort out any problems; you can find those instructions&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  [http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend. To install, do the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].  This is the most complex portion of the install process; read the directions in the link carefully. &lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using [http://www.winzip.com/ WinZip] (must purchase), [http://www.gzip.org/#exe gzip], or [http://www.7-zip.org/ 7-zip] (recommended) such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;If you have any issues, check out the more detailed instructions for this process [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free Apple Developer membership.&lt;br /&gt;
&lt;br /&gt;
If you are running Mac OSX 10.7 (commonly known as Lion), you will download Xcode 4 from the Mac App Store.  If you are running Mac OSX 10.6 or earlier, you will download Xcode 3.  The .dmg download for Xcode 3 is available directly from the box on the left hand side of [http://developer.apple.com/xcode the Xcode page]. &lt;br /&gt;
&lt;br /&gt;
If you are not yet an Apple Developer, which is necessary to download Xcode, you can sign up for free [http://developer.apple.com/programs/register here] by filling out the questionnaire.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note to Windows users:&amp;#039;&amp;#039;&amp;#039; When deciding between 6.9 and 7.0 versions, you should &lt;br /&gt;
read the notes directly under the &amp;quot;Hello World&amp;quot; test program in the &lt;br /&gt;
[[Installing a C Compiler and IDE#Test Programs| Test Programs]] section of this page.&lt;br /&gt;
Even though 6.9 is older you may be interested in installing it instead.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== ME333 Customization ===&lt;br /&gt;
In this course we plan on using two spaces for an indent, and no more than 80 characters per line.  To set these options in NetBeans do the following:&lt;br /&gt;
#click &amp;quot;Tools&amp;gt;Options&amp;quot; &amp;#039;&amp;#039;&amp;#039;(Mac users:  go to Netbeans&amp;gt;Preferences&amp;gt;Editor)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#Then select &amp;quot;Editor&amp;quot; from the buttons at the top&lt;br /&gt;
#Then select the &amp;quot;Formatting&amp;quot; tab  &lt;br /&gt;
#Set &amp;quot;Languages&amp;quot; to &amp;quot;All Languages&amp;quot;&lt;br /&gt;
##change &amp;quot;Number of Spaces per Indent&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Tab Size&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Right Margin&amp;quot; to 80&lt;br /&gt;
##make sure the checkbox for &amp;quot;Expand Tabs to Spaces&amp;quot; is checked&lt;br /&gt;
##&amp;quot;Line Wrap&amp;quot; is set to &amp;quot;After words&amp;quot;&lt;br /&gt;
#Then set &amp;quot;Language&amp;quot; to C, and make sure that the &amp;quot;Override Global Options&amp;quot; checkbox is unchecked.&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This next step may be very important for Windows users!&amp;#039;&amp;#039;&amp;#039;  When a compiled project is run inside of NetBeans, it must decide where to display the output, and if the user is expected to provide input, where that input will come from.  There are three options, an &amp;quot;External Terminal&amp;quot;, &amp;quot;Standard Output&amp;quot; and &amp;quot;Internal Terminal&amp;quot; (at least in NetBeans 7.+).  Depending on how you have your system setup these are not all guaranteed to work!  What you should do is right click on the project name in the &amp;quot;Projects&amp;quot; window, and then click &amp;quot;Project Properties&amp;quot;.  Next click &amp;quot;Run&amp;quot; and locate the &amp;quot;Console Type&amp;quot; drop down menu.  Make sure it is set to &amp;quot;External Terminal&amp;quot;.  In the future if you are getting strange behavior such as print statements that aren&amp;#039;t showing up you might want to check this setting.  Note that &amp;quot;External Terminal&amp;quot; is appropriate for other operating systems as well.  As far as I can tell, this is only an issue in versions of NetBeans newer than 7.0, and it may be quite annoying as it seems there is no way to set this to a default.  If you are bothered by it, consider installing a slightly older version of NetBeans (such as 6.9).  &lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
= Tutorial Sample Code =&lt;br /&gt;
We have provided several simple sample programs to get you started with&lt;br /&gt;
the C language.  You should compile and run each of them, read the comments, answer the questions, and read the portions of the [[Media:CrashCourseinC.pdf|Crash Course in C manual]] referenced for more background.&lt;br /&gt;
&lt;br /&gt;
* [[Media:Simple1.c|Simple1.c]]:  A first simple program to learn about different data types and printing to screen.  This is the output of running the executable version:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
This is a simple message&lt;br /&gt;
The value of the variable c is: c.&lt;br /&gt;
The value of the variable i is: 25.&lt;br /&gt;
The value of the variable f is: 12.500000.&lt;br /&gt;
Again, the values are: c = c, i = 25, and f = 12.500000.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* [[Media:Simple2.c|Simple2.c]]:  A second program to learn about useful C constructs including functions, if statements, and loops.  This is the output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The value of i is 0 and 0/2 is 0.000000.&lt;br /&gt;
The value of i is 1 and 1/2 is 0.500000.&lt;br /&gt;
The value of i is 2 and 2/2 is 1.000000.&lt;br /&gt;
The value of i is 3 and 3/2 is 1.500000.&lt;br /&gt;
The value of i is 4 and 4/2 is 2.000000.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* [[Media:Invest.c|Invest.c]]:  The most complex tutorial program, which exercises a number of the features and capabilities of the C language while performing a very simple function:  calculating the value of an investment over time.  It also provides references to the [[Media:CrashCourseinC.pdf|Crash Course in C manual]] for further reading.  Below is some sample output.  You should be able to understand each step of the program to see how this output is produced.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Enter investment, growth rate, number of yrs (up to 100): 1000.00 1.05 5&lt;br /&gt;
Valid input?  1&lt;br /&gt;
&lt;br /&gt;
RESULTS:&lt;br /&gt;
&lt;br /&gt;
Year   0:     1000.00&lt;br /&gt;
Year   1:     1050.00&lt;br /&gt;
Year   2:     1102.50&lt;br /&gt;
Year   3:     1157.62&lt;br /&gt;
Year   4:     1215.51&lt;br /&gt;
Year   5:     1276.28&lt;br /&gt;
&lt;br /&gt;
Enter investment, growth rate, number of yrs (up to 100): 1000.00 1.05 500&lt;br /&gt;
Valid input?  0&lt;br /&gt;
Invalid input; exiting.&lt;br /&gt;
&lt;br /&gt;
Casting example.&lt;br /&gt;
Ratio, 5/2:   2.00&lt;br /&gt;
Ratio, 5/((float) 2):   2.50&lt;br /&gt;
Ratio, ((float) 5)/((float) 2):   2.50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each of these programs can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20809</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20809"/>
		<updated>2012-01-12T18:49:10Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Setting up the IDE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
If you already have a C compiler you are comfortable with, you can ignore this page.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  If you run into any issues installing GCC, &lt;br /&gt;
check out NetBeans&amp;#039; instructions for each operating system. They have very thorough &lt;br /&gt;
directions that could definitely help to sort out any problems; you can find those instructions&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  [http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend. To install, do the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].  This is the most complex portion of the install process; read the directions in the link carefully. &lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using [http://www.winzip.com/ WinZip] (must purchase), [http://www.gzip.org/#exe gzip], or [http://www.7-zip.org/ 7-zip] (recommended) such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;If you have any issues, check out the more detailed instructions for this process [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free Apple Developer membership.&lt;br /&gt;
&lt;br /&gt;
If you are running Mac OSX 10.7 (commonly known as Lion), you will download Xcode 4 from the Mac App Store.  If you are running Mac OSX 10.6 or earlier, you will download Xcode 3.  The .dmg download for Xcode 3 is available directly from the box on the left hand side of [http://developer.apple.com/xcode the Xcode page]. &lt;br /&gt;
&lt;br /&gt;
If you are not yet an Apple Developer, which is necessary to download Xcode, you can sign up for free [http://developer.apple.com/programs/register here] by filling out the questionnaire.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note to Windows users:&amp;#039;&amp;#039;&amp;#039; When deciding between 6.9 and 7.0 versions, you should &lt;br /&gt;
read the notes directly under the &amp;quot;Hello World&amp;quot; test program in the &lt;br /&gt;
[[Installing a C Compiler and IDE#Test Programs| Test Programs]] section of this page.&lt;br /&gt;
Even though 6.9 is older you may be interested in installing it instead.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== ME333 Customization ===&lt;br /&gt;
In this course we plan on using two spaces for an indent, and no more than 80 characters per line.  To set these options in NetBeans do the following:&lt;br /&gt;
#click &amp;quot;Tools&amp;gt;Options&amp;quot; &amp;#039;&amp;#039;&amp;#039;(Mac users:  go to Netbeans&amp;gt;Preferences&amp;gt;Editor)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#Then select &amp;quot;Editor&amp;quot; from the buttons at the top&lt;br /&gt;
#Then select the &amp;quot;Formatting&amp;quot; tab  &lt;br /&gt;
#Set &amp;quot;Languages&amp;quot; to &amp;quot;All Languages&amp;quot;&lt;br /&gt;
##change &amp;quot;Number of Spaces per Indent&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Tab Size&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Right Margin&amp;quot; to 80&lt;br /&gt;
##make sure the checkbox for &amp;quot;Expand Tabs to Spaces&amp;quot; is checked&lt;br /&gt;
##&amp;quot;Line Wrap&amp;quot; is set to &amp;quot;After words&amp;quot;&lt;br /&gt;
#Then set &amp;quot;Language&amp;quot; to C, and make sure that the &amp;quot;Override Global Options&amp;quot; checkbox is unchecked.&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This next step may be very important for Windows users!&amp;#039;&amp;#039;&amp;#039;  When a compiled project is run inside of NetBeans, it must decide where to display the output, and if the user is expected to provide input, where that input will come from.  There are three options, an &amp;quot;External Terminal&amp;quot;, &amp;quot;Standard Output&amp;quot; and &amp;quot;Internal Terminal&amp;quot; (at least in NetBeans 7.+).  Depending on how you have your system setup these are not all guaranteed to work!  What you should do is right click on the project name in the &amp;quot;Projects&amp;quot; window, and then click &amp;quot;Project Properties&amp;quot;.  Next click &amp;quot;Run&amp;quot; and locate the &amp;quot;Console Type&amp;quot; drop down menu.  Make sure it is set to &amp;quot;External Terminal&amp;quot;.  In the future if you are getting strange behavior such as print statements that aren&amp;#039;t showing up you might want to check this setting.  Note that &amp;quot;External Terminal&amp;quot; is appropriate for other operating systems as well.  As far as I can tell, this is only an issue in versions of NetBeans newer than 7.0, and it may be quite annoying as it seems there is no way to set this to a default.  If you are bothered by it, consider installing a slightly older version of NetBeans (such as 6.9).  &lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
= Tutorial Sample Code =&lt;br /&gt;
We have provided several simple sample programs to get you started with&lt;br /&gt;
the C language.  You should compile and run each of them, read the comments, answer the questions, and read the portions of the [[Media:CrashCourseinC.pdf|Crash Course in C manual]] referenced for more background.&lt;br /&gt;
&lt;br /&gt;
* [[Media:Simple1.c|Simple1.c]]:  A first simple program to learn about different data types and printing to screen.  This is the output of running the executable version:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
This is a simple message&lt;br /&gt;
The value of the variable c is: c.&lt;br /&gt;
The value of the variable i is: 25.&lt;br /&gt;
The value of the variable f is: 12.500000.&lt;br /&gt;
Again, the values are: c = c, i = 25, and f = 12.500000.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* [[Media:Simple2.c|Simple2.c]]:  A second program to learn about useful C constructs including functions, if statements, and loops.  This is the output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The value of i is 0 and 0/2 is 0.000000.&lt;br /&gt;
The value of i is 1 and 1/2 is 0.500000.&lt;br /&gt;
The value of i is 2 and 2/2 is 1.000000.&lt;br /&gt;
The value of i is 3 and 3/2 is 1.500000.&lt;br /&gt;
The value of i is 4 and 4/2 is 2.000000.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* [[Media:Invest.c|Invest.c]]:  The most complex tutorial program, which exercises a number of the features and capabilities of the C language while performing a very simple function:  calculating the value of an investment over time.  It also provides references to the [[Media:CrashCourseinC.pdf|Crash Course in C manual]] for further reading.  Below is some sample output.  You should be able to understand each step of the program to see how this output is produced.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Enter investment, growth rate, number of yrs (up to 100): 1000.00 1.05 5&lt;br /&gt;
Valid input?  1&lt;br /&gt;
&lt;br /&gt;
RESULTS:&lt;br /&gt;
&lt;br /&gt;
Year   0:     1000.00&lt;br /&gt;
Year   1:     1050.00&lt;br /&gt;
Year   2:     1102.50&lt;br /&gt;
Year   3:     1157.62&lt;br /&gt;
Year   4:     1215.51&lt;br /&gt;
Year   5:     1276.28&lt;br /&gt;
&lt;br /&gt;
Enter investment, growth rate, number of yrs (up to 100): 1000.00 1.05 500&lt;br /&gt;
Valid input?  0&lt;br /&gt;
Invalid input; exiting.&lt;br /&gt;
&lt;br /&gt;
Casting example.&lt;br /&gt;
Ratio, 5/2:   2.00&lt;br /&gt;
Ratio, 5/((float) 2):   2.50&lt;br /&gt;
Ratio, ((float) 5)/((float) 2):   2.50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each of these programs can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20808</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20808"/>
		<updated>2012-01-12T18:47:44Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Setting up the IDE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
If you already have a C compiler you are comfortable with, you can ignore this page.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  If you run into any issues installing GCC, &lt;br /&gt;
check out NetBeans&amp;#039; instructions for each operating system. They have very thorough &lt;br /&gt;
directions that could definitely help to sort out any problems; you can find those instructions&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  [http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend. To install, do the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].  This is the most complex portion of the install process; read the directions in the link carefully. &lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using [http://www.winzip.com/ WinZip] (must purchase), [http://www.gzip.org/#exe gzip], or [http://www.7-zip.org/ 7-zip] (recommended) such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;If you have any issues, check out the more detailed instructions for this process [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free Apple Developer membership.&lt;br /&gt;
&lt;br /&gt;
If you are running Mac OSX 10.7 (commonly known as Lion), you will download Xcode 4 from the Mac App Store.  If you are running Mac OSX 10.6 or earlier, you will download Xcode 3.  The .dmg download for Xcode 3 is available directly from the box on the left hand side of [http://developer.apple.com/xcode the Xcode page]. &lt;br /&gt;
&lt;br /&gt;
If you are not yet an Apple Developer, which is necessary to download Xcode, you can sign up for free [http://developer.apple.com/programs/register here] by filling out the questionnaire.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note to Windows users:&amp;#039;&amp;#039;&amp;#039; When deciding between 6.9 and 7.0 versions, you should &lt;br /&gt;
read the notes directly under the &amp;quot;Hello World&amp;quot; test program &lt;br /&gt;
[[Installing a C Compiler and IDE#Test Programs| on this page.]]&lt;br /&gt;
Even though 6.9 is older you may be interested in installing it instead.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== ME333 Customization ===&lt;br /&gt;
In this course we plan on using two spaces for an indent, and no more than 80 characters per line.  To set these options in NetBeans do the following:&lt;br /&gt;
#click &amp;quot;Tools&amp;gt;Options&amp;quot; &amp;#039;&amp;#039;&amp;#039;(Mac users:  go to Netbeans&amp;gt;Preferences&amp;gt;Editor)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#Then select &amp;quot;Editor&amp;quot; from the buttons at the top&lt;br /&gt;
#Then select the &amp;quot;Formatting&amp;quot; tab  &lt;br /&gt;
#Set &amp;quot;Languages&amp;quot; to &amp;quot;All Languages&amp;quot;&lt;br /&gt;
##change &amp;quot;Number of Spaces per Indent&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Tab Size&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Right Margin&amp;quot; to 80&lt;br /&gt;
##make sure the checkbox for &amp;quot;Expand Tabs to Spaces&amp;quot; is checked&lt;br /&gt;
##&amp;quot;Line Wrap&amp;quot; is set to &amp;quot;After words&amp;quot;&lt;br /&gt;
#Then set &amp;quot;Language&amp;quot; to C, and make sure that the &amp;quot;Override Global Options&amp;quot; checkbox is unchecked.&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This next step may be very important for Windows users!&amp;#039;&amp;#039;&amp;#039;  When a compiled project is run inside of NetBeans, it must decide where to display the output, and if the user is expected to provide input, where that input will come from.  There are three options, an &amp;quot;External Terminal&amp;quot;, &amp;quot;Standard Output&amp;quot; and &amp;quot;Internal Terminal&amp;quot; (at least in NetBeans 7.+).  Depending on how you have your system setup these are not all guaranteed to work!  What you should do is right click on the project name in the &amp;quot;Projects&amp;quot; window, and then click &amp;quot;Project Properties&amp;quot;.  Next click &amp;quot;Run&amp;quot; and locate the &amp;quot;Console Type&amp;quot; drop down menu.  Make sure it is set to &amp;quot;External Terminal&amp;quot;.  In the future if you are getting strange behavior such as print statements that aren&amp;#039;t showing up you might want to check this setting.  Note that &amp;quot;External Terminal&amp;quot; is appropriate for other operating systems as well.  As far as I can tell, this is only an issue in versions of NetBeans newer than 7.0, and it may be quite annoying as it seems there is no way to set this to a default.  If you are bothered by it, consider installing a slightly older version of NetBeans (such as 6.9).  &lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
= Tutorial Sample Code =&lt;br /&gt;
We have provided several simple sample programs to get you started with&lt;br /&gt;
the C language.  You should compile and run each of them, read the comments, answer the questions, and read the portions of the [[Media:CrashCourseinC.pdf|Crash Course in C manual]] referenced for more background.&lt;br /&gt;
&lt;br /&gt;
* [[Media:Simple1.c|Simple1.c]]:  A first simple program to learn about different data types and printing to screen.  This is the output of running the executable version:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
This is a simple message&lt;br /&gt;
The value of the variable c is: c.&lt;br /&gt;
The value of the variable i is: 25.&lt;br /&gt;
The value of the variable f is: 12.500000.&lt;br /&gt;
Again, the values are: c = c, i = 25, and f = 12.500000.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* [[Media:Simple2.c|Simple2.c]]:  A second program to learn about useful C constructs including functions, if statements, and loops.  This is the output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The value of i is 0 and 0/2 is 0.000000.&lt;br /&gt;
The value of i is 1 and 1/2 is 0.500000.&lt;br /&gt;
The value of i is 2 and 2/2 is 1.000000.&lt;br /&gt;
The value of i is 3 and 3/2 is 1.500000.&lt;br /&gt;
The value of i is 4 and 4/2 is 2.000000.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* [[Media:Invest.c|Invest.c]]:  The most complex tutorial program, which exercises a number of the features and capabilities of the C language while performing a very simple function:  calculating the value of an investment over time.  It also provides references to the [[Media:CrashCourseinC.pdf|Crash Course in C manual]] for further reading.  Below is some sample output.  You should be able to understand each step of the program to see how this output is produced.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Enter investment, growth rate, number of yrs (up to 100): 1000.00 1.05 5&lt;br /&gt;
Valid input?  1&lt;br /&gt;
&lt;br /&gt;
RESULTS:&lt;br /&gt;
&lt;br /&gt;
Year   0:     1000.00&lt;br /&gt;
Year   1:     1050.00&lt;br /&gt;
Year   2:     1102.50&lt;br /&gt;
Year   3:     1157.62&lt;br /&gt;
Year   4:     1215.51&lt;br /&gt;
Year   5:     1276.28&lt;br /&gt;
&lt;br /&gt;
Enter investment, growth rate, number of yrs (up to 100): 1000.00 1.05 500&lt;br /&gt;
Valid input?  0&lt;br /&gt;
Invalid input; exiting.&lt;br /&gt;
&lt;br /&gt;
Casting example.&lt;br /&gt;
Ratio, 5/2:   2.00&lt;br /&gt;
Ratio, 5/((float) 2):   2.50&lt;br /&gt;
Ratio, ((float) 5)/((float) 2):   2.50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each of these programs can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20807</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20807"/>
		<updated>2012-01-12T18:47:16Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Setting up the IDE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
If you already have a C compiler you are comfortable with, you can ignore this page.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  If you run into any issues installing GCC, &lt;br /&gt;
check out NetBeans&amp;#039; instructions for each operating system. They have very thorough &lt;br /&gt;
directions that could definitely help to sort out any problems; you can find those instructions&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  [http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend. To install, do the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].  This is the most complex portion of the install process; read the directions in the link carefully. &lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using [http://www.winzip.com/ WinZip] (must purchase), [http://www.gzip.org/#exe gzip], or [http://www.7-zip.org/ 7-zip] (recommended) such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;If you have any issues, check out the more detailed instructions for this process [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free Apple Developer membership.&lt;br /&gt;
&lt;br /&gt;
If you are running Mac OSX 10.7 (commonly known as Lion), you will download Xcode 4 from the Mac App Store.  If you are running Mac OSX 10.6 or earlier, you will download Xcode 3.  The .dmg download for Xcode 3 is available directly from the box on the left hand side of [http://developer.apple.com/xcode the Xcode page]. &lt;br /&gt;
&lt;br /&gt;
If you are not yet an Apple Developer, which is necessary to download Xcode, you can sign up for free [http://developer.apple.com/programs/register here] by filling out the questionnaire.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note to Windows users:&amp;#039;&amp;#039;&amp;#039; When deciding between 6.9 and 7.0 versions, you should &lt;br /&gt;
read the notes directly under the &amp;quot;Hello World&amp;quot; test program &lt;br /&gt;
[[Installing a C Compiler and IDE#Test Programs| here.]]&lt;br /&gt;
Even though 6.9 is older you may be interested in installing it instead.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== ME333 Customization ===&lt;br /&gt;
In this course we plan on using two spaces for an indent, and no more than 80 characters per line.  To set these options in NetBeans do the following:&lt;br /&gt;
#click &amp;quot;Tools&amp;gt;Options&amp;quot; &amp;#039;&amp;#039;&amp;#039;(Mac users:  go to Netbeans&amp;gt;Preferences&amp;gt;Editor)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#Then select &amp;quot;Editor&amp;quot; from the buttons at the top&lt;br /&gt;
#Then select the &amp;quot;Formatting&amp;quot; tab  &lt;br /&gt;
#Set &amp;quot;Languages&amp;quot; to &amp;quot;All Languages&amp;quot;&lt;br /&gt;
##change &amp;quot;Number of Spaces per Indent&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Tab Size&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Right Margin&amp;quot; to 80&lt;br /&gt;
##make sure the checkbox for &amp;quot;Expand Tabs to Spaces&amp;quot; is checked&lt;br /&gt;
##&amp;quot;Line Wrap&amp;quot; is set to &amp;quot;After words&amp;quot;&lt;br /&gt;
#Then set &amp;quot;Language&amp;quot; to C, and make sure that the &amp;quot;Override Global Options&amp;quot; checkbox is unchecked.&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This next step may be very important for Windows users!&amp;#039;&amp;#039;&amp;#039;  When a compiled project is run inside of NetBeans, it must decide where to display the output, and if the user is expected to provide input, where that input will come from.  There are three options, an &amp;quot;External Terminal&amp;quot;, &amp;quot;Standard Output&amp;quot; and &amp;quot;Internal Terminal&amp;quot; (at least in NetBeans 7.+).  Depending on how you have your system setup these are not all guaranteed to work!  What you should do is right click on the project name in the &amp;quot;Projects&amp;quot; window, and then click &amp;quot;Project Properties&amp;quot;.  Next click &amp;quot;Run&amp;quot; and locate the &amp;quot;Console Type&amp;quot; drop down menu.  Make sure it is set to &amp;quot;External Terminal&amp;quot;.  In the future if you are getting strange behavior such as print statements that aren&amp;#039;t showing up you might want to check this setting.  Note that &amp;quot;External Terminal&amp;quot; is appropriate for other operating systems as well.  As far as I can tell, this is only an issue in versions of NetBeans newer than 7.0, and it may be quite annoying as it seems there is no way to set this to a default.  If you are bothered by it, consider installing a slightly older version of NetBeans (such as 6.9).  &lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
= Tutorial Sample Code =&lt;br /&gt;
We have provided several simple sample programs to get you started with&lt;br /&gt;
the C language.  You should compile and run each of them, read the comments, answer the questions, and read the portions of the [[Media:CrashCourseinC.pdf|Crash Course in C manual]] referenced for more background.&lt;br /&gt;
&lt;br /&gt;
* [[Media:Simple1.c|Simple1.c]]:  A first simple program to learn about different data types and printing to screen.  This is the output of running the executable version:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
This is a simple message&lt;br /&gt;
The value of the variable c is: c.&lt;br /&gt;
The value of the variable i is: 25.&lt;br /&gt;
The value of the variable f is: 12.500000.&lt;br /&gt;
Again, the values are: c = c, i = 25, and f = 12.500000.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* [[Media:Simple2.c|Simple2.c]]:  A second program to learn about useful C constructs including functions, if statements, and loops.  This is the output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The value of i is 0 and 0/2 is 0.000000.&lt;br /&gt;
The value of i is 1 and 1/2 is 0.500000.&lt;br /&gt;
The value of i is 2 and 2/2 is 1.000000.&lt;br /&gt;
The value of i is 3 and 3/2 is 1.500000.&lt;br /&gt;
The value of i is 4 and 4/2 is 2.000000.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* [[Media:Invest.c|Invest.c]]:  The most complex tutorial program, which exercises a number of the features and capabilities of the C language while performing a very simple function:  calculating the value of an investment over time.  It also provides references to the [[Media:CrashCourseinC.pdf|Crash Course in C manual]] for further reading.  Below is some sample output.  You should be able to understand each step of the program to see how this output is produced.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Enter investment, growth rate, number of yrs (up to 100): 1000.00 1.05 5&lt;br /&gt;
Valid input?  1&lt;br /&gt;
&lt;br /&gt;
RESULTS:&lt;br /&gt;
&lt;br /&gt;
Year   0:     1000.00&lt;br /&gt;
Year   1:     1050.00&lt;br /&gt;
Year   2:     1102.50&lt;br /&gt;
Year   3:     1157.62&lt;br /&gt;
Year   4:     1215.51&lt;br /&gt;
Year   5:     1276.28&lt;br /&gt;
&lt;br /&gt;
Enter investment, growth rate, number of yrs (up to 100): 1000.00 1.05 500&lt;br /&gt;
Valid input?  0&lt;br /&gt;
Invalid input; exiting.&lt;br /&gt;
&lt;br /&gt;
Casting example.&lt;br /&gt;
Ratio, 5/2:   2.00&lt;br /&gt;
Ratio, 5/((float) 2):   2.50&lt;br /&gt;
Ratio, ((float) 5)/((float) 2):   2.50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each of these programs can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20806</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20806"/>
		<updated>2012-01-12T18:37:00Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Test Programs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
If you already have a C compiler you are comfortable with, you can ignore this page.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  If you run into any issues installing GCC, &lt;br /&gt;
check out NetBeans&amp;#039; instructions for each operating system. They have very thorough &lt;br /&gt;
directions that could definitely help to sort out any problems; you can find those instructions&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  [http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend. To install, do the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].  This is the most complex portion of the install process; read the directions in the link carefully. &lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using [http://www.winzip.com/ WinZip] (must purchase), [http://www.gzip.org/#exe gzip], or [http://www.7-zip.org/ 7-zip] (recommended) such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;If you have any issues, check out the more detailed instructions for this process [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free Apple Developer membership.&lt;br /&gt;
&lt;br /&gt;
If you are running Mac OSX 10.7 (commonly known as Lion), you will download Xcode 4 from the Mac App Store.  If you are running Mac OSX 10.6 or earlier, you will download Xcode 3.  The .dmg download for Xcode 3 is available directly from the box on the left hand side of [http://developer.apple.com/xcode the Xcode page]. &lt;br /&gt;
&lt;br /&gt;
If you are not yet an Apple Developer, which is necessary to download Xcode, you can sign up for free [http://developer.apple.com/programs/register here] by filling out the questionnaire.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== ME333 Customization ===&lt;br /&gt;
In this course we plan on using two spaces for an indent, and no more than 80 characters per line.  To set these options in NetBeans do the following:&lt;br /&gt;
#click &amp;quot;Tools&amp;gt;Options&amp;quot; &amp;#039;&amp;#039;&amp;#039;(Mac users:  go to Netbeans&amp;gt;Preferences&amp;gt;Editor)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#Then select &amp;quot;Editor&amp;quot; from the buttons at the top&lt;br /&gt;
#Then select the &amp;quot;Formatting&amp;quot; tab  &lt;br /&gt;
#Set &amp;quot;Languages&amp;quot; to &amp;quot;All Languages&amp;quot;&lt;br /&gt;
##change &amp;quot;Number of Spaces per Indent&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Tab Size&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Right Margin&amp;quot; to 80&lt;br /&gt;
##make sure the checkbox for &amp;quot;Expand Tabs to Spaces&amp;quot; is checked&lt;br /&gt;
##&amp;quot;Line Wrap&amp;quot; is set to &amp;quot;After words&amp;quot;&lt;br /&gt;
#Then set &amp;quot;Language&amp;quot; to C, and make sure that the &amp;quot;Override Global Options&amp;quot; checkbox is unchecked.&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This next step may be very important for Windows users!&amp;#039;&amp;#039;&amp;#039;  When a compiled project is run inside of NetBeans, it must decide where to display the output, and if the user is expected to provide input, where that input will come from.  There are three options, an &amp;quot;External Terminal&amp;quot;, &amp;quot;Standard Output&amp;quot; and &amp;quot;Internal Terminal&amp;quot; (at least in NetBeans 7.+).  Depending on how you have your system setup these are not all guaranteed to work!  What you should do is right click on the project name in the &amp;quot;Projects&amp;quot; window, and then click &amp;quot;Project Properties&amp;quot;.  Next click &amp;quot;Run&amp;quot; and locate the &amp;quot;Console Type&amp;quot; drop down menu.  Make sure it is set to &amp;quot;External Terminal&amp;quot;.  In the future if you are getting strange behavior such as print statements that aren&amp;#039;t showing up you might want to check this setting.  Note that &amp;quot;External Terminal&amp;quot; is appropriate for other operating systems as well.  As far as I can tell, this is only an issue in versions of NetBeans newer than 7.0, and it may be quite annoying as it seems there is no way to set this to a default.  If you are bothered by it, consider installing a slightly older version of NetBeans (such as 6.9).  &lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
= Tutorial Sample Code =&lt;br /&gt;
We have provided several simple sample programs to get you started with&lt;br /&gt;
the C language.  You should compile and run each of them, read the comments, answer the questions, and read the portions of the [[Media:CrashCourseinC.pdf|Crash Course in C manual]] referenced for more background.&lt;br /&gt;
&lt;br /&gt;
* [[Media:Simple1.c|Simple1.c]]:  A first simple program to learn about different data types and printing to screen.  This is the output of running the executable version:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
This is a simple message&lt;br /&gt;
The value of the variable c is: c.&lt;br /&gt;
The value of the variable i is: 25.&lt;br /&gt;
The value of the variable f is: 12.500000.&lt;br /&gt;
Again, the values are: c = c, i = 25, and f = 12.500000.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* [[Media:Simple2.c|Simple2.c]]:  A second program to learn about useful C constructs including functions, if statements, and loops.  This is the output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The value of i is 0 and 0/2 is 0.000000.&lt;br /&gt;
The value of i is 1 and 1/2 is 0.500000.&lt;br /&gt;
The value of i is 2 and 2/2 is 1.000000.&lt;br /&gt;
The value of i is 3 and 3/2 is 1.500000.&lt;br /&gt;
The value of i is 4 and 4/2 is 2.000000.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* [[Media:Invest.c|Invest.c]]:  The most complex tutorial program, which exercises a number of the features and capabilities of the C language while performing a very simple function:  calculating the value of an investment over time.  It also provides references to the [[Media:CrashCourseinC.pdf|Crash Course in C manual]] for further reading.  Below is some sample output.  You should be able to understand each step of the program to see how this output is produced.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Enter investment, growth rate, number of yrs (up to 100): 1000.00 1.05 5&lt;br /&gt;
Valid input?  1&lt;br /&gt;
&lt;br /&gt;
RESULTS:&lt;br /&gt;
&lt;br /&gt;
Year   0:     1000.00&lt;br /&gt;
Year   1:     1050.00&lt;br /&gt;
Year   2:     1102.50&lt;br /&gt;
Year   3:     1157.62&lt;br /&gt;
Year   4:     1215.51&lt;br /&gt;
Year   5:     1276.28&lt;br /&gt;
&lt;br /&gt;
Enter investment, growth rate, number of yrs (up to 100): 1000.00 1.05 500&lt;br /&gt;
Valid input?  0&lt;br /&gt;
Invalid input; exiting.&lt;br /&gt;
&lt;br /&gt;
Casting example.&lt;br /&gt;
Ratio, 5/2:   2.00&lt;br /&gt;
Ratio, 5/((float) 2):   2.50&lt;br /&gt;
Ratio, ((float) 5)/((float) 2):   2.50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each of these programs can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20617</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20617"/>
		<updated>2011-12-16T15:15:17Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Windows */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
If you already have a C compiler you are comfortable with, you can ignore this page.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  If you run into any issues installing GCC, &lt;br /&gt;
check out NetBeans&amp;#039; instructions for each operating system. They have very thorough &lt;br /&gt;
directions that could definitely help to sort out any problems; you can find those instructions&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  [http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend. To install, do the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].  This is the most complex portion of the install process; read the directions in the link carefully. &lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using [http://www.winzip.com/ WinZip] (must purchase), [http://www.gzip.org/#exe gzip], or [http://www.7-zip.org/ 7-zip] (recommended) such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;If you have any issues, check out the more detailed instructions for this process [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free ADC membership.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== ME333 Customization ===&lt;br /&gt;
In this course we plan on using two spaces for an indent, and no more than 80 characters per line.  To set these options in NetBeans do the following:&lt;br /&gt;
#click &amp;quot;Tools&amp;gt;Options&amp;quot;&lt;br /&gt;
#Then select &amp;quot;Editor&amp;quot; from the buttons at the top&lt;br /&gt;
#Then select the &amp;quot;Formatting&amp;quot; tab  &lt;br /&gt;
#Set &amp;quot;Languages&amp;quot; to &amp;quot;All Languages&amp;quot;&lt;br /&gt;
##change &amp;quot;Number of Spaces per Indent&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Tab Size&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Right Margin&amp;quot; to 80&lt;br /&gt;
##make sure the checkbox for &amp;quot;Expand Tabs to Spaces&amp;quot; is checked&lt;br /&gt;
##&amp;quot;Line Wrap&amp;quot; is set to &amp;quot;After words&amp;quot;&lt;br /&gt;
#Then set &amp;quot;Language&amp;quot; to C, and make sure that the &amp;quot;Override Global Options&amp;quot; checkbox is unchecked.&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This next step may be very important for Windows users!&amp;#039;&amp;#039;&amp;#039;  When a compiled project is run inside of NetBeans, it must decide where to display the output, and if the user is expected to provide input, where that input will come from.  There are three options, an &amp;quot;External Terminal&amp;quot;, &amp;quot;Standard Output&amp;quot; and &amp;quot;Internal Terminal&amp;quot; (at least in NetBeans 7.+).  Depending on how you have your system setup these are not all guaranteed to work!  What you should do is right click on the project name in the &amp;quot;Projects&amp;quot; window, and then click &amp;quot;Project Properties&amp;quot;.  Next click &amp;quot;Run&amp;quot; and locate the &amp;quot;Console Type&amp;quot; drop down menu.  Make sure it is set to &amp;quot;External Terminal&amp;quot;.  In the future if you are getting strange behavior such as print statements that aren&amp;#039;t showing up you might want to check this setting.  Note that &amp;quot;External Terminal&amp;quot; is appropriate for other operating systems as well.&lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Tutorial Sample Code =&lt;br /&gt;
We have provided several other pieces of sample code to facilitate learning &lt;br /&gt;
the C language.  You should compile and run each of them, read the comments, answer the questions, and read the portions of [[Media:EssentialC.pdf|the Essential C manual]] referenced for more background.&lt;br /&gt;
&lt;br /&gt;
* [[Media:Simple1.c|Simple1.c]]:  A first simple program to learn about different data types and printing to screen.&lt;br /&gt;
* [[Media:Simple2.c|Simple2.c]]:  A second program to learn about useful C constructs including functions, if statements, loops, and this [[media:Invest.c|tutorial code]].  &lt;br /&gt;
* [[Media:Invest.c|Invest.c]]:  The most complex tutorial program, which exercises a number of the features and capabilities of the C language while performing a very simple function:  calculating the value of an investment over time.  It also provides references to the Essential C manual for further reading.&lt;br /&gt;
&lt;br /&gt;
Each of these programs can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20616</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20616"/>
		<updated>2011-12-16T15:07:40Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Setting up a compiler */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
If you already have a C compiler you are comfortable with, you can ignore this page.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  If you run into any issues installing GCC, &lt;br /&gt;
check out NetBeans&amp;#039; instructions for each operating system. They have very thorough &lt;br /&gt;
directions that could definitely help to sort out any problems; you can find those instructions&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  [http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend. To install, do the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].&lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using WinZip, gzip, or 7-zip such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;If you have any issues, check out the more detailed instructions for this process [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free ADC membership.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== ME333 Customization ===&lt;br /&gt;
In this course we plan on using two spaces for an indent, and no more than 80 characters per line.  To set these options in NetBeans do the following:&lt;br /&gt;
#click &amp;quot;Tools&amp;gt;Options&amp;quot;&lt;br /&gt;
#Then select &amp;quot;Editor&amp;quot; from the buttons at the top&lt;br /&gt;
#Then select the &amp;quot;Formatting&amp;quot; tab  &lt;br /&gt;
#Set &amp;quot;Languages&amp;quot; to &amp;quot;All Languages&amp;quot;&lt;br /&gt;
##change &amp;quot;Number of Spaces per Indent&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Tab Size&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Right Margin&amp;quot; to 80&lt;br /&gt;
##make sure the checkbox for &amp;quot;Expand Tabs to Spaces&amp;quot; is checked&lt;br /&gt;
##&amp;quot;Line Wrap&amp;quot; is set to &amp;quot;After words&amp;quot;&lt;br /&gt;
#Then set &amp;quot;Language&amp;quot; to C, and make sure that the &amp;quot;Override Global Options&amp;quot; checkbox is unchecked.&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This next step may be very important for Windows users!&amp;#039;&amp;#039;&amp;#039;  When a compiled project is run inside of NetBeans, it must decide where to display the output, and if the user is expected to provide input, where that input will come from.  There are three options, an &amp;quot;External Terminal&amp;quot;, &amp;quot;Standard Output&amp;quot; and &amp;quot;Internal Terminal&amp;quot; (at least in NetBeans 7.+).  Depending on how you have your system setup these are not all guaranteed to work!  What you should do is right click on the project name in the &amp;quot;Projects&amp;quot; window, and then click &amp;quot;Project Properties&amp;quot;.  Next click &amp;quot;Run&amp;quot; and locate the &amp;quot;Console Type&amp;quot; drop down menu.  Make sure it is set to &amp;quot;External Terminal&amp;quot;.  In the future if you are getting strange behavior such as print statements that aren&amp;#039;t showing up you might want to check this setting.  Note that &amp;quot;External Terminal&amp;quot; is appropriate for other operating systems as well.&lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Tutorial Sample Code =&lt;br /&gt;
We have provided several other pieces of sample code to facilitate learning &lt;br /&gt;
the C language.  You should compile and run each of them, read the comments, answer the questions, and read the portions of [[Media:EssentialC.pdf|the Essential C manual]] referenced for more background.&lt;br /&gt;
&lt;br /&gt;
* [[Media:Simple1.c|Simple1.c]]:  A first simple program to learn about different data types and printing to screen.&lt;br /&gt;
* [[Media:Simple2.c|Simple2.c]]:  A second program to learn about useful C constructs including functions, if statements, loops, and this [[media:Invest.c|tutorial code]].  &lt;br /&gt;
* [[Media:Invest.c|Invest.c]]:  The most complex tutorial program, which exercises a number of the features and capabilities of the C language while performing a very simple function:  calculating the value of an investment over time.  It also provides references to the Essential C manual for further reading.&lt;br /&gt;
&lt;br /&gt;
Each of these programs can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=20593</id>
		<title>ME 333 Introduction to Mechatronics (Archive Winter 2012)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2012)&amp;diff=20593"/>
		<updated>2011-12-15T23:41:47Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Checklist to Complete Before the First Day of Class */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Winter Quarter 2012 -- ***UNDER CONSTRUCTION***&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[ME 333 Introduction to Mechatronics (Archive Winter 2011)|(Archive of Winter 2011)]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;First day of class is Thursday Jan 5!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Section 20:  Prof. Kevin Lynch, T Th, 11:00-12:20, Tech LR5&lt;br /&gt;
* Section 21:  Prof. Nick Marchuk, T Th, 12:30-1:50, Tech LR5&lt;br /&gt;
* TAs:  Nelson Rosa, nelsonrosa2013 at u.northwestern.edu; Jarvis Schultz, JarvisSchultz2012 at u.northwestern.edu&lt;br /&gt;
* Office Hours:  TBA&lt;br /&gt;
* Circuits Q&amp;amp;A Session:  TBA&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Final demo&amp;#039;&amp;#039;&amp;#039; (in lieu of final exam):  11-12:20 section Wed March 14 9-11 AM; 12:30-1:50 section Monday March 12 3-5 PM&lt;br /&gt;
&lt;br /&gt;
== Checklist to Complete Before the First Day of Class ==&lt;br /&gt;
&lt;br /&gt;
Attendance at the first day of class (Thursday Jan 5) is mandatory.  By the first day of class, you should:&lt;br /&gt;
&lt;br /&gt;
* Be able to solve circuit problems similar to those on the practice problem set and last year&amp;#039;s quiz at the bottom of [[ME_333_Circuits_Review_Material|this page]].  Be prepared for a short quiz on this material in the second week of class.  We will only spend one class period reviewing this material.&lt;br /&gt;
* 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.  Your laptop should have Matlab installed.&lt;br /&gt;
* Download and install the Netbeans C compiler following the instructions [[Installing_a_C_Compiler_and_IDE|here]].  Verify that you can compile and run this [[Media:starter.c|starter C program]] and this second, more complex, [[Media:invest.c|tutorial C program]].  If you are new to C, it would be a good idea to experiment with these in advance of the course and to read the portions of [[Media:EssentialC.pdf|Essential C]] referenced in the second tutorial program.  This will allow you to start quickly in ME 333.&lt;br /&gt;
* Download and install software described on [[NU32v2: Software to Install|this page]].  &lt;br /&gt;
* Buy your class kit [http:// here].  You will not be able to start the course until you have purchased 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.&lt;br /&gt;
&lt;br /&gt;
== Student Contract ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* Allowing another student to copy your code.&lt;br /&gt;
* Copying another student&amp;#039;s code, in whole or in part.&lt;br /&gt;
* Transforming copied sections of code to try to disguise their origin.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
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 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 and the 2011 quiz on [[ME_333_Circuits_Review_Material|this page]].&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
&lt;br /&gt;
* [[Media:EssentialC.pdf|Essential C]]:  A brief introduction to the C programming language&lt;br /&gt;
* [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] (254 pages, 5 MB pdf)&lt;br /&gt;
* [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;amp;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.&lt;br /&gt;
* PIC32MX Peripheral Library (included as a .chm file under &amp;quot;Program Files\Microchip\MPLAB C32\doc&amp;quot; with your C32 compiler installation)&lt;br /&gt;
&lt;br /&gt;
Useful, but not required:&lt;br /&gt;
&lt;br /&gt;
* [http://www.amazon.com/Programming-32-bit-Microcontrollers-Exploring-Technology/dp/0750687096/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1294091438&amp;amp;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.&lt;br /&gt;
* MPLAB C32 Libraries Guide and MPLAB C32 User Guide, included under &amp;quot;doc&amp;quot; of your C32 compiler installation&lt;br /&gt;
* Other C resources, such as [http://publications.gbdirect.co.uk/c_book/ online] as well as this [[Media:CBook.pdf|pdf version]] of &amp;quot;The C Book,&amp;quot; and the classic [http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1294091625&amp;amp;sr=1-1 C Programming Language] reference book by Kernighan and Ritchie&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
Grades will be approximately 40% quizzes and 60% assignments.  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.  We will have a final demo in lieu of a final exam.&lt;br /&gt;
&lt;br /&gt;
== Approximate Syllabus ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;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. &lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Topics we will cover include:&lt;br /&gt;
&lt;br /&gt;
* introduction to C programming (here&amp;#039;s a [[Media:invest.c|simple tutorial C program]])&lt;br /&gt;
* quiz on circuits&lt;br /&gt;
* introduction to the PIC32 hardware, and programming the PIC32 in C&lt;br /&gt;
* digital I/O&lt;br /&gt;
* counters/timers and interrupts&lt;br /&gt;
* analog input&lt;br /&gt;
* sensor smorgasbord&lt;br /&gt;
* digital signal processing:  filters and FFTs&lt;br /&gt;
* analog output and pulse-width modulation&lt;br /&gt;
* brushed permanent magnet DC motors:  theory and control&lt;br /&gt;
* stepper motors and RC servo motors&lt;br /&gt;
* communication by SPI, I2C, and RS-232&lt;br /&gt;
&lt;br /&gt;
By class (note:  DS = Data Sheet, RM = Reference Manual):&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 1&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Course overview.  Circuits review.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  Practice problem set and quiz on [[ME_333_Circuits_Review_Material|this page]], as well as background reading as needed.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 2&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  None.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (bits, bytes, binary, hex, data types, memory, pointers, compiling).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  [[Media:invest.c|Sample program]], [[Media:EssentialC.pdf|Essential C]] (page numbers referenced in program comments).  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 3&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz&amp;#039;&amp;#039;&amp;#039;:  Circuits.  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Topic&amp;#039;&amp;#039;&amp;#039;:  Introduction to C (cont).&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading&amp;#039;&amp;#039;&amp;#039;:  &lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment out&amp;#039;&amp;#039;&amp;#039;: &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Final Demo&amp;#039;&amp;#039;&amp;#039;:  Monday 3/12, 3-5 PM, for 12:30-1:50 section; Wednesday 3/14, 9-11 AM, for 11:00-12:20 section &lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
&lt;br /&gt;
Q: Do I need to know the C language to take this course?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: Is there an independent project?&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q: What kind of laptop do I need?&lt;br /&gt;
&lt;br /&gt;
A: You need a laptop with at least 2 USB ports.  Any operating system is fine.&lt;br /&gt;
&lt;br /&gt;
== ME 333 Winter 2010 (obsolete) ==&lt;br /&gt;
&lt;br /&gt;
* [[ME 333 Circuits Review Material]]&lt;br /&gt;
* [http://www.youtube.com/NUmechatronics NUmechatronics youtube channel]&lt;br /&gt;
* [[ME 333 final projects]]&lt;br /&gt;
* [[PCB Artist]]&lt;br /&gt;
* [[ME 333 Suggested Final Projects]]&lt;br /&gt;
* [[ME 333 end of course schedule]]&lt;br /&gt;
* [[ME 333 Lab Kits]]&lt;br /&gt;
* [[Processing]] (software allowing you to create GUIs on your PC and interface through your USB port)&lt;br /&gt;
* Labs from Winter 2010&lt;br /&gt;
** [[Getting Started with PIC32|ME 333 Lab 1:  Getting started with the PIC32]]&lt;br /&gt;
** [[ME 333 Lab 2]]&lt;br /&gt;
** [http://lims.mech.northwestern.edu/~lynch/courses/ME333/PIClabs/lab3/lab3.html ME 333 Lab 3]&lt;br /&gt;
** [[ME 333 Lab 4]]&lt;br /&gt;
** [[ME 333 Lab 5]]&lt;br /&gt;
* Ungraded study problems (be sure to attempt to solve the problems before looking at the solutions!)&lt;br /&gt;
** [[ME 333 Circuits Review Material]]&lt;br /&gt;
** [[Media:MotorProblems.pdf|Practice DC motor problems]] and their [[Media:MotorProblemSolutions.pdf|solutions]]&lt;br /&gt;
** [[Media:PIC32StudyGuide.pdf|PIC32 Study Guide]] and [[Media:PIC32StudyGuideSolutions.pdf|solutions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[NU32v2:  A Detailed Look at Programming the PIC32]]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20592</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20592"/>
		<updated>2011-12-15T23:39:03Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Test Programs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C-language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
Note that if you already have a compiler and/ or IDE that you are comfortable &lt;br /&gt;
and experienced with this page may be of little use to you.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  They have very thorough directions for &lt;br /&gt;
setting up the GCC compiler on every operating system &lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  &lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend.  &amp;#039;&amp;#039;&amp;#039;Complete, detailed instructions for this process can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
A quick summary of these steps is provided in the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].&lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using WinZip, gzip, or 7-zip such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free ADC membership.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== ME333 Customization ===&lt;br /&gt;
In this course we plan on using two spaces for an indent, and no more than 80 characters per line.  To set these options in NetBeans do the following:&lt;br /&gt;
#click &amp;quot;Tools&amp;gt;Options&amp;quot;&lt;br /&gt;
#Then select &amp;quot;Editor&amp;quot; from the buttons at the top&lt;br /&gt;
#Then select the &amp;quot;Formatting&amp;quot; tab  &lt;br /&gt;
#Set &amp;quot;Languages&amp;quot; to &amp;quot;All Languages&amp;quot;&lt;br /&gt;
##change &amp;quot;Number of Spaces per Indent&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Tab Size&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Right Margin&amp;quot; to 80&lt;br /&gt;
##make sure the checkbox for &amp;quot;Expand Tabs to Spaces&amp;quot; is checked&lt;br /&gt;
##&amp;quot;Line Wrap&amp;quot; is set to &amp;quot;After words&amp;quot;&lt;br /&gt;
#Then set &amp;quot;Language&amp;quot; to C, and make sure that the &amp;quot;Override Global Options&amp;quot; checkbox is unchecked.&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This next step may be very important for Windows users!&amp;#039;&amp;#039;&amp;#039;  When a compiled project is run inside of NetBeans, it must decide where to display the output, and if the user is expected to provide input, where that input will come from.  There are three options, an &amp;quot;External Terminal&amp;quot;, &amp;quot;Standard Output&amp;quot; and &amp;quot;Internal Terminal&amp;quot; (at least in NetBeans 7.+).  Depending on how you have your system setup these are not all guaranteed to work!  What you should do is right click on the project name in the &amp;quot;Projects&amp;quot; window, and then click &amp;quot;Project Properties&amp;quot;.  Next click &amp;quot;Run&amp;quot; and locate the &amp;quot;Console Type&amp;quot; drop down menu.  Make sure it is set to &amp;quot;External Terminal&amp;quot;.  In the future if you are getting strange behavior such as print statements that aren&amp;#039;t showing up you might want to check this setting.  Note that &amp;quot;External Terminal&amp;quot; is appropriate for other operating systems as well.&lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Other Sample Code ===&lt;br /&gt;
We have provided several other sample pieces of code to facilitate learning &lt;br /&gt;
the C-language.  The first you should look at can be found [[media:starter.c|here]], and a &lt;br /&gt;
slightly more complicated piece of code can be found [[media:Invest.c| here]].  &lt;br /&gt;
Each of these can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20591</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20591"/>
		<updated>2011-12-15T23:37:47Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Test Programs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C-language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
Note that if you already have a compiler and/ or IDE that you are comfortable &lt;br /&gt;
and experienced with this page may be of little use to you.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  They have very thorough directions for &lt;br /&gt;
setting up the GCC compiler on every operating system &lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  &lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend.  &amp;#039;&amp;#039;&amp;#039;Complete, detailed instructions for this process can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
A quick summary of these steps is provided in the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].&lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using WinZip, gzip, or 7-zip such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free ADC membership.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== ME333 Customization ===&lt;br /&gt;
In this course we plan on using two spaces for an indent, and no more than 80 characters per line.  To set these options in NetBeans do the following:&lt;br /&gt;
#click &amp;quot;Tools&amp;gt;Options&amp;quot;&lt;br /&gt;
#Then select &amp;quot;Editor&amp;quot; from the buttons at the top&lt;br /&gt;
#Then select the &amp;quot;Formatting&amp;quot; tab  &lt;br /&gt;
#Set &amp;quot;Languages&amp;quot; to &amp;quot;All Languages&amp;quot;&lt;br /&gt;
##change &amp;quot;Number of Spaces per Indent&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Tab Size&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Right Margin&amp;quot; to 80&lt;br /&gt;
##make sure the checkbox for &amp;quot;Expand Tabs to Spaces&amp;quot; is checked&lt;br /&gt;
##&amp;quot;Line Wrap&amp;quot; is set to &amp;quot;After words&amp;quot;&lt;br /&gt;
#Then set &amp;quot;Language&amp;quot; to C, and make sure that the &amp;quot;Override Global Options&amp;quot; checkbox is unchecked.&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This next step may be very important for Windows users!&amp;#039;&amp;#039;&amp;#039;  When a compiled project is run inside of NetBeans, it must decide where to display the output, and if the user is expected to provide input, where that input will come from.  There are three options an &amp;quot;External Terminal&amp;quot;, &amp;quot;Standard Output&amp;quot; and &amp;quot;Internal Terminal&amp;quot; (at least in NetBeans 7.+).  Depending on how you have your system setup these are not all guaranteed to work!  What you should do is right click on the project name in the &amp;quot;Projects&amp;quot; window, and then click &amp;quot;Project Properties&amp;quot;.  Next click &amp;quot;Run&amp;quot; and locate the &amp;quot;Console Type&amp;quot; drop down menu.  Make sure it is set to &amp;quot;External Terminal&amp;quot;.  In the future if you are getting strange behavior such as print statements that aren&amp;#039;t showing up you might want to check this setting.&lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Other Sample Code ===&lt;br /&gt;
We have provided several other sample pieces of code to facilitate learning &lt;br /&gt;
the C-language.  The first you should look at can be found [[media:starter.c|here]], and a &lt;br /&gt;
slightly more complicated piece of code can be found [[media:Invest.c| here]].  &lt;br /&gt;
Each of these can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20590</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20590"/>
		<updated>2011-12-15T23:28:44Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Setting up the IDE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C-language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
Note that if you already have a compiler and/ or IDE that you are comfortable &lt;br /&gt;
and experienced with this page may be of little use to you.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  They have very thorough directions for &lt;br /&gt;
setting up the GCC compiler on every operating system &lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  &lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend.  &amp;#039;&amp;#039;&amp;#039;Complete, detailed instructions for this process can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
A quick summary of these steps is provided in the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].&lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using WinZip, gzip, or 7-zip such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free ADC membership.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== ME333 Customization ===&lt;br /&gt;
In this course we plan on using two spaces for an indent, and no more than 80 characters per line.  To set these options in NetBeans do the following:&lt;br /&gt;
#click &amp;quot;Tools&amp;gt;Options&amp;quot;&lt;br /&gt;
#Then select &amp;quot;Editor&amp;quot; from the buttons at the top&lt;br /&gt;
#Then select the &amp;quot;Formatting&amp;quot; tab  &lt;br /&gt;
#Set &amp;quot;Languages&amp;quot; to &amp;quot;All Languages&amp;quot;&lt;br /&gt;
##change &amp;quot;Number of Spaces per Indent&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Tab Size&amp;quot; to 2&lt;br /&gt;
##&amp;quot;Right Margin&amp;quot; to 80&lt;br /&gt;
##make sure the checkbox for &amp;quot;Expand Tabs to Spaces&amp;quot; is checked&lt;br /&gt;
##&amp;quot;Line Wrap&amp;quot; is set to &amp;quot;After words&amp;quot;&lt;br /&gt;
#Then set &amp;quot;Language&amp;quot; to C, and make sure that the &amp;quot;Override Global Options&amp;quot; checkbox is unchecked.&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Other Sample Code ===&lt;br /&gt;
We have provided several other sample pieces of code to facilitate learning &lt;br /&gt;
the C-language.  The first you should look at can be found [[media:starter.c|here]], and a &lt;br /&gt;
slightly more complicated piece of code can be found [[media:Invest.c| here]].  &lt;br /&gt;
Each of these can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20589</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20589"/>
		<updated>2011-12-15T23:11:15Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Setting up a compiler */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C-language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
Note that if you already have a compiler and/ or IDE that you are comfortable &lt;br /&gt;
and experienced with this page may be of little use to you.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  They have very thorough directions for &lt;br /&gt;
setting up the GCC compiler on every operating system &lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  &lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend.  &amp;#039;&amp;#039;&amp;#039;Complete, detailed instructions for this process can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
A quick summary of these steps is provided in the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].&lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using WinZip, gzip, or 7-zip such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free ADC membership.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Other Sample Code ===&lt;br /&gt;
We have provided several other sample pieces of code to facilitate learning &lt;br /&gt;
the C-language.  The first you should look at can be found [[media:starter.c|here]], and a &lt;br /&gt;
slightly more complicated piece of code can be found [[media:Invest.c| here]].  &lt;br /&gt;
Each of these can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20588</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20588"/>
		<updated>2011-12-15T23:11:01Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Test Programs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C-language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
Note that if you already have a compiler and/ or IDE that you are comfortable &lt;br /&gt;
and experienced with this page may be of little use to you.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  They have very thorough directions for &lt;br /&gt;
setting up the GCC compiler on every operating system &lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  &lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend.  &amp;#039;&amp;#039;&amp;#039;Complete, detailed instructions for this process can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
A quick summary of these steps is provided in the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].&lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using WinZip, gzip, or 7-zip such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free ADC membership.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Other Sample Code ===&lt;br /&gt;
We have provided several other sample pieces of code to facilitate learning &lt;br /&gt;
the C-language.  The first you should look at can be found [[media:starter.c|here]], and a &lt;br /&gt;
slightly more complicated piece of code can be found [[media:Invest.c| here]].  &lt;br /&gt;
Each of these can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20587</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20587"/>
		<updated>2011-12-15T23:10:10Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Conclusions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C-language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
Note that if you already have a compiler and/ or IDE that you are comfortable &lt;br /&gt;
and experienced with this page may be of little use to you.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  They have very thorough directions for &lt;br /&gt;
setting up the GCC compiler on every operating system &lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  &lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend.  &amp;#039;&amp;#039;&amp;#039;Complete, detailed instructions for this process can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
A quick summary of these steps is provided in the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].&lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using WinZip, gzip, or 7-zip such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free ADC membership.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Other Sample Code ===&lt;br /&gt;
We have provided several other sample pieces of code to facilitate learning &lt;br /&gt;
the C-language.  The first you should look at can be found [[media:starter.c|here]], and a &lt;br /&gt;
slightly more complicated piece of code can be found [[media:Invest.c| here]].  &lt;br /&gt;
Each of these can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Other Resources=&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/kb/docs/cnd/quickstart.html NetBeans C/C++ Projects Quick Start Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite HOWTO Install MinGW Compiler Suite]&lt;br /&gt;
&lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html Configuring the NetBeans IDE for C/C++/Fortran]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/compilingandlinking.html CProgramming Compiling and Linking]&lt;br /&gt;
&lt;br /&gt;
[http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html An introduction to Makefiles]&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20586</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20586"/>
		<updated>2011-12-15T23:08:09Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Test Programs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C-language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
Note that if you already have a compiler and/ or IDE that you are comfortable &lt;br /&gt;
and experienced with this page may be of little use to you.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  They have very thorough directions for &lt;br /&gt;
setting up the GCC compiler on every operating system &lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  &lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend.  &amp;#039;&amp;#039;&amp;#039;Complete, detailed instructions for this process can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
A quick summary of these steps is provided in the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].&lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using WinZip, gzip, or 7-zip such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free ADC membership.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Other Sample Code ===&lt;br /&gt;
We have provided several other sample pieces of code to facilitate learning &lt;br /&gt;
the C-language.  The first you should look at can be found [[media:starter.c|here]], and a &lt;br /&gt;
slightly more complicated piece of code can be found [[media:Invest.c| here]].  &lt;br /&gt;
Each of these can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Conclusions =&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20585</id>
		<title>Installing a C Compiler and IDE</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Installing_a_C_Compiler_and_IDE&amp;diff=20585"/>
		<updated>2011-12-15T23:07:27Z</updated>

		<summary type="html">&lt;p&gt;JarvisSchultz: /* Makefiles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
One of the purposes of this course is to learn the basics of the C programming &lt;br /&gt;
language.  Towards that goal, we will begin the course by writing some simple C&lt;br /&gt;
programs that are built to run on a computer alone, and not any sort of &lt;br /&gt;
microprocessor.  This section will guide you through setting up a C-language &lt;br /&gt;
compiler and an integrated development environment or IDE.  &lt;br /&gt;
&lt;br /&gt;
Note that if you already have a compiler and/ or IDE that you are comfortable &lt;br /&gt;
and experienced with this page may be of little use to you.&lt;br /&gt;
&lt;br /&gt;
= Setting up a compiler =&lt;br /&gt;
Unlike some languages that you may be familiar with (MATLAB for one) the C &lt;br /&gt;
programming language must be &amp;quot;compiled&amp;quot; before it can be run on the computer.  &lt;br /&gt;
A compiler&amp;#039;s job is to take the code that a person writes in the C-language and &lt;br /&gt;
convert it to a &amp;quot;binary file&amp;quot; in machine language that the computer understands.  &lt;br /&gt;
For more info see [http://en.wikipedia.org/wiki/Compiler wikipedia].&lt;br /&gt;
&lt;br /&gt;
The compiler that we recommend is the GNU Compiler collection or [http://gcc.gnu.org/ GCC].  &lt;br /&gt;
This is a widely used cross-platform compiler toolsuite that has libraries and compilers &lt;br /&gt;
for C, C++, Fortran, Java, and more.  Additionally the compiler that we will use &lt;br /&gt;
later on in the course for compiling C code to run on the PIC32 is based on GCC.&lt;br /&gt;
&lt;br /&gt;
In the next section we are going to discuss setting up an integrated development &lt;br /&gt;
environment ([http://en.wikipedia.org/wiki/Integrated_development_environment IDE]) &lt;br /&gt;
called [http://netbeans.org/ NetBeans].  They have very thorough directions for &lt;br /&gt;
setting up the GCC compiler on every operating system &lt;br /&gt;
[http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&lt;br /&gt;
&lt;br /&gt;
=== Windows === &lt;br /&gt;
Windows is arguably the most difficult operating system to get the compiler &lt;br /&gt;
working with.  The GCC toolsuite was originally developed to work with &lt;br /&gt;
Unix/Linux operating systems, but there are two popular Windows ports available, &lt;br /&gt;
Cygwin and MinGW.  &lt;br /&gt;
&lt;br /&gt;
[http://mingw.org/ MinGW] is probably the easier of the two to setup so that is &lt;br /&gt;
what we recommend.  &amp;#039;&amp;#039;&amp;#039;Complete, detailed instructions for this process can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html#mingw here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
A quick summary of these steps is provided in the following:&lt;br /&gt;
&lt;br /&gt;
# Install [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=MinGW-5.1.4.exe&amp;amp;a=57946486 MinGW-5.1.4.exe] (direct link).&lt;br /&gt;
# Add C:\MinGW\bin to the system path by editing your system&amp;#039;s [http://www.mingw.org/wiki/Getting_Started#toc4 Environment Settings].&lt;br /&gt;
# Install MSYS 1.0 files by running [http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe MSYS-1.0.10.exe] (direct link).&lt;br /&gt;
# Install the gdb debugger by downloading [http://sourceforge.net/project/downloading.php?group_id=2435&amp;amp;filename=gdb-6.8-mingw-3.tar.bz2&amp;amp;a=66334146 gdb-6.8-mingw-3.tar.bz2] (direct link) and extracting using WinZip, gzip, or 7-zip such that the gdb executable is in the C:\MinGW\bin directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Apple OSx ===&lt;br /&gt;
To get all of the required tools you must install Xcode and X11 from the [http://developer.apple.com/devcenter/mac/index.action Apple Developer Connection].&lt;br /&gt;
Note that you must sign up for a free ADC membership.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
Many linux distributions have GCC bundled with the install, if you do not have &lt;br /&gt;
it you should be able to get it from your distribution&amp;#039;s repositories using your &lt;br /&gt;
favorite package manager.&lt;br /&gt;
&lt;br /&gt;
= Setting up the IDE =&lt;br /&gt;
Now that you have a compiler, all you really need is a text editor, and you are &lt;br /&gt;
ready to start coding in C.  However, learning the ins and the outs of &lt;br /&gt;
compiling, linking, debugging, Makefiles, etc. can be a bit overwhelming.  So we&lt;br /&gt;
are going to recommend the use of an [http://en.wikipedia.org/wiki/Integrated_development_environment IDE]&lt;br /&gt;
to help you get started.  As well as helping beginners, many experienced &lt;br /&gt;
programmers do all of their development in an IDE.  An IDE can act as a &lt;br /&gt;
source code editor, it can provide graphical interfaces to debuggers and &lt;br /&gt;
compilers, it can autogenerate useful configuration files, and many more useful &lt;br /&gt;
features.  The IDE that we are going to recommend is [http://netbeans.org NetBeans].  &lt;br /&gt;
NetBeans is totally free, it is cross-platform, and Microchip has paired with &lt;br /&gt;
NetBeans to develop their new-generation IDE for PIC development, MPLABX (which &lt;br /&gt;
you will be using later in the course).&lt;br /&gt;
&lt;br /&gt;
To install NetBeans simply visit [http://netbeans.org/downloads/index.html this link] and &lt;br /&gt;
install either 6.9.1 or 7.0.1 for your operating system.  You can install either &lt;br /&gt;
the full version, or just the C/C++ version (recommended).  Note that this &lt;br /&gt;
doesn&amp;#039;t really matter as modules can be added or deleted later on.  &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;More detailed tips on configuring and troubleshooting can be found [http://netbeans.org/community/releases/69/cpp-setup-instructions.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A decent tutorial on setting up and configuring C/C++ projects within NetBeans can be found [http://netbeans.org/kb/docs/cnd/quickstart.html here].&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
= Test Programs =&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_1.JPG|400px|thumb|Step 2 configuration.|right]]&lt;br /&gt;
[[Image:NetBeansSampleProjectConfiguration_2.JPG|400px|thumb|Screenshot of step 3 configuration.|right]]&lt;br /&gt;
In this section, we are going to create a very simple project in NetBeans, and &lt;br /&gt;
then compile it and analyze the output using a few different techniques.&lt;br /&gt;
&lt;br /&gt;
#First open NetBeans, and click File&amp;gt;New Project&lt;br /&gt;
#Select C/C++ Application &lt;br /&gt;
#Configure project as shown.  Be sure &amp;quot;Create Main File&amp;quot; and &amp;quot;Set as Main Project&amp;quot; checkboxes are selected, and that the language of choice is C (not C++).  Also be sure your compiler is selected under &amp;quot;Tool Collection.&amp;quot;&lt;br /&gt;
#Locate the &amp;quot;Projects&amp;quot; window.  If it is not already visible, you can select it under the Window menu at the top of the screen.&lt;br /&gt;
#Clicking the plus next to &amp;quot;Source Files&amp;quot; in the project window should reveal a file called &amp;quot;main.c&amp;quot;.  This is basically a blank C source code template that you can work from. Open this file by double clicking on it.&lt;br /&gt;
#Edit the &amp;quot;main&amp;quot; function so that it looks like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
      int main(int argc, char** argv) {&lt;br /&gt;
        printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        return (EXIT_SUCCESS);&lt;br /&gt;
      }&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Your project is now created, and we will look at a couple of different ways to compile and run it.&lt;br /&gt;
&lt;br /&gt;
=== Using the IDE to compile ===&lt;br /&gt;
To compile the code you can click &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.  Note the text that &lt;br /&gt;
is printed in the &amp;quot;Output&amp;quot; window.  If no errors are printed and you see &lt;br /&gt;
something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; BUILD SUCCESSFUL (total time: 2s) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then everything worked and you are ready to run the code.  Clicking the green &lt;br /&gt;
triangle button, or &amp;quot;Run&amp;gt;Run Main Project&amp;quot; will actually run the code.  You &lt;br /&gt;
should see something like  &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; Hello World! &amp;lt;/font&amp;gt; &lt;br /&gt;
     &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; RUN SUCCESSFUL (total time: 144ms) &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
printed in the &amp;quot;Output&amp;quot; window.  If all of this worked, you have just written, &lt;br /&gt;
compiled, and ran a test C program.&lt;br /&gt;
&lt;br /&gt;
Note that there are several output files that are created by this compilation &lt;br /&gt;
process.  In your project directory there are two subdirectories called &amp;quot;build/&amp;quot; &lt;br /&gt;
and &amp;quot;dist/&amp;quot;.  Inside of the &amp;quot;build/&amp;quot; directory are the so-called object files &lt;br /&gt;
generated by the compiler.  These are essentially just machine code versions of &lt;br /&gt;
the raw source code that you wrote.  Inside of the &amp;quot;dist/&amp;quot; directory, you will &lt;br /&gt;
find an executable file that is actually capable of running on your system.&lt;br /&gt;
For example, on a Windows machine that followed all previous instructions, you&lt;br /&gt;
will find the following file &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt; &amp;lt;PROJECT_DIRECTORY&amp;gt;\dist\Debug\MinGW-Windows\helloworld.exe &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This executable can be run just like any other executable on your system.  Note &lt;br /&gt;
that in OSx or Linux there will not be a &amp;quot;.exe&amp;quot; extension on your executable.  &lt;br /&gt;
The compiler name found in the above directory may vary as well.&lt;br /&gt;
&lt;br /&gt;
=== Command Line Usage ===&lt;br /&gt;
To further analyze what just happened we are going to do a couple of things from&lt;br /&gt;
the command line.  In your OS, open a command line.  In OSx this is called &lt;br /&gt;
&amp;quot;Terminal&amp;quot; and in Windows this is called cmd (Click &amp;quot;Start&amp;gt;Run&amp;quot; then type cmd &lt;br /&gt;
and hit enter).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by simply executing the file generated by the previous compilation.&lt;br /&gt;
So we are going to navigate to the aforementioned executable &lt;br /&gt;
output directory of the project.  Note that the command &amp;quot;cd&amp;quot; will allow you to &lt;br /&gt;
change directories.  So for example on Windows you might type something like &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd C:\Users\&amp;lt;USERNAME&amp;gt;\Documents\NetBeansProjects\HelloWorld\dist\Debug\MinGW-Windows &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx or Linux I might type something like&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd /home/&amp;lt;USERNAME&amp;gt;/NetBeansProjects/dist/Debug/GNU-Linux-x86/ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where you must replace &amp;lt;USERNAME&amp;gt; with your username.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typing &amp;quot;ls&amp;quot; in the command line will then print the contents of the current &lt;br /&gt;
directory.  Note that in Windows, &amp;quot;ls&amp;quot; is not part of the normal command line &lt;br /&gt;
interface, but earlier when we installed MSYS, we enabled this.  If for some &lt;br /&gt;
reason &amp;quot;ls&amp;quot; does not work to print the directory contents, try typing &amp;quot;dir&amp;quot;.&lt;br /&gt;
Printing the contents of the output directory should reveal just one executable &lt;br /&gt;
file, &amp;quot;helloworld.exe&amp;quot; (Windows) or simply &amp;quot;helloworld&amp;quot; (Linux/OSx).  Let&amp;#039;s run &lt;br /&gt;
that executable now so we can see its output.  On Windows simply type &lt;br /&gt;
&amp;quot;helloworld.exe&amp;quot; (no quotes) into the command line and press enter; in OSx, &lt;br /&gt;
type &amp;quot;./helloworld&amp;quot;.  You should see &amp;quot;Hello World!&amp;quot; echoed back to you.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s attempt to compile this file by invoking the compiler manually.  We &lt;br /&gt;
want to navigate to the base project directory.  On any OS that can be &lt;br /&gt;
accomplished by typing &lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; cd ../../../ &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that here the &amp;quot;..&amp;quot; implies the parent directory of the current directory.  Now we are ready&lt;br /&gt;
to compile the file using GCC.  On Windows we can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc.exe -o helloworld.exe main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or on OSx you can type&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;font size=3&amp;gt; gcc -o helloworld main.c &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a new executable file in the current directory called &lt;br /&gt;
&amp;quot;helloworld(.exe)&amp;quot;.  This can be executed as we just did above.  Note that the &lt;br /&gt;
&amp;quot;-o&amp;quot; in the above commands is an option telling the compiler where to generate &lt;br /&gt;
the output. There hundreds of different options that can be passed to the compiler and many &lt;br /&gt;
different configurations for how projects are compiled.  It can be quite &lt;br /&gt;
confusing! This is one of the things that the IDE does for you.  It sets all of &lt;br /&gt;
these options either automatically or through graphical interfaces.&lt;br /&gt;
&lt;br /&gt;
=== Makefiles === &lt;br /&gt;
Note that in the project base directory there is a file called &amp;quot;Makefile.&amp;quot;  &lt;br /&gt;
This file combined with several other &amp;quot;Makefiles&amp;quot; in the nbproject directory is &lt;br /&gt;
where all of these options are stored.  One of the programs that was &lt;br /&gt;
installed earlier when we setup a compiler is called &amp;quot;make&amp;quot;.  Its job is to read &lt;br /&gt;
the configurations stored in &amp;quot;Makefiles&amp;quot; and call the compiler accordingly.  &lt;br /&gt;
&lt;br /&gt;
On complicated projects, compiling can take a very long time.  One of the main&lt;br /&gt;
features of &amp;quot;make&amp;quot; is that before it compiles anything, it looks at what files &lt;br /&gt;
have changed since compilation last occurred.  It then compiles only the files &lt;br /&gt;
that must be recompiled to reflect changes.  This can significantly increase &lt;br /&gt;
compilation speed.  &amp;quot;Make&amp;quot; is what NetBeans is actually calling when you are &lt;br /&gt;
clicking &amp;quot;Build&amp;quot; or &amp;quot;Clean and Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can invoke it from the project base directory by simply typing the word &lt;br /&gt;
&amp;quot;make&amp;quot; in the command line.  The printed output should be the same thing that &lt;br /&gt;
you would see if you opened NetBeans and clicked &amp;quot;Run&amp;gt;Build Main Project&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Other Sample Code ==&lt;br /&gt;
We have provided several other sample pieces of code to facilitate learning &lt;br /&gt;
the C-language.  The first you should look at can be found [[media:starter.c|here]], and a &lt;br /&gt;
slightly more complicated piece of code can be found [[media:Invest.c| here]].  &lt;br /&gt;
Each of these can be compiled by creating a new NetBeans project as described above except &lt;br /&gt;
this time you will want to uncheck &amp;quot;Create Main File.&amp;quot;  To add one of the downloaded example codes &lt;br /&gt;
to your project simply alternate click (right click Windows, Ctrl+click OSx) where it says &lt;br /&gt;
&amp;quot;Source Files&amp;quot; in the &amp;quot;Projects&amp;quot; window and select &amp;quot;Add Existing Item...&amp;quot;.  Once the file is added to&lt;br /&gt;
your project you should be able to build and run it using the instructions from above.&lt;br /&gt;
&lt;br /&gt;
= Conclusions =&lt;/div&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
</feed>