<?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=VladSeghete</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=VladSeghete"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php/Special:Contributions/VladSeghete"/>
	<updated>2026-05-13T15:58:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=SPI_-_Serial_Peripheral_Interface_-_on_the_PIC&amp;diff=9557</id>
		<title>SPI - Serial Peripheral Interface - on the PIC</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=SPI_-_Serial_Peripheral_Interface_-_on_the_PIC&amp;diff=9557"/>
		<updated>2008-12-18T01:21:22Z</updated>

		<summary type="html">&lt;p&gt;VladSeghete: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
SPI or [http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus Serial Peripheral Interface] is a communication method that was once used to connect devices such as printers, cameras, scanners, etc. to a desktop computer. SPI runs as a master slave set-up and can run in full duplex mode, meaning that signals from the master to the slave and vis versa can be transferred at the same time.&lt;br /&gt;
SPI involves four lines, and is therefore often termed the “four wire” serial bus. The four lines are:&lt;br /&gt;
&lt;br /&gt;
SCLK — Serial Clock (output from master)&lt;br /&gt;
&lt;br /&gt;
MOSI/SIMO — Master Output, Slave Input (output from master)&lt;br /&gt;
&lt;br /&gt;
MISO/SOMI — Master Input, Slave Output (output from slave)&lt;br /&gt;
&lt;br /&gt;
SS — Slave Select(active low; output from master)&lt;br /&gt;
&lt;br /&gt;
SPI communication is done in bytes or words - a start signal, after which a given amount of data bits are transmitted serially, followed by a stop signal.&lt;br /&gt;
&lt;br /&gt;
==PIC Controller==&lt;br /&gt;
Using SPI with the PIC and the CCS compiler is quite straightforward. Some versions of the PIC offer hardware support for SPI on reserved pins. However, the compiler also includes software SPI support, which allows the use of any of the communication pins on the PIC. &lt;br /&gt;
&lt;br /&gt;
To set up SPI, all we need to do is include one line in the header of our source file:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
 #use spi(DO = &amp;lt;data out&amp;gt;, DI = &amp;lt;data_in&amp;gt;, CLK = &amp;lt;serial_clock&amp;gt;, ENABLE = &amp;lt;enable_pin&amp;gt;, BITS = &amp;lt;8|16&amp;gt;, etc. )&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This includes code that implements software SPI communication on the pins defined in DO, DI, CLK and ENABLE. The use of the other options is device and application specific and a list of them is provided with the compiler documentation.&lt;br /&gt;
&lt;br /&gt;
To actually send a word, one simply needs to use the spi_xfer() function:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
 spi_xfer(0x1337);&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
which, in our example, will send the hex word 0x1337 to the SPI slave.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
Communication to the [[Waveform_Generation_with_AD9833 | AD9833]] is done through SPI.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus Serial Peripheral Interface Wikipedia Page]&lt;/div&gt;</summary>
		<author><name>VladSeghete</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=SPI_-_Serial_Peripheral_Interface_-_on_the_PIC&amp;diff=9556</id>
		<title>SPI - Serial Peripheral Interface - on the PIC</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=SPI_-_Serial_Peripheral_Interface_-_on_the_PIC&amp;diff=9556"/>
		<updated>2008-12-18T01:20:36Z</updated>

		<summary type="html">&lt;p&gt;VladSeghete: /* PIC Controller */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
SPI or [http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus Serial Peripheral Interface] is a communication method that was once used to connect devices such as printers, cameras, scanners, etc. to a desktop computer. SPI runs as a master slave set-up and can run in full duplex mode, meaning that signals from the master to the slave and vis versa can be transferred at the same time.&lt;br /&gt;
SPI involves four lines, and is therefore often termed the “four wire” serial bus. The four lines are:&lt;br /&gt;
&lt;br /&gt;
SCLK — Serial Clock (output from master)&lt;br /&gt;
&lt;br /&gt;
MOSI/SIMO — Master Output, Slave Input (output from master)&lt;br /&gt;
&lt;br /&gt;
MISO/SOMI — Master Input, Slave Output (output from slave)&lt;br /&gt;
&lt;br /&gt;
SS — Slave Select(active low; output from master)&lt;br /&gt;
&lt;br /&gt;
SPI communication is done in bytes or words - a start signal, after which a given amount of data bits are transmitted serially, followed by a stop signal.&lt;br /&gt;
&lt;br /&gt;
==PIC Controller==&lt;br /&gt;
Using SPI with the PIC and the CCS compiler is quite straightforward. Some versions of the PIC offer hardware support for SPI on reserved pins. However, the compiler also includes software SPI support, which allows the use of any of the communication pins on the PIC. &lt;br /&gt;
&lt;br /&gt;
To set up SPI, all we need to do is include one line in the header of our source file:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
 #use spi(DO = &amp;lt;data out&amp;gt;, DI = &amp;lt;data_in&amp;gt;, CLK = &amp;lt;serial_clock&amp;gt;, ENABLE = &amp;lt;enable_pin&amp;gt;, BITS = &amp;lt;8|16&amp;gt;, etc. )&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This includes code that implements software SPI communication on the pins defined in DO, DI, CLK and ENABLE. The use of the other options is device and application specific and a list of them is provided with the compiler documentation.&lt;br /&gt;
&lt;br /&gt;
To actually send a word, one simply needs to use the spi_xfer() function:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
 spi_xfer(0x1337);&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
which, in our example, will send the hex word 0x1337 to the SPI slave.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
Communication to the [[Waveform_Generation_with_AD9833%2C_and_SPI | AD9833]] is done through SPI.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus Serial Peripheral Interface Wikipedia Page]&lt;/div&gt;</summary>
		<author><name>VladSeghete</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=SPI_-_Serial_Peripheral_Interface_-_on_the_PIC&amp;diff=9555</id>
		<title>SPI - Serial Peripheral Interface - on the PIC</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=SPI_-_Serial_Peripheral_Interface_-_on_the_PIC&amp;diff=9555"/>
		<updated>2008-12-18T01:17:06Z</updated>

		<summary type="html">&lt;p&gt;VladSeghete: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
