<?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=AlexAnsari</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=AlexAnsari"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php/Special:Contributions/AlexAnsari"/>
	<updated>2026-04-22T11:03:48Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.9</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME333_Unofficial_Sample_Code&amp;diff=22099</id>
		<title>ME333 Unofficial Sample Code</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME333_Unofficial_Sample_Code&amp;diff=22099"/>
		<updated>2013-02-25T06:35:20Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: /* Extra PIC32 Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;DO NOT USE SAMPLE CODE ON THIS PAGE!  IT IS STILL IN TESTING MODE.  USE [[ME333_Sample_Code|THIS PAGE]] INSTEAD.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Code for ME333 instructors to test before it goes live.&lt;br /&gt;
&lt;br /&gt;
Code with &amp;#039;&amp;#039;&amp;#039;TESTED&amp;#039;&amp;#039;&amp;#039; has been tested and is ready to go live.&lt;br /&gt;
&lt;br /&gt;
Code with &amp;#039;&amp;#039;&amp;#039;EDITS&amp;#039;&amp;#039;&amp;#039; has been updated but not fully test.&lt;br /&gt;
&lt;br /&gt;
Code without any marking has not been looked at yet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== PIC32 Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Bootloader Project&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/30/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32_bootloader.zip|NU32_bootloader.zip]]: (Updated 1/30 to make it jump to the noncacheable virtual address, not cacheable, just for conceptual clarity.) All files in one folder.  Kevin&amp;#039;s version building on Nick&amp;#039;s.  Jumps to application at new jump location that doesn&amp;#039;t waste flash.  Also sets config bits for Shadow Register Set.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32_old_bootloader.zip|Nick&amp;#039;s bootloader app as of Jan 20, that doesn&amp;#039;t compile]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Simple PIC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 1/16/2013&amp;#039;&amp;#039;&amp;#039; [[Media:simplePIC.c|simplePIC.c]]: Flashes LEDs on the NU32 unless the USER button is pressed.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 1/16/2013&amp;#039;&amp;#039;&amp;#039; [[Media:simplePIC_standalone.c|simplePIC_standalone.c]]:  Standalone version of simplePIC.c.&lt;br /&gt;
&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;
* &amp;#039;&amp;#039;&amp;#039;1/17/2013&amp;#039;&amp;#039;&amp;#039; [[Media:talkingPIC.c|talkingPIC.c]]:  echoes strings sent from keyboard back to computer screen&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/21/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32bootloaded.ld|NU32bootloaded.ld]]:  Use this linker script when creating executables to be bootloaded on NU32 (not app.ld).  Kevin&amp;#039;s version which puts the program starting at 0x9D000000, allowing access to full amount of flash.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32.c|NU32.c]]: NU32 board library.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/28/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32.h|NU32.h]]: NU32 header file, updated to have config bits for Shadow Register Set and to include &amp;lt;plib.h&amp;gt;.&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;LCD code (to be moved into NU32.c)&amp;#039;&amp;#039;&amp;#039;&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;Serial Sample code for Invest.c&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_serial_for_invest.c|NU32_serial_for_invest.c]]:  An example of serial communication, useful for converting invest.c to the PIC32.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Communication Examples&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Serial to a terminal&lt;br /&gt;
* Serial to MATLAB&lt;br /&gt;
* Serial to Processing&lt;br /&gt;
* Output 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;
* [[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;Counter/timer&amp;#039;&amp;#039;&amp;#039;&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;Interrupts&amp;#039;&amp;#039;&amp;#039;&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;
* Peripheral timer interrupt.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Output compare (PWM)&amp;#039;&amp;#039;&amp;#039;&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;Analog to digital&amp;#039;&amp;#039;&amp;#039; &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;
* Something else, scanning mode, asynchronous results check on the buffer, and/or interrupt generated when some results are ready.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using the UART&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/6/2013&amp;#039;&amp;#039;&amp;#039; [[Media:Uart_loop.c|Uart_loop.c]]: Simple RS232 communication:  one UART to another on the same PIC&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:Uart_pic2pic.c|Uart_pic2pic.c]]: Simple RS232 communication:  PIC to PIC&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:Uart_hfc.c|Uart_hfc.c]]: RS232 with hardware flow control&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/10/2013&amp;#039;&amp;#039;&amp;#039; [[Media:Uart_ftdi.c|Uart_ftdi.c]]: Talking to a PC with an FTDI cable&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using I2C&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32_I2C.c|NU32_I2C.c]], [[Media:NU32_I2C.h|NU32_I2C.h]]: Library files.&lt;br /&gt;
* I2C1 to I2C2 on one PIC&lt;br /&gt;
* PIC to PIC&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:I2C_DAC.c|I2C_DAC.c]]: MAX518 8bit I2C DAC&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:I2C_ADC.c|I2C_ADC.c]]: NAU7802 24bit I2C ADC&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:I2C_RAM.c|I2C_RAM.c]]: PCF8570 2kbit I2C SRAM&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using SPI&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:SPILoopback.c|SPILoopback.c]]: SPI4 to SPI1 on one PIC&lt;br /&gt;
* PIC to PIC&lt;br /&gt;
* MCP4922 12bit SPI DAC&lt;br /&gt;
* MCP3008 10bit SPI ADC&lt;br /&gt;
* Microchip 23k256 256kbit SPI SRAM&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Comparator&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:Comparator.c‎|Comparator.c‎]]: Toggle an LED based on the relative state of two pins&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:ComparatorOutput.c‎|ComparatorOutput.c‎]]: Output analogue ref voltage based on the difference between source pins&lt;br /&gt;
* turn a light on or off based on potentiometer reading&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Input Capture&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:Input_capture.c|Input_capture.c]]: Create a PWM signal (duty cycle controlled by a potentiometer) and read in to an input capture, display the pulse width or duty cycle&lt;br /&gt;
&lt;br /&gt;
== Applications ==&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;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Reading a quadrature encoder with the dsPIC33FJ12MC201 breakout board&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_dsPIC_QEI_example.c | NU32_dsPIC_QEI_example.c]]: Read the encoder count at 250Hz, send to the computer at 5Hz&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Controlling a stepper motor with the TB6612&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_stepper_example.c | NU32_stepper_example.c]]: Use the TB6612 to step the motor at 25 Hz steps (1 rev in 16s)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Controlling an RC servo motor&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_rcservo_pwm_example.c|NU32_rcservo_pwm_example.c]]: Use a PWM pin to set the position of the servo (note you only have 5 PWM pins)&lt;br /&gt;
* [[Media:NU32_rcservo_digio_example.c|NU32_rcservo_digio_example.c]]: Use any digital IO pin and a timer to set the position of the servo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extra PIC32 Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;USB&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/17/2013&amp;#039;&amp;#039;&amp;#039; [[Media:USBHost-MassStorage.zip|USBHost-MassStorage.zip]]: Writes the voltage on an analog pin to a ADC.csv file on an external USB stick approx. 5 times per second.  Writing starts when the USB is inserted and stops when the USER button is pressed.  Remember to press the USER button to stop writing data before removing the USB stick.  View the README.txt file to build&lt;br /&gt;
* HID to Processing on a PC&lt;br /&gt;
* CDC to PC&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Watchdog Timer&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:WatchdogTimer.c|WatchdogTimer.c]]: User button turns on LED the LED turns off again when PIC restarts due to watchdog timer&lt;br /&gt;
* Press a button every so often or watch the PIC reset itself (and perhaps a light stays off until you manually reset it or something)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using the RTCC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Keeping time:  set time from a PC, display current time on same PC&lt;br /&gt;
* alarm clock demo?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Programming the onboard flash&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Flash self programming: displays saved data at power on, allows user to enter new data (button presses, whatever), displays the new data, and when you power cycle, PIC displays the most recent data on startup &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Sleep, Idle, Freeze&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* config bits?&lt;br /&gt;
* demonstrate little current usage in sleep mode; wake up at predefined intervals or on certain signals and do something (and see the spike in current usage?)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using CAN&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Three PICs establishing a CAN bus:  each PIC has a button and the state of the LEDs on each NU32 changes depending on which buttons are pressed (confirm communication between PICs)&lt;br /&gt;
* PC to PIC (Peak card?)&lt;br /&gt;
* some CAN chip?  sensor?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DIP PIC32 with reconfigurable pins (1/2xx)&amp;#039;&amp;#039;&amp;#039; (11/21)&lt;br /&gt;
&lt;br /&gt;
* Reconfiguring the pins.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Data logging on a uSD card&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Using the Microchip FAT32 library, AN1045&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:USBHost-MassStorage.zip&amp;diff=22098</id>
		<title>File:USBHost-MassStorage.zip</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:USBHost-MassStorage.zip&amp;diff=22098"/>
		<updated>2013-02-25T06:28:37Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME333_Unofficial_Sample_Code&amp;diff=22032</id>
		<title>ME333 Unofficial Sample Code</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME333_Unofficial_Sample_Code&amp;diff=22032"/>
		<updated>2013-02-07T23:41:34Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: /* PIC32 Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;DO NOT USE SAMPLE CODE ON THIS PAGE!  IT IS STILL IN TESTING MODE.  USE [[ME333_Sample_Code|THIS PAGE]] INSTEAD.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Code for ME333 instructors to test before it goes live.&lt;br /&gt;
&lt;br /&gt;
Code with &amp;#039;&amp;#039;&amp;#039;TESTED&amp;#039;&amp;#039;&amp;#039; has been tested and is ready to go live.&lt;br /&gt;
&lt;br /&gt;
Code with &amp;#039;&amp;#039;&amp;#039;EDITS&amp;#039;&amp;#039;&amp;#039; has been updated but not fully test.&lt;br /&gt;
&lt;br /&gt;
Code without any marking has not been looked at yet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== PIC32 Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Bootloader Project&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/30/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32_bootloader.zip|NU32_bootloader.zip]]: (Updated 1/30 to make it jump to the noncacheable virtual address, not cacheable, just for conceptual clarity.) All files in one folder.  Kevin&amp;#039;s version building on Nick&amp;#039;s.  Jumps to application at new jump location that doesn&amp;#039;t waste flash.  Also sets config bits for Shadow Register Set.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32_old_bootloader.zip|Nick&amp;#039;s bootloader app as of Jan 20, that doesn&amp;#039;t compile]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Simple PIC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 1/16/2013&amp;#039;&amp;#039;&amp;#039; [[Media:simplePIC.c|simplePIC.c]]: Flashes LEDs on the NU32 unless the USER button is pressed.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 1/16/2013&amp;#039;&amp;#039;&amp;#039; [[Media:simplePIC_standalone.c|simplePIC_standalone.c]]:  Standalone version of simplePIC.c.&lt;br /&gt;
&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;
* &amp;#039;&amp;#039;&amp;#039;1/17/2013&amp;#039;&amp;#039;&amp;#039; [[Media:talkingPIC.c|talkingPIC.c]]:  echoes strings sent from keyboard back to computer screen&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/21/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32bootloaded.ld|NU32bootloaded.ld]]:  Use this linker script when creating executables to be bootloaded on NU32 (not app.ld).  Kevin&amp;#039;s version which puts the program starting at 0x9D000000, allowing access to full amount of flash.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32.c|NU32.c]]: NU32 board library.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/28/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32.h|NU32.h]]: NU32 header file, updated to have config bits for Shadow Register Set and to include &amp;lt;plib.h&amp;gt;.&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;LCD code (to be moved into NU32.c)&amp;#039;&amp;#039;&amp;#039;&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;Serial Sample code for Invest.c&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_serial_for_invest.c|NU32_serial_for_invest.c]]:  An example of serial communication, useful for converting invest.c to the PIC32.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Communication Examples&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Serial to a terminal&lt;br /&gt;
* Serial to MATLAB&lt;br /&gt;
* Serial to Processing&lt;br /&gt;
* Output 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;
* [[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;Counter/timer&amp;#039;&amp;#039;&amp;#039;&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;Interrupts&amp;#039;&amp;#039;&amp;#039;&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;
* Peripheral timer interrupt.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Output compare (PWM)&amp;#039;&amp;#039;&amp;#039;&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;Analog to digital&amp;#039;&amp;#039;&amp;#039; &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;
* Something else, scanning mode, asynchronous results check on the buffer, and/or interrupt generated when some results are ready.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using the UART&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* Simple RS232 communication:  one UART to another on the same PIC&lt;br /&gt;
* [[Media:Uart_pic2pic.c|Uart_pic2pic.c]]: Simple RS232 communication:  PIC to PIC&lt;br /&gt;
* [[Media:Uart_hfc.c|Uart_hfc.c]]: RS232 with hardware flow control&lt;br /&gt;
* Talking to a PC with an FTDI cable&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using I2C&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* I2C1 to I2C2 on one PIC&lt;br /&gt;
* PIC to PIC&lt;br /&gt;
* MAX518 8bit I2C DAC&lt;br /&gt;
* NAU7802 24bit I2C ADC&lt;br /&gt;
* PCF8570 2kbit I2C SRAM&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using SPI&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:SPILoopback.c|SPILoopback.c]]: SPI4 to SPI1 on one PIC&lt;br /&gt;
* PIC to PIC&lt;br /&gt;
* MCP4922 12bit SPI DAC&lt;br /&gt;
* MCP3008 10bit SPI ADC&lt;br /&gt;
* Microchip 23k256 256kbit SPI SRAM&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Comparator&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:Comparator.c‎|Comparator.c‎]]: Toggle an LED based on the relative state of two pins&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:ComparatorOutput.c‎|ComparatorOutput.c‎]]: Output analogue ref voltage based on the difference between source pins&lt;br /&gt;
* turn a light on or off based on potentiometer reading&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Input Capture&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:Input_capture.c|Input_capture.c]]: Create a PWM signal (duty cycle controlled by a potentiometer) and read in to an input capture, display the pulse width or duty cycle&lt;br /&gt;
&lt;br /&gt;
== Applications ==&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;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Reading a quadrature encoder with the dsPIC33FJ12MC201 breakout board&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_dsPIC_QEI_example.c | NU32_dsPIC_QEI_example.c]]: Read the encoder count at 250Hz, send to the computer at 5Hz&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Controlling a stepper motor with the TB6612&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_stepper_example.c | NU32_stepper_example.c]]: Use the TB6612 to step the motor at 25 Hz steps (1 rev in 16s)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Controlling an RC servo motor&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_rcservo_pwm_example.c|NU32_rcservo_pwm_example.c]]: Use a PWM pin to set the position of the servo (note you only have 5 PWM pins)&lt;br /&gt;
* [[Media:NU32_rcservo_digio_example.c|NU32_rcservo_digio_example.c]]: Use any digital IO pin and a timer to set the position of the servo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extra PIC32 Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;USB&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* HID to Processing on a PC&lt;br /&gt;
* CDC to PC&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Watchdog Timer&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:WatchdogTimer.c|WatchdogTimer.c]]: User button turns on LED the LED turns off again when PIC restarts due to watchdog timer&lt;br /&gt;
* Press a button every so often or watch the PIC reset itself (and perhaps a light stays off until you manually reset it or something)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using the RTCC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Keeping time:  set time from a PC, display current time on same PC&lt;br /&gt;
* alarm clock demo?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Programming the onboard flash&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Flash self programming: displays saved data at power on, allows user to enter new data (button presses, whatever), displays the new data, and when you power cycle, PIC displays the most recent data on startup &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Sleep, Idle, Freeze&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* config bits?&lt;br /&gt;
* demonstrate little current usage in sleep mode; wake up at predefined intervals or on certain signals and do something (and see the spike in current usage?)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using CAN&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Three PICs establishing a CAN bus:  each PIC has a button and the state of the LEDs on each NU32 changes depending on which buttons are pressed (confirm communication between PICs)&lt;br /&gt;
* PC to PIC (Peak card?)&lt;br /&gt;
* some CAN chip?  sensor?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DIP PIC32 with reconfigurable pins (1/2xx)&amp;#039;&amp;#039;&amp;#039; (11/21)&lt;br /&gt;
&lt;br /&gt;
* Reconfiguring the pins.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Data logging on a uSD card&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Using the Microchip FAT32 library, AN1045&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Input_capture.c&amp;diff=22031</id>
		<title>File:Input capture.c</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Input_capture.c&amp;diff=22031"/>
		<updated>2013-02-07T23:39:37Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME333_Unofficial_Sample_Code&amp;diff=22030</id>
		<title>ME333 Unofficial Sample Code</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME333_Unofficial_Sample_Code&amp;diff=22030"/>
		<updated>2013-02-07T21:59:02Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: /* PIC32 Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;DO NOT USE SAMPLE CODE ON THIS PAGE!  IT IS STILL IN TESTING MODE.  USE [[ME333_Sample_Code|THIS PAGE]] INSTEAD.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Code for ME333 instructors to test before it goes live.&lt;br /&gt;
&lt;br /&gt;
Code with &amp;#039;&amp;#039;&amp;#039;TESTED&amp;#039;&amp;#039;&amp;#039; has been tested and is ready to go live.&lt;br /&gt;
&lt;br /&gt;
Code with &amp;#039;&amp;#039;&amp;#039;EDITS&amp;#039;&amp;#039;&amp;#039; has been updated but not fully test.&lt;br /&gt;
&lt;br /&gt;
Code without any marking has not been looked at yet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== PIC32 Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Bootloader Project&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/30/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32_bootloader.zip|NU32_bootloader.zip]]: (Updated 1/30 to make it jump to the noncacheable virtual address, not cacheable, just for conceptual clarity.) All files in one folder.  Kevin&amp;#039;s version building on Nick&amp;#039;s.  Jumps to application at new jump location that doesn&amp;#039;t waste flash.  Also sets config bits for Shadow Register Set.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32_old_bootloader.zip|Nick&amp;#039;s bootloader app as of Jan 20, that doesn&amp;#039;t compile]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Simple PIC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 1/16/2013&amp;#039;&amp;#039;&amp;#039; [[Media:simplePIC.c|simplePIC.c]]: Flashes LEDs on the NU32 unless the USER button is pressed.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 1/16/2013&amp;#039;&amp;#039;&amp;#039; [[Media:simplePIC_standalone.c|simplePIC_standalone.c]]:  Standalone version of simplePIC.c.&lt;br /&gt;
&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;
* &amp;#039;&amp;#039;&amp;#039;1/17/2013&amp;#039;&amp;#039;&amp;#039; [[Media:talkingPIC.c|talkingPIC.c]]:  echoes strings sent from keyboard back to computer screen&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/21/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32bootloaded.ld|NU32bootloaded.ld]]:  Use this linker script when creating executables to be bootloaded on NU32 (not app.ld).  Kevin&amp;#039;s version which puts the program starting at 0x9D000000, allowing access to full amount of flash.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32.c|NU32.c]]: NU32 board library.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/28/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32.h|NU32.h]]: NU32 header file, updated to have config bits for Shadow Register Set and to include &amp;lt;plib.h&amp;gt;.&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;LCD code (to be moved into NU32.c)&amp;#039;&amp;#039;&amp;#039;&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;Serial Sample code for Invest.c&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_serial_for_invest.c|NU32_serial_for_invest.c]]:  An example of serial communication, useful for converting invest.c to the PIC32.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Communication Examples&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Serial to a terminal&lt;br /&gt;
* Serial to MATLAB&lt;br /&gt;
* Serial to Processing&lt;br /&gt;
* Output 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;
* [[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;Counter/timer&amp;#039;&amp;#039;&amp;#039;&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;Interrupts&amp;#039;&amp;#039;&amp;#039;&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;
* Peripheral timer interrupt.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Output compare (PWM)&amp;#039;&amp;#039;&amp;#039;&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;Analog to digital&amp;#039;&amp;#039;&amp;#039; &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;
* Something else, scanning mode, asynchronous results check on the buffer, and/or interrupt generated when some results are ready.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using the UART&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* Simple RS232 communication:  one UART to another on the same PIC&lt;br /&gt;
* [[Media:Uart_pic2pic.c|Uart_pic2pic.c]]: Simple RS232 communication:  PIC to PIC&lt;br /&gt;
* [[Media:Uart_hfc.c|Uart_hfc.c]]: RS232 with hardware flow control&lt;br /&gt;
* Talking to a PC with an FTDI cable&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using I2C&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* I2C1 to I2C2 on one PIC&lt;br /&gt;
* PIC to PIC&lt;br /&gt;
* MAX518 8bit I2C DAC&lt;br /&gt;
* NAU7802 24bit I2C ADC&lt;br /&gt;
* PCF8570 2kbit I2C SRAM&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using SPI&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:SPILoopback.c|SPILoopback.c]]: SPI4 to SPI1 on one PIC&lt;br /&gt;
* PIC to PIC&lt;br /&gt;
* MCP4922 12bit SPI DAC&lt;br /&gt;
* MCP3008 10bit SPI ADC&lt;br /&gt;
* Microchip 23k256 256kbit SPI SRAM&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Comparator&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:Comparator.c‎|Comparator.c‎]]: Toggle an LED based on the relative state of two pins&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:ComparatorOutput.c‎|ComparatorOutput.c‎]]: Output analogue ref voltage based on the difference between source pins&lt;br /&gt;
* turn a light on or off based on potentiometer reading&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Input Capture&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* create a PWM signal (duty cycle controlled by a potentiometer) and read in to an input capture, display the pulse width or duty cycle&lt;br /&gt;
&lt;br /&gt;
== Applications ==&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;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Reading a quadrature encoder with the dsPIC33FJ12MC201 breakout board&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_dsPIC_QEI_example.c | NU32_dsPIC_QEI_example.c]]: Read the encoder count at 250Hz, send to the computer at 5Hz&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Controlling a stepper motor with the TB6612&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_stepper_example.c | NU32_stepper_example.c]]: Use the TB6612 to step the motor at 25 Hz steps (1 rev in 16s)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Controlling an RC servo motor&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_rcservo_pwm_example.c|NU32_rcservo_pwm_example.c]]: Use a PWM pin to set the position of the servo (note you only have 5 PWM pins)&lt;br /&gt;
* [[Media:NU32_rcservo_digio_example.c|NU32_rcservo_digio_example.c]]: Use any digital IO pin and a timer to set the position of the servo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extra PIC32 Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;USB&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* HID to Processing on a PC&lt;br /&gt;
* CDC to PC&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Watchdog Timer&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:WatchdogTimer.c|WatchdogTimer.c]]: User button turns on LED the LED turns off again when PIC restarts due to watchdog timer&lt;br /&gt;
* Press a button every so often or watch the PIC reset itself (and perhaps a light stays off until you manually reset it or something)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using the RTCC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Keeping time:  set time from a PC, display current time on same PC&lt;br /&gt;
* alarm clock demo?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Programming the onboard flash&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Flash self programming: displays saved data at power on, allows user to enter new data (button presses, whatever), displays the new data, and when you power cycle, PIC displays the most recent data on startup &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Sleep, Idle, Freeze&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* config bits?&lt;br /&gt;
* demonstrate little current usage in sleep mode; wake up at predefined intervals or on certain signals and do something (and see the spike in current usage?)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using CAN&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Three PICs establishing a CAN bus:  each PIC has a button and the state of the LEDs on each NU32 changes depending on which buttons are pressed (confirm communication between PICs)&lt;br /&gt;
* PC to PIC (Peak card?)&lt;br /&gt;
* some CAN chip?  sensor?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DIP PIC32 with reconfigurable pins (1/2xx)&amp;#039;&amp;#039;&amp;#039; (11/21)&lt;br /&gt;
&lt;br /&gt;
* Reconfiguring the pins.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Data logging on a uSD card&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Using the Microchip FAT32 library, AN1045&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:ComparatorOutput.c&amp;diff=22029</id>
		<title>File:ComparatorOutput.c</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:ComparatorOutput.c&amp;diff=22029"/>
		<updated>2013-02-07T21:53:58Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Comparator.c&amp;diff=22028</id>
		<title>File:Comparator.c</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Comparator.c&amp;diff=22028"/>
		<updated>2013-02-07T21:53:06Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: uploaded a new version of &amp;amp;quot;File:Comparator.c&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Comparator.c&amp;diff=22027</id>
		<title>File:Comparator.c</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Comparator.c&amp;diff=22027"/>
		<updated>2013-02-07T21:43:42Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME333_Unofficial_Sample_Code&amp;diff=22026</id>
		<title>ME333 Unofficial Sample Code</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME333_Unofficial_Sample_Code&amp;diff=22026"/>
		<updated>2013-02-07T21:41:48Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: /* Extra PIC32 Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;DO NOT USE SAMPLE CODE ON THIS PAGE!  IT IS STILL IN TESTING MODE.  USE [[ME333_Sample_Code|THIS PAGE]] INSTEAD.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Code for ME333 instructors to test before it goes live.&lt;br /&gt;
&lt;br /&gt;
Code with &amp;#039;&amp;#039;&amp;#039;TESTED&amp;#039;&amp;#039;&amp;#039; has been tested and is ready to go live.&lt;br /&gt;
&lt;br /&gt;
Code with &amp;#039;&amp;#039;&amp;#039;EDITS&amp;#039;&amp;#039;&amp;#039; has been updated but not fully test.&lt;br /&gt;
&lt;br /&gt;
Code without any marking has not been looked at yet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== PIC32 Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Bootloader Project&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/30/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32_bootloader.zip|NU32_bootloader.zip]]: (Updated 1/30 to make it jump to the noncacheable virtual address, not cacheable, just for conceptual clarity.) All files in one folder.  Kevin&amp;#039;s version building on Nick&amp;#039;s.  Jumps to application at new jump location that doesn&amp;#039;t waste flash.  Also sets config bits for Shadow Register Set.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32_old_bootloader.zip|Nick&amp;#039;s bootloader app as of Jan 20, that doesn&amp;#039;t compile]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Simple PIC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 1/16/2013&amp;#039;&amp;#039;&amp;#039; [[Media:simplePIC.c|simplePIC.c]]: Flashes LEDs on the NU32 unless the USER button is pressed.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 1/16/2013&amp;#039;&amp;#039;&amp;#039; [[Media:simplePIC_standalone.c|simplePIC_standalone.c]]:  Standalone version of simplePIC.c.&lt;br /&gt;
&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;
* &amp;#039;&amp;#039;&amp;#039;1/17/2013&amp;#039;&amp;#039;&amp;#039; [[Media:talkingPIC.c|talkingPIC.c]]:  echoes strings sent from keyboard back to computer screen&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/21/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32bootloaded.ld|NU32bootloaded.ld]]:  Use this linker script when creating executables to be bootloaded on NU32 (not app.ld).  Kevin&amp;#039;s version which puts the program starting at 0x9D000000, allowing access to full amount of flash.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32.c|NU32.c]]: NU32 board library.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/28/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32.h|NU32.h]]: NU32 header file, updated to have config bits for Shadow Register Set and to include &amp;lt;plib.h&amp;gt;.&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;LCD code (to be moved into NU32.c)&amp;#039;&amp;#039;&amp;#039;&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;Serial Sample code for Invest.c&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_serial_for_invest.c|NU32_serial_for_invest.c]]:  An example of serial communication, useful for converting invest.c to the PIC32.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Communication Examples&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Serial to a terminal&lt;br /&gt;
* Serial to MATLAB&lt;br /&gt;
* Serial to Processing&lt;br /&gt;
* Output 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;
* [[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;Counter/timer&amp;#039;&amp;#039;&amp;#039;&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;Interrupts&amp;#039;&amp;#039;&amp;#039;&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;
* Peripheral timer interrupt.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Output compare (PWM)&amp;#039;&amp;#039;&amp;#039;&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;Analog to digital&amp;#039;&amp;#039;&amp;#039; &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;
* Something else, scanning mode, asynchronous results check on the buffer, and/or interrupt generated when some results are ready.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using the UART&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* Simple RS232 communication:  one UART to another on the same PIC&lt;br /&gt;
* [[Media:Uart_pic2pic.c|Uart_pic2pic.c]]: Simple RS232 communication:  PIC to PIC&lt;br /&gt;
* [[Media:Uart_hfc.c|Uart_hfc.c]]: RS232 with hardware flow control&lt;br /&gt;
* Talking to a PC with an FTDI cable&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using I2C&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* I2C1 to I2C2 on one PIC&lt;br /&gt;
* PIC to PIC&lt;br /&gt;
* MAX518 8bit I2C DAC&lt;br /&gt;
* NAU7802 24bit I2C ADC&lt;br /&gt;
* PCF8570 2kbit I2C SRAM&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using SPI&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:SPILoopback.c|SPILoopback.c]]: SPI4 to SPI1 on one PIC&lt;br /&gt;
* PIC to PIC&lt;br /&gt;
* MCP4922 12bit SPI DAC&lt;br /&gt;
* MCP3008 10bit SPI ADC&lt;br /&gt;
* Microchip 23k256 256kbit SPI SRAM&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Comparator&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* turn a light on or off based on potentiometer reading&lt;br /&gt;
* 16-value analog output?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Input Capture&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* create a PWM signal (duty cycle controlled by a potentiometer) and read in to an input capture, display the pulse width or duty cycle&lt;br /&gt;
&lt;br /&gt;
== Applications ==&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;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Reading a quadrature encoder with the dsPIC33FJ12MC201 breakout board&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_dsPIC_QEI_example.c | NU32_dsPIC_QEI_example.c]]: Read the encoder count at 250Hz, send to the computer at 5Hz&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Controlling a stepper motor with the TB6612&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_stepper_example.c | NU32_stepper_example.c]]: Use the TB6612 to step the motor at 25 Hz steps (1 rev in 16s)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Controlling an RC servo motor&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_rcservo_pwm_example.c|NU32_rcservo_pwm_example.c]]: Use a PWM pin to set the position of the servo (note you only have 5 PWM pins)&lt;br /&gt;
* [[Media:NU32_rcservo_digio_example.c|NU32_rcservo_digio_example.c]]: Use any digital IO pin and a timer to set the position of the servo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extra PIC32 Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;USB&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* HID to Processing on a PC&lt;br /&gt;
* CDC to PC&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Watchdog Timer&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:WatchdogTimer.c|WatchdogTimer.c]]: User button turns on LED the LED turns off again when PIC restarts due to watchdog timer&lt;br /&gt;
* Press a button every so often or watch the PIC reset itself (and perhaps a light stays off until you manually reset it or something)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using the RTCC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Keeping time:  set time from a PC, display current time on same PC&lt;br /&gt;
* alarm clock demo?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Programming the onboard flash&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Flash self programming: displays saved data at power on, allows user to enter new data (button presses, whatever), displays the new data, and when you power cycle, PIC displays the most recent data on startup &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Sleep, Idle, Freeze&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* config bits?&lt;br /&gt;
* demonstrate little current usage in sleep mode; wake up at predefined intervals or on certain signals and do something (and see the spike in current usage?)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using CAN&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Three PICs establishing a CAN bus:  each PIC has a button and the state of the LEDs on each NU32 changes depending on which buttons are pressed (confirm communication between PICs)&lt;br /&gt;
* PC to PIC (Peak card?)&lt;br /&gt;
* some CAN chip?  sensor?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DIP PIC32 with reconfigurable pins (1/2xx)&amp;#039;&amp;#039;&amp;#039; (11/21)&lt;br /&gt;
&lt;br /&gt;
* Reconfiguring the pins.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Data logging on a uSD card&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Using the Microchip FAT32 library, AN1045&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:WatchdogTimer.c&amp;diff=22025</id>
		<title>File:WatchdogTimer.c</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:WatchdogTimer.c&amp;diff=22025"/>
		<updated>2013-02-07T21:36:15Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME333_Unofficial_Sample_Code&amp;diff=22024</id>
		<title>ME333 Unofficial Sample Code</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME333_Unofficial_Sample_Code&amp;diff=22024"/>
		<updated>2013-02-07T21:34:14Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: /* PIC32 Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;DO NOT USE SAMPLE CODE ON THIS PAGE!  IT IS STILL IN TESTING MODE.  USE [[ME333_Sample_Code|THIS PAGE]] INSTEAD.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Code for ME333 instructors to test before it goes live.&lt;br /&gt;
&lt;br /&gt;
Code with &amp;#039;&amp;#039;&amp;#039;TESTED&amp;#039;&amp;#039;&amp;#039; has been tested and is ready to go live.&lt;br /&gt;
&lt;br /&gt;
Code with &amp;#039;&amp;#039;&amp;#039;EDITS&amp;#039;&amp;#039;&amp;#039; has been updated but not fully test.&lt;br /&gt;
&lt;br /&gt;
Code without any marking has not been looked at yet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== PIC32 Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Bootloader Project&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/30/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32_bootloader.zip|NU32_bootloader.zip]]: (Updated 1/30 to make it jump to the noncacheable virtual address, not cacheable, just for conceptual clarity.) All files in one folder.  Kevin&amp;#039;s version building on Nick&amp;#039;s.  Jumps to application at new jump location that doesn&amp;#039;t waste flash.  Also sets config bits for Shadow Register Set.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32_old_bootloader.zip|Nick&amp;#039;s bootloader app as of Jan 20, that doesn&amp;#039;t compile]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Simple PIC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 1/16/2013&amp;#039;&amp;#039;&amp;#039; [[Media:simplePIC.c|simplePIC.c]]: Flashes LEDs on the NU32 unless the USER button is pressed.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 1/16/2013&amp;#039;&amp;#039;&amp;#039; [[Media:simplePIC_standalone.c|simplePIC_standalone.c]]:  Standalone version of simplePIC.c.&lt;br /&gt;
&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;
* &amp;#039;&amp;#039;&amp;#039;1/17/2013&amp;#039;&amp;#039;&amp;#039; [[Media:talkingPIC.c|talkingPIC.c]]:  echoes strings sent from keyboard back to computer screen&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/21/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32bootloaded.ld|NU32bootloaded.ld]]:  Use this linker script when creating executables to be bootloaded on NU32 (not app.ld).  Kevin&amp;#039;s version which puts the program starting at 0x9D000000, allowing access to full amount of flash.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/20/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32.c|NU32.c]]: NU32 board library.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;1/28/2013&amp;#039;&amp;#039;&amp;#039; [[Media:NU32.h|NU32.h]]: NU32 header file, updated to have config bits for Shadow Register Set and to include &amp;lt;plib.h&amp;gt;.&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;LCD code (to be moved into NU32.c)&amp;#039;&amp;#039;&amp;#039;&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;Serial Sample code for Invest.c&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_serial_for_invest.c|NU32_serial_for_invest.c]]:  An example of serial communication, useful for converting invest.c to the PIC32.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Communication Examples&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Serial to a terminal&lt;br /&gt;
* Serial to MATLAB&lt;br /&gt;
* Serial to Processing&lt;br /&gt;
* Output 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;
* [[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;Counter/timer&amp;#039;&amp;#039;&amp;#039;&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;Interrupts&amp;#039;&amp;#039;&amp;#039;&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;
* Peripheral timer interrupt.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Output compare (PWM)&amp;#039;&amp;#039;&amp;#039;&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;Analog to digital&amp;#039;&amp;#039;&amp;#039; &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;
* Something else, scanning mode, asynchronous results check on the buffer, and/or interrupt generated when some results are ready.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using the UART&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* Simple RS232 communication:  one UART to another on the same PIC&lt;br /&gt;
* [[Media:Uart_pic2pic.c|Uart_pic2pic.c]]: Simple RS232 communication:  PIC to PIC&lt;br /&gt;
* [[Media:Uart_hfc.c|Uart_hfc.c]]: RS232 with hardware flow control&lt;br /&gt;
* Talking to a PC with an FTDI cable&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using I2C&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* I2C1 to I2C2 on one PIC&lt;br /&gt;
* PIC to PIC&lt;br /&gt;
* MAX518 8bit I2C DAC&lt;br /&gt;
* NAU7802 24bit I2C ADC&lt;br /&gt;
* PCF8570 2kbit I2C SRAM&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using SPI&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;TESTED 2/7/2013&amp;#039;&amp;#039;&amp;#039; [[Media:SPILoopback.c|SPILoopback.c]]: SPI4 to SPI1 on one PIC&lt;br /&gt;
* PIC to PIC&lt;br /&gt;
* MCP4922 12bit SPI DAC&lt;br /&gt;
* MCP3008 10bit SPI ADC&lt;br /&gt;
* Microchip 23k256 256kbit SPI SRAM&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Comparator&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
* turn a light on or off based on potentiometer reading&lt;br /&gt;
* 16-value analog output?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Input Capture&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* create a PWM signal (duty cycle controlled by a potentiometer) and read in to an input capture, display the pulse width or duty cycle&lt;br /&gt;
&lt;br /&gt;
== Applications ==&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;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Reading a quadrature encoder with the dsPIC33FJ12MC201 breakout board&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_dsPIC_QEI_example.c | NU32_dsPIC_QEI_example.c]]: Read the encoder count at 250Hz, send to the computer at 5Hz&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Controlling a stepper motor with the TB6612&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_stepper_example.c | NU32_stepper_example.c]]: Use the TB6612 to step the motor at 25 Hz steps (1 rev in 16s)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Controlling an RC servo motor&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* [[Media:NU32_rcservo_pwm_example.c|NU32_rcservo_pwm_example.c]]: Use a PWM pin to set the position of the servo (note you only have 5 PWM pins)&lt;br /&gt;
* [[Media:NU32_rcservo_digio_example.c|NU32_rcservo_digio_example.c]]: Use any digital IO pin and a timer to set the position of the servo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extra PIC32 Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;USB&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* HID to Processing on a PC&lt;br /&gt;
* CDC to PC&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Watchdog Timer&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Press a button every so often or watch the PIC reset itself (and perhaps a light stays off until you manually reset it or something)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using the RTCC&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Keeping time:  set time from a PC, display current time on same PC&lt;br /&gt;
* alarm clock demo?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Programming the onboard flash&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Flash self programming: displays saved data at power on, allows user to enter new data (button presses, whatever), displays the new data, and when you power cycle, PIC displays the most recent data on startup &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Sleep, Idle, Freeze&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* config bits?&lt;br /&gt;
* demonstrate little current usage in sleep mode; wake up at predefined intervals or on certain signals and do something (and see the spike in current usage?)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using CAN&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Three PICs establishing a CAN bus:  each PIC has a button and the state of the LEDs on each NU32 changes depending on which buttons are pressed (confirm communication between PICs)&lt;br /&gt;
* PC to PIC (Peak card?)&lt;br /&gt;
* some CAN chip?  sensor?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DIP PIC32 with reconfigurable pins (1/2xx)&amp;#039;&amp;#039;&amp;#039; (11/21)&lt;br /&gt;
&lt;br /&gt;
* Reconfiguring the pins.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Data logging on a uSD card&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Using the Microchip FAT32 library, AN1045&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:SPILoopback.c&amp;diff=22023</id>
		<title>File:SPILoopback.c</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:SPILoopback.c&amp;diff=22023"/>
		<updated>2013-02-07T21:29:46Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2013)&amp;diff=21956</id>
		<title>ME 333 Introduction to Mechatronics (Archive Winter 2013)</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_Introduction_to_Mechatronics_(Archive_Winter_2013)&amp;diff=21956"/>
		<updated>2013-01-27T20:18:06Z</updated>

		<summary type="html">&lt;p&gt;AlexAnsari: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Winter Quarter 2013&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;First day of class is Tuesday Jan 8&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:  Alex Ansari, AlexanderAnsari2011 at u.northwestern.edu; Jian Shi, JianShi2011 at u.northwestern.edu&lt;br /&gt;
* C Peer Instruction Sessions:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Final demo&amp;#039;&amp;#039;&amp;#039; (in lieu of final exam):  Monday March 18 3-5 PM (12:30-1:50 section) and Wed March 20 9-11 AM (11-12:20 section) in LR5   &lt;br /&gt;
* Office Hours:  &lt;br /&gt;
** Mon-Fri 3-5 PM: Prof. Marchuk, Mechatronics Lab, Ford B100&lt;br /&gt;
** Mon 11:30-1:30 PM:  Alex Ansari, Willens Wing Atrium&lt;br /&gt;
** Tues 2-3 PM:  Prof. Lynch, B290 &lt;br /&gt;
** Wed 12-2 PM:  Jian Shi, NxR Lab, B230&lt;br /&gt;
** Thurs 3-4 PM:  Prof. Lynch, B290&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose of this Course ==&lt;br /&gt;
&lt;br /&gt;
The purpose of this course is to &amp;#039;&amp;#039;&amp;#039;provide tools that help you express your creativity&amp;#039;&amp;#039;&amp;#039;.  Maybe you want to build a robot, or a piece of kinetic art, or an automatic ball-throwing device to entertain your dog; maybe you&amp;#039;ve identified a market for a new smart product and you&amp;#039;d like to prototype the device.  This course provides fundamentals of mechatronics to give you confidence to take on these projects.  You are encouraged to take what you learn in this course and apply it in the project-based ME 433 Advanced Mechatronics course, Design Competition, or independent projects.&lt;br /&gt;
&lt;br /&gt;
== Approximate Syllabus ==&lt;br /&gt;
&lt;br /&gt;
This course is for students that want to build microprocessor-controlled electromechanical devices.  &lt;br /&gt;
&lt;br /&gt;
To do this, 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;
&amp;#039;&amp;#039;&amp;#039;You will do a lot of programming in this course!&amp;#039;&amp;#039;&amp;#039;  If you are certain you hate programming, then this is not the course for you.  But knowing how to program is very useful for any modern engineer.  The language we will use is C, a fairly low-level language that works well for microcontrollers, without being nearly as painful and low-level as assembly language.  If you don&amp;#039;t know C, that&amp;#039;s not a problem, most students don&amp;#039;t before taking ME 333; but you should plan to learn it, and rather quickly.  You will have all the materials you need to start learning C before class starts, and &amp;#039;&amp;#039;&amp;#039;the first assignment on C is due on the first day of class&amp;#039;&amp;#039;&amp;#039;!  The reason:  even though we start out with C, that&amp;#039;s not the main goal of this course.  The main goal is to teach you about microcontrollers and mechatronics.  Plus some students already have C background.&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;
&amp;#039;&amp;#039;&amp;#039;It is essential you do the assigned reading in advance of class.&amp;#039;&amp;#039;&amp;#039;  Classes will begin with you turning in a short problem set related to the reading.  (This includes the very first day of class!)  Once a week we will have a short quiz.  Most classes will be a combination of a brief review, Q&amp;amp;A, and working individually or in small groups on problems while the instructors help answer any questions.&lt;br /&gt;
&lt;br /&gt;
Topics we will cover include:&lt;br /&gt;
&lt;br /&gt;
* introduction to C programming&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;
== Checklist to Complete Before the First Day of Class ==&lt;br /&gt;
&lt;br /&gt;
Attendance at the first day of class (Tuesday Jan 8) is mandatory.  By the first day of class, you should:&lt;br /&gt;
&lt;br /&gt;
* Complete the reading and assignment 1, which is &amp;#039;&amp;#039;&amp;#039;due the first day of class!&amp;#039;&amp;#039;&amp;#039;  In fact, the first two weeks of assignments are already posted, so you are welcome to complete them all over the break and coast through the first two weeks of class.  The first assignments are designed to get you up to speed on the C programming language, which we will use throughout the course.&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;
* Be prepared to buy your class kit, consisting of the portable NUscope oscilloscope, the NU32 PIC32 development board, and lots of other goodies.  Price $125 if you are starting from scratch; $75 if you already have the NUscope.  &lt;br /&gt;
&amp;lt;!-- * 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.--&amp;gt;&lt;br /&gt;
&amp;lt;!-- * 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. --&amp;gt;&lt;br /&gt;
&amp;lt;!--* &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;--&amp;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, and if you understand how the code works.&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. You can find refresher material and a sample quiz at [[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.  Sample code from this appendix can be found [[ME333 Sample Code|here]].&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/TechDoc.aspx?type=ReferenceManuals PIC32 Family Reference Manual, by chapter], and an [[Media:61132B_PIC32ReferenceManual.pdf‎|earlier version]] that conveniently has all chapters in one document.  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.  These chapters include 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 total 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;
&lt;br /&gt;
All homework will be submitted on Blackboard.  All homeworks should be submitted by 11 AM on the day it is due (i.e., before the first section of the day).  Late homeworks will not be accepted.&lt;br /&gt;
&lt;br /&gt;
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 IDE/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.  Text editors with IDEs such as Netbeans and MPLAB X 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, pay attention to any compiler warnings.  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.  &lt;br /&gt;
&amp;lt;!--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.--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Schedule ==&lt;br /&gt;
&lt;br /&gt;
All tutorial C code from &amp;quot;A Crash Course in C,&amp;quot; as well as sample PIC32 code, can be found at this page:  [[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;
&amp;#039;&amp;#039;&amp;#039;Winter Break&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading due for first class&amp;#039;&amp;#039;&amp;#039;:  pages 1-10 of [[Media:CrashCourseinC.pdf|A Crash Course in C]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 due&amp;#039;&amp;#039;&amp;#039;:  problems 1-4, 6-8, 10-11, 14-15 of A Crash Course in C.  Bring your laptop to class and demonstrate your HelloWorld.c program.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 1&amp;#039;&amp;#039;&amp;#039; (T 1/8)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 1 due&amp;#039;&amp;#039;&amp;#039;:  Hand in paper versions of your solutions at the beginning of class.  No blackboard today.  Also, bring your laptop to class to demonstrate HelloWorld.c.&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Class Topic&amp;#039;&amp;#039;&amp;#039;:  Course overview and C programming&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading for next class&amp;#039;&amp;#039;&amp;#039;:  pages 10-15 of A Crash Course in C&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 out&amp;#039;&amp;#039;&amp;#039;:  problems 16-20, 23&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 2&amp;#039;&amp;#039;&amp;#039; (Th 1/10)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 2 due&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Class Topic&amp;#039;&amp;#039;&amp;#039;:  C programming continued&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading for next class&amp;#039;&amp;#039;&amp;#039;:  pages 19-34 of A Crash Course in C (most of this is reference; the real goal is to fully understand the program invest.c)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 out&amp;#039;&amp;#039;&amp;#039;:  problems 24-26, 28-30, 32&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 3&amp;#039;&amp;#039;&amp;#039; (T 1/15)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 3 due&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Class Topic&amp;#039;&amp;#039;&amp;#039;:  C programming continued&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading for next class&amp;#039;&amp;#039;&amp;#039;:  make sure you fully understand invest.c&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 out&amp;#039;&amp;#039;&amp;#039;:  problem 33&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 4&amp;#039;&amp;#039;&amp;#039; (Th 1/17)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 4 due&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Class Topic&amp;#039;&amp;#039;&amp;#039;:  C programming conclusion.  Thanks to Elliot Hevel, C newbie, for this [[Media:GradeSorter.c|C code]] he wrote in class today to solve problem 34 of a Crash Course in C.  (The code seems to work fine, but we haven&amp;#039;t tested exhaustively!  No claims that it is the best or most efficient way to solve the problem, but definitely a nice job in the short time period.  We removed an extraneous &amp;amp; seen in class today.)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading for next class&amp;#039;&amp;#039;&amp;#039;:  make sure you fully understand invest.c and are ready for a quiz on related C topics&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 out&amp;#039;&amp;#039;&amp;#039;:  Purchase your ME 333 equipment [https://it.mccormick.northwestern.edu/matlab/student_license/login.php here].  If you have problems contact your instructor.  Also, download the following (we will use them in Class 5):&lt;br /&gt;
 Download and install:  &lt;br /&gt;
 * the free [http://www.microchip.com/pagehandler/en-us/family/mplabx/#downloads Microchip XC32 compiler] and [http://www.microchip.com/pagehandler/en-us/family/mplabx/ Microchip MPLAB X IDE] for your operating system&lt;br /&gt;
 * the [http://www.ftdichip.com/Drivers/VCP.htm FTDI virtual COM port (VCP) driver] for your operating system&lt;br /&gt;
 * the [http://processing.org/download/ Processing language] for your operating system&lt;br /&gt;
 * a terminal emulator program like [http://freeware.the-meiers.org/ CoolTerm]&lt;br /&gt;
&amp;lt;!-- if you are using Windows, the [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] terminal emulator program --&amp;gt;&lt;br /&gt;
 Also, download the [[Media:PIC32MX5XX6XX7XX_Family_Data_Sheet.pdf|PIC32 Data Sheet]] and the [[Media:61132B_PIC32ReferenceManual.pdf‎|PIC32 Reference Manual]].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 5&amp;#039;&amp;#039;&amp;#039; (T 1/22)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 5 due&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz 1&amp;#039;&amp;#039;&amp;#039;:  [[Media:ME333-2013-q1.pdf|Solutions]] On C programming (data types, pointers) and syntax similar to invest.c.  &amp;#039;&amp;#039;&amp;#039;As with all quizzes, no notes, computers, calculators, etc. are allowed.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Class Topic&amp;#039;&amp;#039;&amp;#039;:  our first programs for the PIC32, following chapter 1 and the [[NU32:_Quickstart|quickstart]]&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading for next class&amp;#039;&amp;#039;&amp;#039;:  [[Media:ME333-Ch1-Ch2.pdf|Chapters 1 and 2]] of the class notes&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 out&amp;#039;&amp;#039;&amp;#039;:  problems 1-7 of Chapter 2&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 6&amp;#039;&amp;#039;&amp;#039; (Th 1/24)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 6 due&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Class Topic&amp;#039;&amp;#039;&amp;#039;:  PIC32 and NU32 hardware&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading for next class&amp;#039;&amp;#039;&amp;#039;:  finish Chapter 2 of the notes&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 out&amp;#039;&amp;#039;&amp;#039;:  problems 8-16 of Chapter 2&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 7&amp;#039;&amp;#039;&amp;#039; (T 1/29)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 7 due&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Class Topic&amp;#039;&amp;#039;&amp;#039;:  PIC32 software&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading for next class&amp;#039;&amp;#039;&amp;#039;:  [[Media:ME333-Ch3.pdf|Chapter 3]] of the notes through Chapter 3.5&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 8 out&amp;#039;&amp;#039;&amp;#039;:  problems 1-6 of Chapter 3&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Class 8&amp;#039;&amp;#039;&amp;#039; (Th 1/31)&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 8 due&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Quiz 2&amp;#039;&amp;#039;&amp;#039;:  PIC32 and NU32 hardware&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Class Topic&amp;#039;&amp;#039;&amp;#039;:  PIC32 software&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Reading for next class&amp;#039;&amp;#039;&amp;#039;:  finish Chapter 3 of the notes&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Assignment 9 out&amp;#039;&amp;#039;&amp;#039;:  problems 7-12 of Chapter 2&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/18, 3-5 PM (12:30-1:50 section) and Wednesday 3/20, 9-11 AM (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 a 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;/div&gt;</summary>
		<author><name>AlexAnsari</name></author>
	</entry>
</feed>