<?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=SandeepPrabhu</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=SandeepPrabhu"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php/Special:Contributions/SandeepPrabhu"/>
	<updated>2026-05-16T19:01:12Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8101</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8101"/>
		<updated>2008-03-20T14:26:13Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* Circuitry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
&lt;br /&gt;
[[Image:LearningOscMC |thumb|150px|right| Main Circuit]]&lt;br /&gt;
&lt;br /&gt;
[[Image:LearningOscAM |thumb|150px|right| Accelerometer on mass]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main elements of the circuit were a PIC, DAC ([[http://hades.mech.northwestern.edu/wiki/index.php/PIC18F4520:_Serial_Digital-to-Analog_Conversion Digital-to-Analog converter]]) and accelerometer. The PIC would store a discretized sine waveform with integer values from 0-255. It would then output a function of this sine wave (our control signal) to the DAC. The analog signal output from the DAC would be sent to the amplifier, which would then power the speaker. The accelerometer on the mass would feedback the actual acceleration profile of the mass back to Matlab. Matlab would then recompute the next control signal and repeat the cycle until the mass was moving with the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Great results were achieved from the learning algorithm. For engineers working on it in the future, here are some topics for further investigation to get a more complete understanding about the control system:&lt;br /&gt;
&lt;br /&gt;
* In this project, the control signal was manually phase-shifted by pi radians before outputting it to the speaker&lt;br /&gt;
** This made the algorithm work perfectly&lt;br /&gt;
** It is not well-understood why this step was necessary&lt;br /&gt;
** The algorithm would not work otherwise&lt;br /&gt;
&lt;br /&gt;
* In the input for the FFT, the transfer function used in this project did not have an imaginary component&lt;br /&gt;
** The robust algorithm still worked perfectly, and would shift phase and &#039;learn&#039; when the program was run&lt;br /&gt;
** In future experiments, a transfer function including an imaginary term could be used, to fully utilize the capabilities of the algorithm&lt;br /&gt;
&lt;br /&gt;
* Faster learning&lt;br /&gt;
** The various constants in the algorithm equations can be tweaked for faster learning&lt;br /&gt;
** Currently, it takes about 10-20 iterations to hit the desired waveform&lt;br /&gt;
** More rapid learning would be a huge benefit in real-world applications&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [http://electronics.howstuffworks.com/speaker5.htm How speakers work]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/~lynch/ Professor Kevin Lynch]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/students/vose/ Tom Vose], author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8100</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8100"/>
		<updated>2008-03-20T14:25:37Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* Circuitry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
&lt;br /&gt;
[[Image:LearningOscMC |thumb|300px|center| Main Circuit]]&lt;br /&gt;
&lt;br /&gt;
[[Image:LearningOscAM |thumb|300px|right| Accelerometer on mass]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main elements of the circuit were a PIC, DAC ([[http://hades.mech.northwestern.edu/wiki/index.php/PIC18F4520:_Serial_Digital-to-Analog_Conversion Digital-to-Analog converter]]) and accelerometer. The PIC would store a discretized sine waveform with integer values from 0-255. It would then output a function of this sine wave (our control signal) to the DAC. The analog signal output from the DAC would be sent to the amplifier, which would then power the speaker. The accelerometer on the mass would feedback the actual acceleration profile of the mass back to Matlab. Matlab would then recompute the next control signal and repeat the cycle until the mass was moving with the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Great results were achieved from the learning algorithm. For engineers working on it in the future, here are some topics for further investigation to get a more complete understanding about the control system:&lt;br /&gt;
&lt;br /&gt;
* In this project, the control signal was manually phase-shifted by pi radians before outputting it to the speaker&lt;br /&gt;
** This made the algorithm work perfectly&lt;br /&gt;
** It is not well-understood why this step was necessary&lt;br /&gt;
** The algorithm would not work otherwise&lt;br /&gt;
&lt;br /&gt;
* In the input for the FFT, the transfer function used in this project did not have an imaginary component&lt;br /&gt;
** The robust algorithm still worked perfectly, and would shift phase and &#039;learn&#039; when the program was run&lt;br /&gt;
** In future experiments, a transfer function including an imaginary term could be used, to fully utilize the capabilities of the algorithm&lt;br /&gt;
&lt;br /&gt;
* Faster learning&lt;br /&gt;
** The various constants in the algorithm equations can be tweaked for faster learning&lt;br /&gt;
** Currently, it takes about 10-20 iterations to hit the desired waveform&lt;br /&gt;
** More rapid learning would be a huge benefit in real-world applications&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [http://electronics.howstuffworks.com/speaker5.htm How speakers work]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/~lynch/ Professor Kevin Lynch]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/students/vose/ Tom Vose], author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8099</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8099"/>
		<updated>2008-03-20T14:25:19Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* Circuitry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
&lt;br /&gt;
[[Image:LearningOscMC |thumb|300px|left| Main Circuit]]&lt;br /&gt;
&lt;br /&gt;
[[Image:LearningOscAM |thumb|300px|right| Accelerometer on mass]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main elements of the circuit were a PIC, DAC ([[http://hades.mech.northwestern.edu/wiki/index.php/PIC18F4520:_Serial_Digital-to-Analog_Conversion Digital-to-Analog converter]]) and accelerometer. The PIC would store a discretized sine waveform with integer values from 0-255. It would then output a function of this sine wave (our control signal) to the DAC. The analog signal output from the DAC would be sent to the amplifier, which would then power the speaker. The accelerometer on the mass would feedback the actual acceleration profile of the mass back to Matlab. Matlab would then recompute the next control signal and repeat the cycle until the mass was moving with the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Great results were achieved from the learning algorithm. For engineers working on it in the future, here are some topics for further investigation to get a more complete understanding about the control system:&lt;br /&gt;
&lt;br /&gt;
* In this project, the control signal was manually phase-shifted by pi radians before outputting it to the speaker&lt;br /&gt;
** This made the algorithm work perfectly&lt;br /&gt;
** It is not well-understood why this step was necessary&lt;br /&gt;
** The algorithm would not work otherwise&lt;br /&gt;
&lt;br /&gt;
* In the input for the FFT, the transfer function used in this project did not have an imaginary component&lt;br /&gt;
** The robust algorithm still worked perfectly, and would shift phase and &#039;learn&#039; when the program was run&lt;br /&gt;
** In future experiments, a transfer function including an imaginary term could be used, to fully utilize the capabilities of the algorithm&lt;br /&gt;
&lt;br /&gt;
* Faster learning&lt;br /&gt;
** The various constants in the algorithm equations can be tweaked for faster learning&lt;br /&gt;
** Currently, it takes about 10-20 iterations to hit the desired waveform&lt;br /&gt;
** More rapid learning would be a huge benefit in real-world applications&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [http://electronics.howstuffworks.com/speaker5.htm How speakers work]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/~lynch/ Professor Kevin Lynch]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/students/vose/ Tom Vose], author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:LearningOscAM&amp;diff=8098</id>
		<title>File:LearningOscAM</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:LearningOscAM&amp;diff=8098"/>
		<updated>2008-03-20T14:24:26Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:LearningOscAM.jpg&amp;diff=8097</id>
		<title>File:LearningOscAM.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:LearningOscAM.jpg&amp;diff=8097"/>
		<updated>2008-03-20T14:23:51Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8096</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8096"/>
		<updated>2008-03-20T14:23:31Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* Circuitry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
&lt;br /&gt;
[[Image:LearningOscMC |thumb|300px|right| Main Circuit]]&lt;br /&gt;
&lt;br /&gt;
[[Image:LearningOscAM |thumb|300px|right| Accelerometer on mass]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main elements of the circuit were a PIC, DAC ([[http://hades.mech.northwestern.edu/wiki/index.php/PIC18F4520:_Serial_Digital-to-Analog_Conversion Digital-to-Analog converter]]) and accelerometer. The PIC would store a discretized sine waveform with integer values from 0-255. It would then output a function of this sine wave (our control signal) to the DAC. The analog signal output from the DAC would be sent to the amplifier, which would then power the speaker. The accelerometer on the mass would feedback the actual acceleration profile of the mass back to Matlab. Matlab would then recompute the next control signal and repeat the cycle until the mass was moving with the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Great results were achieved from the learning algorithm. For engineers working on it in the future, here are some topics for further investigation to get a more complete understanding about the control system:&lt;br /&gt;
&lt;br /&gt;
* In this project, the control signal was manually phase-shifted by pi radians before outputting it to the speaker&lt;br /&gt;
** This made the algorithm work perfectly&lt;br /&gt;
** It is not well-understood why this step was necessary&lt;br /&gt;
** The algorithm would not work otherwise&lt;br /&gt;
&lt;br /&gt;
* In the input for the FFT, the transfer function used in this project did not have an imaginary component&lt;br /&gt;
** The robust algorithm still worked perfectly, and would shift phase and &#039;learn&#039; when the program was run&lt;br /&gt;
** In future experiments, a transfer function including an imaginary term could be used, to fully utilize the capabilities of the algorithm&lt;br /&gt;
&lt;br /&gt;
* Faster learning&lt;br /&gt;
** The various constants in the algorithm equations can be tweaked for faster learning&lt;br /&gt;
** Currently, it takes about 10-20 iterations to hit the desired waveform&lt;br /&gt;
** More rapid learning would be a huge benefit in real-world applications&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [http://electronics.howstuffworks.com/speaker5.htm How speakers work]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/~lynch/ Professor Kevin Lynch]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/students/vose/ Tom Vose], author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:LearningOscMC.jpg&amp;diff=8095</id>
		<title>File:LearningOscMC.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:LearningOscMC.jpg&amp;diff=8095"/>
		<updated>2008-03-20T14:21:57Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:LearningOscMC&amp;diff=8094</id>
		<title>File:LearningOscMC</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:LearningOscMC&amp;diff=8094"/>
		<updated>2008-03-20T14:21:19Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8093</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8093"/>
		<updated>2008-03-20T14:20:43Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* Circuitry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Main Circuit |thumb|300px|right| Main Circuit]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Main Circuit |thumb|300px|right| Accelerometer on mass]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main elements of the circuit were a PIC, DAC ([[http://hades.mech.northwestern.edu/wiki/index.php/PIC18F4520:_Serial_Digital-to-Analog_Conversion Digital-to-Analog converter]]) and accelerometer. The PIC would store a discretized sine waveform with integer values from 0-255. It would then output a function of this sine wave (our control signal) to the DAC. The analog signal output from the DAC would be sent to the amplifier, which would then power the speaker. The accelerometer on the mass would feedback the actual acceleration profile of the mass back to Matlab. Matlab would then recompute the next control signal and repeat the cycle until the mass was moving with the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Great results were achieved from the learning algorithm. For engineers working on it in the future, here are some topics for further investigation to get a more complete understanding about the control system:&lt;br /&gt;
&lt;br /&gt;
* In this project, the control signal was manually phase-shifted by pi radians before outputting it to the speaker&lt;br /&gt;
** This made the algorithm work perfectly&lt;br /&gt;
** It is not well-understood why this step was necessary&lt;br /&gt;
** The algorithm would not work otherwise&lt;br /&gt;
&lt;br /&gt;
* In the input for the FFT, the transfer function used in this project did not have an imaginary component&lt;br /&gt;
** The robust algorithm still worked perfectly, and would shift phase and &#039;learn&#039; when the program was run&lt;br /&gt;
** In future experiments, a transfer function including an imaginary term could be used, to fully utilize the capabilities of the algorithm&lt;br /&gt;
&lt;br /&gt;
* Faster learning&lt;br /&gt;
** The various constants in the algorithm equations can be tweaked for faster learning&lt;br /&gt;
** Currently, it takes about 10-20 iterations to hit the desired waveform&lt;br /&gt;
** More rapid learning would be a huge benefit in real-world applications&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [http://electronics.howstuffworks.com/speaker5.htm How speakers work]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/~lynch/ Professor Kevin Lynch]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/students/vose/ Tom Vose], author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8092</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8092"/>
		<updated>2008-03-20T14:15:44Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* Circuitry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
The main elements of the circuit were a PIC, DAC ([[http://hades.mech.northwestern.edu/wiki/index.php/PIC18F4520:_Serial_Digital-to-Analog_Conversion Digital-to-Analog converter]]) and accelerometer. The PIC would store a discretized sine waveform with integer values from 0-255. It would then output a function of this sine wave (our control signal) to the DAC. The analog signal output from the DAC would be sent to the amplifier, which would then power the speaker. The accelerometer on the mass would feedback the actual acceleration profile of the mass back to Matlab. Matlab would then recompute the next control signal and repeat the cycle until the mass was moving with the desired acceleration profile. &lt;br /&gt;
&lt;br /&gt;
[[Image:Main Circuit |thumb|300px|left| Main Circuit]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Main Circuit |thumb|300px|right| Accelerometer on mass]]&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Great results were achieved from the learning algorithm. For engineers working on it in the future, here are some topics for further investigation to get a more complete understanding about the control system:&lt;br /&gt;
&lt;br /&gt;
* In this project, the control signal was manually phase-shifted by pi radians before outputting it to the speaker&lt;br /&gt;
** This made the algorithm work perfectly&lt;br /&gt;
** It is not well-understood why this step was necessary&lt;br /&gt;
** The algorithm would not work otherwise&lt;br /&gt;
&lt;br /&gt;
* In the input for the FFT, the transfer function used in this project did not have an imaginary component&lt;br /&gt;
** The robust algorithm still worked perfectly, and would shift phase and &#039;learn&#039; when the program was run&lt;br /&gt;
** In future experiments, a transfer function including an imaginary term could be used, to fully utilize the capabilities of the algorithm&lt;br /&gt;
&lt;br /&gt;
* Faster learning&lt;br /&gt;
** The various constants in the algorithm equations can be tweaked for faster learning&lt;br /&gt;
** Currently, it takes about 10-20 iterations to hit the desired waveform&lt;br /&gt;
** More rapid learning would be a huge benefit in real-world applications&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [http://electronics.howstuffworks.com/speaker5.htm How speakers work]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/~lynch/ Professor Kevin Lynch]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/students/vose/ Tom Vose], author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8091</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8091"/>
		<updated>2008-03-20T14:14:16Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* Circuitry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
The main elements of the circuit were a PIC, DAC ([[http://hades.mech.northwestern.edu/wiki/index.php/PIC18F4520:_Serial_Digital-to-Analog_Conversion Digital-to-Analog converter]]) and accelerometer. The PIC would store a discretized sine waveform with integer values from 0-255. It would then output a function of this sine wave (our control signal) to the DAC. The analog signal output from the DAC would be sent to the amplifier, which would then power the speaker. The accelerometer on the mass would feedback the actual acceleration profile of the mass back to Matlab. Matlab would then recompute the next control signal and repeat the cycle until the mass was moving with the desired acceleration profile. &lt;br /&gt;
&lt;br /&gt;
[[|thumb|300px|left| Main Circuit]]&lt;br /&gt;
&lt;br /&gt;
[[|thumb|300px|right| Accelerometer on mass]]&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Great results were achieved from the learning algorithm. For engineers working on it in the future, here are some topics for further investigation to get a more complete understanding about the control system:&lt;br /&gt;
&lt;br /&gt;
* In this project, the control signal was manually phase-shifted by pi radians before outputting it to the speaker&lt;br /&gt;
** This made the algorithm work perfectly&lt;br /&gt;
** It is not well-understood why this step was necessary&lt;br /&gt;
** The algorithm would not work otherwise&lt;br /&gt;
&lt;br /&gt;
* In the input for the FFT, the transfer function used in this project did not have an imaginary component&lt;br /&gt;
** The robust algorithm still worked perfectly, and would shift phase and &#039;learn&#039; when the program was run&lt;br /&gt;
** In future experiments, a transfer function including an imaginary term could be used, to fully utilize the capabilities of the algorithm&lt;br /&gt;
&lt;br /&gt;
* Faster learning&lt;br /&gt;
** The various constants in the algorithm equations can be tweaked for faster learning&lt;br /&gt;
** Currently, it takes about 10-20 iterations to hit the desired waveform&lt;br /&gt;
** More rapid learning would be a huge benefit in real-world applications&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [http://electronics.howstuffworks.com/speaker5.htm How speakers work]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/~lynch/ Professor Kevin Lynch]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/students/vose/ Tom Vose], author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8090</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8090"/>
		<updated>2008-03-20T14:01:17Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Great results were achieved from the learning algorithm. For engineers working on it in the future, here are some topics for further investigation to get a more complete understanding about the control system:&lt;br /&gt;
&lt;br /&gt;
* In this project, the control signal was manually phase-shifted by pi radians before outputting it to the speaker&lt;br /&gt;
** This made the algorithm work perfectly&lt;br /&gt;
** It is not well-understood why this step was necessary&lt;br /&gt;
** The algorithm would not work otherwise&lt;br /&gt;
&lt;br /&gt;
* In the input for the FFT, the transfer function used in this project did not have an imaginary component&lt;br /&gt;
** The robust algorithm still worked perfectly, and would shift phase and &#039;learn&#039; when the program was run&lt;br /&gt;
** In future experiments, a transfer function including an imaginary term could be used, to fully utilize the capabilities of the algorithm&lt;br /&gt;
&lt;br /&gt;
* Faster learning&lt;br /&gt;
** The various constants in the algorithm equations can be tweaked for faster learning&lt;br /&gt;
** Currently, it takes about 10-20 iterations to hit the desired waveform&lt;br /&gt;
** More rapid learning would be a huge benefit in real-world applications&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [http://electronics.howstuffworks.com/speaker5.htm How speakers work]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/~lynch/ Professor Kevin Lynch]&lt;br /&gt;
* [http://lims.mech.northwestern.edu/students/vose/ Tom Vose], author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8089</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8089"/>
		<updated>2008-03-20T13:59:55Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* Reflections */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
Great results were achieved from the learning algorithm. For engineers working on it in the future, here are some topics for further investigation to get a more complete understanding about the control system:&lt;br /&gt;
&lt;br /&gt;
* In this project, the control signal was manually phase-shifted by pi radians before outputting it to the speaker&lt;br /&gt;
** This made the algorithm work perfectly&lt;br /&gt;
** It is not well-understood why this step was necessary&lt;br /&gt;
** The algorithm would not work otherwise&lt;br /&gt;
&lt;br /&gt;
* In the input for the FFT, the transfer function used in this project did not have an imaginary component&lt;br /&gt;
** The robust algorithm still worked perfectly, and would shift phase and &#039;learn&#039; when the program was run&lt;br /&gt;
** In future experiments, a transfer function including an imaginary term could be used, to fully utilize the capabilities of the algorithm&lt;br /&gt;
&lt;br /&gt;
* Faster learning&lt;br /&gt;
** The various constants in the algorithm equations can be tweaked for faster learning&lt;br /&gt;
** Currently, it takes about 10-20 iterations to hit the desired waveform&lt;br /&gt;
** More rapid learning would be a huge benefit in real-world applications&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [http://electronics.howstuffworks.com/speaker5.htm How speakers work]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* Professor Kevin Lynch&lt;br /&gt;
* Tom Vose, author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8087</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8087"/>
		<updated>2008-03-20T13:45:28Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [http://electronics.howstuffworks.com/speaker5.htm How speakers work]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* Professor Kevin Lynch&lt;br /&gt;
* Tom Vose, author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8086</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8086"/>
		<updated>2008-03-20T13:43:31Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [How speakers work]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* Professor Kevin Lynch&lt;br /&gt;
* Tom Vose, author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8085</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8085"/>
		<updated>2008-03-20T13:42:30Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [[How speakers work]]&lt;br /&gt;
* [[Iterative Learning Control]]&lt;br /&gt;
* Professor Kevin Lynch&lt;br /&gt;
* Tom Vose, author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Iterative_Learning_Control&amp;diff=8084</id>
		<title>File:Iterative Learning Control</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Iterative_Learning_Control&amp;diff=8084"/>
		<updated>2008-03-20T13:38:38Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8083</id>
		<title>Intelligent Oscillation Controller</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Intelligent_Oscillation_Controller&amp;diff=8083"/>
		<updated>2008-03-20T13:37:57Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
&#039;&#039;&#039;Scott Mcleod:&#039;&#039;&#039; &#039;&#039;Electrical Engineering Class of 2009&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Brett Pihl:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sandeep Prabhu:&#039;&#039;&#039; &#039;&#039;Mechanical Engineering Class of 2008&lt;br /&gt;
&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to &amp;quot;learn.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mechanics ==&lt;br /&gt;
&lt;br /&gt;
The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex. This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The forces exerted by the speaker are small enough (our measurements show only about 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn&#039;t require any additional mass to satisfy this constraint. The other end of the rod simply attached to the block which we machined and mounted atop the bearing. A piece of sheet metal was screwed into the other side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection.&lt;br /&gt;
&lt;br /&gt;
It is important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.&lt;br /&gt;
&lt;br /&gt;
The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed. &lt;br /&gt;
&lt;br /&gt;
This current design is advantageous  because it is modular. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.&lt;br /&gt;
&lt;br /&gt;
== Circuitry ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
=== PIC Code ===&lt;br /&gt;
In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals.  Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable.  This setup simplified the program for the PIC.&lt;br /&gt;
&lt;br /&gt;
To generate the waveform of voltage levels sent to the speaker, a single quantized period was used.  Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion.  The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.&lt;br /&gt;
&lt;br /&gt;
Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals.  We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR).  To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform).  For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_main.c|&#039;&#039;&#039;PIC Learning Control&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_pic_bode.c|&#039;&#039;&#039;PIC Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Matlab Code ===&lt;br /&gt;
The Matlab code simply follows the protocol as established above.  The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform.  *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).&lt;br /&gt;
&lt;br /&gt;
Below are the 4 m files used in Matlab.  Their names must be changed to the last part of their filenames as they are functions.&lt;br /&gt;
&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_main.m|&#039;&#039;&#039;Main Matlab Loop&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_learn.m|&#039;&#039;&#039;Learning Control Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_smooth.m|&#039;&#039;&#039;Smoothing Algorithm&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_startplot.m|&#039;&#039;&#039;Plot Initialization Code&#039;&#039;&#039;]]&lt;br /&gt;
 [[Media:ME333_Learning_Oscillator_bode.m|&#039;&#039;&#039;Bode Plot Generator&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
=== Program Flow ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Program_Flow.jpg|center|thumb|400px|Program Flow]]&lt;br /&gt;
&lt;br /&gt;
=== Control System ===&lt;br /&gt;
To “learn” the control voltages to create a desired waveform, a simple proportional control system was used.  We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project.  Below is our understanding of Tom’s control algorithm.&lt;br /&gt;
&lt;br /&gt;
The system first guesses a control voltage of all zeros.  This ideally results in no forcing of the speaker and a flat response of acceleration.  After this initial guess, the program uses proportional control to match the desired acceleration waveform.  Mathematically, it multiplies the error by a proportional factor k.  The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration.  This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz.  The resulting signal is the control signal u, in the frequency domain.  From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC.  All of the math is computed in discrete time, for the waveforms of 100 samples long.  Below is a block diagram of this control system.  Note that it is in the standard unity feedback form.&lt;br /&gt;
&lt;br /&gt;
[[Image:Oscillator_Control_System.jpg|center|933x200 px|Learning Control System]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Below are three tests performed on various superpositions of sin waves at 10 and 20Hz.  We have adjusted the phase of the waves to produce different results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery Caption=&amp;quot;Matlab Plots Acceleration Desired vs. Experimental Acceleration&amp;quot;&amp;gt;&lt;br /&gt;
Image:Oscillator_test1.jpg|Wave 1&lt;br /&gt;
Image:Oscillator_test2.jpg|Wave 2&lt;br /&gt;
Image:Oscillator_test3.jpg|Wave 3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each diagram, shows one period of an acceleration profile.  The faint blue curve in the left subplot is the desired acceleration motion.  The red lines on top of the blue curve are experimental accelerations as recorded by the pic.  We can see that the red lines converge on top of the desired blue motion.  The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.&lt;br /&gt;
&lt;br /&gt;
Each wave follows the equation below with the given parameters:&lt;br /&gt;
&lt;br /&gt;
acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)&lt;br /&gt;
&lt;br /&gt;
Wave 1: phi1 = 1, phi2 = 2&lt;br /&gt;
Wave 2: phi1 = 0, phi2 = 0&lt;br /&gt;
Wave 3: phi1 = 1, phi2 = 0&lt;br /&gt;
&lt;br /&gt;
== Potential Applications ==&lt;br /&gt;
&lt;br /&gt;
A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.&lt;br /&gt;
&lt;br /&gt;
== Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [How speakers work]&lt;br /&gt;
2. [[Media:Iterative Learning Control]]&lt;br /&gt;
3. Professor Kevin Lynch&lt;br /&gt;
4. Tom Vose, author of the learning algorithm used in this project&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=7246</id>
		<title>ME 333 final projects</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=7246"/>
		<updated>2008-03-08T20:02:25Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* Frequency Learner */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[ME 333 end of course schedule]]&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== ME 333 Final Projects 2008 ==&lt;br /&gt;
&lt;br /&gt;
=== [[IR Tracker]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Pctopic.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
The IR Tracker detects the position of an infrared emitter in two axises, and orients itself to line up with the emitter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Project Title 2]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Pictopic.jpg|right|thumb|200px]] &lt;br /&gt;
&lt;br /&gt;
Here are a few words describing your project, just a teaser to go with the picture at the side.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Learning Oscillator]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:vibrator.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
The Learning Oscillator is given a desired acceleration profile for a linear oscillating mass. It then &#039;learns&#039; and adjusts the frequency of its force source so the oscillating mass eventually matches the desired acceleration profile. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=7245</id>
		<title>ME 333 final projects</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=7245"/>
		<updated>2008-03-08T19:55:52Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* ME 333 Final Projects 2008 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[ME 333 end of course schedule]]&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== ME 333 Final Projects 2008 ==&lt;br /&gt;
&lt;br /&gt;
=== [[IR Tracker]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Pctopic.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
The IR Tracker detects the position of an infrared emitter in two axises, and orients itself to line up with the emitter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Project Title 2]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Pictopic.jpg|right|thumb|200px]] &lt;br /&gt;
&lt;br /&gt;
Here are a few words describing your project, just a teaser to go with the picture at the side.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Frequency Learner]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:vibrator.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
The Frequency Learner controls the force source of a linear oscillator so the actual frequency of the oscillating mass matches a desired frequency profile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Serial_communication_with_Matlab&amp;diff=6574</id>
		<title>Serial communication with Matlab</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Serial_communication_with_Matlab&amp;diff=6574"/>
		<updated>2008-02-06T02:18:20Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
Matlab has a &amp;quot;serial&amp;quot; function that allows it to communicate through a serial port.  This project is to establish serial port connection with the PIC and demonstrate bidirectional communication between the PIC and a Matlab program, using, for example, a USB to RS232 adapter and level shifter chip.  The Matlab program could simply log data from the PIC (e.g., the angle of a potentiometer knob), or plot it on a user interface in real time.  Keystrokes from the user of the Matlab program should be obviously received by the PIC, perhaps by lighting the LEDs on the PIC board.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
Matlab has a &amp;quot;serial&amp;quot; function that allows it to communicate through a serial port. This project is to establish serial port connection with the PIC and demonstrate bidirectional communication between the PIC and a Matlab program. To demonstrate this, the PIC will send potentiometer readings to Matlab as well as receive keystrokes from the Matlab user to light up LEDs on its circuit board.&lt;br /&gt;
&lt;br /&gt;
A USB to RS232 adapter and level shifter chip were used to hook up the computer to the PIC. A level shifter is necessary because the power/ground voltages are different for the desktop computer and the PIC. An RS232 plug looks like this: http://www.aggsoft.com/rs232-pinout-cable/serial-cable-connections.htm&lt;br /&gt;
&lt;br /&gt;
The RS232 was wired to our level shifter to convert the voltages, and then the level shifter was wired to our PIC. Refer to the Circuit section for details.&lt;br /&gt;
&lt;br /&gt;
First, the PIC was stamped with our C code (Refer to PIC Code below). It was programmed to read the potentiometer readings from its ADC (Analog to Digital Convertor) port and transmit the digitized readings through the RS232 cables to Matlab. If the Matlab user typed a character, the PIC was also programmed to display the character on its LED array. (8 on/off LEDs represent the 1 byte binary equivalent of any character). In real-time, Matlab would display the potentiometer reading from the PIC and the PIC LEDs would display the keystroke from the user.&lt;br /&gt;
&lt;br /&gt;
== Circuit ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== PIC Code ==&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
    SerialComm.c Scott McLeod, Sandeep Prabhu, Brett Pihl 2/4/2008&lt;br /&gt;
    This program is designed to communicate to a computer using RS232 (Serial) Communication.&lt;br /&gt;
    &lt;br /&gt;
    The main loop of this program waits for a data transmission over the Serial port, and&lt;br /&gt;
    responds with a current reading of an analog input (potentiometer) and the last received data.&lt;br /&gt;
   &lt;br /&gt;
    Note the analog input is only for testing purposes, and is not necessary for serial communication.&lt;br /&gt;
    Lines unnecessary for RS232 communication are commented with enclosing asterisks (&#039;*..*&#039;).&lt;br /&gt;
  */&lt;br /&gt;
  &lt;br /&gt;
 #include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 #fuses HS,NOLVP,NOWDT,NOPROTECT&lt;br /&gt;
 #DEVICE ADC=8                          // *set ADC to 8 bit accuracy*&lt;br /&gt;
 #use delay(clock=20000000)             // 20 MHz clock&lt;br /&gt;
 #use rs232(baud=19200, UART1)          // Set up PIC UART on RC6 (tx) and RC7 (rx)  &lt;br /&gt;
  &lt;br /&gt;
 int8 data_tx, data_rx = 0;             // Set up data_tx (transmit value), data_rx (recieve value)&lt;br /&gt;
  &lt;br /&gt;
 void main()&lt;br /&gt;
 {&lt;br /&gt;
    setup_adc_ports(AN0);               // *Enable AN0 as analog potentiometer input*&lt;br /&gt;
    setup_adc(ADC_CLOCK_INTERNAL);      // *the range selected has to start with AN0*&lt;br /&gt;
    set_adc_channel(0);                 // *Enable AN0 as analog input*&lt;br /&gt;
    delay_us(10);                       // *Pause 10us to set up ADC*&lt;br /&gt;
    &lt;br /&gt;
    while (TRUE)&lt;br /&gt;
    {&lt;br /&gt;
       data_tx = read_adc();            // *Read POT on analog port (0-255)*&lt;br /&gt;
       output_d(data_rx);               // Output last recieved value from computer&lt;br /&gt;
       delay_ms(10);&lt;br /&gt;
       &lt;br /&gt;
       if (kbhit())                     // If PIC senses data pushed to serial buffer&lt;br /&gt;
       {&lt;br /&gt;
          data_rx = fgetc();            // Read in recieved value from buffer&lt;br /&gt;
          printf(&amp;quot;Pot: %u Char: %u\n&amp;quot;, data_tx, data_rx);  // Once data sent and read, PIC sends data back&lt;br /&gt;
          delay_ms(100);&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Matlab Code ==&lt;br /&gt;
 %  SerialComm.m  Scott McLeod, Sandeep Prabhu, Brett Pihl 2/4/2008&lt;br /&gt;
 %  This program is designed to communicate to a PIC 18F4520 via RS232 (Serial) Communication.&lt;br /&gt;
 %  &lt;br /&gt;
 %  The main loop of this program waits for a character input from the user,&lt;br /&gt;
 %  upon which it transmits the ascii value and waits for data to be written.&lt;br /&gt;
 &lt;br /&gt;
 s = serial(&#039;COM14&#039;,&#039;BAUD&#039;,19200);           % Create serial object (PORT Dependent)&lt;br /&gt;
 fopen(s)                                    % Open the serial port for r/w&lt;br /&gt;
 &lt;br /&gt;
 myChar = &#039;a&#039;;                               &lt;br /&gt;
 prompt = &#039;Enter a character (q to exit): &#039;; &lt;br /&gt;
 &lt;br /&gt;
 while (myChar ~= &#039;q&#039;)                       % While user hasn&#039;t typed &#039;q&#039;&lt;br /&gt;
     myChar = input(prompt, &#039;s&#039;);            % Get user input&lt;br /&gt;
     fprintf(s, &#039;%s&#039;, myChar(1))             % Write first char of user input to serial port&lt;br /&gt;
     fprintf(fscanf(s))                      % Read Data back from PIC&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 fclose(s);                                  % Close the serial port&lt;br /&gt;
 delete(s);                                  % Delete the serial object&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If your program doesn&#039;t close and delete the serial port object correctly, you can use the command shown below to delete all of the serial port objects.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 delete(instrfind)&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Serial_communication_with_Matlab&amp;diff=6573</id>
		<title>Serial communication with Matlab</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Serial_communication_with_Matlab&amp;diff=6573"/>
		<updated>2008-02-06T02:14:34Z</updated>

		<summary type="html">&lt;p&gt;SandeepPrabhu: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
Matlab has a &amp;quot;serial&amp;quot; function that allows it to communicate through a serial port.  This project is to establish serial port connection with the PIC and demonstrate bidirectional communication between the PIC and a Matlab program, using, for example, a USB to RS232 adapter and level shifter chip.  The Matlab program could simply log data from the PIC (e.g., the angle of a potentiometer knob), or plot it on a user interface in real time.  Keystrokes from the user of the Matlab program should be obviously received by the PIC, perhaps by lighting the LEDs on the PIC board.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
Matlab has a &amp;quot;serial&amp;quot; function that allows it to communicate through a serial port. This project is to establish serial port connection with the PIC and demonstrate bidirectional communication between the PIC and a Matlab program. To demonstrate this, the PIC will send potentiometer readings to Matlab as well as receive keystrokes from the Matlab user to light up LEDs on its circuit board.&lt;br /&gt;
&lt;br /&gt;
A USB to RS232 adapter and level shifter chip were used to hook up the computer to the PIC. A level shifter is necessary because the power/ground voltages are different for the desktop computer and the PIC. An RS232 plug looks like this: http://www.aggsoft.com/rs232-pinout-cable/serial-cable-connections.htm&lt;br /&gt;
&lt;br /&gt;
The RS232 was wired to our level shifter to convert the voltages, and then the level shifter was wired to our PIC. Refer to the Circuit section for details.&lt;br /&gt;
&lt;br /&gt;
First, we stamped the PIC with our C code (Refer to PIC Code below). It was programmed to read the potentiometer readings from its ADC (Analog to Digital Convertor) port and transmit the digitized readings through the RS232 cables to Matlab. If the Matlab user typed a character, the PIC was also programmed to display the character on its LED array. (8 on/off LEDs represent the 1 byte binary equivalent of any character)&lt;br /&gt;
&lt;br /&gt;
In this way, Serial communication between a PIC and Matlab was demonstrated.&lt;br /&gt;
&lt;br /&gt;
== Circuit ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== PIC Code ==&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
    SerialComm.c Scott McLeod, Sandeep Prabhu, Brett Pihl 2/4/2008&lt;br /&gt;
    This program is designed to communicate to a computer using RS232 (Serial) Communication.&lt;br /&gt;
    &lt;br /&gt;
    The main loop of this program waits for a data transmission over the Serial port, and&lt;br /&gt;
    responds with a current reading of an analog input (potentiometer) and the last received data.&lt;br /&gt;
   &lt;br /&gt;
    Note the analog input is only for testing purposes, and is not necessary for serial communication.&lt;br /&gt;
    Lines unnecessary for RS232 communication are commented with enclosing asterisks (&#039;*..*&#039;).&lt;br /&gt;
  */&lt;br /&gt;
  &lt;br /&gt;
 #include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 #fuses HS,NOLVP,NOWDT,NOPROTECT&lt;br /&gt;
 #DEVICE ADC=8                          // *set ADC to 8 bit accuracy*&lt;br /&gt;
 #use delay(clock=20000000)             // 20 MHz clock&lt;br /&gt;
 #use rs232(baud=19200, UART1)          // Set up PIC UART on RC6 (tx) and RC7 (rx)  &lt;br /&gt;
  &lt;br /&gt;
 int8 data_tx, data_rx = 0;             // Set up data_tx (transmit value), data_rx (recieve value)&lt;br /&gt;
  &lt;br /&gt;
 void main()&lt;br /&gt;
 {&lt;br /&gt;
    setup_adc_ports(AN0);               // *Enable AN0 as analog potentiometer input*&lt;br /&gt;
    setup_adc(ADC_CLOCK_INTERNAL);      // *the range selected has to start with AN0*&lt;br /&gt;
    set_adc_channel(0);                 // *Enable AN0 as analog input*&lt;br /&gt;
    delay_us(10);                       // *Pause 10us to set up ADC*&lt;br /&gt;
    &lt;br /&gt;
    while (TRUE)&lt;br /&gt;
    {&lt;br /&gt;
       data_tx = read_adc();            // *Read POT on analog port (0-255)*&lt;br /&gt;
       output_d(data_rx);               // Output last recieved value from computer&lt;br /&gt;
       delay_ms(10);&lt;br /&gt;
       &lt;br /&gt;
       if (kbhit())                     // If PIC senses data pushed to serial buffer&lt;br /&gt;
       {&lt;br /&gt;
          data_rx = fgetc();            // Read in recieved value from buffer&lt;br /&gt;
          printf(&amp;quot;Pot: %u Char: %u\n&amp;quot;, data_tx, data_rx);  // Once data sent and read, PIC sends data back&lt;br /&gt;
          delay_ms(100);&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Matlab Code ==&lt;br /&gt;
 %  SerialComm.m  Scott McLeod, Sandeep Prabhu, Brett Pihl 2/4/2008&lt;br /&gt;
 %  This program is designed to communicate to a PIC 18F4520 via RS232 (Serial) Communication.&lt;br /&gt;
 %  &lt;br /&gt;
 %  The main loop of this program waits for a character input from the user,&lt;br /&gt;
 %  upon which it transmits the ascii value and waits for data to be written.&lt;br /&gt;
 &lt;br /&gt;
 s = serial(&#039;COM14&#039;,&#039;BAUD&#039;,19200);           % Create serial object (PORT Dependent)&lt;br /&gt;
 fopen(s)                                    % Open the serial port for r/w&lt;br /&gt;
 &lt;br /&gt;
 myChar = &#039;a&#039;;                               &lt;br /&gt;
 prompt = &#039;Enter a character (q to exit): &#039;; &lt;br /&gt;
 &lt;br /&gt;
 while (myChar ~= &#039;q&#039;)                       % While user hasn&#039;t typed &#039;q&#039;&lt;br /&gt;
     myChar = input(prompt, &#039;s&#039;);            % Get user input&lt;br /&gt;
     fprintf(s, &#039;%s&#039;, myChar(1))             % Write first char of user input to serial port&lt;br /&gt;
     fprintf(fscanf(s))                      % Read Data back from PIC&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 fclose(s);                                  % Close the serial port&lt;br /&gt;
 delete(s);                                  % Delete the serial object&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If your program doesn&#039;t close and delete the serial port object correctly, you can use the command shown below to delete all of the serial port objects.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 delete(instrfind)&lt;/div&gt;</summary>
		<author><name>SandeepPrabhu</name></author>
	</entry>
</feed>