SPI or [http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus Serial Peripheral Interface] is a communication method that was once used to connect devices such as printers, cameras, scanners, etc. to a desktop computer. SPI runs as a master slave set-up and can run in full duplex mode, meaning that signals from the master to the slave and vis versa can be transferred at the same time.&lt;br /&gt;
SPI involves four lines, and is therefore often termed the “four wire” serial bus. The four lines are:&lt;br /&gt;
&lt;br /&gt;
SCLK — Serial Clock (output from master)&lt;br /&gt;
&lt;br /&gt;
MOSI/SIMO — Master Output, Slave Input (output from master)&lt;br /&gt;
&lt;br /&gt;
MISO/SOMI — Master Input, Slave Output (output from slave)&lt;br /&gt;
&lt;br /&gt;
SS — Slave Select(active low; output from master)&lt;br /&gt;
&lt;br /&gt;
SPI communication is done in bytes or words - a start signal, after which a given amount of data bits are transmitted serially, followed by a stop signal.&lt;br /&gt;
&lt;br /&gt;
==PIC Controller==&lt;br /&gt;
Using SPI with the PIC and the CCS compiler is quite straightforward. Some versions of the PIC offer hardware support for SPI on reserved pins. However, the compiler also includes software SPI support, which allows the use of any of the communication pins on the PIC. &lt;br /&gt;
&lt;br /&gt;
To set up SPI, all we need to do is include one line in the header of our source file:&lt;br /&gt;
&lt;br /&gt;
#use spi(DO = &amp;lt;data out&amp;gt;, DI = &amp;lt;data_in&amp;gt;, CLK = &amp;lt;serial_clock&amp;gt;, ENABLE = &amp;lt;enable_pin&amp;gt;, BITS = &amp;lt;8|16&amp;gt;, MASTER, ENABLE_ACTIVE = &amp;lt;0|1&amp;gt;, MSB_FIRST, IDLE = &amp;lt;0|1&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
This includes code that implements software SPI communication on the pins defined in DO, DI, CLK and ENABLE. The other options are device specific.&lt;br /&gt;
&lt;br /&gt;
To actually send a word, one simply needs to use the spi_xfer() function:&lt;br /&gt;
&lt;br /&gt;
spi_xfer(0x1337);&lt;br /&gt;
&lt;br /&gt;
which, in our example, will send the hex word 0x1337 to the SPI slave. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
Communication to the [[Waveform_Generation_with_AD9833%2C_and_SPI | AD9833]] is done through SPI.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus Serial Peripheral Interface Wikipedia Page]&lt;/div&gt;</summary>
		<author><name>VladSeghete</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Main_Page&amp;diff=9554</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Main_Page&amp;diff=9554"/>
		<updated>2008-12-18T00:54:46Z</updated>

		<summary type="html">&lt;p&gt;VladSeghete: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Northwestern University mechatronics design wiki provides reference material on the theory and applications of electronics, sensors, actuators, etc., for use in mechatronics-related research and projects.  Practical applications often refer to equipment and supplies available in the [http://mechatronics.mech.northwestern.edu/ Northwestern Mechatronics Design Lab].&lt;br /&gt;
&lt;br /&gt;
Important:  Please be sure to read the [http://mechatronics.mech.northwestern.edu/mech-rules.pdf Rules for Using the Mechatronics Design Lab].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Design Competition 2008&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wiki pages on sensors, actuators, programming, and microcontrollers: use pages below&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* [http://www.mech.northwestern.edu/courses/433/Writeups/QuickStart/ Parts in the DC2008 quick start pack]&lt;br /&gt;
* [http://peshkin.mech.northwestern.edu/pic/info/piccintro_2008-01-24.pdf PIC C intro slides, as presented 2008/01/24 (pdf)]&lt;br /&gt;
* [http://peshkin.mech.northwestern.edu/pic/info/picinterfacing_2008-01-28.pdf PIC interfacing slides, as presented 2008/01/28 (pdf)]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Sensors and actuators for DC&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[Using Solderless Breadboard|Solderless Breadboard &amp;amp; wiring that works]]&lt;br /&gt;
* [[Using LEDs &amp;amp; IREDs]]&lt;br /&gt;
* [[Using a laser]]&lt;br /&gt;
* [[Sensing optical tape|Infrared reflectivity]]&lt;br /&gt;
** Using phototransistors&lt;br /&gt;
** Sensing optical tape&lt;br /&gt;
* [[Comparators | Comparators : the analog digital interface]]&lt;br /&gt;
* [http://www.robotroom.com/FaulhaberGearmotor.html Faulhaber MiniMotor SA gearmotor with encoder], as well as [[Actuators_Available_in_the_Mechatronics_Lab#Faulhaber_1524E006S_motor_with_141:1_gearhead_and_HES164A_magnetic_quadrature_encoder|the local wiki page]]&lt;br /&gt;
* [[Adding a magnetic encoder to a GM3 Gearmotor]]&lt;br /&gt;
** Using magnetic switches (Hall Effect)&lt;br /&gt;
* [[High-current devices|Driving high-current devices: several options]]&lt;br /&gt;
* [[Driving a Stepper Motor]]&lt;br /&gt;
* [[Driving an RC Servo]]&lt;br /&gt;
* [[Accelerometers]]&lt;br /&gt;
* [[Strain gauges]]&lt;br /&gt;
* [[Using the Basic Stamp Microcontroller|Basic Stamp Microcontroller]] &amp;lt;b&amp;gt;Not recommended for DC2008&amp;lt;/b&amp;gt;&lt;br /&gt;
* [http://www.mech.northwestern.edu/courses/433/Writeups/Battery_NiMH/ NiMH rechargable batteries and chargers]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; [http://peshkin.mech.northwestern.edu/datasheets Prof. Peshkin&#039;s favorite datasheets]&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;PIC 18F4520 prototyping board &amp;lt;/h3&amp;gt;&lt;br /&gt;
*[[4520 Board intro|Prototyping board intro]]&lt;br /&gt;
*[[4520 Board construction|Assembling the 18F4520 prototyping board, circuit, parts]]&lt;br /&gt;
*[[4520 Board use|Using the 18F4520 prototyping board]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Programming with CCS C &amp;lt;/h3&amp;gt;&lt;br /&gt;
*[[C language|The C language]]&lt;br /&gt;
*[[CCS C|CCS C, specifically for the 18F4520]]&lt;br /&gt;
*[[Embedded Programming Tips for CCS C]]&lt;br /&gt;
*[[CCS IDE|Using the CCS development environment]]&lt;br /&gt;
*[[Debugging C on a PIC]]&lt;br /&gt;
*[[More debugging tips]]&lt;br /&gt;
*[http://www.ccsinfo.com/forum/ CCS user forum]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Interfacing and skeleton code for the PIC 18F4520&amp;lt;/h3&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;These topics have wiki pages &amp;lt;i&amp;gt;and&amp;lt;/i&amp;gt; sample code available&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;[http://peshkin.mech.northwestern.edu/pic/code Link to all sample code here.]&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* [[Digital inputs &amp;amp; outputs]] (filename: DigitalIO)&lt;br /&gt;
* [[Analog Input]] (filename: AnalogInput)&lt;br /&gt;
** reading a trimpot&lt;br /&gt;
** reading a phototransistor&lt;br /&gt;
** amplified phototransistor, and IRED strobing&lt;br /&gt;
** using an instrumentation amp (example: for a strain gauge)&lt;br /&gt;
* [[Analog Output|Analog Output, and the I2C bus]] (filename: AnalogOutput)&lt;br /&gt;
* [[Waveform Generation with AD9833]] (filename: AD9833)&lt;br /&gt;
* [[SPI - Serial Peripheral Interface - on the PIC]]&lt;br /&gt;
*[[Pulse width modulation|Pulse width modulation (PWM) for driving motors or other high current devices]] (filename: MotorPWM)&lt;br /&gt;
** using H-bridges&lt;br /&gt;
* [[Interrupts]]&lt;br /&gt;
* [[Quadrature decoding in software]] (filename: QuadratureSoft)&lt;br /&gt;
* [[Quadrature decoding in hardware, or just counters]] (filename: QuadratureHard)&lt;br /&gt;
* [[Running RC servos]] (filename: RCservoSoft &amp;amp; RCservoHard)&lt;br /&gt;
* [[Watchdog timer]] (filename: Watchdog)&lt;br /&gt;
* [[PIC RS232|RS-232 serial communication between a PC and a PIC]] (filename: RS232)&lt;br /&gt;
* [[C Example: Serial LCD|Text output to a serial LCD display]]&lt;br /&gt;
* [[C Example: Parallel Interfacing with LCDs|Text output to a parallel LCD display]]&lt;br /&gt;
* [[Servo skeleton with fast &amp;amp; slow interrupts]]&lt;br /&gt;
* [[XBee radio communication between PICs]] (and between a PC and a PIC)&lt;br /&gt;
* [[I2C communication between PICs]]&lt;br /&gt;
* [[Serial communication with Matlab]]&lt;br /&gt;
* [[SPI communication between PICs]] &amp;lt;b&amp;gt; (Note:  this function has not been successfully tested)&amp;lt;/b&amp;gt;&lt;br /&gt;
* [[Microphones]]&lt;br /&gt;
* [[Ambient light color sensing]]&lt;br /&gt;
* [[Controlling a seven segment display]]&lt;br /&gt;
* [[Storing constant data in program memory]]&lt;br /&gt;
* [[PIC computation time benchmarks]]&lt;br /&gt;
* [[Stepper motor control with the PIC]]&lt;br /&gt;
* [[Global Positioning System]]&lt;br /&gt;
* [[IR communication between PICs]] &amp;lt;b&amp;gt; (Note:  this function has not been successfully tested) &amp;lt;/b&amp;gt;&lt;br /&gt;
* [[Interfacing to External EEPROM]]&lt;br /&gt;
* [[I2C Motor Controller]]&lt;br /&gt;
* [[Interfacing with a Photodiode Array]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;These topics have sample code available, but no wiki pages yet&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;[http://peshkin.mech.northwestern.edu/pic/code Link to all sample code here.]&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Counter0 - Counting pulses with Timer0]&lt;br /&gt;
* Counter1 - Counting pulses with Timer1]&lt;br /&gt;
* Interrupt0 - Periodic servo cycles using interrupt routines, 10mS &amp;amp; slower; Timer 0]&lt;br /&gt;
* Interrupt2 - Periodic servo cycles using interrupt routines; 10mS &amp;amp; faster; Timer 2]&lt;br /&gt;
* InterruptExternal - Interrupts generated by an external pulse]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;These topics need more development&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;[http://peshkin.mech.northwestern.edu/pic/code Link to all sample code here.]&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
* AnalogOutputParallel - Analog output using 8 digital lines]&lt;br /&gt;
* PIC-to-PIC communication &lt;br /&gt;
* Zigbee radio communication&lt;br /&gt;
* Modulated IR communication&lt;br /&gt;
* Strobing LEDs or IREDs for better range and immunity to background light&lt;br /&gt;
* I2C communication &lt;br /&gt;
* CAN bus&lt;br /&gt;
* Capturing data to Matlab&lt;br /&gt;
* Running stepper motors&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;PIC Microcontrollers&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[PIC Microcontrollers with CCS Compiler]], for DC, 333, etc, using the CCS ICD-U40 device &amp;lt;b&amp;gt;[this section has been replaced by the material above]&amp;lt;/b&amp;gt;&lt;br /&gt;
* [[PIC Microcontrollers with C18 Compiler]], for e-puck, or using the Microchip ICD device or&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;e-puck Mobile Robot&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[e-puck Mobile Robot]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;[[Printing Circuit Boards]]&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[PCB Artist | PCB Artist: Software provided by Advanced Circuits]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Electronics &amp;lt;/h3&amp;gt;&lt;br /&gt;
* [http://hades.mech.northwestern.edu/wiki/index.php/Category:Electronics Electronics]&lt;br /&gt;
* [[Phase-Sensitive Detection]]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Operational_amplifier_applications Op-Amp Applications]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Analog and Digital chips&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[Comparators | Comparators: the analog to digital interface]]&lt;br /&gt;
* [[Filtering with the LMF100 | Filtering with the LMF100]]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Operational_amplifier_applications Opamps : building blocks of analog computation]&lt;br /&gt;
* [http://www.mech.northwestern.edu/courses/433/Writeups/InstAmp/instamp.htm Instrumentation amps, and NU circuit board for them]&lt;br /&gt;
* [[LED Drivers | Controlling larg numbers of LEDs with LED drivers]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;[[:Category:Sensors|Sensors]]&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Potentiometers|Angle, Linear Position: Potentiometers]]&lt;br /&gt;
* [[Optointerrupter|Beam Breaker: Optointerrupter]]&lt;br /&gt;
* [[Optoreflector|Proximity: Optoreflector]]&lt;br /&gt;
* [[Sensing optical tape|Infrared reflectivity : Sensing optical tape]]&lt;br /&gt;
* [[Reed Switch|Proximity: Reed Switch]]&lt;br /&gt;
* [[Hall Effect Sensor|Proximity, Angle: Hall Effect Sensor]]&lt;br /&gt;
* [[Rotary Encoder|Angle: Rotary Encoder]]&lt;br /&gt;
* Angular Velocity: Tachometer&lt;br /&gt;
* [[Photodiodes and Phototransistors|Light: Photodiodes and Phototransistors]]&lt;br /&gt;
* [[Photocell|Ambient Light: Photocell]]&lt;br /&gt;
* [[Thermistor|Temperature: Thermistor]]&lt;br /&gt;
* Temperature: Thermotransistor IC&lt;br /&gt;
* Audio: [[Microphones]]&lt;br /&gt;
* [[Accelerometers|Tilt, Acceleration: Accelerometers]]&lt;br /&gt;
* [[Strain Gauge|Force: Strain Gauge]]&lt;br /&gt;
* Current: Current Sense Resistor&lt;br /&gt;
* [[Limit Switch|Contact: Microswitch (Limit Switch)]]&lt;br /&gt;
* [[Ambient light color sensing]]&lt;br /&gt;
* [[Global Positioning System]]&lt;br /&gt;
* [[Optics]]&lt;br /&gt;
* [[Optical Locating]]&lt;br /&gt;
* [[Lateral-Effect Photodiode]]&lt;br /&gt;
* [[IR Target Illumination|IRED&#039;s]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;[[:Category:Actuators|Actuators]]&amp;lt;/h3&amp;gt;&lt;br /&gt;
[[image:All-actuators-captions-small.jpg|thumb|300px|[[Actuators Available in the Mechatronics Lab|Available Actuators]]|right]]&lt;br /&gt;
&lt;br /&gt;
* [[Brushed DC Motor Theory|Brushed DC Motors]]&lt;br /&gt;
** [[Choosing a Motor and Gearing Combination|Choosing a Motor and Gearing Combination]]&lt;br /&gt;
** [[Linear Amplifier Motor Driver|Driving Using a Linear Amplifier]]&lt;br /&gt;
** [[Driving using a single MOSFET|Driving using a single MOSFET]]&lt;br /&gt;
** [[Pulse Width Modulation|Driving Using Pulse Width Modulation]]&lt;br /&gt;
** [[PIC PWM Motor Driver]]&lt;br /&gt;
** [[Gear Motor]]&lt;br /&gt;
** [[Pulse Width Modulation]]&lt;br /&gt;
** [[Pulse_width_modulation]]&lt;br /&gt;
** [[Driving using a single MOSFET | Driving a DC motor using a single MOSFET]]&lt;br /&gt;
** [[Driving a DC Motor using PWM]]&lt;br /&gt;
** [[Driving a high current DC Motor using an H-bridge]]&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/AddEncoderHobbyEngGearMotor Adding a rotation encoder to a gearmotor]&lt;br /&gt;
** [[Using Opto-Isolators to Prevent Interference]]&lt;br /&gt;
* [[Brushless DC Motors]]&lt;br /&gt;
** [[Driving Brushless DC Motors]]&lt;br /&gt;
* [[Stepper Motor Theory|Stepper Motors]]&lt;br /&gt;
** [[Stepper Motor Circuits|Driving Stepper Motors]]&lt;br /&gt;
** [[Unipolar Stepper Motor Driver Circuit]]&lt;br /&gt;
** [[Bipolar Stepper Motor Driver Circuit]]&lt;br /&gt;
* [[RC Servo Theory|RC Servos]]&lt;br /&gt;
** [[555 Servo Circuit|Driving Your Servo Using a 555 Timer]]&lt;br /&gt;
* [[Solenoid Theory|Solenoids]]&lt;br /&gt;
** Practice: Driving Your Solenoid&lt;br /&gt;
* AC Motors&lt;br /&gt;
** [[Using the Yaskawa Motors]]&lt;br /&gt;
* [[Actuators Available in the Mechatronics Lab]]&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Mechanical Design&amp;lt;/h3&amp;gt;&lt;br /&gt;
*Mechanics of Materials&lt;br /&gt;
**Beam Mechanics&lt;br /&gt;
**[[Mohr&#039;s Circle]]&lt;br /&gt;
*Failure Theories&lt;br /&gt;
**Static Loading&lt;br /&gt;
**Variable Loading and Fatigue&lt;br /&gt;
*Fastening&lt;br /&gt;
**Nuts and Bolts&lt;br /&gt;
**Keys and Keyways&lt;br /&gt;
**Press-fits&lt;br /&gt;
**Set Screws&lt;br /&gt;
*Support&lt;br /&gt;
**Housings&lt;br /&gt;
**Shafts&lt;br /&gt;
**[[Bearings]]&lt;br /&gt;
*Transmission&lt;br /&gt;
**Rigid: [[Gears]]&lt;br /&gt;
**Flexible: Belts, Chains&lt;br /&gt;
**Motion Connection/Separation: Clutches, Brakes, Couplings&lt;br /&gt;
*Linkages&lt;br /&gt;
**Serial Chains&lt;br /&gt;
**Parallel and Closed-Loop Chains&lt;br /&gt;
*Other: springs/dampers, cams, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;The PC/104 Stack&amp;lt;/h3&amp;gt;&lt;br /&gt;
[[Image:Img0174.jpg|thumb|300px|[[PC104 Overview|The PC104 Stack]]|right]]&lt;br /&gt;
* [[PC104 Overview|Overview]]&lt;br /&gt;
* [[The PC/104 Lab Kit]]&lt;br /&gt;
* Hardware:&lt;br /&gt;
** [[Advantech CPU Card]]&lt;br /&gt;
** [[Sensoray 526 Data Aquisition Card]]&lt;br /&gt;
&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/PC104BoB/stack.htm#power[Power Components]]&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/PC104BoB/stack.htm#electrical[I/O Electronics: Analog I/O, Digital I/O, Encoder Connections]]&lt;br /&gt;
* Advanced: Creating a Working Stack from Parts&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/PC104BoB/stack.htm [Building the Breakout Board]]&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/PC104BoB/stack.htm#ribboncables[Breakout Board Ribbon Cables]]&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/PC104BoB/stack.htm#mechanical[Assembling the PC104 Stack]]&lt;br /&gt;
** &#039;&#039;&#039;[[Creating an xPC Flash Boot Disk]]&#039;&#039;&#039; &amp;lt;- when new version of MATLAB&lt;br /&gt;
* Custom Boards&lt;br /&gt;
** Dual PWM Motor Controller&lt;br /&gt;
** Dual Linear Amplifier Motor Controller&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;xPC Target Real-Time Operating System&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[xPC Overview|Overview of Real-Time Programming with Simulink and xPC Target]]&lt;br /&gt;
* [[Configuring xPC Target PC|Configuring xPC Host/Target PC]]&lt;br /&gt;
* [[Creating a Simple xPC Program|&#039;&#039;&#039;Quickstart&#039;&#039;&#039;:Creating a simple xPC Program]]&lt;br /&gt;
* [[Common xPC Blocks|Commonly Used Blocks]]&lt;br /&gt;
* [[Using the Host Scope]]&lt;br /&gt;
*Advanced&lt;br /&gt;
** Model Properties&lt;br /&gt;
** [[XPC M-file Communication|M-file communication]]&lt;br /&gt;
** Using outside of the lab&lt;br /&gt;
** [[media:standalone.pdf|Standalone Mode]]&lt;br /&gt;
** Stateflow&lt;br /&gt;
* Code Examples&lt;br /&gt;
** [[Controlling a DC Motor with an Encoder]]&lt;br /&gt;
** Something With State Machine&lt;br /&gt;
** [[Using RS-232 and Printing to LCD]]&lt;br /&gt;
**[[UDP Communications between Target and Host PC]]&lt;br /&gt;
** M-functions and S-functions&lt;br /&gt;
** [[xPC Code From Student Projects]]&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;QNX Real-Time Operating System&amp;lt;/h3&amp;gt;&lt;br /&gt;
*[[media:qnxtemplate.zip|QNX Control Program with Interrupts]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Lab Supplies and Data Sheets&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [http://spreadsheets.google.com/pub?key=pa_bNAhFF-OvvxpSje1KDYg&amp;amp;output=html&amp;amp;gid=0&amp;amp;single=true Generally stocked lab inventory ]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;[[Vendors]]&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Other Software&amp;lt;/h3&amp;gt;&lt;br /&gt;
*[[List of Useful Software for Download]]&lt;br /&gt;
*Circuit Schematics and PCB Layout&lt;br /&gt;
*LaTex Document Preparation&lt;br /&gt;
** [http://meta.wikimedia.org/wiki/Help:Formula Mathematical Formulae]&lt;br /&gt;
** Document Formatting&lt;br /&gt;
** [[LaTeX Software Setup|Software Setup]]&lt;br /&gt;
** IEEE Styles&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;[[Other Lab Equipment]]&amp;lt;/h3&amp;gt;&lt;br /&gt;
* Prototyping Tools&lt;br /&gt;
** [[Tektronix TDS220 Oscilloscope]]&lt;br /&gt;
** [[Tektronix CFG253 Function Generator]]&lt;br /&gt;
** [[media:Mastech_power_supply_manual.pdf|Mastech Power Supply]]&lt;br /&gt;
** Fluke III Multimeter&lt;br /&gt;
** Benchtop Multimeter&lt;br /&gt;
** Powered Breadboard&lt;br /&gt;
** Soldering Iron&lt;br /&gt;
* [http://ediacaran.mech.northwestern.edu/neuromech/index.php/Lab_Equipment High Performance Neuromechatronics Benches]&lt;br /&gt;
* The Sensoray 626 DAQ Card&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Course Material&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[ME 224 Experimental Engineering]]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/~lynch/courses/ME333/2008/index.html ME 333 Introduction to Mechatronics]&lt;br /&gt;
** [[Lab 5]]&lt;br /&gt;
** [[Suggested final projects]]&lt;br /&gt;
** [[ME 333 final projects]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [http://www.mech.northwestern.edu/hartmann/ME333_CourseInformation.html ME 333 Mechatronics]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
* [http://www.mech.northwestern.edu/courses/433/ ME 433 Advanced Mechatronics] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Miscellaneous&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[Swarm Robot Project]]&lt;br /&gt;
** [[Swarm Robot Project Links]]&lt;br /&gt;
&lt;br /&gt;
* [[Indoor Localization System]]&lt;br /&gt;
* [[Robot Helicopter Project]]&lt;br /&gt;
* [[E-Puck Color Sensing Project]]&lt;br /&gt;
* [[Guitar Tunning Project]]&lt;/div&gt;</summary>
		<author><name>VladSeghete</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Waveform_Generation_with_AD9833&amp;diff=9553</id>
		<title>Waveform Generation with AD9833</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Waveform_Generation_with_AD9833&amp;diff=9553"/>
		<updated>2008-12-18T00:42:42Z</updated>

		<summary type="html">&lt;p&gt;VladSeghete: Removed SPI from title&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:AD9833Connsmall.jpg | right | thumb | Connection diagram for the AD9833 function generator.]]&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
The AD9833 is a programmable waveform generator capable of creating sine, triangular, or square wave outputs in a frequency range of 0 to 12.5 MHz.  It has two 28-bit frequency registers and two 12-bit phase registers whose values can be used to calculate the frequency and phase of an output waveform.  This chip is perfectly suited for use with the PIC 18F4520, as it uses SPI communication for its setup and control.  A connection diagram for the AD9833 is given to the right.  The MCLK pin is tied directly to the oscillator of the PIC, and the three SPI communication lines are connected to three I/O pins on the PIC (in this case pins A1, A2, and A3).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Setup=&lt;br /&gt;
&lt;br /&gt;
In order to establish communication between the PIC and the AD9833, we need to set up the SPI for the pins we wish to use. Here, we use the software support included with the CCS compiler (the PIC also offers hardware support, which we did not use. It should, however, be very similar). The following should be added to the header of your program.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 #use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The first three arguments determine which three pins we will be using: DO is the &amp;quot;SDATA&amp;quot; pin of the AD9833, CLK is the &amp;quot;SCLK&amp;quot; pin, and ENABLE is the &amp;quot;FSYNC&amp;quot; pin.  The next argument states that the max number of bits in one transfer is 16.  The next argument specifies that the PIC is the master and the AD9833 is the slave.  The AD9833&#039;s FSYNC pin is active low, and it accepts the most significant bit (MSB) of each transfer first.  The SCLK pin is also specified to be kept high when not in use.  After this initial setup, the SPI communication is quite straightforward.  We simply use the function &#039;&#039;&#039;spi_xfer()&#039;&#039;&#039; whenever we want to send information via SPI to the AD9833.&lt;br /&gt;
&lt;br /&gt;
=AD9833 Control Register=&lt;br /&gt;
In order to program the frequency generator, we need to write to its internal control register. This control register is used for resetting the chip, setting the mode of operation and selecting the frequency and phase registers on which the output is to be based. &lt;br /&gt;
&lt;br /&gt;
Each of the 16 bits transferred has a meaning, and these meanings are described in the Table below.  Note that the if a frequency register is being written to (first two bits = 01 or 10), the last 14 bits are the value of the write, and do not have the same meaning as specified in the table.  Similarly, if a phase register is being written to (first two bits = 11), the last 12 bits are the value of the write.  Only if the control register is being written to (first two bits = 00) are most of the meanings specified in the table applicable.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;3&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Bit!! Significance&lt;br /&gt;
|-&lt;br /&gt;
|D15,D14(MSB) || 10 = FREQ1 write, 01 = FREQ0 write, 11 = PHASE write, 00 = control write&lt;br /&gt;
|-&lt;br /&gt;
|D13 ||If D15,D14 = 00, 0 = individual LSB and MSB FREQ write, 1 = both LSB and MSB FREQ writes consecutively&lt;br /&gt;
|-&lt;br /&gt;
| ||If D15,D14 = 11, 0 = PHASE0 write, 1 = PHASE1 write&lt;br /&gt;
|-&lt;br /&gt;
|D12||0 = writing LSB independently, 1 = writing MSB independently&lt;br /&gt;
|-&lt;br /&gt;
|D11||0 = output FREQ0, 1 = output FREQ1&lt;br /&gt;
|-&lt;br /&gt;
|D10||0 = output PHASE0, 1 = output PHASE1&lt;br /&gt;
|-&lt;br /&gt;
|D9||Reserved.  Must be 0.&lt;br /&gt;
|-&lt;br /&gt;
|D8||0 = RESET disabled, 1 = RESET enabled&lt;br /&gt;
|-&lt;br /&gt;
|D7||0 = internal clock is enabled, 1 = internal clock is disabled&lt;br /&gt;
|-&lt;br /&gt;
|D6||0 = onboard DAC is active for sine and triangle wave output, 1 = put DAC to sleep for square wave output&lt;br /&gt;
|-&lt;br /&gt;
|D5||0 = output depends on D1, 1 = output is a square wave&lt;br /&gt;
|-&lt;br /&gt;
|D4||Reserved.  Must be 0.&lt;br /&gt;
|-&lt;br /&gt;
|D3||0 = square wave of half frequency output, 1 = square wave output&lt;br /&gt;
|-&lt;br /&gt;
|D2||Reserved.  Must be 0.&lt;br /&gt;
|-&lt;br /&gt;
|D1||If D5 = 1, D1 = 0. Otherwise 0 = sine output, 1 = triangle output&lt;br /&gt;
|-&lt;br /&gt;
|D0||Reserved.  Must be 0.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Frequency and Phase Registers=&lt;br /&gt;
In order for the chip to output at a frequency &amp;lt;math&amp;gt;f_{out}&amp;lt;/math&amp;gt; and phase shift &amp;lt;math&amp;gt;\Phi_{shift}&amp;lt;/math&amp;gt; we need to have:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f_{out}=\frac{f_{MCLK}}{2^{28}}\times FREQREG&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Phi_{shift} = \frac{2\pi}{4096}\times PHASEREG&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
In other words, the output frequency and phase shift are not the values of the frequency or phase registers.  They are related by the above equations, so the values you send to the registers need to be modified from the actual frequency and phase shift.  For instance, if we sent 200 to the FREQ register and 100 to the PHASE register, and we were using a 20 MHz MCLK, we would output a 14.9 Hz wave with a phase shift of 0.15 radians.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The chip has two frequency registers (FREQ0 and FREQ1) and two phase registers (PHASE0 and PHASE1). By setting or resetting pins 11 (FSELECT) and 10 (PSELECT) of the control word we select which frequency register and which phase register to combine in order to produce the output waveform.&lt;br /&gt;
&lt;br /&gt;
=Writing to the Registers=&lt;br /&gt;
The first two bits (most significant) of the SPI message select which of the registers is being written. The next bit is used in order to distinguish between the two phase registers, in case one of them is being written to. &lt;br /&gt;
&lt;br /&gt;
==Phase Registers==&lt;br /&gt;
In order to write to a phase register, the most significant two bits of the serially transmitted word have to be 11. The next bit is the number of the phase register that is being written, following is a &amp;quot;don&#039;t care&amp;quot; bit and the rest represent the value to be written.&lt;br /&gt;
&lt;br /&gt;
==Control Register==&lt;br /&gt;
Writing to the control register is done by setting the first two bits to 00. The other bits should be set according to the desired values found from the above table.&lt;br /&gt;
&lt;br /&gt;
==Frequency Registers==&lt;br /&gt;
Writing to the frequency registers can be done in two ways:&lt;br /&gt;
1. Both the 14 MSB (most significant bits) and 14 LSB (least significant bits) of a frequency register will be altered - coarse tuning&lt;br /&gt;
2. Only the MSB or the LSB will be written - fine tuning&lt;br /&gt;
In order to specify which kind of write is being performed we need to set bit 12(HLB) and 13(B28) of the control register accordingly.&lt;br /&gt;
To specify which of the two frequency registers is being written, we have to set the first two bits preceding the data to either 01 for FREQ0 or 10 for FREQ1. &lt;br /&gt;
&lt;br /&gt;
=Example=&lt;br /&gt;
In order to setup or update the AD9833 you first need to reset it, then transfer the frequency and phase information, then &amp;quot;unreset&amp;quot; it.  For example, if we wanted to output a 20 kHz square wave with no phase shift, we would send the following:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 spi_xfer(0b0010000101101000);&lt;br /&gt;
&lt;br /&gt;
This resets the AD9833 (D8), tells it that we will be using the next two transfers to input both LSB and MSB (D13) of the FREQ0 register (D11), the internal clock is enabled (D7), the DAC has been put to sleep (D6), the output is to be a square wave (D5), and the square wave frequency is not to be divided by two (D3).&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 spi_xfer(0b0101100010010011);&lt;br /&gt;
 spi_xfer(0b0100000000010000);&lt;br /&gt;
&lt;br /&gt;
These transfers are writing to the value of the FREQ0 register (D15-D14), with the last 14 bits of each transfer representing first the LSB, then the MSB of the value.  This writes a value of 0000000001000001100010010011 (268435 decimal) to the FREQ0 register.  If we use the formula above, we see this corresponds to an output frequency of 20 kHz.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 spi_xfer(0b1100000000000000);&lt;br /&gt;
&lt;br /&gt;
This transfer is writing to the PHASE0 register (D15,D14,D13) and is writing a twelve bit value of zero (D11-D0).&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 spi_xfer(0b0000000001101000);&lt;br /&gt;
&lt;br /&gt;
This transfer &amp;quot;unresets&amp;quot; the AD9833 (D8).&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
With a small variation in the values of the five transfers, all of the frequency and phase registers can be written to and output from the VOUT pin of the AD9833.&lt;br /&gt;
==References==&lt;br /&gt;
*[http://www.analog.com/static/imported-files/Data_Sheets/AD9833.pdf AD9833 Datasheet, Analog Devices]&lt;/div&gt;</summary>
		<author><name>VladSeghete</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Main_Page&amp;diff=9552</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Main_Page&amp;diff=9552"/>
		<updated>2008-12-18T00:41:04Z</updated>

		<summary type="html">&lt;p&gt;VladSeghete: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Northwestern University mechatronics design wiki provides reference material on the theory and applications of electronics, sensors, actuators, etc., for use in mechatronics-related research and projects.  Practical applications often refer to equipment and supplies available in the [http://mechatronics.mech.northwestern.edu/ Northwestern Mechatronics Design Lab].&lt;br /&gt;
&lt;br /&gt;
Important:  Please be sure to read the [http://mechatronics.mech.northwestern.edu/mech-rules.pdf Rules for Using the Mechatronics Design Lab].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Design Competition 2008&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wiki pages on sensors, actuators, programming, and microcontrollers: use pages below&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* [http://www.mech.northwestern.edu/courses/433/Writeups/QuickStart/ Parts in the DC2008 quick start pack]&lt;br /&gt;
* [http://peshkin.mech.northwestern.edu/pic/info/piccintro_2008-01-24.pdf PIC C intro slides, as presented 2008/01/24 (pdf)]&lt;br /&gt;
* [http://peshkin.mech.northwestern.edu/pic/info/picinterfacing_2008-01-28.pdf PIC interfacing slides, as presented 2008/01/28 (pdf)]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Sensors and actuators for DC&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[Using Solderless Breadboard|Solderless Breadboard &amp;amp; wiring that works]]&lt;br /&gt;
* [[Using LEDs &amp;amp; IREDs]]&lt;br /&gt;
* [[Using a laser]]&lt;br /&gt;
* [[Sensing optical tape|Infrared reflectivity]]&lt;br /&gt;
** Using phototransistors&lt;br /&gt;
** Sensing optical tape&lt;br /&gt;
* [[Comparators | Comparators : the analog digital interface]]&lt;br /&gt;
* [http://www.robotroom.com/FaulhaberGearmotor.html Faulhaber MiniMotor SA gearmotor with encoder], as well as [[Actuators_Available_in_the_Mechatronics_Lab#Faulhaber_1524E006S_motor_with_141:1_gearhead_and_HES164A_magnetic_quadrature_encoder|the local wiki page]]&lt;br /&gt;
* [[Adding a magnetic encoder to a GM3 Gearmotor]]&lt;br /&gt;
** Using magnetic switches (Hall Effect)&lt;br /&gt;
* [[High-current devices|Driving high-current devices: several options]]&lt;br /&gt;
* [[Driving a Stepper Motor]]&lt;br /&gt;
* [[Driving an RC Servo]]&lt;br /&gt;
* [[Accelerometers]]&lt;br /&gt;
* [[Strain gauges]]&lt;br /&gt;
* [[Using the Basic Stamp Microcontroller|Basic Stamp Microcontroller]] &amp;lt;b&amp;gt;Not recommended for DC2008&amp;lt;/b&amp;gt;&lt;br /&gt;
* [http://www.mech.northwestern.edu/courses/433/Writeups/Battery_NiMH/ NiMH rechargable batteries and chargers]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; [http://peshkin.mech.northwestern.edu/datasheets Prof. Peshkin&#039;s favorite datasheets]&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;PIC 18F4520 prototyping board &amp;lt;/h3&amp;gt;&lt;br /&gt;
*[[4520 Board intro|Prototyping board intro]]&lt;br /&gt;
*[[4520 Board construction|Assembling the 18F4520 prototyping board, circuit, parts]]&lt;br /&gt;
*[[4520 Board use|Using the 18F4520 prototyping board]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Programming with CCS C &amp;lt;/h3&amp;gt;&lt;br /&gt;
*[[C language|The C language]]&lt;br /&gt;
*[[CCS C|CCS C, specifically for the 18F4520]]&lt;br /&gt;
*[[Embedded Programming Tips for CCS C]]&lt;br /&gt;
*[[CCS IDE|Using the CCS development environment]]&lt;br /&gt;
*[[Debugging C on a PIC]]&lt;br /&gt;
*[[More debugging tips]]&lt;br /&gt;
*[http://www.ccsinfo.com/forum/ CCS user forum]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Interfacing and skeleton code for the PIC 18F4520&amp;lt;/h3&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;These topics have wiki pages &amp;lt;i&amp;gt;and&amp;lt;/i&amp;gt; sample code available&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;[http://peshkin.mech.northwestern.edu/pic/code Link to all sample code here.]&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* [[Digital inputs &amp;amp; outputs]] (filename: DigitalIO)&lt;br /&gt;
* [[Analog Input]] (filename: AnalogInput)&lt;br /&gt;
** reading a trimpot&lt;br /&gt;
** reading a phototransistor&lt;br /&gt;
** amplified phototransistor, and IRED strobing&lt;br /&gt;
** using an instrumentation amp (example: for a strain gauge)&lt;br /&gt;
* [[Analog Output|Analog Output, and the I2C bus]] (filename: AnalogOutput)&lt;br /&gt;
* [[Waveform Generation with AD9833]] (filename: AD9833)&lt;br /&gt;
* [[SPI (Serial Pulse Interface) Interfacing on the PIC]]&lt;br /&gt;
*[[Pulse width modulation|Pulse width modulation (PWM) for driving motors or other high current devices]] (filename: MotorPWM)&lt;br /&gt;
** using H-bridges&lt;br /&gt;
* [[Interrupts]]&lt;br /&gt;
* [[Quadrature decoding in software]] (filename: QuadratureSoft)&lt;br /&gt;
* [[Quadrature decoding in hardware, or just counters]] (filename: QuadratureHard)&lt;br /&gt;
* [[Running RC servos]] (filename: RCservoSoft &amp;amp; RCservoHard)&lt;br /&gt;
* [[Watchdog timer]] (filename: Watchdog)&lt;br /&gt;
* [[PIC RS232|RS-232 serial communication between a PC and a PIC]] (filename: RS232)&lt;br /&gt;
* [[C Example: Serial LCD|Text output to a serial LCD display]]&lt;br /&gt;
* [[C Example: Parallel Interfacing with LCDs|Text output to a parallel LCD display]]&lt;br /&gt;
* [[Servo skeleton with fast &amp;amp; slow interrupts]]&lt;br /&gt;
* [[XBee radio communication between PICs]] (and between a PC and a PIC)&lt;br /&gt;
* [[I2C communication between PICs]]&lt;br /&gt;
* [[Serial communication with Matlab]]&lt;br /&gt;
* [[SPI communication between PICs]] &amp;lt;b&amp;gt; (Note:  this function has not been successfully tested)&amp;lt;/b&amp;gt;&lt;br /&gt;
* [[Microphones]]&lt;br /&gt;
* [[Ambient light color sensing]]&lt;br /&gt;
* [[Controlling a seven segment display]]&lt;br /&gt;
* [[Storing constant data in program memory]]&lt;br /&gt;
* [[PIC computation time benchmarks]]&lt;br /&gt;
* [[Stepper motor control with the PIC]]&lt;br /&gt;
* [[Global Positioning System]]&lt;br /&gt;
* [[IR communication between PICs]] &amp;lt;b&amp;gt; (Note:  this function has not been successfully tested) &amp;lt;/b&amp;gt;&lt;br /&gt;
* [[Interfacing to External EEPROM]]&lt;br /&gt;
* [[I2C Motor Controller]]&lt;br /&gt;
* [[Interfacing with a Photodiode Array]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;These topics have sample code available, but no wiki pages yet&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;[http://peshkin.mech.northwestern.edu/pic/code Link to all sample code here.]&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Counter0 - Counting pulses with Timer0]&lt;br /&gt;
* Counter1 - Counting pulses with Timer1]&lt;br /&gt;
* Interrupt0 - Periodic servo cycles using interrupt routines, 10mS &amp;amp; slower; Timer 0]&lt;br /&gt;
* Interrupt2 - Periodic servo cycles using interrupt routines; 10mS &amp;amp; faster; Timer 2]&lt;br /&gt;
* InterruptExternal - Interrupts generated by an external pulse]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;These topics need more development&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;[http://peshkin.mech.northwestern.edu/pic/code Link to all sample code here.]&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
* AnalogOutputParallel - Analog output using 8 digital lines]&lt;br /&gt;
* PIC-to-PIC communication &lt;br /&gt;
* Zigbee radio communication&lt;br /&gt;
* Modulated IR communication&lt;br /&gt;
* Strobing LEDs or IREDs for better range and immunity to background light&lt;br /&gt;
* I2C communication &lt;br /&gt;
* CAN bus&lt;br /&gt;
* Capturing data to Matlab&lt;br /&gt;
* Running stepper motors&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;PIC Microcontrollers&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[PIC Microcontrollers with CCS Compiler]], for DC, 333, etc, using the CCS ICD-U40 device &amp;lt;b&amp;gt;[this section has been replaced by the material above]&amp;lt;/b&amp;gt;&lt;br /&gt;
* [[PIC Microcontrollers with C18 Compiler]], for e-puck, or using the Microchip ICD device or&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;e-puck Mobile Robot&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[e-puck Mobile Robot]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;[[Printing Circuit Boards]]&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[PCB Artist | PCB Artist: Software provided by Advanced Circuits]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Electronics &amp;lt;/h3&amp;gt;&lt;br /&gt;
* [http://hades.mech.northwestern.edu/wiki/index.php/Category:Electronics Electronics]&lt;br /&gt;
* [[Phase-Sensitive Detection]]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Operational_amplifier_applications Op-Amp Applications]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Analog and Digital chips&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[Comparators | Comparators: the analog to digital interface]]&lt;br /&gt;
* [[Filtering with the LMF100 | Filtering with the LMF100]]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Operational_amplifier_applications Opamps : building blocks of analog computation]&lt;br /&gt;
* [http://www.mech.northwestern.edu/courses/433/Writeups/InstAmp/instamp.htm Instrumentation amps, and NU circuit board for them]&lt;br /&gt;
* [[LED Drivers | Controlling larg numbers of LEDs with LED drivers]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;[[:Category:Sensors|Sensors]]&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Potentiometers|Angle, Linear Position: Potentiometers]]&lt;br /&gt;
* [[Optointerrupter|Beam Breaker: Optointerrupter]]&lt;br /&gt;
* [[Optoreflector|Proximity: Optoreflector]]&lt;br /&gt;
* [[Sensing optical tape|Infrared reflectivity : Sensing optical tape]]&lt;br /&gt;
* [[Reed Switch|Proximity: Reed Switch]]&lt;br /&gt;
* [[Hall Effect Sensor|Proximity, Angle: Hall Effect Sensor]]&lt;br /&gt;
* [[Rotary Encoder|Angle: Rotary Encoder]]&lt;br /&gt;
* Angular Velocity: Tachometer&lt;br /&gt;
* [[Photodiodes and Phototransistors|Light: Photodiodes and Phototransistors]]&lt;br /&gt;
* [[Photocell|Ambient Light: Photocell]]&lt;br /&gt;
* [[Thermistor|Temperature: Thermistor]]&lt;br /&gt;
* Temperature: Thermotransistor IC&lt;br /&gt;
* Audio: [[Microphones]]&lt;br /&gt;
* [[Accelerometers|Tilt, Acceleration: Accelerometers]]&lt;br /&gt;
* [[Strain Gauge|Force: Strain Gauge]]&lt;br /&gt;
* Current: Current Sense Resistor&lt;br /&gt;
* [[Limit Switch|Contact: Microswitch (Limit Switch)]]&lt;br /&gt;
* [[Ambient light color sensing]]&lt;br /&gt;
* [[Global Positioning System]]&lt;br /&gt;
* [[Optics]]&lt;br /&gt;
* [[Optical Locating]]&lt;br /&gt;
* [[Lateral-Effect Photodiode]]&lt;br /&gt;
* [[IR Target Illumination|IRED&#039;s]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;[[:Category:Actuators|Actuators]]&amp;lt;/h3&amp;gt;&lt;br /&gt;
[[image:All-actuators-captions-small.jpg|thumb|300px|[[Actuators Available in the Mechatronics Lab|Available Actuators]]|right]]&lt;br /&gt;
&lt;br /&gt;
* [[Brushed DC Motor Theory|Brushed DC Motors]]&lt;br /&gt;
** [[Choosing a Motor and Gearing Combination|Choosing a Motor and Gearing Combination]]&lt;br /&gt;
** [[Linear Amplifier Motor Driver|Driving Using a Linear Amplifier]]&lt;br /&gt;
** [[Driving using a single MOSFET|Driving using a single MOSFET]]&lt;br /&gt;
** [[Pulse Width Modulation|Driving Using Pulse Width Modulation]]&lt;br /&gt;
** [[PIC PWM Motor Driver]]&lt;br /&gt;
** [[Gear Motor]]&lt;br /&gt;
** [[Pulse Width Modulation]]&lt;br /&gt;
** [[Pulse_width_modulation]]&lt;br /&gt;
** [[Driving using a single MOSFET | Driving a DC motor using a single MOSFET]]&lt;br /&gt;
** [[Driving a DC Motor using PWM]]&lt;br /&gt;
** [[Driving a high current DC Motor using an H-bridge]]&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/AddEncoderHobbyEngGearMotor Adding a rotation encoder to a gearmotor]&lt;br /&gt;
** [[Using Opto-Isolators to Prevent Interference]]&lt;br /&gt;
* [[Brushless DC Motors]]&lt;br /&gt;
** [[Driving Brushless DC Motors]]&lt;br /&gt;
* [[Stepper Motor Theory|Stepper Motors]]&lt;br /&gt;
** [[Stepper Motor Circuits|Driving Stepper Motors]]&lt;br /&gt;
** [[Unipolar Stepper Motor Driver Circuit]]&lt;br /&gt;
** [[Bipolar Stepper Motor Driver Circuit]]&lt;br /&gt;
* [[RC Servo Theory|RC Servos]]&lt;br /&gt;
** [[555 Servo Circuit|Driving Your Servo Using a 555 Timer]]&lt;br /&gt;
* [[Solenoid Theory|Solenoids]]&lt;br /&gt;
** Practice: Driving Your Solenoid&lt;br /&gt;
* AC Motors&lt;br /&gt;
** [[Using the Yaskawa Motors]]&lt;br /&gt;
* [[Actuators Available in the Mechatronics Lab]]&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Mechanical Design&amp;lt;/h3&amp;gt;&lt;br /&gt;
*Mechanics of Materials&lt;br /&gt;
**Beam Mechanics&lt;br /&gt;
**[[Mohr&#039;s Circle]]&lt;br /&gt;
*Failure Theories&lt;br /&gt;
**Static Loading&lt;br /&gt;
**Variable Loading and Fatigue&lt;br /&gt;
*Fastening&lt;br /&gt;
**Nuts and Bolts&lt;br /&gt;
**Keys and Keyways&lt;br /&gt;
**Press-fits&lt;br /&gt;
**Set Screws&lt;br /&gt;
*Support&lt;br /&gt;
**Housings&lt;br /&gt;
**Shafts&lt;br /&gt;
**[[Bearings]]&lt;br /&gt;
*Transmission&lt;br /&gt;
**Rigid: [[Gears]]&lt;br /&gt;
**Flexible: Belts, Chains&lt;br /&gt;
**Motion Connection/Separation: Clutches, Brakes, Couplings&lt;br /&gt;
*Linkages&lt;br /&gt;
**Serial Chains&lt;br /&gt;
**Parallel and Closed-Loop Chains&lt;br /&gt;
*Other: springs/dampers, cams, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;The PC/104 Stack&amp;lt;/h3&amp;gt;&lt;br /&gt;
[[Image:Img0174.jpg|thumb|300px|[[PC104 Overview|The PC104 Stack]]|right]]&lt;br /&gt;
* [[PC104 Overview|Overview]]&lt;br /&gt;
* [[The PC/104 Lab Kit]]&lt;br /&gt;
* Hardware:&lt;br /&gt;
** [[Advantech CPU Card]]&lt;br /&gt;
** [[Sensoray 526 Data Aquisition Card]]&lt;br /&gt;
&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/PC104BoB/stack.htm#power[Power Components]]&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/PC104BoB/stack.htm#electrical[I/O Electronics: Analog I/O, Digital I/O, Encoder Connections]]&lt;br /&gt;
* Advanced: Creating a Working Stack from Parts&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/PC104BoB/stack.htm [Building the Breakout Board]]&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/PC104BoB/stack.htm#ribboncables[Breakout Board Ribbon Cables]]&lt;br /&gt;
** [http://www.mech.northwestern.edu/courses/433/Writeups/PC104BoB/stack.htm#mechanical[Assembling the PC104 Stack]]&lt;br /&gt;
** &#039;&#039;&#039;[[Creating an xPC Flash Boot Disk]]&#039;&#039;&#039; &amp;lt;- when new version of MATLAB&lt;br /&gt;
* Custom Boards&lt;br /&gt;
** Dual PWM Motor Controller&lt;br /&gt;
** Dual Linear Amplifier Motor Controller&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;xPC Target Real-Time Operating System&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[xPC Overview|Overview of Real-Time Programming with Simulink and xPC Target]]&lt;br /&gt;
* [[Configuring xPC Target PC|Configuring xPC Host/Target PC]]&lt;br /&gt;
* [[Creating a Simple xPC Program|&#039;&#039;&#039;Quickstart&#039;&#039;&#039;:Creating a simple xPC Program]]&lt;br /&gt;
* [[Common xPC Blocks|Commonly Used Blocks]]&lt;br /&gt;
* [[Using the Host Scope]]&lt;br /&gt;
*Advanced&lt;br /&gt;
** Model Properties&lt;br /&gt;
** [[XPC M-file Communication|M-file communication]]&lt;br /&gt;
** Using outside of the lab&lt;br /&gt;
** [[media:standalone.pdf|Standalone Mode]]&lt;br /&gt;
** Stateflow&lt;br /&gt;
* Code Examples&lt;br /&gt;
** [[Controlling a DC Motor with an Encoder]]&lt;br /&gt;
** Something With State Machine&lt;br /&gt;
** [[Using RS-232 and Printing to LCD]]&lt;br /&gt;
**[[UDP Communications between Target and Host PC]]&lt;br /&gt;
** M-functions and S-functions&lt;br /&gt;
** [[xPC Code From Student Projects]]&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;QNX Real-Time Operating System&amp;lt;/h3&amp;gt;&lt;br /&gt;
*[[media:qnxtemplate.zip|QNX Control Program with Interrupts]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Lab Supplies and Data Sheets&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [http://spreadsheets.google.com/pub?key=pa_bNAhFF-OvvxpSje1KDYg&amp;amp;output=html&amp;amp;gid=0&amp;amp;single=true Generally stocked lab inventory ]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;[[Vendors]]&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Other Software&amp;lt;/h3&amp;gt;&lt;br /&gt;
*[[List of Useful Software for Download]]&lt;br /&gt;
*Circuit Schematics and PCB Layout&lt;br /&gt;
*LaTex Document Preparation&lt;br /&gt;
** [http://meta.wikimedia.org/wiki/Help:Formula Mathematical Formulae]&lt;br /&gt;
** Document Formatting&lt;br /&gt;
** [[LaTeX Software Setup|Software Setup]]&lt;br /&gt;
** IEEE Styles&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;[[Other Lab Equipment]]&amp;lt;/h3&amp;gt;&lt;br /&gt;
* Prototyping Tools&lt;br /&gt;
** [[Tektronix TDS220 Oscilloscope]]&lt;br /&gt;
** [[Tektronix CFG253 Function Generator]]&lt;br /&gt;
** [[media:Mastech_power_supply_manual.pdf|Mastech Power Supply]]&lt;br /&gt;
** Fluke III Multimeter&lt;br /&gt;
** Benchtop Multimeter&lt;br /&gt;
** Powered Breadboard&lt;br /&gt;
** Soldering Iron&lt;br /&gt;
* [http://ediacaran.mech.northwestern.edu/neuromech/index.php/Lab_Equipment High Performance Neuromechatronics Benches]&lt;br /&gt;
* The Sensoray 626 DAQ Card&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Course Material&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[ME 224 Experimental Engineering]]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/~lynch/courses/ME333/2008/index.html ME 333 Introduction to Mechatronics]&lt;br /&gt;
** [[Lab 5]]&lt;br /&gt;
** [[Suggested final projects]]&lt;br /&gt;
** [[ME 333 final projects]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [http://www.mech.northwestern.edu/hartmann/ME333_CourseInformation.html ME 333 Mechatronics]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
* [http://www.mech.northwestern.edu/courses/433/ ME 433 Advanced Mechatronics] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Miscellaneous&amp;lt;/h3&amp;gt;&lt;br /&gt;
* [[Swarm Robot Project]]&lt;br /&gt;
** [[Swarm Robot Project Links]]&lt;br /&gt;
&lt;br /&gt;
* [[Indoor Localization System]]&lt;br /&gt;
* [[Robot Helicopter Project]]&lt;br /&gt;
* [[E-Puck Color Sensing Project]]&lt;br /&gt;
* [[Guitar Tunning Project]]&lt;/div&gt;</summary>
		<author><name>VladSeghete</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Waveform_Generation_with_AD9833,_and_SPI&amp;diff=9551</id>
		<title>Waveform Generation with AD9833, and SPI</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Waveform_Generation_with_AD9833,_and_SPI&amp;diff=9551"/>
		<updated>2008-12-18T00:31:39Z</updated>

		<summary type="html">&lt;p&gt;VladSeghete: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:AD9833Connsmall.jpg | right | thumb | Connection diagram for the AD9833 function generator.]]&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
The AD9833 is a programmable waveform generator capable of creating sine, triangular, or square wave outputs in a frequency range of 0 to 12.5 MHz.  It has two 28-bit frequency registers and two 12-bit phase registers whose values can be used to calculate the frequency and phase of an output waveform.  This chip is perfectly suited for use with the PIC 18F4520, as it uses SPI communication for its setup and control.  A connection diagram for the AD9833 is given to the right.  The MCLK pin is tied directly to the oscillator of the PIC, and the three SPI communication lines are connected to three I/O pins on the PIC (in this case pins A1, A2, and A3).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Setup=&lt;br /&gt;
&lt;br /&gt;
In order to establish communication between the PIC and the AD9833, we need to set up the SPI for the pins we wish to use. Here, we use the software support included with the CCS compiler (the PIC also offers hardware support, which we did not use. It should, however, be very similar). The following should be added to the header of your program.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 #use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The first three arguments determine which three pins we will be using: DO is the &amp;quot;SDATA&amp;quot; pin of the AD9833, CLK is the &amp;quot;SCLK&amp;quot; pin, and ENABLE is the &amp;quot;FSYNC&amp;quot; pin.  The next argument states that the max number of bits in one transfer is 16.  The next argument specifies that the PIC is the master and the AD9833 is the slave.  The AD9833&#039;s FSYNC pin is active low, and it accepts the most significant bit (MSB) of each transfer first.  The SCLK pin is also specified to be kept high when not in use.  After this initial setup, the SPI communication is quite straightforward.  We simply use the function &#039;&#039;&#039;spi_xfer()&#039;&#039;&#039; whenever we want to send information via SPI to the AD9833.&lt;br /&gt;
&lt;br /&gt;
=AD9833 Control Register=&lt;br /&gt;
In order to program the frequency generator, we need to write to its internal control register. This control register is used for resetting the chip, setting the mode of operation and selecting the frequency and phase registers on which the output is to be based. &lt;br /&gt;
&lt;br /&gt;
Each of the 16 bits transferred has a meaning, and these meanings are described in the Table below.  Note that the if a frequency register is being written to (first two bits = 01 or 10), the last 14 bits are the value of the write, and do not have the same meaning as specified in the table.  Similarly, if a phase register is being written to (first two bits = 11), the last 12 bits are the value of the write.  Only if the control register is being written to (first two bits = 00) are most of the meanings specified in the table applicable.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;3&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Bit!! Significance&lt;br /&gt;
|-&lt;br /&gt;
|D15,D14(MSB) || 10 = FREQ1 write, 01 = FREQ0 write, 11 = PHASE write, 00 = control write&lt;br /&gt;
|-&lt;br /&gt;
|D13 ||If D15,D14 = 00, 0 = individual LSB and MSB FREQ write, 1 = both LSB and MSB FREQ writes consecutively&lt;br /&gt;
|-&lt;br /&gt;
| ||If D15,D14 = 11, 0 = PHASE0 write, 1 = PHASE1 write&lt;br /&gt;
|-&lt;br /&gt;
|D12||0 = writing LSB independently, 1 = writing MSB independently&lt;br /&gt;
|-&lt;br /&gt;
|D11||0 = output FREQ0, 1 = output FREQ1&lt;br /&gt;
|-&lt;br /&gt;
|D10||0 = output PHASE0, 1 = output PHASE1&lt;br /&gt;
|-&lt;br /&gt;
|D9||Reserved.  Must be 0.&lt;br /&gt;
|-&lt;br /&gt;
|D8||0 = RESET disabled, 1 = RESET enabled&lt;br /&gt;
|-&lt;br /&gt;
|D7||0 = internal clock is enabled, 1 = internal clock is disabled&lt;br /&gt;
|-&lt;br /&gt;
|D6||0 = onboard DAC is active for sine and triangle wave output, 1 = put DAC to sleep for square wave output&lt;br /&gt;
|-&lt;br /&gt;
|D5||0 = output depends on D1, 1 = output is a square wave&lt;br /&gt;
|-&lt;br /&gt;
|D4||Reserved.  Must be 0.&lt;br /&gt;
|-&lt;br /&gt;
|D3||0 = square wave of half frequency output, 1 = square wave output&lt;br /&gt;
|-&lt;br /&gt;
|D2||Reserved.  Must be 0.&lt;br /&gt;
|-&lt;br /&gt;
|D1||If D5 = 1, D1 = 0. Otherwise 0 = sine output, 1 = triangle output&lt;br /&gt;
|-&lt;br /&gt;
|D0||Reserved.  Must be 0.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Frequency and Phase Registers=&lt;br /&gt;
In order for the chip to output at a frequency &amp;lt;math&amp;gt;f_{out}&amp;lt;/math&amp;gt; and phase shift &amp;lt;math&amp;gt;\Phi_{shift}&amp;lt;/math&amp;gt; we need to have:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f_{out}=\frac{f_{MCLK}}{2^{28}}\times FREQREG&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Phi_{shift} = \frac{2\pi}{4096}\times PHASEREG&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
In other words, the output frequency and phase shift are not the values of the frequency or phase registers.  They are related by the above equations, so the values you send to the registers need to be modified from the actual frequency and phase shift.  For instance, if we sent 200 to the FREQ register and 100 to the PHASE register, and we were using a 20 MHz MCLK, we would output a 14.9 Hz wave with a phase shift of 0.15 radians.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The chip has two frequency registers (FREQ0 and FREQ1) and two phase registers (PHASE0 and PHASE1). By setting or resetting pins 11 (FSELECT) and 10 (PSELECT) of the control word we select which frequency register and which phase register to combine in order to produce the output waveform.&lt;br /&gt;
&lt;br /&gt;
=Writing to the Registers=&lt;br /&gt;
The first two bits (most significant) of the SPI message select which of the registers is being written. The next bit is used in order to distinguish between the two phase registers, in case one of them is being written to. &lt;br /&gt;
&lt;br /&gt;
==Phase Registers==&lt;br /&gt;
In order to write to a phase register, the most significant two bits of the serially transmitted word have to be 11. The next bit is the number of the phase register that is being written, following is a &amp;quot;don&#039;t care&amp;quot; bit and the rest represent the value to be written.&lt;br /&gt;
&lt;br /&gt;
==Control Register==&lt;br /&gt;
Writing to the control register is done by setting the first two bits to 00. The other bits should be set according to the desired values found from the above table.&lt;br /&gt;
&lt;br /&gt;
==Frequency Registers==&lt;br /&gt;
Writing to the frequency registers can be done in two ways:&lt;br /&gt;
1. Both the 14 MSB (most significant bits) and 14 LSB (least significant bits) of a frequency register will be altered - coarse tuning&lt;br /&gt;
2. Only the MSB or the LSB will be written - fine tuning&lt;br /&gt;
In order to specify which kind of write is being performed we need to set bit 12(HLB) and 13(B28) of the control register accordingly.&lt;br /&gt;
To specify which of the two frequency registers is being written, we have to set the first two bits preceding the data to either 01 for FREQ0 or 10 for FREQ1. &lt;br /&gt;
&lt;br /&gt;
=Example=&lt;br /&gt;
In order to setup or update the AD9833 you first need to reset it, then transfer the frequency and phase information, then &amp;quot;unreset&amp;quot; it.  For example, if we wanted to output a 20 kHz square wave with no phase shift, we would send the following:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 spi_xfer(0b0010000101101000);&lt;br /&gt;
&lt;br /&gt;
This resets the AD9833 (D8), tells it that we will be using the next two transfers to input both LSB and MSB (D13) of the FREQ0 register (D11), the internal clock is enabled (D7), the DAC has been put to sleep (D6), the output is to be a square wave (D5), and the square wave frequency is not to be divided by two (D3).&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 spi_xfer(0b0101100010010011);&lt;br /&gt;
 spi_xfer(0b0100000000010000);&lt;br /&gt;
&lt;br /&gt;
These transfers are writing to the value of the FREQ0 register (D15-D14), with the last 14 bits of each transfer representing first the LSB, then the MSB of the value.  This writes a value of 0000000001000001100010010011 (268435 decimal) to the FREQ0 register.  If we use the formula above, we see this corresponds to an output frequency of 20 kHz.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 spi_xfer(0b1100000000000000);&lt;br /&gt;
&lt;br /&gt;
This transfer is writing to the PHASE0 register (D15,D14,D13) and is writing a twelve bit value of zero (D11-D0).&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 spi_xfer(0b0000000001101000);&lt;br /&gt;
&lt;br /&gt;
This transfer &amp;quot;unresets&amp;quot; the AD9833 (D8).&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
With a small variation in the values of the five transfers, all of the frequency and phase registers can be written to and output from the VOUT pin of the AD9833.&lt;br /&gt;
==References==&lt;br /&gt;
*[http://www.analog.com/static/imported-files/Data_Sheets/AD9833.pdf AD9833 Datasheet, Analog Devices]&lt;/div&gt;</summary>
		<author><name>VladSeghete</name></author>
	</entry>
</feed>