<?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=Chris+Chow</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=Chris+Chow"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php/Special:Contributions/Chris_Chow"/>
	<updated>2026-05-14T22:05:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11735</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11735"/>
		<updated>2009-03-19T04:36:57Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Experimental Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project also includes a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
=== Equations ===&lt;br /&gt;
As explained in the overview, the Chladni plate generates patterns when the frequency of the plate oscillation is at a resonant frequency for the plate. At resonance, the plate has portions where it has non-zero amplitude during oscillation, which is where the salt moves away from toward areas of zero amplitude. Areas of zero amplitude are called nodes or zeros of vibration, and salt collects at these regions on the plate at resonance. The nodes of vibration of a circular or square plate can be mathematically calculated for different modes of vibration.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation [[image:chladni_zeros_square_plate]] solves for the zeros of the standing wave for a square plate constrained at the center, such as the one we used for our one-speaker configuration. The variable L is the side length of the plate, m is the number of diametric nodes and n is the number of radial nodes. Solve for x and y to get the zero locations.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation to find the zeros for a circular plate is [[image:chladni_zeros_circular_plate]]. The Jn(K*r) term is using the n-th order [http://en.wikipedia.org/wiki/Bessel_function Bessel function].&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The following equation is Chladni&#039;s Law: [[image:chladnis_law]]. This equation relates the modes of vibration to the frequency of the modes for circular plates with a fixed center, similar to the one used by our three-speaker system except that our plate is fixed at three points away from the center. In the equation, C and p are defined based on the properties of the plate. For circular plates, p is approximately 2. The values of m and n are chosen based on the diametric and radial modes which can be determined by the shapes of the nodes on the plate, then converted to the frequency of the plate that made that shape.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  You can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[image:chladni_speaker_cover|left|Dust cap removal|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker|left|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate. &lt;br /&gt;
  &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|left|Three-speaker setup|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|left|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|left|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|left|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.youtube.com/watch?v=0qsijdgoGDc Click here for a video of our Three-speaker Chladni setup]&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
[http://www.youtube.com/watch?v=Sz1AuS-qA1c Click here for a video of our one-speaker Chladni setup]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As you can see from the previous video, the one-speaker setup gives more distinct patterns than our three-speaker setup. This may be because there is no other interference with the vibration that more speakers connected to the same plate may cause. The patterns are all very different from each other, indicating the different diametric and radial modes of the square plate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Experimental Notes ===&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; AD9833 Waveform Generator &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While a tremendously versatile and useful chip, we found it extremely difficult to work with.  The chip itself is very small and as mentioned above needs to be soldered to an adapter.  Surface mount soldering this chip is not easy to do by hand and the connection may be weak even if you&#039;ve tested with a multimeter.  We even found that performance of the chip can be improved simply by putting pressure on the chip which shows how difficult making a solid connection can be. However if working properly this chip can be very powerful.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; SPI communication with multiple AD9833 chips &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We had wanted to try to send three different frequencies, one to each speaker. This would require the use of three AD9833s, which we attempted to build a circuit for. From the example code we used and edited from the [[Waveform_Generation_with_AD9833,_and_SPI]] page, we saw that the PIC could only use one pin A3 (digital output) of the PIC for communication with the chip, while the other two pins A1 and A2 were used as Enable and CLK. We tried duplicating the SPI connections from the PIC to three AD9833s, using the same connections for each chip, but after programming the PIC and running the program, we saw that the AD9833 chips were not responding in the correct way. We thought that the issue may be that the AD9833s could not be programmed at the same time, so we tried another method. We used three 2-input AND gates and fed the CLK line as one input to each AND gate, with the other input being a switch from the PIC that would go high if that certain AD9833 was to be programmed. The other two PIC outputs Enable and Digital Output would still go to each AD9833. The output of each AND gate would feed into SCLK (pin 7) of the AD9833 and go low if the CLK was low and the switch was high, signaling that the AD9833 should be programmed (AD9833 is programmed with SCLK is low). The AD9833s would then be programmed in series, as the switch for the first AD9833 would go high, then the second switch would go high while the first went low, and so on. However, this method did not cause the AD9833s to be programmed/output a signal at all. In the end, we found that just using one SPI connection to one AD9833 gave the best frequency output, so we decided to split that signal into three and send them through unity gain buffers (preventing undesired loading or interference). The output of the buffers would be sent to the LA160 car audio amplifer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Sending Different Frequencies to Different Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This was difficult to experiment with because of our issues with SPI communication to separate AD9833 chips.  However throughout the project we experienced times when the speakers were operating at different frequencies.  From what we have seen all speakers must be operating at the same frequencies for any pattern to show.  Whenever there was a phase issue or difference in frequency the plate would exhibit buckling behavior throwing the salt several inches into the air.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Aluminum Plate &amp;lt;/b&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
When deciding how to space the speakers we had to consider the aluminum plate.  Too far apart and a thin plate might sag in the middle, while too close together and the plate might sag around the edges.  Sag would create artificial nodes and cause salt to accumulate in the wrong areas.  &lt;br /&gt;
&lt;br /&gt;
We decided early on to space the centers of the speakers 13&amp;quot; apart and began testing to see which size and shape plate would give us the least sag.  Ultimately 28&amp;quot; diameter circle plate allowed us the largest possible plate - so we could have larger patterns - without the plate sagging around the edges or in the middle.  We started with 36&amp;quot; x 36&amp;quot; plate and band sawed our circular plate out of it.&lt;br /&gt;
&lt;br /&gt;
Also we noticed that our patterns did not have perfect radial symmetry.  As the patterns rely heavily on the shape of the plate, imperfections in the plate can cause unsymmetrical patterns.  In addition to a few small dents and scratches, band-sawing the circle out of the large plate yielded jagged and crooked edges at several points.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_tda2040_circuit|right|TDA-2040 circuit|thumb|150px]]&lt;br /&gt;
&amp;lt;b&amp;gt; Amplifier Chips &amp;lt;/b&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
At first we planned to use the TDA-2040 audio amp chips.  Our original circuit is pictured to the right.  When working with one speaker the TDA-2040 chip worked beautifully.  It requires a lot of power - 24 volts - which was supplied using -12V to +12V.  The one speaker video was actually done with the TDA-2040 audio amp chip.  &lt;br /&gt;
&lt;br /&gt;
The next step was to have a TDA-2040 amplify the other two speakers.  Each of the audio amps would need 24 volts.  When we added the other speakers we noticed that this caused all the speakers to experience a drop in amplitude. Providing each audio amp with its own 24 volt power supply only yielded marginal improvements.  However the signal was still very inconsistent and noisy.  &lt;br /&gt;
&lt;br /&gt;
For the purposes of demonstration we decided to use the LA160 car amp for a much cleaner signal and far more defined Chladni patterns.&lt;br /&gt;
&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
* Try sending different frequencies (by figuring out how to program multiple AD9833 chips with one PIC) to each speaker to see if they generate different patterns.&lt;br /&gt;
* Use different plate size or different amount of speakers.  For example, use 4 speakers and a large square plate to change the types of visible shapes at resonance.&lt;br /&gt;
* Figure out the power issue with multiple TDA-2040 audio amp chips so the project wouldn&#039;t rely on the LA160 car amp.  &lt;br /&gt;
* Use a more rigid plate or construct one with less defects in shape.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[http://local.wasp.uwa.edu.au/~pbourke/geometry/chladni/ Chladni Plate Mathematics]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Chladni&#039;s_law Chladni&#039;s Law]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.phy.davidson.edu/StuHome/derekk/Chladni/pages/menu.htm A study of vibrating plates]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11734</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11734"/>
		<updated>2009-03-19T04:36:12Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Experimental Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project also includes a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
=== Equations ===&lt;br /&gt;
As explained in the overview, the Chladni plate generates patterns when the frequency of the plate oscillation is at a resonant frequency for the plate. At resonance, the plate has portions where it has non-zero amplitude during oscillation, which is where the salt moves away from toward areas of zero amplitude. Areas of zero amplitude are called nodes or zeros of vibration, and salt collects at these regions on the plate at resonance. The nodes of vibration of a circular or square plate can be mathematically calculated for different modes of vibration.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation [[image:chladni_zeros_square_plate]] solves for the zeros of the standing wave for a square plate constrained at the center, such as the one we used for our one-speaker configuration. The variable L is the side length of the plate, m is the number of diametric nodes and n is the number of radial nodes. Solve for x and y to get the zero locations.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation to find the zeros for a circular plate is [[image:chladni_zeros_circular_plate]]. The Jn(K*r) term is using the n-th order [http://en.wikipedia.org/wiki/Bessel_function Bessel function].&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The following equation is Chladni&#039;s Law: [[image:chladnis_law]]. This equation relates the modes of vibration to the frequency of the modes for circular plates with a fixed center, similar to the one used by our three-speaker system except that our plate is fixed at three points away from the center. In the equation, C and p are defined based on the properties of the plate. For circular plates, p is approximately 2. The values of m and n are chosen based on the diametric and radial modes which can be determined by the shapes of the nodes on the plate, then converted to the frequency of the plate that made that shape.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  You can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[image:chladni_speaker_cover|left|Dust cap removal|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker|left|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate. &lt;br /&gt;
  &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|left|Three-speaker setup|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|left|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|left|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|left|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.youtube.com/watch?v=0qsijdgoGDc Click here for a video of our Three-speaker Chladni setup]&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
[http://www.youtube.com/watch?v=Sz1AuS-qA1c Click here for a video of our one-speaker Chladni setup]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As you can see from the previous video, the one-speaker setup gives more distinct patterns than our three-speaker setup. This may be because there is no other interference with the vibration that more speakers connected to the same plate may cause. The patterns are all very different from each other, indicating the different diametric and radial modes of the square plate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Experimental Notes ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; AD9833 Waveform Generator &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While a tremendously versatile and useful chip, we found it extremely difficult to work with.  The chip itself is very small and as mentioned above needs to be soldered to an adapter.  Surface mount soldering this chip is not easy to do by hand and the connection may be weak even if you&#039;ve tested with a multimeter.  We even found that performance of the chip can be improved simply by putting pressure on the chip which shows how difficult making a solid connection can be. However if working properly this chip can be very powerful.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; SPI communication with multiple AD9833 chips &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We had wanted to try to send three different frequencies, one to each speaker. This would require the use of three AD9833s, which we attempted to build a circuit for. From the example code we used and edited from the [[Waveform_Generation_with_AD9833,_and_SPI]] page, we saw that the PIC could only use one pin A3 (digital output) of the PIC for communication with the chip, while the other two pins A1 and A2 were used as Enable and CLK. We tried duplicating the SPI connections from the PIC to three AD9833s, using the same connections for each chip, but after programming the PIC and running the program, we saw that the AD9833 chips were not responding in the correct way. We thought that the issue may be that the AD9833s could not be programmed at the same time, so we tried another method. We used three 2-input AND gates and fed the CLK line as one input to each AND gate, with the other input being a switch from the PIC that would go high if that certain AD9833 was to be programmed. The other two PIC outputs Enable and Digital Output would still go to each AD9833. The output of each AND gate would feed into SCLK (pin 7) of the AD9833 and go low if the CLK was low and the switch was high, signaling that the AD9833 should be programmed (AD9833 is programmed with SCLK is low). The AD9833s would then be programmed in series, as the switch for the first AD9833 would go high, then the second switch would go high while the first went low, and so on. However, this method did not cause the AD9833s to be programmed/output a signal at all. In the end, we found that just using one SPI connection to one AD9833 gave the best frequency output, so we decided to split that signal into three and send them through unity gain buffers (preventing undesired loading or interference). The output of the buffers would be sent to the LA160 car audio amplifer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Sending Different Frequencies to Different Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This was difficult to experiment with because of our issues with SPI communication to separate AD9833 chips.  However throughout the project we experienced times when the speakers were operating at different frequencies.  From what we have seen all speakers must be operating at the same frequencies for any pattern to show.  Whenever there was a phase issue or difference in frequency the plate would exhibit buckling behavior throwing the salt several inches into the air.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Aluminum Plate &amp;lt;/b&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
When deciding how to space the speakers we had to consider the aluminum plate.  Too far apart and a thin plate might sag in the middle, while too close together and the plate might sag around the edges.  Sag would create artificial nodes and cause salt to accumulate in the wrong areas.  &lt;br /&gt;
&lt;br /&gt;
We decided early on to space the centers of the speakers 13&amp;quot; apart and began testing to see which size and shape plate would give us the least sag.  Ultimately 28&amp;quot; diameter circle plate allowed us the largest possible plate - so we could have larger patterns - without the plate sagging around the edges or in the middle.  We started with 36&amp;quot; x 36&amp;quot; plate and band sawed our circular plate out of it.&lt;br /&gt;
&lt;br /&gt;
Also we noticed that our patterns did not have perfect radial symmetry.  As the patterns rely heavily on the shape of the plate, imperfections in the plate can cause unsymmetrical patterns.  In addition to a few small dents and scratches, band-sawing the circle out of the large plate yielded jagged and crooked edges at several points.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_tda2040_circuit|right|TDA-2040 circuit|thumb|150px]]&lt;br /&gt;
&amp;lt;b&amp;gt; Amplifier Chips &amp;lt;/b&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
At first we planned to use the TDA-2040 audio amp chips.  Our original circuit is pictured to the right.  When working with one speaker the TDA-2040 chip worked beautifully.  It requires a lot of power - 24 volts - which was supplied using -12V to +12V.  The one speaker video was actually done with the TDA-2040 audio amp chip.  &lt;br /&gt;
&lt;br /&gt;
The next step was to have a TDA-2040 amplify the other two speakers.  Each of the audio amps would need 24 volts.  When we added the other speakers we noticed that this caused all the speakers to experience a drop in amplitude. Providing each audio amp with its own 24 volt power supply only yielded marginal improvements.  However the signal was still very inconsistent and noisy.  &lt;br /&gt;
&lt;br /&gt;
For the purposes of demonstration we decided to use the LA160 car amp for a much cleaner signal and far more defined Chladni patterns.&lt;br /&gt;
&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
* Try sending different frequencies (by figuring out how to program multiple AD9833 chips with one PIC) to each speaker to see if they generate different patterns.&lt;br /&gt;
* Use different plate size or different amount of speakers.  For example, use 4 speakers and a large square plate to change the types of visible shapes at resonance.&lt;br /&gt;
* Figure out the power issue with multiple TDA-2040 audio amp chips so the project wouldn&#039;t rely on the LA160 car amp.  &lt;br /&gt;
* Use a more rigid plate or construct one with less defects in shape.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[http://local.wasp.uwa.edu.au/~pbourke/geometry/chladni/ Chladni Plate Mathematics]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Chladni&#039;s_law Chladni&#039;s Law]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.phy.davidson.edu/StuHome/derekk/Chladni/pages/menu.htm A study of vibrating plates]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11733</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11733"/>
		<updated>2009-03-19T04:35:59Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Experimental Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project also includes a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
=== Equations ===&lt;br /&gt;
As explained in the overview, the Chladni plate generates patterns when the frequency of the plate oscillation is at a resonant frequency for the plate. At resonance, the plate has portions where it has non-zero amplitude during oscillation, which is where the salt moves away from toward areas of zero amplitude. Areas of zero amplitude are called nodes or zeros of vibration, and salt collects at these regions on the plate at resonance. The nodes of vibration of a circular or square plate can be mathematically calculated for different modes of vibration.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation [[image:chladni_zeros_square_plate]] solves for the zeros of the standing wave for a square plate constrained at the center, such as the one we used for our one-speaker configuration. The variable L is the side length of the plate, m is the number of diametric nodes and n is the number of radial nodes. Solve for x and y to get the zero locations.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation to find the zeros for a circular plate is [[image:chladni_zeros_circular_plate]]. The Jn(K*r) term is using the n-th order [http://en.wikipedia.org/wiki/Bessel_function Bessel function].&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The following equation is Chladni&#039;s Law: [[image:chladnis_law]]. This equation relates the modes of vibration to the frequency of the modes for circular plates with a fixed center, similar to the one used by our three-speaker system except that our plate is fixed at three points away from the center. In the equation, C and p are defined based on the properties of the plate. For circular plates, p is approximately 2. The values of m and n are chosen based on the diametric and radial modes which can be determined by the shapes of the nodes on the plate, then converted to the frequency of the plate that made that shape.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  You can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[image:chladni_speaker_cover|left|Dust cap removal|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker|left|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate. &lt;br /&gt;
  &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|left|Three-speaker setup|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|left|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|left|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|left|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.youtube.com/watch?v=0qsijdgoGDc Click here for a video of our Three-speaker Chladni setup]&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
[http://www.youtube.com/watch?v=Sz1AuS-qA1c Click here for a video of our one-speaker Chladni setup]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As you can see from the previous video, the one-speaker setup gives more distinct patterns than our three-speaker setup. This may be because there is no other interference with the vibration that more speakers connected to the same plate may cause. The patterns are all very different from each other, indicating the different diametric and radial modes of the square plate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Experimental Notes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; AD9833 Waveform Generator &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While a tremendously versatile and useful chip, we found it extremely difficult to work with.  The chip itself is very small and as mentioned above needs to be soldered to an adapter.  Surface mount soldering this chip is not easy to do by hand and the connection may be weak even if you&#039;ve tested with a multimeter.  We even found that performance of the chip can be improved simply by putting pressure on the chip which shows how difficult making a solid connection can be. However if working properly this chip can be very powerful.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; SPI communication with multiple AD9833 chips &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We had wanted to try to send three different frequencies, one to each speaker. This would require the use of three AD9833s, which we attempted to build a circuit for. From the example code we used and edited from the [[Waveform_Generation_with_AD9833,_and_SPI]] page, we saw that the PIC could only use one pin A3 (digital output) of the PIC for communication with the chip, while the other two pins A1 and A2 were used as Enable and CLK. We tried duplicating the SPI connections from the PIC to three AD9833s, using the same connections for each chip, but after programming the PIC and running the program, we saw that the AD9833 chips were not responding in the correct way. We thought that the issue may be that the AD9833s could not be programmed at the same time, so we tried another method. We used three 2-input AND gates and fed the CLK line as one input to each AND gate, with the other input being a switch from the PIC that would go high if that certain AD9833 was to be programmed. The other two PIC outputs Enable and Digital Output would still go to each AD9833. The output of each AND gate would feed into SCLK (pin 7) of the AD9833 and go low if the CLK was low and the switch was high, signaling that the AD9833 should be programmed (AD9833 is programmed with SCLK is low). The AD9833s would then be programmed in series, as the switch for the first AD9833 would go high, then the second switch would go high while the first went low, and so on. However, this method did not cause the AD9833s to be programmed/output a signal at all. In the end, we found that just using one SPI connection to one AD9833 gave the best frequency output, so we decided to split that signal into three and send them through unity gain buffers (preventing undesired loading or interference). The output of the buffers would be sent to the LA160 car audio amplifer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Sending Different Frequencies to Different Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This was difficult to experiment with because of our issues with SPI communication to separate AD9833 chips.  However throughout the project we experienced times when the speakers were operating at different frequencies.  From what we have seen all speakers must be operating at the same frequencies for any pattern to show.  Whenever there was a phase issue or difference in frequency the plate would exhibit buckling behavior throwing the salt several inches into the air.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Aluminum Plate &amp;lt;/b&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
When deciding how to space the speakers we had to consider the aluminum plate.  Too far apart and a thin plate might sag in the middle, while too close together and the plate might sag around the edges.  Sag would create artificial nodes and cause salt to accumulate in the wrong areas.  &lt;br /&gt;
&lt;br /&gt;
We decided early on to space the centers of the speakers 13&amp;quot; apart and began testing to see which size and shape plate would give us the least sag.  Ultimately 28&amp;quot; diameter circle plate allowed us the largest possible plate - so we could have larger patterns - without the plate sagging around the edges or in the middle.  We started with 36&amp;quot; x 36&amp;quot; plate and band sawed our circular plate out of it.&lt;br /&gt;
&lt;br /&gt;
Also we noticed that our patterns did not have perfect radial symmetry.  As the patterns rely heavily on the shape of the plate, imperfections in the plate can cause unsymmetrical patterns.  In addition to a few small dents and scratches, band-sawing the circle out of the large plate yielded jagged and crooked edges at several points.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_tda2040_circuit|right|TDA-2040 circuit|thumb|150px]]&lt;br /&gt;
&amp;lt;b&amp;gt; Amplifier Chips &amp;lt;/b&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
At first we planned to use the TDA-2040 audio amp chips.  Our original circuit is pictured to the right.  When working with one speaker the TDA-2040 chip worked beautifully.  It requires a lot of power - 24 volts - which was supplied using -12V to +12V.  The one speaker video was actually done with the TDA-2040 audio amp chip.  &lt;br /&gt;
&lt;br /&gt;
The next step was to have a TDA-2040 amplify the other two speakers.  Each of the audio amps would need 24 volts.  When we added the other speakers we noticed that this caused all the speakers to experience a drop in amplitude. Providing each audio amp with its own 24 volt power supply only yielded marginal improvements.  However the signal was still very inconsistent and noisy.  &lt;br /&gt;
&lt;br /&gt;
For the purposes of demonstration we decided to use the LA160 car amp for a much cleaner signal and far more defined Chladni patterns.&lt;br /&gt;
&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
* Try sending different frequencies (by figuring out how to program multiple AD9833 chips with one PIC) to each speaker to see if they generate different patterns.&lt;br /&gt;
* Use different plate size or different amount of speakers.  For example, use 4 speakers and a large square plate to change the types of visible shapes at resonance.&lt;br /&gt;
* Figure out the power issue with multiple TDA-2040 audio amp chips so the project wouldn&#039;t rely on the LA160 car amp.  &lt;br /&gt;
* Use a more rigid plate or construct one with less defects in shape.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[http://local.wasp.uwa.edu.au/~pbourke/geometry/chladni/ Chladni Plate Mathematics]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Chladni&#039;s_law Chladni&#039;s Law]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.phy.davidson.edu/StuHome/derekk/Chladni/pages/menu.htm A study of vibrating plates]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11727</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11727"/>
		<updated>2009-03-19T04:28:33Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Possible Future Improvements/Enhancements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
=== Equations ===&lt;br /&gt;
As explained in the overview, the Chladni plate generates patterns when the frequency of the plate oscillation is at a resonant frequency for the plate. At resonance, the plate has portions where it has non-zero amplitude during oscillation, which is where the salt moves away from toward areas of zero amplitude. Areas of zero amplitude are called nodes or zeros of vibration, and salt collects at these regions on the plate at resonance. The nodes of vibration of a circular or square plate can be mathematically calculated for different modes of vibration.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation [[image:chladni_zeros_square_plate]] solves for the zeros of the standing wave for a square plate constrained at the center, such as the one we used for our one-speaker configuration. The variable L is the side length of the plate, m is the number of diametric nodes and n is the number of radial nodes. Solve for x and y for the zero locations.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation to find the zeros for a circular plate is [[image:chladni_zeros_circular_plate]]. The Jn(K*r) term is using the n-th order [http://en.wikipedia.org/wiki/Bessel_function Bessel function].&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The following equation is Chladni&#039;s Law: [[image:chladnis_law]]. This equations relates the modes of vibration to the frequency of the modes for circular plates with a fixed center, similar to the one used by our three-speaker system except that our plate is fixed at three points away from the center. In the equation, C and p are defined based on the properties of the plate. For circular plates, p is approximately 2. The values of m and n are chosen based on the diametric and radial modes which can be determined by the shape of the salt on the plate, then converted to the frequency of the plate that made that shape.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  You can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[image:chladni_speaker_cover|left|Dust cap removal|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker|left|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate. &lt;br /&gt;
  &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|left|Three-speaker setup|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|left|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|left|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|left|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.youtube.com/watch?v=0qsijdgoGDc Click here for a video of our Three-speaker Chladni setup]&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
[http://www.youtube.com/watch?v=Sz1AuS-qA1c Click here for a video of our one-speaker Chladni setup]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As you can see from the previous video, the one-speaker setup gives more distinct patterns than our three-speaker setup. This may be because there is no other interference with the vibration that more speakers connected to the same plate may cause. The patterns are all very different from each other, indicating the different diametric and radial modes of the square plate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Experimental Notes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; AD9833 Waveform Generator &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While a tremendously versatile and useful chip, we found it extremely difficult to work with.  The chip itself is very small and as mentioned above needs to be soldered to an adapter.  Surface mount soldering this chip is not easy to do by hand and the connection may be weak even if you&#039;ve tested with a multimeter.  We even found that performance of the chip can be improved simply by putting pressure on the chip which shows how difficult making a solid connection can be. However if working properly this chip can be very powerful.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; SPI communication with multiple AD9833 chips &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We had wanted to try to send three different frequencies, one to each speaker. This would require the use of three AD9833s, which we attempted to build a circuit for. From the example code we used and edited from the [[Waveform_Generation_with_AD9833,_and_SPI]] page, we saw that the PIC could only use one pin A3 (digital output) of the PIC for communication with the chip, while the other two pins A1 and A2 were used as Enable and CLK. We tried duplicating the SPI connections from the PIC to three AD9833s, using the same connections for each chip, but after programming the PIC and running the program, we saw that the AD9833 chips were not responding in the correct way. We thought that the issue may be that the AD9833s could not be programmed at the same time, so we tried another method. We used three 2-input AND gates and fed the CLK line as one input to each AND gate, with the other input being a switch from the PIC that would go high if that certain AD9833 was to be programmed. The other two PIC outputs Enable and Digital Output would still go to each AD9833. The output of each AND gate would feed into SCLK (pin 7) of the AD9833 and go low if the CLK was low and the switch was high, signaling that the AD9833 should be programmed (AD9833 is programmed with SCLK is low). The AD9833s would then be programmed in series, as the switch for the first AD9833 would go high, then the second switch would go high while the first went low, and so on. However, this method did not cause the AD9833s to be programmed/output a signal at all. In the end, we found that just using one SPI connection to one AD9833 gave the best frequency output, so we decided to split that signal into three and send them through unity gain buffers (preventing undesired loading or interference). The output of the buffers would be sent to the LA160 car audio amplifer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Sending Different Frequencies to Different Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This was difficult to experiment with because of our issues with SPI communication to separate AD9833 chips.  However throughout the project we experienced times when the speakers were operating at different frequencies.  From what we have seen all speakers must be operating at the same frequencies for any pattern to show.  Whenever there was a phase issue or difference in frequency the plate would exhibit buckling behavior throwing the salt several inches into the air.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Aluminum Plate &amp;lt;/b&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
When deciding how to space the speakers we had to consider the aluminum plate.  Too far apart and a thin plate might sag in the middle, while too close together and the plate might sag around the edges.  Sag would create artificial nodes and cause salt to accumulate in the wrong areas.  &lt;br /&gt;
&lt;br /&gt;
We decided early on to space the centers of the speakers 13&amp;quot; apart and began testing to see which size and shape plate would give us the least sag.  Ultimately 28&amp;quot; diameter circle plate allowed us the largest possible plate - so we could have larger patterns - without the plate sagging around the edges or in the middle.  We started with 36&amp;quot; x 36&amp;quot; plate and band sawed our circular plate out of it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_tda2040_circuit|right|TDA-2040 circuit|thumb|150px]]&lt;br /&gt;
&amp;lt;b&amp;gt; Amplifier Chips &amp;lt;/b&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
At first we planned to use the TDA-2040 audio amp chips.  Our original circuit is pictured to the right.  When working with one speaker the TDA-2040 chip worked beautifully.  It requires a lot of power - 24 volts - which was supplied using -12V to +12V.  The one speaker video was actually done with the TDA-2040 audio amp chip.  &lt;br /&gt;
&lt;br /&gt;
The next step was to have a TDA-2040 amplify the other two speakers.  Each of the audio amps would need 24 volts.  When we added the other speakers we noticed that this caused all the speakers to experience a drop in amplitude. Providing each audio amp with its own 24 volt power supply only yielded marginal improvements.  However the signal was still very inconsistent and noisy.  &lt;br /&gt;
&lt;br /&gt;
For the purposes of demonstration we decided to use the Legacy II car amp for a much cleaner signal and far more defined Chladni patterns.&lt;br /&gt;
&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
* Try sending different frequencies (by figuring out how to program multiple AD9833 chips with one PIC) to each speaker to see if they generate different patterns.&lt;br /&gt;
* Use different plate size or different amount of speakers.  For example, use 4 speakers and a large square plate to change the types of visible shapes at resonance.&lt;br /&gt;
* Figure out the power issue with multiple TDA-2040 audio amp chips so the project wouldn&#039;t rely on the LA160 car amp.  &lt;br /&gt;
* Use a more rigid plate or construct one with less defects in shape.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[http://local.wasp.uwa.edu.au/~pbourke/geometry/chladni/ Chladni Plate Mathematics]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Chladni&#039;s_law Chladni&#039;s Law]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.phy.davidson.edu/StuHome/derekk/Chladni/pages/menu.htm A study of vibrating plates]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11715</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11715"/>
		<updated>2009-03-19T03:58:39Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Experimental Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
=== Equations ===&lt;br /&gt;
As explained in the overview, the Chladni plate generates patterns when the frequency of the plate oscillation is at a resonant frequency for the plate. At resonance, the plate has portions where it has non-zero amplitude during oscillation, which is where the salt moves away from toward areas of zero amplitude. Areas of zero amplitude are called nodes or zeros of vibration, and salt collects at these regions on the plate at resonance. The nodes of vibration of a circular or square plate can be mathematically calculated for different modes of vibration.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation [[image:chladni_zeros_square_plate]] solves for the zeros of the standing wave for a square plate constrained at the center, such as the one we used for our one-speaker configuration. The variable L is the side length of the plate, m is the number of diametric nodes and n is the number of radial nodes. Solve for x and y for the zero locations.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation to find the zeros for a circular plate is [[image:chladni_zeros_circular_plate]]. The Jn(K*r) term is using the n-th order [http://en.wikipedia.org/wiki/Bessel_function Bessel function].&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The following equation is Chladni&#039;s Law: [[image:chladnis_law]]. This equations relates the modes of vibration to the frequency of the modes for circular plates with a fixed center, similar to the one used by our three-speaker system except that our plate is fixed at three points away from the center. In the equation, C and p are defined based on the properties of the plate. For circular plates, p is approximately 2. The values of m and n are chosen based on the diametric and radial modes which can be determined by the shape of the salt on the plate, then converted to the frequency of the plate that made that shape.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  You can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[image:chladni_speaker_cover|left|Dust cap removal|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker|left|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate. &lt;br /&gt;
  &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|left|Three-speaker setup|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|left|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|left|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|left|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.youtube.com/watch?v=0qsijdgoGDc Click here for a video of our Three-speaker Chladni setup]&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
[http://www.youtube.com/watch?v=Sz1AuS-qA1c Click here for a video of our one-speaker Chladni setup]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As you can see from the previous video, the one-speaker setup gives more distinct patterns than our three-speaker setup. This may be because there is no other interference with the vibration that more speakers connected to the same plate may cause. The patterns are all very different from each other, indicating the different diametric and radial modes of the square plate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Experimental Notes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; AD9833 Waveform Generator &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While a tremendously versatile and useful chip, we found it extremely difficult to work with.  The chip itself is very small and as mentioned above needs to be soldered to an adapter.  Surface mount soldering this chip is not easy to do by hand and the connection may be weak even if you&#039;ve tested with a multimeter.  We even found that performance of the chip can be improved simply by putting pressure on the chip which shows how difficult making a solid connection can be. However if working properly this chip can be very powerful.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; SPI communication with multiple AD9833 chips &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[http://local.wasp.uwa.edu.au/~pbourke/geometry/chladni/ Chladni Plate Mathematics]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Chladni&#039;s_law Chladni&#039;s Law]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.phy.davidson.edu/StuHome/derekk/Chladni/pages/menu.htm A study of vibrating plates]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11711</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11711"/>
		<updated>2009-03-19T03:48:13Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Experimental Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
=== Equations ===&lt;br /&gt;
As explained in the overview, the Chladni plate generates patterns when the frequency of the plate oscillation is at a resonant frequency for the plate. At resonance, the plate has portions where it has non-zero amplitude during oscillation, which is where the salt moves away from toward areas of zero amplitude. Areas of zero amplitude are called nodes or zeros of vibration, and salt collects at these regions on the plate at resonance. The nodes of vibration of a circular or square plate can be mathematically calculated for different modes of vibration.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation [[image:chladni_zeros_square_plate]] solves for the zeros of the standing wave for a square plate constrained at the center, such as the one we used for our one-speaker configuration. The variable L is the side length of the plate, m is the number of diametric nodes and n is the number of radial nodes. Solve for x and y for the zero locations.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation to find the zeros for a circular plate is [[image:chladni_zeros_circular_plate]]. The Jn(K*r) term is using the n-th order [http://en.wikipedia.org/wiki/Bessel_function Bessel function].&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The following equation is Chladni&#039;s Law: [[image:chladnis_law]]. This equations relates the modes of vibration to the frequency of the modes for circular plates with a fixed center, similar to the one used by our three-speaker system except that our plate is fixed at three points away from the center. In the equation, C and p are defined based on the properties of the plate. For circular plates, p is approximately 2. The values of m and n are chosen based on the diametric and radial modes which can be determined by the shape of the salt on the plate, then converted to the frequency of the plate that made that shape.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  You can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[image:chladni_speaker_cover|left|Dust cap removal|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker|left|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate. &lt;br /&gt;
  &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|left|Three-speaker setup|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|left|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|left|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|left|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Experimental Notes ===&lt;br /&gt;
&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[http://local.wasp.uwa.edu.au/~pbourke/geometry/chladni/ Chladni Plate Mathematics]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Chladni&#039;s_law Chladni&#039;s Law]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.phy.davidson.edu/StuHome/derekk/Chladni/pages/menu.htm A study of vibrating plates]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11710</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11710"/>
		<updated>2009-03-19T03:47:43Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Additional Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
=== Equations ===&lt;br /&gt;
As explained in the overview, the Chladni plate generates patterns when the frequency of the plate oscillation is at a resonant frequency for the plate. At resonance, the plate has portions where it has non-zero amplitude during oscillation, which is where the salt moves away from toward areas of zero amplitude. Areas of zero amplitude are called nodes or zeros of vibration, and salt collects at these regions on the plate at resonance. The nodes of vibration of a circular or square plate can be mathematically calculated for different modes of vibration.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation [[image:chladni_zeros_square_plate]] solves for the zeros of the standing wave for a square plate constrained at the center, such as the one we used for our one-speaker configuration. The variable L is the side length of the plate, m is the number of diametric nodes and n is the number of radial nodes. Solve for x and y for the zero locations.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation to find the zeros for a circular plate is [[image:chladni_zeros_circular_plate]]. The Jn(K*r) term is using the n-th order [http://en.wikipedia.org/wiki/Bessel_function Bessel function].&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The following equation is Chladni&#039;s Law: [[image:chladnis_law]]. This equations relates the modes of vibration to the frequency of the modes for circular plates with a fixed center, similar to the one used by our three-speaker system except that our plate is fixed at three points away from the center. In the equation, C and p are defined based on the properties of the plate. For circular plates, p is approximately 2. The values of m and n are chosen based on the diametric and radial modes which can be determined by the shape of the salt on the plate, then converted to the frequency of the plate that made that shape.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  You can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[image:chladni_speaker_cover|left|Dust cap removal|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker|left|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate. &lt;br /&gt;
  &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|left|Three-speaker setup|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|left|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|left|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|left|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Experimental Notes ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[http://local.wasp.uwa.edu.au/~pbourke/geometry/chladni/ Chladni Plate Mathematics]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Chladni&#039;s_law Chladni&#039;s Law]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.phy.davidson.edu/StuHome/derekk/Chladni/pages/menu.htm A study of vibrating plates]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11709</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11709"/>
		<updated>2009-03-19T03:42:01Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Parts List */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
=== Equations ===&lt;br /&gt;
As explained in the overview, the Chladni plate generates patterns when the frequency of the plate oscillation is at a resonant frequency for the plate. At resonance, the plate has portions where it has non-zero amplitude during oscillation, which is where the salt moves away from toward areas of zero amplitude. Areas of zero amplitude are called nodes or zeros of vibration, and salt collects at these regions on the plate at resonance. The nodes of vibration of a circular or square plate can be mathematically calculated for different modes of vibration.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation [[image:chladni_zeros_square_plate]] solves for the zeros of the standing wave for a square plate constrained at the center, such as the one we used for our one-speaker configuration. The variable L is the side length of the plate, m is the number of diametric nodes and n is the number of radial nodes. Solve for x and y for the zero locations.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The equation to find the zeros for a circular plate is [[image:chladni_zeros_circular_plate]]. The Jn(K*r) term is using the n-th order [http://en.wikipedia.org/wiki/Bessel_function Bessel function].&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The following equation is Chladni&#039;s Law: [[image:chladnis_law]]. This equations relates the modes of vibration to the frequency of the modes for circular plates with a fixed center, similar to the one used by our three-speaker system except that our plate is fixed at three points away from the center. In the equation, C and p are defined based on the properties of the plate. For circular plates, p is approximately 2. The values of m and n are chosen based on the diametric and radial modes which can be determined by the shape of the salt on the plate, then converted to the frequency of the plate that made that shape.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  You can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[image:chladni_speaker_cover|left|Dust cap removal|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker|left|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate. &lt;br /&gt;
  &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|left|Three-speaker setup|thumb|300px]]&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|left|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|left|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|left|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[http://local.wasp.uwa.edu.au/~pbourke/geometry/chladni/ Chladni Plate Mathematics]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Chladni&#039;s_law Chladni&#039;s Law]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.phy.davidson.edu/StuHome/derekk/Chladni/pages/menu.htm A study of vibrating plates]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11554</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11554"/>
		<updated>2009-03-18T21:37:19Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Breakdown of Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker|right|Speaker box|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|right|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate. &lt;br /&gt;
  &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|right|User interface box|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_underside|left|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|left|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11552</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11552"/>
		<updated>2009-03-18T21:36:12Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Breakdown of Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker|right|Speaker box|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|right|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate. &lt;br /&gt;
  &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_setup|left|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11550</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11550"/>
		<updated>2009-03-18T21:35:29Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Breakdown of Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker|right|Speaker box|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|right|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate. &lt;br /&gt;
  &lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11549</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11549"/>
		<updated>2009-03-18T21:34:42Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Breakdown of Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker|right|Speaker box|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|right|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11548</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11548"/>
		<updated>2009-03-18T21:33:41Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker|right|Speaker box|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|left|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_setup|left|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11546</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11546"/>
		<updated>2009-03-18T21:30:34Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker|right|Speaker box|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker_bottom|left|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_base|center|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
[[image:chladni_3speaker_setup|right|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11531</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11531"/>
		<updated>2009-03-18T21:15:04Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni pattern generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to adapt the speakers to attach to the metal plate, the second was the speaker housing, and the third was the user interface/circuit box.  These are detailed with pictures below.  &lt;br /&gt;
&lt;br /&gt;
If you are trying to replicate this project, note that many of these specifications can change and still yield interesting, but different results.  Another thing to note is all the specifications are for our particular speakers.  Dimensions and materials can change according to what you&#039;re working with and what is available.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|right|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|right|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11527</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11527"/>
		<updated>2009-03-18T21:07:46Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator setup is pretty straightforward.  There were three major areas of design we had to account for.  One was how to setup the speaker&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|right|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|right|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Putting it Together &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The last piece needed is a metal plate.  We cut down the 36&amp;quot; x 36&amp;quot; aluminum plate into a 28&amp;quot; diameter circular plate.    &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Pictured to the side is the complete set up.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11520</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11520"/>
		<updated>2009-03-18T20:55:19Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Constructing the Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The speaker set up sits in a 32&amp;quot; x 32&amp;quot; foamcore box reinforced with L-brackets.  This is to catch the salt that spills off of the aluminum plate.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|right|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; User Interface and Circuit Box &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; A simple box with a hinged top that can be made out of anything, we chose to use a black Polystyrene material that was available.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; The user interface panel needs to have slots cut for the two power switches, and LCD screen, and a knob.  The laser printer and mill were both used to make these cutouts.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11514</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11514"/>
		<updated>2009-03-18T20:38:32Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Constructing the Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Cut a hole into the top of the speaker box to seat the speaker.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We planned the base so that the speakers would be radially separated by 120 degrees and the centers of each speaker to create a 13&amp;quot; equilateral triangle with each other.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We lined the bottoms of the speaker boxes and the base with Velcro for convenience and accessibility.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11513</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11513"/>
		<updated>2009-03-18T20:33:16Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;gt; We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Constructing the Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11512</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11512"/>
		<updated>2009-03-18T20:32:20Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;- First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
&amp;lt;br&amp;gt;- Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
&amp;lt;br&amp;gt;- Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
&amp;lt;br&amp;gt;- We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Constructing the Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11511</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11511"/>
		<updated>2009-03-18T20:29:55Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
* Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
* Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
* We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Constructing the Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11509</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11509"/>
		<updated>2009-03-18T20:28:59Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can change many of the parts to suit different components.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-First we cut away the dust-cap as pictured to the right  &lt;br /&gt;
-Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  &lt;br /&gt;
-Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  &lt;br /&gt;
-We screwed a hole into the center of the polycarbonate and put in a screw. &lt;br /&gt;
&lt;br /&gt;
The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Constructing the Speaker-boxes and Base &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11507</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11507"/>
		<updated>2009-03-18T20:25:09Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can undoubtedly change many of the parts.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First we cut away the dust-cap as pictured to the right.  Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  We screwed a hole into the center of the polycarbonate and put in a screw. The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11506</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11506"/>
		<updated>2009-03-18T20:24:52Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can undoubtedly change many of the parts.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup.jpg|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First we cut away the dust-cap as pictured to the right.  Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  We screwed a hole into the center of the polycarbonate and put in a screw. The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11505</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11505"/>
		<updated>2009-03-18T20:21:39Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can undoubtedly change many of the parts.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Adapting Speakers===&lt;br /&gt;
&lt;br /&gt;
First we cut away the dust-cap as pictured to the right.  Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  We screwed a hole into the center of the polycarbonate and put in a screw. The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11504</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11504"/>
		<updated>2009-03-18T20:20:51Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can undoubtedly change many of the parts.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First we cut away the dust-cap as pictured to the right.  Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  We screwed a hole into the center of the polycarbonate and put in a screw. The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11502</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11502"/>
		<updated>2009-03-18T20:16:58Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Breakdown of Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can undoubtedly change many of the parts.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Adapting Speakers &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First we cut away the dust-cap as pictured to the right.  Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  We screwed a hole into the center of the polycarbonate and put in a screw. The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11500</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11500"/>
		<updated>2009-03-18T20:14:22Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Breakdown of Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can undoubtedly change many of the parts.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adapting Speakers&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
First we cut away the dust-cap as pictured to the right.  Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  We screwed a hole into the center of the polycarbonate and put in a screw. The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|right|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:IMG_8568.JPG&amp;diff=11499</id>
		<title>File:IMG 8568.JPG</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:IMG_8568.JPG&amp;diff=11499"/>
		<updated>2009-03-18T20:08:05Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11498</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11498"/>
		<updated>2009-03-18T20:05:44Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can undoubtedly change many of the parts.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adapting Speakers&#039;&#039;&#039;&lt;br /&gt;
First we cut away the dust-cap as pictured to the right.  Glued onto the diaphragm of the speaker and over the dustcap is a 2 inch long PVC pipe that covers the hole.  Over the PVC pipe we glued a 2&amp;quot; x 2&amp;quot; piece of polycarbonate.  We screwed a hole into the center of the polycarbonate and put in a screw. The screw is fastened with nuts and washers.  The flexible aluminum plate will ultimately be attached to the speaker through this screw. &lt;br /&gt;
&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11497</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11497"/>
		<updated>2009-03-18T19:58:50Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can undoubtedly change many of the parts.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11496</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11496"/>
		<updated>2009-03-18T19:57:34Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  [[Image:[[Image:Example.jpg]][[Image:Example.jpg]]]]&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can undoubtedly change many of the parts.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Components ===&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11495</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11495"/>
		<updated>2009-03-18T19:56:04Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  [[Image:[[Image:Example.jpg]][[Image:Example.jpg]]]]&lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can undoubtedly change many of the parts.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered. A picture of this is shown on the right.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC. Through the code described below via SPI, information about the wave to be generated is transmitted and the function wave is generated accordingly.&lt;br /&gt;
A 10K potentiometer is used as input from the user in the form of a knob to set the frequency. It is connected to pin A0 of the PIC, and its use is described in detail under the Code section.&lt;br /&gt;
&lt;br /&gt;
The output of the AD9833 chip is connected to the non-inverting inputs of three LM741 Op Amps. These op-amps are not used to amplify the signal, but to serve as a unity gain buffer for the signals. They are connected to a +/- 12V power supply. This buffer essentially makes a copy of the input at the output, without drawing any current from the source of the input, i.e., the function generator chip, which gets its power from the PIC supply. Instead, the output signal draws power from the op-amp itself. The goal is to ensure that doing the measurement of a voltage does not disturb the circuit producing the voltage to be measured.&lt;br /&gt;
&lt;br /&gt;
The outputs of the op-amps are then connected to the car amplifier using standard RCA input cables. The car amplifier, which is connected to a 12V supply, amplifies the signal to audible amplitudes and the outputs are connected to the three speakers. The speakers draw power from the car amplifier.&lt;br /&gt;
&lt;br /&gt;
The D0-D6 outputs of the PIC are connected to the Parallel LCD. To learn more about how to get the LCD working, refer to [[C_Example:_Parallel_Interfacing_with_LCDs|C Example: Parallel Interfacing with LCDs]]. The LCD is made to display the target frequency that the user inputs using the knob (which is on the potentiometer), and also the value of the frequency of the wave that is being generated at the moment.&lt;br /&gt;
&lt;br /&gt;
For easier and more convenient use, sockets were made for header pins from the power supplies, potentiometer, RCA input cables and the parallel LCD. This way, the components can be plugged in and out easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NEED TO INCLUDE STUFF ABOUT&lt;br /&gt;
- WARNING ABOUT HOW DELICATE THE AD9833 CHIP IS&lt;br /&gt;
- USE OF MORE THAN ONE AD9833&lt;br /&gt;
- AUDIO AMP CIRCUITS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The following images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. The less-clear ones might be due to imperfections in the plate or the speakers not hitting the exact resonant frequency. Some frequencies shown in these results are different than the ones in the code displayed above. The ones displayed below were chosen for their clarity and contrast from each other because some frequencies in the displayed code do not shift in pattern as much.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 339 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 424 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 554 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 632 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 660 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|300px]]&amp;lt;br&amp;gt;Three-Speaker Configuration at 734 Hz&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11410</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11410"/>
		<updated>2009-03-18T07:11:50Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Parts List */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
The parts and prices below are specific to the project we did.  However if you were to replicate this you can undoubtedly change many of the parts.  We were fortunate to have most of the materials in supply so we could save money for the aluminum plate and electronics.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Base Box ===&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Three-Speaker Base ===&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Interface Box ===&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Chladni Plate ===&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC.&lt;br /&gt;
&lt;br /&gt;
[[ http://hades.mech.northwestern.edu/wiki/images/math/f/b/d/fbd0abe078f3a06ad554be1ffc67e857.png]]&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
Note: When wiring the touchscreen you have a couple of options. The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC. If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable. This can be down with a wire stripper and soldering. The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The follows images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. &lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11409</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11409"/>
		<updated>2009-03-18T07:09:22Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Parts List */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Base Box ===&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Three-Speaker Base ===&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Interface Box ===&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Chladni Plate ===&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC.&lt;br /&gt;
&lt;br /&gt;
[[ http://hades.mech.northwestern.edu/wiki/images/math/f/b/d/fbd0abe078f3a06ad554be1ffc67e857.png]]&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
Note: When wiring the touchscreen you have a couple of options. The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC. If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable. This can be down with a wire stripper and soldering. The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The follows images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. &lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11408</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11408"/>
		<updated>2009-03-18T07:08:56Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Parts List */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Wood stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~40&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polystyrene Sheets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;quot;X40&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$20.68&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PVC tube 1.5&amp;quot; Dia&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~ 1 ft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Polycarbonate sheet&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~6&amp;quot;X6&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Nuts, Bolts, Washers&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Foamcore&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2 Sheets 36&amp;quot;X28&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;EDC Supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;L Brackets&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;~20&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop supply&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Base Box ===&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Three-Speaker Base ===&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Interface Box ===&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Chladni Plate ===&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC.&lt;br /&gt;
&lt;br /&gt;
[[ http://hades.mech.northwestern.edu/wiki/images/math/f/b/d/fbd0abe078f3a06ad554be1ffc67e857.png]]&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
Note: When wiring the touchscreen you have a couple of options. The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC. If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable. This can be down with a wire stripper and soldering. The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The follows images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. &lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11406</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11406"/>
		<updated>2009-03-18T06:57:52Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Parts List */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;AL 6061) .032&amp;quot; THICK, 36&amp;quot;X36&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;89015K71&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$53.23&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;1/4&amp;quot; bearing&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;60355K33&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;8&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$39.84&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;3/8&amp;quot; bearing&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;60355K35&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$20.68&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;3/4&amp;quot; bearing&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;60355K38&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$33.40&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Thrust bearing&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;6655K22&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$10.96&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SAE 841 1/2&amp;quot; bushing&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;6391K212&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;10&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$6.50&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SAE 814 3/4&amp;quot; bushing 1&amp;quot; long&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;6391K259&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$2.98&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SAE 814 3/4&amp;quot; bushing 2&amp;quot; long&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;6391K269&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$8.40&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;1/2&amp;quot; steel drive shaft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1346K17&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$25.84&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;3/4&amp;quot; steel drive shaft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1346K31&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$19.12&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;spring&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;9620K57&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$17.68&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;1/2&amp;quot;-10 Acme threaded rod&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;98935A823&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$7.12&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Bronze 1/2&amp;quot;-10 Acme nut&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1343K134&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$72.24&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Misc. fasteners and stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Base Box ===&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Three-Speaker Base ===&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Interface Box ===&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Chladni Plate ===&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC.&lt;br /&gt;
&lt;br /&gt;
[[ http://hades.mech.northwestern.edu/wiki/images/math/f/b/d/fbd0abe078f3a06ad554be1ffc67e857.png]]&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
Note: When wiring the touchscreen you have a couple of options. The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC. If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable. This can be down with a wire stripper and soldering. The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
The follows images show the results of the Three-Speaker Chladni system at six different resonant frequencies. Some of these frequencies have clearer patterns than others, such as 424 Hz, 554 Hz, and 660 Hz. &lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11404</id>
		<title>Three-speaker Chladni Patterns</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Three-speaker_Chladni_Patterns&amp;diff=11404"/>
		<updated>2009-03-18T06:54:10Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team Members ==&lt;br /&gt;
[[image:chladni_team|right]]&lt;br /&gt;
* Christopher Chow (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Anup Tapase (Electrical Engineering, Class of 2010)&lt;br /&gt;
* Lingyu Xie (Electrical Engineering, Class of 2009)&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The purpose of this project was to build on the past projects that have been seen on Youtube and other sites involving vibrating a metal plate using one speaker or violin bow. This project uses three speakers separated by 120 degrees which vibrate a circular plate to generate patterns with salt. These patterns are created because when the speakers hit the resonant frequency of the plate, nodes are created on the plate and the salt migrates to these nodes because they are vibrating the least. The project should also include a user interface which the user can use to select different patterns or frequencies for the plate.&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
The Chladni generator  &lt;br /&gt;
&lt;br /&gt;
=== Parts List ===&lt;br /&gt;
&amp;lt;table border=1&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Part&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Part No.&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Qty&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Vendor&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Price (Total)&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;PYRAMID 8&amp;quot; Originals 300W&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;WX85&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Lab&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Shoulder Screw&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;91259A535&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;8&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$6.56&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;1/4&amp;quot; bearing&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;60355K33&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;8&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$39.84&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;3/8&amp;quot; bearing&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;60355K35&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$20.68&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;3/4&amp;quot; bearing&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;60355K38&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$33.40&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Thrust bearing&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;6655K22&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$10.96&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SAE 841 1/2&amp;quot; bushing&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;6391K212&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;10&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$6.50&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SAE 814 3/4&amp;quot; bushing 1&amp;quot; long&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;6391K259&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$2.98&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SAE 814 3/4&amp;quot; bushing 2&amp;quot; long&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;6391K269&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$8.40&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;1/2&amp;quot; steel drive shaft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1346K17&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$25.84&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;3/4&amp;quot; steel drive shaft&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1346K31&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$19.12&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;spring&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;9620K57&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$17.68&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;1/2&amp;quot;-10 Acme threaded rod&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;98935A823&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$7.12&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Bronze 1/2&amp;quot;-10 Acme nut&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1343K134&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.mcmaster.com McMaster]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$72.24&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Misc. fasteners and stock&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shop&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;-&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Base Box ===&lt;br /&gt;
[[image:chladni_1speaker_setup|One speaker setup inside base box made from foamcore|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Three-Speaker Base ===&lt;br /&gt;
[[image:chladni_3speaker_base|Three-speaker wooden base with velcro|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_3speaker_setup|Three-speaker setup|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker|Speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_speaker_bottom|Bottom of speaker box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Interface Box ===&lt;br /&gt;
[[image:chladni_UI_box|User interface box|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_UI_underside|Underside of cover|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_la160_car_amp|Inside box with car amp|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Chladni Plate ===&lt;br /&gt;
[[image:chladni_plate|Chladni plate made from aluminum|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
=== Primary Components ===&lt;br /&gt;
[[image:chladni_ad9833_adapter|AD9833 on adapter|thumb|300px]]&lt;br /&gt;
The primary components required to implement the circuit include:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;1) PIC 18F4520&lt;br /&gt;
&amp;lt;br&amp;gt;2) AD9833 BRMZ-ND Function Generator chip *&lt;br /&gt;
&amp;lt;br&amp;gt;3) LM 741 Op Amp (x3)&lt;br /&gt;
&amp;lt;br&amp;gt;4) JHD 162A Parallel LCD&lt;br /&gt;
&amp;lt;br&amp;gt;5) Car audio amplifier, at least 3-channel (Legacy LA160 4 Channel 300 Watt used here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Alternative components that are needed if car amplifier is not available:&lt;br /&gt;
&amp;lt;br&amp;gt;1) TDA 2040 audio amplifier chip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;*Note: The AD9833 is a surface mount chip, and needs a 10-pin adaptor, 33010CA-ND onto which it is soldered&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;The PIC communicates with the AD9833 function generator chip through SPI interface. Refer to [[Waveform_Generation_with_AD9833%2C_and_SPI|Waveform Generation with AD9833, and SPI]] for how to use this chip. The Master Clock is connected to the CLK of the PIC, and the three SPI communication lines are connected to the three I/O pins A1, A2 and A3 on the PIC.&lt;br /&gt;
&lt;br /&gt;
[[ http://hades.mech.northwestern.edu/wiki/images/math/f/b/d/fbd0abe078f3a06ad554be1ffc67e857.png]]&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
Note: When wiring the touchscreen you have a couple of options. The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC. If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable. This can be down with a wire stripper and soldering. The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
=== Circuit Notes ===&lt;br /&gt;
[[image:chladni_circuit_plugged|Circuit board with components plugged in|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[image:chladni_circuit_unplugged|Circuit board with components un-plugged|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Circuit Diagram ===&lt;br /&gt;
[[image:chladni_circuit_actual|Circuit schematic of circuit used for demonstration 3-speaker Chladni|thumb|600px]]&lt;br /&gt;
[[image:tda2040_circuit|TDA-2040 Audio Amp Circuit[http://www.datasheetcatalog.org/datasheet/stmicroelectronics/1460.pdf&#039;]|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
=== Main frequency sweep code ===&lt;br /&gt;
[[media:chladni_code.c|Full code here]]&lt;br /&gt;
&lt;br /&gt;
The first thing that this code does is that it initializes the variables target_freq_reg and old_target_freq_reg to the register value of 298 Hz, which is a non-resonant frequency. See [[Waveform_Generation_with_AD9833,_and_SPI]] to find out how to convert between frequency and register value for commands sent to the AD9833 function generator chip, and sending commands to the AD9833 using SPI.&lt;br /&gt;
After this, the analog port pin is set up and the lcd_init() function is called to set up the LCD display. The LCD displays the current frequency that the AD9833 is currently outputting and the target frequency that the chip is supposed to sweep up/down to. See [[C Example: Parallel Interfacing with LCDs]] to learn about how to interface and send information to the LCD.&lt;br /&gt;
&lt;br /&gt;
Once the initial set up information is finished, the code sends the first frequency command to the AD9833, starting it at a frequency of 298 Hz by giving it the target_freq_reg register value (initialized at 298 Hz). This allows the speakers to sweep up to the first resonant frequency and oscillate the salt into the first resonant shape when the system is turned on. The register values are then converted to Hz and displayed on the LCD. From there, the code goes into a while() loop which continuously checks the input from the user interface knob which indicates the target frequency that the AD9833 should go to. After getting the target frequency from check_input(), the code compares this new frequency information to the old frequency information (old_freq_reg). If they are different, then the knob was switched to a new frequency and the AD9833 needs to sweep up or down to the new frequency. Depending on whether the new frequency is above or below the old frequency, a for-loop will keep sending new frequency register commands to the AD9833, shifting up or down by 1 Hz every 100 ms, constantly updating the LCD to display the current and target frequency, until the actual frequency is equal to the target frequency. The function check_input() is called for each iteration of the for-loop to check if the target frequency was changed. The old_target_freq_reg is then set equal to the target_freq_reg and the program then holds at this one resonant frequency until the knob sends a different target_freq_reg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Chladni Code&lt;br /&gt;
Lingyu Xie, Anup Tapase, Chris Chow&lt;br /&gt;
ME333 Winter 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#DEVICE ADC=8                   // set ADC to 8 bit accuracy&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
#use spi(DO = PIN_A3, CLK = PIN_A2, ENABLE = PIN_A1, BITS = 16, MASTER, ENABLE_ACTIVE = 0, MSB_FIRST, IDLE = 1)&lt;br /&gt;
&lt;br /&gt;
int16 freq,target_freq;&lt;br /&gt;
int16 target_freq_reg, old_target_freq_reg;&lt;br /&gt;
int8 knob_val=0;&lt;br /&gt;
&lt;br /&gt;
void check_input();&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
   int16 ct;&lt;br /&gt;
   &lt;br /&gt;
   target_freq_reg=2000+16384;         // initialize starting frequency of speakers to 298 Hz (non-resonant)&lt;br /&gt;
   old_target_freq_reg=2000+16384;     // set old target freq variable to equal target freq&lt;br /&gt;
&lt;br /&gt;
   setup_adc_ports(AN0);               // Set up analog input port as pin A0&lt;br /&gt;
   setup_adc(ADC_CLOCK_INTERNAL);&lt;br /&gt;
   &lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
   &lt;br /&gt;
   //INITIAL FREQUENCY FOR AD9833&lt;br /&gt;
   spi_xfer(0b0010000100000000); //format command, output sine wave&lt;br /&gt;
               &lt;br /&gt;
   spi_xfer(target_freq_reg);    //1st set of bits, 14 LSB, this range is good enough for our use&lt;br /&gt;
                                 //send the target frequency register value (freq + 16384) to AD9833 chip&lt;br /&gt;
   spi_xfer(0b0100000000000000); //2nd set of bits, 14 MSB&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b1100000000000000); //phase register: 0 phase shift (B0-B13)&lt;br /&gt;
   &lt;br /&gt;
   spi_xfer(0b0000000000000000); //unformat&lt;br /&gt;
   &lt;br /&gt;
   freq=(float).149011 * (float)(target_freq_reg - 16384);  //convert the target freq register value to actual freq value&lt;br /&gt;
   target_freq=freq; // initialize target freq as current freq&lt;br /&gt;
&lt;br /&gt;
   printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
   printf(lcd_putc,&amp;quot;Target: %Lu H\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
   &lt;br /&gt;
   while(TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      check_input(); //check the knob input to see if target frequency has changed&lt;br /&gt;
      &lt;br /&gt;
      if(old_target_freq_reg != target_freq_reg) //go in here if target freq changed after calling check_input()&lt;br /&gt;
      {&lt;br /&gt;
         if(target_freq_reg &amp;gt; old_target_freq_reg) //sweep up to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;lt;=target_freq_reg; ct=ct+7) //ct+7 approximate increases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping up by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384);&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384);&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
               &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
               &lt;br /&gt;
         }&lt;br /&gt;
         else if(target_freq_reg &amp;lt; old_target_freq_reg) //sweep down to target freq&lt;br /&gt;
         {&lt;br /&gt;
            for(ct=old_target_freq_reg; ct&amp;gt;=target_freq_reg; ct=ct-7) //ct+7 approximate decreases frequency by 1 Hz&lt;br /&gt;
            {&lt;br /&gt;
               spi_xfer(0b0010000100000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(ct); //set AD9833 frequency to ct, which is freq register that is sweeping down by 7 each time loop is run&lt;br /&gt;
               spi_xfer(0b0100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b1100000000000000);&lt;br /&gt;
               &lt;br /&gt;
               spi_xfer(0b0000000000000000);&lt;br /&gt;
               &lt;br /&gt;
               &lt;br /&gt;
               freq=(float).149011 * (float)(ct - 16384); //convert current freq register value (ct) to frequency value&lt;br /&gt;
               target_freq=(float).149011 * (float)(target_freq_reg - 16384); //convert target freq register to target freq value&lt;br /&gt;
         &lt;br /&gt;
               printf(lcd_putc,&amp;quot;\fFreq: %Lu Hz\n&amp;quot;,freq); //display current freq&lt;br /&gt;
               printf(lcd_putc,&amp;quot;Target: %Lu Hz\n&amp;quot;,target_freq); //display target freq&lt;br /&gt;
               &lt;br /&gt;
               check_input(); //see if knob position has selected different target freq&lt;br /&gt;
               delay_ms(90);  //delay to allow speakers to play freq for 90 ms + 10 ms (in check_input() function)&lt;br /&gt;
            }&lt;br /&gt;
   &lt;br /&gt;
            old_target_freq_reg = target_freq_reg; //reached target freq, set both variables equal until knob position changed&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Checking user input ===&lt;br /&gt;
This function is used to check the knob/potentiometer position at certain points during the changing of frequencies in the main function. It sets the ADC channel to 0 and takes the analog input from pin A0 on the PIC using read_adc(). This input, set to the variable knob_val, is an integer between 0-255 which corresponds to the voltage coming out of the knob/potentiometer, which is 0 if the output is at 0V and 255 if the output is at 5V. By checking if knob_val is between a certain integer range corresponding to the different numbers on the knob (numbered 0-10), the target frequency can be set by the user. Nine target resonant frequencies were programmed in this function based on the good clarity of the shapes they produced on the plate, but more resonant frequencies exist and can be added to the if-statement in this function. The target frequency registers should be adjusted depending on the plate shape and size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void check_input() //check knob position to see if target freq has changed&lt;br /&gt;
{      &lt;br /&gt;
      set_adc_channel(0);     // Set the analog input channel to 0&lt;br /&gt;
      delay_us(10);           // wait 10uS for ADC to settle to a newly selected input&lt;br /&gt;
      knob_val = read_adc();  // Read in knob user input to tell speakers what resonant freq to sweep up to&lt;br /&gt;
      &lt;br /&gt;
      delay_ms(10);           // delay 10 ms to allow reading of analog input&lt;br /&gt;
      &lt;br /&gt;
      //check and set target_freq_reg according to knob position (0-255 values split into 9 discrete levels)&lt;br /&gt;
      if (knob_val &amp;gt;= 0 &amp;amp;&amp;amp; knob_val&amp;lt; 22 )&lt;br /&gt;
         target_freq_reg = 2281+16384; //339 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 22 &amp;amp;&amp;amp; knob_val&amp;lt; 54)&lt;br /&gt;
         target_freq_reg = 3308+16384; //493 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 54 &amp;amp;&amp;amp; knob_val&amp;lt; 86)&lt;br /&gt;
         target_freq_reg = 3778+16384; //563 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 86 &amp;amp;&amp;amp; knob_val&amp;lt; 117)&lt;br /&gt;
         target_freq_reg = 3986+16384; //594 Hz&lt;br /&gt;
      else if(knob_val &amp;gt;= 117 &amp;amp;&amp;amp; knob_val&amp;lt; 147)&lt;br /&gt;
         target_freq_reg = 4207+16384; //627 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 147 &amp;amp;&amp;amp; knob_val&amp;lt; 178)&lt;br /&gt;
         target_freq_reg = 4362+16384; //650 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 178 &amp;amp;&amp;amp; knob_val&amp;lt; 209)&lt;br /&gt;
         target_freq_reg = 5006+16384; //746 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 209 &amp;amp;&amp;amp; knob_val&amp;lt; 239)&lt;br /&gt;
         target_freq_reg = 5308+16384; //791 Hz &lt;br /&gt;
      else if(knob_val &amp;gt;= 239 &amp;amp;&amp;amp; knob_val&amp;lt; 255)&lt;br /&gt;
         target_freq_reg = 5872+16384; //875 Hz &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
=== Three-Speaker Chladni===&lt;br /&gt;
[[image:chladni_339hz|Three-Speaker Configuration at 339 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_424hz|Three-Speaker Configuration at 424 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_554hz|Three-Speaker Configuration at 554 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_632hz|Three-Speaker Configuration at 632 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_660hz|Three-Speaker Configuration at 660 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[image:chladni_734hz|Three-Speaker Configuration at 734 Hz|thumb|300px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== One-Speaker Chladni ===&lt;br /&gt;
-add video of one-speaker config&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
=== Possible Future Improvements/Enhancements ===&lt;br /&gt;
-Try sending different frequencies (by figuring out how to program multiple AD9833 chips) to each speaker to see if they generate different patterns&lt;br /&gt;
&amp;lt;br&amp;gt;-Use different plate size or add 4th speaker and use large square plate to change the types of visible shapes at resonance&lt;br /&gt;
&amp;lt;br&amp;gt;-Figure out issue with TDA-2040 audio amp so the project wouldn&#039;t have to rely on car audio amp&lt;br /&gt;
&amp;lt;br&amp;gt;-Use more rigid plate or construct one with less defects in shape&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10702</id>
		<title>Interfacing with a touchscreen</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10702"/>
		<updated>2009-02-12T18:27:26Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Experimental Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
Interface the PIC with a surplus touchscreen from the LIMS lab and display (x,y) data on an LCD screen (see, e.g., [[C Example: Serial LCD]] or [[C Example: Parallel Interfacing with LCDs]]) or a PC (e.g., matlab or hyperterminal).&lt;br /&gt;
&lt;br /&gt;
Spec sheet: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/]&lt;br /&gt;
(Use the last .pdf under Reference Materials)&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:touchscreen|thumb|200px|How a touchscreen works [http://www.touchscreenguide.com/]|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of the project is to interface the PIC18F4520 with the 3M EX II 7720SC capacitive touchscreen. The spec sheet is located here: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/] (Use the last .pdf under Reference Materials). In addition, when a finger makes contact with the touchscreen, the X-Y coordinates will be displayed on a JHD 162A Parallel LCD (see [[C Example: Parallel Interfacing with LCDs]]).&lt;br /&gt;
&lt;br /&gt;
There are many different types of touchscreen technologies. The one used below is a capacitive touchscreen. A capacitive touchscreen is usually coated in a charge storing material, such as indium tin oxide. Voltage is applied to each corner of the glass screen and electrodes are spread uniformly throughout the screen. Capacitive touchscreens are only responsive to finger touch which draw current from each side of the screen. The controller will then calculate the X-Y position of the finger from the current. &lt;br /&gt;
&lt;br /&gt;
Advantages of the touchscreen are high touch resolution, high image clarity, and is not affected by dirt, grease, or moisture. However it can only be activated by the touch of something conductive, such as one&#039;s finger. [http://www.touchscreens.com/intro-touchtypes-capacitive.html]&lt;br /&gt;
&lt;br /&gt;
On this page you will find the steps to implement the touchscreen interface on your own. This includes the code, circuit diagram, and other notes about creating the interface.  If you build the circuit as displayed below and run the program through the PIC, you should be able to display on an LCD a finger&#039;s X-Y position on the touchscreen.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Circuit ==&lt;br /&gt;
[[image:lcd_circuit|thumb|300px|Circuit schematic of connections between PIC, LCD, MAX232 and touchscreen|right]]&lt;br /&gt;
[[image:photo_lcd_circuit|thumb|300px|Photo of circuit|right]]&lt;br /&gt;
&lt;br /&gt;
The image on the right is the circuit schematic showing the connections between all the components. An actual picture of the circuit is also shown.&lt;br /&gt;
&lt;br /&gt;
The chips required for implementing this circuit are:&amp;lt;br&amp;gt;&lt;br /&gt;
1) PIC 18F4520&amp;lt;br&amp;gt;&lt;br /&gt;
2) MAX232N Dual EIA-232 Driver/Receiver &amp;lt;br&amp;gt;&lt;br /&gt;
3) EXII 7720SC (touchscreen controller chip)&amp;lt;br&amp;gt;&lt;br /&gt;
4) JHD 162A Parallel LCD&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
&lt;br /&gt;
Note:  When wiring the touchscreen you have a couple of options.  The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC.  If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable.  This can be down with a wire stripper and soldering.  The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
The file &amp;quot;flex_lcd.c&amp;quot; is required in order for the PIC to communicate with the LCD. The code for the file can be found here: [[C Example: Parallel Interfacing with LCDs]]&lt;br /&gt;
&lt;br /&gt;
The PIC first transmits a &amp;quot;Format Tablet&amp;quot; command to the touchscreen chip, which tells the touchscreen what to transmit back to the PIC. When a finger makes contact with the touchscreen, the chip sends back a 10-byte string of hex values with the X and Y coordinates embedded in the first 5 bytes. This 10-byte string is processed by the PIC, which extracts the X and Y coordinates, converts them to int16 format, and outputs the numbers to the LCD.&lt;br /&gt;
&lt;br /&gt;
The format of each touch signal returned from the touchscreen controller can be found on Table 8 (page 27) of the [http://multimedia.mmm.com/mws/mediawebserver.dyn?6666660Zjcf6lVs6EVs66SBhjCOrrrrQ-| EXII 7720SC spec sheet]. The code takes bits 0-13 of the X and Y parts of the signal (X0 - X13 and Y0 - Y13) and combines them into int16 variables x_pos and y_pos, which are displayed on the LCD.&lt;br /&gt;
&lt;br /&gt;
Remember to change the baud rate in the code to 9600 baud, since this is the rate used by the touchscreen chip.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
touchscreen.c&lt;br /&gt;
Chris Chow, Anup Tapase, Lingyu Xie&lt;br /&gt;
Interface PIC with capacitive touchscreen and display X-Y coordinates on LCD&lt;br /&gt;
Feb 12, 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#use rs232(baud=9600, UART1)      // hardware UART; uses  RC6/TX and RC7/RX&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
&lt;br /&gt;
int j;&lt;br /&gt;
int16 x_pos, y_pos;&lt;br /&gt;
&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos);&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
&lt;br /&gt;
   //command Format Tablet: &amp;quot;&amp;lt;SOH&amp;gt;FT&amp;lt;CR&amp;gt;&amp;quot; sent to touchscreen via RC6/TX pin&lt;br /&gt;
   putc(0x01);&lt;br /&gt;
   putc(0x46);&lt;br /&gt;
   putc(0x54);&lt;br /&gt;
   putc(0x0D);&lt;br /&gt;
&lt;br /&gt;
   while (TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      //get the finger position relative to the touchscreen in 16-bit int format&lt;br /&gt;
      get_screen_pos(x_pos, y_pos);&lt;br /&gt;
&lt;br /&gt;
      printf(lcd_putc,&amp;quot;\fX: %Lu\n&amp;quot;,x_pos); //output &amp;quot;X: &amp;lt;x_pos&amp;gt;&amp;quot; to first line of LCD&lt;br /&gt;
      printf(lcd_putc,&amp;quot;Y: %Lu&amp;quot;,y_pos);     //output &amp;quot;Y: &amp;lt;y_pos&amp;gt;&amp;quot; to second line of LCD&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Function adapted from Nick Marchuk&#039;s IR touchscreen code&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos)&lt;br /&gt;
{&lt;br /&gt;
   int i, gotD8, j;&lt;br /&gt;
   int touchscreen_rcx[20];&lt;br /&gt;
   int pos[5];&lt;br /&gt;
   int16 high16, low16, xtotal16, ytotal16;&lt;br /&gt;
   int temp4, total8;&lt;br /&gt;
   high16 = 0;&lt;br /&gt;
   low16 = 0;&lt;br /&gt;
   xtotal16 = 0;&lt;br /&gt;
   ytotal16 = 0;&lt;br /&gt;
   temp4 = 0;&lt;br /&gt;
   total8 = 0;&lt;br /&gt;
&lt;br /&gt;
   //get 10 bytes from the touchscreen (each touch signal is 10 bytes)&lt;br /&gt;
   for (i=1;i&amp;lt;=10;++i)&lt;br /&gt;
   {&lt;br /&gt;
      touchscreen_rcx[i] = getc();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //find the first instance of 0xD8 (start of each signal)&lt;br /&gt;
   gotD8 = 0;&lt;br /&gt;
   j = 1;&lt;br /&gt;
   while(gotD8==0)&lt;br /&gt;
   {&lt;br /&gt;
      if((touchscreen_rcx[j] == 0xD8))&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //j is the location of 0xD8&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         j = j+1;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      if(j==9)&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //didnt find it, dont loop forever&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   pos[1] = touchscreen_rcx[j+1]; //xlow, bits: 0 X6 X5 X4 X3 X2 X1 X0 (see touchscreen datasheet for FT response))&lt;br /&gt;
   pos[2] = touchscreen_rcx[j+2]; //xhigh, bits: 0 X13 X12 X11 X10 X9 X8 X7&lt;br /&gt;
   pos[3] = touchscreen_rcx[j+3]; //ylow, bits: 0 Y6 Y5 Y4 Y3 Y2 Y1 Y0&lt;br /&gt;
   pos[4] = touchscreen_rcx[j+4]; //yhigh, bits: 0 Y13 Y12 Y11 Y10 Y9 Y8 Y7&lt;br /&gt;
&lt;br /&gt;
   //make the x&lt;br /&gt;
   temp4 = pos[2];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0X13X12X11 X10X9X8X7&lt;br /&gt;
   low16 = pos[1]; //make low16= 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   xtotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00X13X12 X11X10X9X8 X7000 0000 with 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
   x_pos = xtotal16; //x_pos=00X13X12 X11X10X9X8 X7X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   //make the y&lt;br /&gt;
   temp4 = pos[4];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0Y13Y12Y11 Y10Y9Y8Y7&lt;br /&gt;
   low16 = pos[3]; //make low16= 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
&lt;br /&gt;
   ytotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00Y13Y12 Y11Y10Y9Y8 Y7000 0000 with 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
   y_pos = ytotal16;             //x_pos=00Y13Y12 Y11Y10Y9Y8 Y7Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Experimental Notes ==&lt;br /&gt;
&lt;br /&gt;
A vibration is felt when a finger is moved along the touchscreen. Since the finger activates the touchscreen by drawing current and acting as a capacitor, we think that the slight vibrations that are felt are due to the current being drawn through the finger.&lt;br /&gt;
&lt;br /&gt;
When two fingers touch the screen at the same time, the output is the average of the two sets of coordinates. For example, if a finger is placed at X:0 Y:0 and another is placed on X: 16000 Y: 16000, the output is X: 8000 Y: 8000. We see the same behavior as we put more fingers on the screen at different locations; the output is the average of all the location coordinates. This can even be seen if only one finger is touching it; depending on how much of the finger is touching the screen, the output changes to get the center of the contact point.&lt;br /&gt;
&lt;br /&gt;
The reason why a finger works with the touchscreen is that the finger exhibits capacitive qualities. The human body has charge that can draw current from the touchscreen. When someone touches the screen some of the charge on the surface is transferred to the person creating a drop in the charge on the screen.  The relative difference in charge from each of the corners of the screen is calculated and a location is the output.  We suspect that other materials that can draw current, such as a piece of fruit, might also work.[http://computer.howstuffworks.com/question716.htm]&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10701</id>
		<title>Interfacing with a touchscreen</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10701"/>
		<updated>2009-02-12T18:19:58Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
Interface the PIC with a surplus touchscreen from the LIMS lab and display (x,y) data on an LCD screen (see, e.g., [[C Example: Serial LCD]] or [[C Example: Parallel Interfacing with LCDs]]) or a PC (e.g., matlab or hyperterminal).&lt;br /&gt;
&lt;br /&gt;
Spec sheet: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/]&lt;br /&gt;
(Use the last .pdf under Reference Materials)&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:touchscreen|thumb|200px|How a touchscreen works [http://www.touchscreenguide.com/]|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of the project is to interface the PIC18F4520 with the 3M EX II 7720SC capacitive touchscreen. The spec sheet is located here: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/] (Use the last .pdf under Reference Materials). In addition, when a finger makes contact with the touchscreen, the X-Y coordinates will be displayed on a JHD 162A Parallel LCD (see [[C Example: Parallel Interfacing with LCDs]]).&lt;br /&gt;
&lt;br /&gt;
There are many different types of touchscreen technologies. The one used below is a capacitive touchscreen. A capacitive touchscreen is usually coated in a charge storing material, such as indium tin oxide. Voltage is applied to each corner of the glass screen and electrodes are spread uniformly throughout the screen. Capacitive touchscreens are only responsive to finger touch which draw current from each side of the screen. The controller will then calculate the X-Y position of the finger from the current. &lt;br /&gt;
&lt;br /&gt;
Advantages of the touchscreen are high touch resolution, high image clarity, and is not affected by dirt, grease, or moisture. However it can only be activated by the touch of something conductive, such as one&#039;s finger. [http://www.touchscreens.com/intro-touchtypes-capacitive.html]&lt;br /&gt;
&lt;br /&gt;
On this page you will find the steps to implement the touchscreen interface on your own. This includes the code, circuit diagram, and other notes about creating the interface.  If you build the circuit as displayed below and run the program through the PIC, you should be able to display on an LCD a finger&#039;s X-Y position on the touchscreen.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Circuit ==&lt;br /&gt;
[[image:lcd_circuit|thumb|300px|Circuit schematic of connections between PIC, LCD, MAX232 and touchscreen|right]]&lt;br /&gt;
[[image:photo_lcd_circuit|thumb|300px|Photo of circuit|right]]&lt;br /&gt;
&lt;br /&gt;
The image on the right is the circuit schematic showing the connections between all the components. An actual picture of the circuit is also shown.&lt;br /&gt;
&lt;br /&gt;
The chips required for implementing this circuit are:&amp;lt;br&amp;gt;&lt;br /&gt;
1) PIC 18F4520&amp;lt;br&amp;gt;&lt;br /&gt;
2) MAX232N Dual EIA-232 Driver/Receiver &amp;lt;br&amp;gt;&lt;br /&gt;
3) EXII 7720SC (touchscreen controller chip)&amp;lt;br&amp;gt;&lt;br /&gt;
4) JHD 162A Parallel LCD&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
&lt;br /&gt;
Note:  When wiring the touchscreen you have a couple of options.  The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC.  If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable.  This can be down with a wire stripper and soldering.  The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
The file &amp;quot;flex_lcd.c&amp;quot; is required in order for the PIC to communicate with the LCD. The code for the file can be found here: [[C Example: Parallel Interfacing with LCDs]]&lt;br /&gt;
&lt;br /&gt;
The PIC first transmits a &amp;quot;Format Tablet&amp;quot; command to the touchscreen chip, which tells the touchscreen what to transmit back to the PIC. When a finger makes contact with the touchscreen, the chip sends back a 10-byte string of hex values with the X and Y coordinates embedded in the first 5 bytes. This 10-byte string is processed by the PIC, which extracts the X and Y coordinates, converts them to int16 format, and outputs the numbers to the LCD.&lt;br /&gt;
&lt;br /&gt;
The format of each touch signal returned from the touchscreen controller can be found on Table 8 (page 27) of the [http://multimedia.mmm.com/mws/mediawebserver.dyn?6666660Zjcf6lVs6EVs66SBhjCOrrrrQ-| EXII 7720SC spec sheet]. The code takes bits 0-13 of the X and Y parts of the signal (X0 - X13 and Y0 - Y13) and combines them into int16 variables x_pos and y_pos, which are displayed on the LCD.&lt;br /&gt;
&lt;br /&gt;
Remember to change the baud rate in the code to 9600 baud, since this is the rate used by the touchscreen chip.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
touchscreen.c&lt;br /&gt;
Chris Chow, Anup Tapase, Lingyu Xie&lt;br /&gt;
Interface PIC with capacitive touchscreen and display X-Y coordinates on LCD&lt;br /&gt;
Feb 12, 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#use rs232(baud=9600, UART1)      // hardware UART; uses  RC6/TX and RC7/RX&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
&lt;br /&gt;
int j;&lt;br /&gt;
int16 x_pos, y_pos;&lt;br /&gt;
&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos);&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
&lt;br /&gt;
   //command Format Tablet: &amp;quot;&amp;lt;SOH&amp;gt;FT&amp;lt;CR&amp;gt;&amp;quot; sent to touchscreen via RC6/TX pin&lt;br /&gt;
   putc(0x01);&lt;br /&gt;
   putc(0x46);&lt;br /&gt;
   putc(0x54);&lt;br /&gt;
   putc(0x0D);&lt;br /&gt;
&lt;br /&gt;
   while (TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      //get the finger position relative to the touchscreen in 16-bit int format&lt;br /&gt;
      get_screen_pos(x_pos, y_pos);&lt;br /&gt;
&lt;br /&gt;
      printf(lcd_putc,&amp;quot;\fX: %Lu\n&amp;quot;,x_pos); //output &amp;quot;X: &amp;lt;x_pos&amp;gt;&amp;quot; to first line of LCD&lt;br /&gt;
      printf(lcd_putc,&amp;quot;Y: %Lu&amp;quot;,y_pos);     //output &amp;quot;Y: &amp;lt;y_pos&amp;gt;&amp;quot; to second line of LCD&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Function adapted from Nick Marchuk&#039;s IR touchscreen code&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos)&lt;br /&gt;
{&lt;br /&gt;
   int i, gotD8, j;&lt;br /&gt;
   int touchscreen_rcx[20];&lt;br /&gt;
   int pos[5];&lt;br /&gt;
   int16 high16, low16, xtotal16, ytotal16;&lt;br /&gt;
   int temp4, total8;&lt;br /&gt;
   high16 = 0;&lt;br /&gt;
   low16 = 0;&lt;br /&gt;
   xtotal16 = 0;&lt;br /&gt;
   ytotal16 = 0;&lt;br /&gt;
   temp4 = 0;&lt;br /&gt;
   total8 = 0;&lt;br /&gt;
&lt;br /&gt;
   //get 10 bytes from the touchscreen (each touch signal is 10 bytes)&lt;br /&gt;
   for (i=1;i&amp;lt;=10;++i)&lt;br /&gt;
   {&lt;br /&gt;
      touchscreen_rcx[i] = getc();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //find the first instance of 0xD8 (start of each signal)&lt;br /&gt;
   gotD8 = 0;&lt;br /&gt;
   j = 1;&lt;br /&gt;
   while(gotD8==0)&lt;br /&gt;
   {&lt;br /&gt;
      if((touchscreen_rcx[j] == 0xD8))&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //j is the location of 0xD8&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         j = j+1;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      if(j==9)&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //didnt find it, dont loop forever&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   pos[1] = touchscreen_rcx[j+1]; //xlow, bits: 0 X6 X5 X4 X3 X2 X1 X0 (see touchscreen datasheet for FT response))&lt;br /&gt;
   pos[2] = touchscreen_rcx[j+2]; //xhigh, bits: 0 X13 X12 X11 X10 X9 X8 X7&lt;br /&gt;
   pos[3] = touchscreen_rcx[j+3]; //ylow, bits: 0 Y6 Y5 Y4 Y3 Y2 Y1 Y0&lt;br /&gt;
   pos[4] = touchscreen_rcx[j+4]; //yhigh, bits: 0 Y13 Y12 Y11 Y10 Y9 Y8 Y7&lt;br /&gt;
&lt;br /&gt;
   //make the x&lt;br /&gt;
   temp4 = pos[2];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0X13X12X11 X10X9X8X7&lt;br /&gt;
   low16 = pos[1]; //make low16= 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   xtotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00X13X12 X11X10X9X8 X7000 0000 with 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
   x_pos = xtotal16; //x_pos=00X13X12 X11X10X9X8 X7X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   //make the y&lt;br /&gt;
   temp4 = pos[4];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0Y13Y12Y11 Y10Y9Y8Y7&lt;br /&gt;
   low16 = pos[3]; //make low16= 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
&lt;br /&gt;
   ytotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00Y13Y12 Y11Y10Y9Y8 Y7000 0000 with 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
   y_pos = ytotal16;             //x_pos=00Y13Y12 Y11Y10Y9Y8 Y7Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Experimental Notes ==&lt;br /&gt;
&lt;br /&gt;
A vibration is felt when a finger is moved along the touchscreen. Since the finger activates the touchscreen by drawing current and acting as a capacitor, we think that the slight vibrations that are felt are due to the current being drawn through the finger.&lt;br /&gt;
&lt;br /&gt;
When two fingers touch the screen at the same time, the output is the average of the two sets of coordinates. For example, if a finger is placed at X:0 Y:0 and another is placed on X: 16000 Y: 16000, the output is X: 8000 Y: 8000. We see the same behavior as we put more fingers on the screen at different locations; the output is the average of all the location coordinates. This can even be seen if only one finger is touching it; depending on how much of the finger is touching the screen, the output changes to get the center of the contact point.&lt;br /&gt;
&lt;br /&gt;
The reason why a finger works with the touchscreen is that the finger exhibits capacitive qualities. The human body has charge that can draw current from the touchscreen. When someone touches the screen some of the charge on the surface is transferred to the person creating a drop in the charge on the screen.  The relative difference in charge from each of the corners of the screen is calculated and a location is the output.  We suspect that other materials that can draw current, such as a piece of fruit might also work.[http://computer.howstuffworks.com/question716.htm]&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10612</id>
		<title>Interfacing with a touchscreen</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10612"/>
		<updated>2009-02-12T06:39:02Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
Interface the PIC with a surplus touchscreen from the LIMS lab and display (x,y) data on an LCD screen (see, e.g., [[C Example: Serial LCD]] or [[C Example: Parallel Interfacing with LCDs]]) or a PC (e.g., matlab or hyperterminal).&lt;br /&gt;
&lt;br /&gt;
Spec sheet: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/]&lt;br /&gt;
(Use the last .pdf under Reference Materials)&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:touchscreen|thumb|200px|How a touchscreen works [http://www.touchscreenguide.com/]|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of the project is to interface the PIC18F4520 with the 3M EX II 7720SC capacitive touchscreen. The spec sheet is located here: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/] (Use the last .pdf under Reference Materials). In addition, when a finger makes contact with the touchscreen, the X-Y coordinates will be displayed on a JHD 162A Parallel LCD (see [[C Example: Parallel Interfacing with LCDs]]).&lt;br /&gt;
&lt;br /&gt;
There are many different types of touchscreen technologies. The one used below is a capacitive touchscreen. A capacitive touchscreen is usually coated in a charge storing material, such as indium tin oxide. Voltage is applied to each corner of the glass screen and electrodes are spread uniformly throughout the screen. Capacitive touchscreens are only responsive to finger touch which draw current from each side of the screen. The controller will then calculate the X-Y position of the finger from the current. &lt;br /&gt;
&lt;br /&gt;
Advantages of the touchscreen are high touch resolution, high image clarity, and is not affected by dirt, grease, or moisture. However it can only be activated by the touch of something conductive, such as one&#039;s finger. [http://www.touchscreens.com/intro-touchtypes-capacitive.html]&lt;br /&gt;
&lt;br /&gt;
On this page you will find the steps to implement the touchscreen interface on your own. This includes the code, circuit diagram, and other notes about creating the interface.  If you build the circuit as displayed below and run the program through the PIC, you should be able to track a finger along the surface of the touchscreen.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Circuit ==&lt;br /&gt;
[[image:lcd_circuit|thumb|300px|Circuit schematic of connections between PIC, LCD, MAX232 and touchscreen|right]]&lt;br /&gt;
[[image:photo_lcd_circuit|thumb|300px|Photo of circuit|right]]&lt;br /&gt;
&lt;br /&gt;
The image on the right is the circuit schematic showing the connections between all the components. An actual picture of the circuit is also shown.&lt;br /&gt;
&lt;br /&gt;
The chips required for implementing this circuit are:&amp;lt;br&amp;gt;&lt;br /&gt;
1) PIC 18F4520&amp;lt;br&amp;gt;&lt;br /&gt;
2) MAX232N Dual EIA-232 Driver/Receiver &amp;lt;br&amp;gt;&lt;br /&gt;
3) EXII 7720SC (touchscreen controller chip)&amp;lt;br&amp;gt;&lt;br /&gt;
4) JHD 162A Parallel LCD&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
&lt;br /&gt;
Note:  When wiring the touchscreen you have a couple of options.  The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC.  If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable.  This can be down with a wire stripper and soldering.  The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
The file &amp;quot;flex_lcd.c&amp;quot; is required in order for the PIC to communicate with the LCD. The code for the file can be found here: [[C Example: Parallel Interfacing with LCDs]]&lt;br /&gt;
&lt;br /&gt;
The PIC first transmits a &amp;quot;Format Tablet&amp;quot; command to the touchscreen chip, which tells the touchscreen what to transmit back to the PIC. When a finger makes contact with the touchscreen, the chip sends back a 10-byte string of hex values with the X and Y coordinates embedded in the first 5 bytes. This 10-byte string is processed by the PIC, which extracts the X and Y coordinates, converts them to int16 format, and outputs the numbers to the LCD.&lt;br /&gt;
&lt;br /&gt;
The format of each touch signal returned from the touchscreen controller can be found on Table 8 (page 27) of the [http://multimedia.mmm.com/mws/mediawebserver.dyn?6666660Zjcf6lVs6EVs66SBhjCOrrrrQ-| EXII 7720SC spec sheet]. The code takes bits 0-13 of the X and Y parts of the signal (X0 - X13 and Y0 - Y13) and combines them into int16 variables x_pos and y_pos, which are displayed on the LCD.&lt;br /&gt;
&lt;br /&gt;
Remember to change the baud rate in the code to 9600 baud, since this is the rate used by the touchscreen chip.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
touchscreen.c&lt;br /&gt;
Chris Chow, Anup Tapase, Lingyu Xie&lt;br /&gt;
Interface PIC with capacitive touchscreen and display X-Y coordinates on LCD&lt;br /&gt;
Feb 12, 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#use rs232(baud=9600, UART1)      // hardware UART; uses  RC6/TX and RC7/RX&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
&lt;br /&gt;
int j;&lt;br /&gt;
int16 x_pos, y_pos;&lt;br /&gt;
&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos);&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
&lt;br /&gt;
   //command Format Tablet: &amp;quot;&amp;lt;SOH&amp;gt;FT&amp;lt;CR&amp;gt;&amp;quot; sent to touchscreen via RC6/TX pin&lt;br /&gt;
   putc(0x01);&lt;br /&gt;
   putc(0x46);&lt;br /&gt;
   putc(0x54);&lt;br /&gt;
   putc(0x0D);&lt;br /&gt;
&lt;br /&gt;
   while (TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      //get the finger position relative to the touchscreen in 16-bit int format&lt;br /&gt;
      get_screen_pos(x_pos, y_pos);&lt;br /&gt;
&lt;br /&gt;
      printf(lcd_putc,&amp;quot;\fX: %Lu\n&amp;quot;,x_pos); //output &amp;quot;X: &amp;lt;x_pos&amp;gt;&amp;quot; to first line of LCD&lt;br /&gt;
      printf(lcd_putc,&amp;quot;Y: %Lu&amp;quot;,y_pos);     //output &amp;quot;Y: &amp;lt;y_pos&amp;gt;&amp;quot; to second line of LCD&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Function adapted from Nick Marchuk&#039;s IR touchscreen code&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos)&lt;br /&gt;
{&lt;br /&gt;
   int i, gotD8, j;&lt;br /&gt;
   int touchscreen_rcx[20];&lt;br /&gt;
   int pos[5];&lt;br /&gt;
   int16 high16, low16, xtotal16, ytotal16;&lt;br /&gt;
   int temp4, total8;&lt;br /&gt;
   high16 = 0;&lt;br /&gt;
   low16 = 0;&lt;br /&gt;
   xtotal16 = 0;&lt;br /&gt;
   ytotal16 = 0;&lt;br /&gt;
   temp4 = 0;&lt;br /&gt;
   total8 = 0;&lt;br /&gt;
&lt;br /&gt;
   //get 10 bytes from the touchscreen (each touch signal is 10 bytes)&lt;br /&gt;
   for (i=1;i&amp;lt;=10;++i)&lt;br /&gt;
   {&lt;br /&gt;
      touchscreen_rcx[i] = getc();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //find the first instance of 0xD8 (start of each signal)&lt;br /&gt;
   gotD8 = 0;&lt;br /&gt;
   j = 1;&lt;br /&gt;
   while(gotD8==0)&lt;br /&gt;
   {&lt;br /&gt;
      if((touchscreen_rcx[j] == 0xD8))&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //j is the location of 0xD8&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         j = j+1;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      if(j==9)&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //didnt find it, dont loop forever&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   pos[1] = touchscreen_rcx[j+1]; //xlow, bits: 0 X6 X5 X4 X3 X2 X1 X0 (see touchscreen datasheet for FT response))&lt;br /&gt;
   pos[2] = touchscreen_rcx[j+2]; //xhigh, bits: 0 X13 X12 X11 X10 X9 X8 X7&lt;br /&gt;
   pos[3] = touchscreen_rcx[j+3]; //ylow, bits: 0 Y6 Y5 Y4 Y3 Y2 Y1 Y0&lt;br /&gt;
   pos[4] = touchscreen_rcx[j+4]; //yhigh, bits: 0 Y13 Y12 Y11 Y10 Y9 Y8 Y7&lt;br /&gt;
&lt;br /&gt;
   //make the x&lt;br /&gt;
   temp4 = pos[2];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0X13X12X11 X10X9X8X7&lt;br /&gt;
   low16 = pos[1]; //make low16= 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   xtotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00X13X12 X11X10X9X8 X7000 0000 with 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
   x_pos = xtotal16; //x_pos=00X13X12 X11X10X9X8 X7X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   //make the y&lt;br /&gt;
   temp4 = pos[4];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0Y13Y12Y11 Y10Y9Y8Y7&lt;br /&gt;
   low16 = pos[3]; //make low16= 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
&lt;br /&gt;
   ytotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00Y13Y12 Y11Y10Y9Y8 Y7000 0000 with 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
   y_pos = ytotal16;             //x_pos=00Y13Y12 Y11Y10Y9Y8 Y7Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Experimental Notes ==&lt;br /&gt;
&lt;br /&gt;
A vibration is felt when a finger is moved along the touchscreen. Since the finger activates the touchscreen by drawing current and acting as a capacitor, we think that the slight vibrations that are felt are due to the current being drawn through the finger.&lt;br /&gt;
&lt;br /&gt;
When two fingers touch the screen at the same time, the output is the average of the two sets of coordinates. For example, if a finger is placed at X:0 Y:0 and another is placed on X: 16000 Y: 16000, the output is X: 8000 Y: 8000. We see the same behavior as we put more fingers on the screen at different locations; the output is the average of all the location coordinates. This can even be seen if only one finger is touching it; depending on how much of the finger is touching the screen, the output changes to get the center of the contact point.&lt;br /&gt;
&lt;br /&gt;
The reason why a finger works with the touchscreen is that the finger exhibits capacitive qualities. The human body has charge that can draw current from the touchscreen. When someone touches the screen some of the charge on the surface is transferred to the person creating a drop in the charge on the screen.  The relative difference in charge from each of the corners of the screen is calculated and a location is the output.  We suspect that other materials that can draw current, such as a piece of fruit might also work.[http://computer.howstuffworks.com/question716.htm]&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10605</id>
		<title>Interfacing with a touchscreen</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10605"/>
		<updated>2009-02-12T06:36:43Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
Interface the PIC with a surplus touchscreen from the LIMS lab and display (x,y) data on an LCD screen (see, e.g., [[C Example: Serial LCD]] or [[C Example: Parallel Interfacing with LCDs]]) or a PC (e.g., matlab or hyperterminal).&lt;br /&gt;
&lt;br /&gt;
Spec sheet: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/]&lt;br /&gt;
(Use the last .pdf under Reference Materials)&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:touchscreen|thumb|200px|How a touchscreen works [http://www.touchscreenguide.com/]|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of the project is to interface the PIC18F4520 with the 3M EX II 7720SC capacitive touchscreen. The spec sheet is located here: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/] (Use the last .pdf under Reference Materials). In addition, when a finger makes contact with the touchscreen, the X-Y coordinates will be displayed on a JHD 162A Parallel LCD (see [[C Example: Parallel Interfacing with LCDs]]).&lt;br /&gt;
&lt;br /&gt;
There are many different types of touchscreen technologies. The one used below is a capacitive touchscreen. A capacitive touchscreen is usually coated in a charge storing material, such as indium tin oxide. Voltage is applied to each corner of the glass screen and electrodes are spread uniformly throughout the screen. Capacitive touchscreens are only responsive to finger touch which draw current from each side of the screen. The controller will then calculate the X-Y position of the finger from the current. &lt;br /&gt;
&lt;br /&gt;
Advantages of the touchscreen are high touch resolution, high image clarity, and is not affected by dirt, grease, or moisture. However it can only be activated by the touch of something conductive, such as one&#039;s finger. [http://www.touchscreens.com/intro-touchtypes-capacitive.html]&lt;br /&gt;
&lt;br /&gt;
On this page you will find the steps to implement the touchscreen interface on your own. This includes the code, circuit diagram, and other notes about creating the interface.  If you build the circuit as displayed below and use the code provided, you should be able to track a finger along the surface of the touchscreen.  &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Circuit ==&lt;br /&gt;
[[image:lcd_circuit|thumb|300px|Circuit schematic of connections between PIC, LCD, MAX232 and touchscreen|right]]&lt;br /&gt;
[[image:photo_lcd_circuit|thumb|300px|Photo of circuit|right]]&lt;br /&gt;
&lt;br /&gt;
The image on the right is the circuit schematic showing the connections between all the components. An actual picture of the circuit is also shown.&lt;br /&gt;
&lt;br /&gt;
The chips required for implementing this circuit are:&amp;lt;br&amp;gt;&lt;br /&gt;
1) PIC 18F4520&amp;lt;br&amp;gt;&lt;br /&gt;
2) MAX232N Dual EIA-232 Driver/Receiver &amp;lt;br&amp;gt;&lt;br /&gt;
3) EXII 7720SC (touchscreen controller chip)&amp;lt;br&amp;gt;&lt;br /&gt;
4) JHD 162A Parallel LCD&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
&lt;br /&gt;
Note:  When wiring the touchscreen you have a couple of options.  The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC.  If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable.  This can be down with a wire stripper and soldering.  The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
The file &amp;quot;flex_lcd.c&amp;quot; is required in order for the PIC to communicate with the LCD. The code for the file can be found here: [[C Example: Parallel Interfacing with LCDs]]&lt;br /&gt;
&lt;br /&gt;
The PIC first transmits a &amp;quot;Format Tablet&amp;quot; command to the touchscreen chip, which tells the touchscreen what to transmit back to the PIC. When a finger makes contact with the touchscreen, the chip sends back a 10-byte string of hex values with the X and Y coordinates embedded in the first 5 bytes. This 10-byte string is processed by the PIC, which extracts the X and Y coordinates, converts them to int16 format, and outputs the numbers to the LCD.&lt;br /&gt;
&lt;br /&gt;
The format of each touch signal returned from the touchscreen controller can be found on Table 8 (page 27) of the [http://multimedia.mmm.com/mws/mediawebserver.dyn?6666660Zjcf6lVs6EVs66SBhjCOrrrrQ-| EXII 7720SC spec sheet]. The code takes bits 0-13 of the X and Y parts of the signal (X0 - X13 and Y0 - Y13) and combines them into int16 variables x_pos and y_pos, which are displayed on the LCD.&lt;br /&gt;
&lt;br /&gt;
Remember to change the baud rate in the code to 9600 baud, since this is the rate used by the touchscreen chip.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
touchscreen.c&lt;br /&gt;
Chris Chow, Anup Tapase, Lingyu Xie&lt;br /&gt;
Interface PIC with capacitive touchscreen and display X-Y coordinates on LCD&lt;br /&gt;
Feb 12, 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#use rs232(baud=9600, UART1)      // hardware UART; uses  RC6/TX and RC7/RX&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
&lt;br /&gt;
int j;&lt;br /&gt;
int16 x_pos, y_pos;&lt;br /&gt;
&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos);&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
&lt;br /&gt;
   //command Format Tablet: &amp;quot;&amp;lt;SOH&amp;gt;FT&amp;lt;CR&amp;gt;&amp;quot; sent to touchscreen via RC6/TX pin&lt;br /&gt;
   putc(0x01);&lt;br /&gt;
   putc(0x46);&lt;br /&gt;
   putc(0x54);&lt;br /&gt;
   putc(0x0D);&lt;br /&gt;
&lt;br /&gt;
   while (TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      //get the finger position relative to the touchscreen in 16-bit int format&lt;br /&gt;
      get_screen_pos(x_pos, y_pos);&lt;br /&gt;
&lt;br /&gt;
      printf(lcd_putc,&amp;quot;\fX: %Lu\n&amp;quot;,x_pos); //output &amp;quot;X: &amp;lt;x_pos&amp;gt;&amp;quot; to first line of LCD&lt;br /&gt;
      printf(lcd_putc,&amp;quot;Y: %Lu&amp;quot;,y_pos);     //output &amp;quot;Y: &amp;lt;y_pos&amp;gt;&amp;quot; to second line of LCD&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Function adapted from Nick Marchuk&#039;s IR touchscreen code&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos)&lt;br /&gt;
{&lt;br /&gt;
   int i, gotD8, j;&lt;br /&gt;
   int touchscreen_rcx[20];&lt;br /&gt;
   int pos[5];&lt;br /&gt;
   int16 high16, low16, xtotal16, ytotal16;&lt;br /&gt;
   int temp4, total8;&lt;br /&gt;
   high16 = 0;&lt;br /&gt;
   low16 = 0;&lt;br /&gt;
   xtotal16 = 0;&lt;br /&gt;
   ytotal16 = 0;&lt;br /&gt;
   temp4 = 0;&lt;br /&gt;
   total8 = 0;&lt;br /&gt;
&lt;br /&gt;
   //get 10 bytes from the touchscreen (each touch signal is 10 bytes)&lt;br /&gt;
   for (i=1;i&amp;lt;=10;++i)&lt;br /&gt;
   {&lt;br /&gt;
      touchscreen_rcx[i] = getc();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //find the first instance of 0xD8 (start of each signal)&lt;br /&gt;
   gotD8 = 0;&lt;br /&gt;
   j = 1;&lt;br /&gt;
   while(gotD8==0)&lt;br /&gt;
   {&lt;br /&gt;
      if((touchscreen_rcx[j] == 0xD8))&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //j is the location of 0xD8&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         j = j+1;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      if(j==9)&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //didnt find it, dont loop forever&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   pos[1] = touchscreen_rcx[j+1]; //xlow, bits: 0 X6 X5 X4 X3 X2 X1 X0 (see touchscreen datasheet for FT response))&lt;br /&gt;
   pos[2] = touchscreen_rcx[j+2]; //xhigh, bits: 0 X13 X12 X11 X10 X9 X8 X7&lt;br /&gt;
   pos[3] = touchscreen_rcx[j+3]; //ylow, bits: 0 Y6 Y5 Y4 Y3 Y2 Y1 Y0&lt;br /&gt;
   pos[4] = touchscreen_rcx[j+4]; //yhigh, bits: 0 Y13 Y12 Y11 Y10 Y9 Y8 Y7&lt;br /&gt;
&lt;br /&gt;
   //make the x&lt;br /&gt;
   temp4 = pos[2];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0X13X12X11 X10X9X8X7&lt;br /&gt;
   low16 = pos[1]; //make low16= 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   xtotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00X13X12 X11X10X9X8 X7000 0000 with 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
   x_pos = xtotal16; //x_pos=00X13X12 X11X10X9X8 X7X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   //make the y&lt;br /&gt;
   temp4 = pos[4];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0Y13Y12Y11 Y10Y9Y8Y7&lt;br /&gt;
   low16 = pos[3]; //make low16= 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
&lt;br /&gt;
   ytotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00Y13Y12 Y11Y10Y9Y8 Y7000 0000 with 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
   y_pos = ytotal16;             //x_pos=00Y13Y12 Y11Y10Y9Y8 Y7Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Experimental Notes ==&lt;br /&gt;
&lt;br /&gt;
A vibration is felt when a finger is moved along the touchscreen. Since the finger activates the touchscreen by drawing current and acting as a capacitor, we think that the slight vibrations that are felt are due to the current being drawn through the finger.&lt;br /&gt;
&lt;br /&gt;
When two fingers touch the screen at the same time, the output is the average of the two sets of coordinates. For example, if a finger is placed at X:0 Y:0 and another is placed on X: 16000 Y: 16000, the output is X: 8000 Y: 8000. We see the same behavior as we put more fingers on the screen at different locations; the output is the average of all the location coordinates. This can even be seen if only one finger is touching it; depending on how much of the finger is touching the screen, the output changes to get the center of the contact point.&lt;br /&gt;
&lt;br /&gt;
The reason why a finger works with the touchscreen is that the finger exhibits capacitive qualities. The human body has charge that can draw current from the touchscreen. When someone touches the screen some of the charge on the surface is transferred to the person creating a drop in the charge on the screen.  The relative difference in charge from each of the corners of the screen is calculated and a location is the output.  We suspect that other materials that can draw current, such as a piece of fruit might also work.[http://computer.howstuffworks.com/question716.htm]&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10602</id>
		<title>Interfacing with a touchscreen</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10602"/>
		<updated>2009-02-12T06:35:04Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Experimental Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
Interface the PIC with a surplus touchscreen from the LIMS lab and display (x,y) data on an LCD screen (see, e.g., [[C Example: Serial LCD]] or [[C Example: Parallel Interfacing with LCDs]]) or a PC (e.g., matlab or hyperterminal).&lt;br /&gt;
&lt;br /&gt;
Spec sheet: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/]&lt;br /&gt;
(Use the last .pdf under Reference Materials)&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:touchscreen|thumb|200px|How a touchscreen works [http://www.touchscreenguide.com/]|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of the project is to interface the PIC18F4520 with the 3M EX II 7720SC capacitive touchscreen. The spec sheet is located here: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/] (Use the last .pdf under Reference Materials). In addition, when a finger makes contact with the touchscreen, the X-Y coordinates will be displayed on a JHD 162A Parallel LCD (see [[C Example: Parallel Interfacing with LCDs]]).&lt;br /&gt;
&lt;br /&gt;
There are many different types of touchscreen technologies. The one used below is a capacitive touchscreen. A capacitive touchscreen is usually coated in a charge storing material, such as indium tin oxide. Voltage is applied to each corner of the glass screen and electrodes are spread uniformly throughout the screen. Capacitive touchscreens are only responsive to finger touch which draw current from each side of the screen. The controller will then calculate the X-Y position of the finger from the current. &lt;br /&gt;
&lt;br /&gt;
Advantages of the touchscreen are high touch resolution, high image clarity, and is not affected by dirt, grease, or moisture. However it can only be activated by the touch of something conductive, such as one&#039;s finger. [http://www.touchscreens.com/intro-touchtypes-capacitive.html]&lt;br /&gt;
&lt;br /&gt;
On this page you will find the steps to implement the touchscreen interface on your own. This includes the code, circuit diagram, and other notes about creating the interface.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Circuit ==&lt;br /&gt;
[[image:lcd_circuit|thumb|300px|Circuit schematic of connections between PIC, LCD, MAX232 and touchscreen|right]]&lt;br /&gt;
[[image:photo_lcd_circuit|thumb|300px|Photo of circuit|right]]&lt;br /&gt;
&lt;br /&gt;
The image on the right is the circuit schematic showing the connections between all the components. An actual picture of the circuit is also shown.&lt;br /&gt;
&lt;br /&gt;
The chips required for implementing this circuit are:&amp;lt;br&amp;gt;&lt;br /&gt;
1) PIC 18F4520&amp;lt;br&amp;gt;&lt;br /&gt;
2) MAX232N Dual EIA-232 Driver/Receiver &amp;lt;br&amp;gt;&lt;br /&gt;
3) EXII 7720SC (touchscreen controller chip)&amp;lt;br&amp;gt;&lt;br /&gt;
4) JHD 162A Parallel LCD&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
&lt;br /&gt;
Note:  When wiring the touchscreen you have a couple of options.  The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC.  If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable.  This can be down with a wire stripper and soldering.  The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
The file &amp;quot;flex_lcd.c&amp;quot; is required in order for the PIC to communicate with the LCD. The code for the file can be found here: [[C Example: Parallel Interfacing with LCDs]]&lt;br /&gt;
&lt;br /&gt;
The PIC first transmits a &amp;quot;Format Tablet&amp;quot; command to the touchscreen chip, which tells the touchscreen what to transmit back to the PIC. When a finger makes contact with the touchscreen, the chip sends back a 10-byte string of hex values with the X and Y coordinates embedded in the first 5 bytes. This 10-byte string is processed by the PIC, which extracts the X and Y coordinates, converts them to int16 format, and outputs the numbers to the LCD.&lt;br /&gt;
&lt;br /&gt;
The format of each touch signal returned from the touchscreen controller can be found on Table 8 (page 27) of the [http://multimedia.mmm.com/mws/mediawebserver.dyn?6666660Zjcf6lVs6EVs66SBhjCOrrrrQ-| EXII 7720SC spec sheet]. The code takes bits 0-13 of the X and Y parts of the signal (X0 - X13 and Y0 - Y13) and combines them into int16 variables x_pos and y_pos, which are displayed on the LCD.&lt;br /&gt;
&lt;br /&gt;
Remember to change the baud rate in the code to 9600 baud, since this is the rate used by the touchscreen chip.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
touchscreen.c&lt;br /&gt;
Chris Chow, Anup Tapase, Lingyu Xie&lt;br /&gt;
Interface PIC with capacitive touchscreen and display X-Y coordinates on LCD&lt;br /&gt;
Feb 12, 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#use rs232(baud=9600, UART1)      // hardware UART; uses  RC6/TX and RC7/RX&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
&lt;br /&gt;
int j;&lt;br /&gt;
int16 x_pos, y_pos;&lt;br /&gt;
&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos);&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
&lt;br /&gt;
   //command Format Tablet: &amp;quot;&amp;lt;SOH&amp;gt;FT&amp;lt;CR&amp;gt;&amp;quot; sent to touchscreen via RC6/TX pin&lt;br /&gt;
   putc(0x01);&lt;br /&gt;
   putc(0x46);&lt;br /&gt;
   putc(0x54);&lt;br /&gt;
   putc(0x0D);&lt;br /&gt;
&lt;br /&gt;
   while (TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      //get the finger position relative to the touchscreen in 16-bit int format&lt;br /&gt;
      get_screen_pos(x_pos, y_pos);&lt;br /&gt;
&lt;br /&gt;
      printf(lcd_putc,&amp;quot;\fX: %Lu\n&amp;quot;,x_pos); //output &amp;quot;X: &amp;lt;x_pos&amp;gt;&amp;quot; to first line of LCD&lt;br /&gt;
      printf(lcd_putc,&amp;quot;Y: %Lu&amp;quot;,y_pos);     //output &amp;quot;Y: &amp;lt;y_pos&amp;gt;&amp;quot; to second line of LCD&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Function adapted from Nick Marchuk&#039;s IR touchscreen code&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos)&lt;br /&gt;
{&lt;br /&gt;
   int i, gotD8, j;&lt;br /&gt;
   int touchscreen_rcx[20];&lt;br /&gt;
   int pos[5];&lt;br /&gt;
   int16 high16, low16, xtotal16, ytotal16;&lt;br /&gt;
   int temp4, total8;&lt;br /&gt;
   high16 = 0;&lt;br /&gt;
   low16 = 0;&lt;br /&gt;
   xtotal16 = 0;&lt;br /&gt;
   ytotal16 = 0;&lt;br /&gt;
   temp4 = 0;&lt;br /&gt;
   total8 = 0;&lt;br /&gt;
&lt;br /&gt;
   //get 10 bytes from the touchscreen (each touch signal is 10 bytes)&lt;br /&gt;
   for (i=1;i&amp;lt;=10;++i)&lt;br /&gt;
   {&lt;br /&gt;
      touchscreen_rcx[i] = getc();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //find the first instance of 0xD8 (start of each signal)&lt;br /&gt;
   gotD8 = 0;&lt;br /&gt;
   j = 1;&lt;br /&gt;
   while(gotD8==0)&lt;br /&gt;
   {&lt;br /&gt;
      if((touchscreen_rcx[j] == 0xD8))&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //j is the location of 0xD8&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         j = j+1;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      if(j==9)&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //didnt find it, dont loop forever&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   pos[1] = touchscreen_rcx[j+1]; //xlow, bits: 0 X6 X5 X4 X3 X2 X1 X0 (see touchscreen datasheet for FT response))&lt;br /&gt;
   pos[2] = touchscreen_rcx[j+2]; //xhigh, bits: 0 X13 X12 X11 X10 X9 X8 X7&lt;br /&gt;
   pos[3] = touchscreen_rcx[j+3]; //ylow, bits: 0 Y6 Y5 Y4 Y3 Y2 Y1 Y0&lt;br /&gt;
   pos[4] = touchscreen_rcx[j+4]; //yhigh, bits: 0 Y13 Y12 Y11 Y10 Y9 Y8 Y7&lt;br /&gt;
&lt;br /&gt;
   //make the x&lt;br /&gt;
   temp4 = pos[2];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0X13X12X11 X10X9X8X7&lt;br /&gt;
   low16 = pos[1]; //make low16= 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   xtotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00X13X12 X11X10X9X8 X7000 0000 with 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
   x_pos = xtotal16; //x_pos=00X13X12 X11X10X9X8 X7X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   //make the y&lt;br /&gt;
   temp4 = pos[4];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0Y13Y12Y11 Y10Y9Y8Y7&lt;br /&gt;
   low16 = pos[3]; //make low16= 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
&lt;br /&gt;
   ytotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00Y13Y12 Y11Y10Y9Y8 Y7000 0000 with 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
   y_pos = ytotal16;             //x_pos=00Y13Y12 Y11Y10Y9Y8 Y7Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Experimental Notes ==&lt;br /&gt;
&lt;br /&gt;
A vibration is felt when a finger is moved along the touchscreen. Since the finger activates the touchscreen by drawing current and acting as a capacitor, we think that the slight vibrations that are felt are due to the current being drawn through the finger.&lt;br /&gt;
&lt;br /&gt;
When two fingers touch the screen at the same time, the output is the average of the two sets of coordinates. For example, if a finger is placed at X:0 Y:0 and another is placed on X: 16000 Y: 16000, the output is X: 8000 Y: 8000. We see the same behavior as we put more fingers on the screen at different locations; the output is the average of all the location coordinates. This can even be seen if only one finger is touching it; depending on how much of the finger is touching the screen, the output changes to get the center of the contact point.&lt;br /&gt;
&lt;br /&gt;
The reason why a finger works with the touchscreen is that the finger exhibits capacitive qualities. The human body has charge that can draw current from the touchscreen. When someone touches the screen some of the charge on the surface is transferred to the person creating a drop in the charge on the screen.  The relative difference in charge from each of the corners of the screen is calculated and a location is the output.  We suspect that other materials that can draw current, such as a piece of fruit might also work.[http://computer.howstuffworks.com/question716.htm]&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10601</id>
		<title>Interfacing with a touchscreen</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10601"/>
		<updated>2009-02-12T06:34:30Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Experimental Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
Interface the PIC with a surplus touchscreen from the LIMS lab and display (x,y) data on an LCD screen (see, e.g., [[C Example: Serial LCD]] or [[C Example: Parallel Interfacing with LCDs]]) or a PC (e.g., matlab or hyperterminal).&lt;br /&gt;
&lt;br /&gt;
Spec sheet: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/]&lt;br /&gt;
(Use the last .pdf under Reference Materials)&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:touchscreen|thumb|200px|How a touchscreen works [http://www.touchscreenguide.com/]|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of the project is to interface the PIC18F4520 with the 3M EX II 7720SC capacitive touchscreen. The spec sheet is located here: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/] (Use the last .pdf under Reference Materials). In addition, when a finger makes contact with the touchscreen, the X-Y coordinates will be displayed on a JHD 162A Parallel LCD (see [[C Example: Parallel Interfacing with LCDs]]).&lt;br /&gt;
&lt;br /&gt;
There are many different types of touchscreen technologies. The one used below is a capacitive touchscreen. A capacitive touchscreen is usually coated in a charge storing material, such as indium tin oxide. Voltage is applied to each corner of the glass screen and electrodes are spread uniformly throughout the screen. Capacitive touchscreens are only responsive to finger touch which draw current from each side of the screen. The controller will then calculate the X-Y position of the finger from the current. &lt;br /&gt;
&lt;br /&gt;
Advantages of the touchscreen are high touch resolution, high image clarity, and is not affected by dirt, grease, or moisture. However it can only be activated by the touch of something conductive, such as one&#039;s finger. [http://www.touchscreens.com/intro-touchtypes-capacitive.html]&lt;br /&gt;
&lt;br /&gt;
On this page you will find the steps to implement the touchscreen interface on your own. This includes the code, circuit diagram, and other notes about creating the interface.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Circuit ==&lt;br /&gt;
[[image:lcd_circuit|thumb|300px|Circuit schematic of connections between PIC, LCD, MAX232 and touchscreen|right]]&lt;br /&gt;
[[image:photo_lcd_circuit|thumb|300px|Photo of circuit|right]]&lt;br /&gt;
&lt;br /&gt;
The image on the right is the circuit schematic showing the connections between all the components. An actual picture of the circuit is also shown.&lt;br /&gt;
&lt;br /&gt;
The chips required for implementing this circuit are:&amp;lt;br&amp;gt;&lt;br /&gt;
1) PIC 18F4520&amp;lt;br&amp;gt;&lt;br /&gt;
2) MAX232N Dual EIA-232 Driver/Receiver &amp;lt;br&amp;gt;&lt;br /&gt;
3) EXII 7720SC (touchscreen controller chip)&amp;lt;br&amp;gt;&lt;br /&gt;
4) JHD 162A Parallel LCD&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
&lt;br /&gt;
Note:  When wiring the touchscreen you have a couple of options.  The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC.  If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable.  This can be down with a wire stripper and soldering.  The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
The file &amp;quot;flex_lcd.c&amp;quot; is required in order for the PIC to communicate with the LCD. The code for the file can be found here: [[C Example: Parallel Interfacing with LCDs]]&lt;br /&gt;
&lt;br /&gt;
The PIC first transmits a &amp;quot;Format Tablet&amp;quot; command to the touchscreen chip, which tells the touchscreen what to transmit back to the PIC. When a finger makes contact with the touchscreen, the chip sends back a 10-byte string of hex values with the X and Y coordinates embedded in the first 5 bytes. This 10-byte string is processed by the PIC, which extracts the X and Y coordinates, converts them to int16 format, and outputs the numbers to the LCD.&lt;br /&gt;
&lt;br /&gt;
The format of each touch signal returned from the touchscreen controller can be found on Table 8 (page 27) of the [http://multimedia.mmm.com/mws/mediawebserver.dyn?6666660Zjcf6lVs6EVs66SBhjCOrrrrQ-| EXII 7720SC spec sheet]. The code takes bits 0-13 of the X and Y parts of the signal (X0 - X13 and Y0 - Y13) and combines them into int16 variables x_pos and y_pos, which are displayed on the LCD.&lt;br /&gt;
&lt;br /&gt;
Remember to change the baud rate in the code to 9600 baud, since this is the rate used by the touchscreen chip.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
touchscreen.c&lt;br /&gt;
Chris Chow, Anup Tapase, Lingyu Xie&lt;br /&gt;
Interface PIC with capacitive touchscreen and display X-Y coordinates on LCD&lt;br /&gt;
Feb 12, 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#use rs232(baud=9600, UART1)      // hardware UART; uses  RC6/TX and RC7/RX&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
&lt;br /&gt;
int j;&lt;br /&gt;
int16 x_pos, y_pos;&lt;br /&gt;
&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos);&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
&lt;br /&gt;
   //command Format Tablet: &amp;quot;&amp;lt;SOH&amp;gt;FT&amp;lt;CR&amp;gt;&amp;quot; sent to touchscreen via RC6/TX pin&lt;br /&gt;
   putc(0x01);&lt;br /&gt;
   putc(0x46);&lt;br /&gt;
   putc(0x54);&lt;br /&gt;
   putc(0x0D);&lt;br /&gt;
&lt;br /&gt;
   while (TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      //get the finger position relative to the touchscreen in 16-bit int format&lt;br /&gt;
      get_screen_pos(x_pos, y_pos);&lt;br /&gt;
&lt;br /&gt;
      printf(lcd_putc,&amp;quot;\fX: %Lu\n&amp;quot;,x_pos); //output &amp;quot;X: &amp;lt;x_pos&amp;gt;&amp;quot; to first line of LCD&lt;br /&gt;
      printf(lcd_putc,&amp;quot;Y: %Lu&amp;quot;,y_pos);     //output &amp;quot;Y: &amp;lt;y_pos&amp;gt;&amp;quot; to second line of LCD&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Function adapted from Nick Marchuk&#039;s IR touchscreen code&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos)&lt;br /&gt;
{&lt;br /&gt;
   int i, gotD8, j;&lt;br /&gt;
   int touchscreen_rcx[20];&lt;br /&gt;
   int pos[5];&lt;br /&gt;
   int16 high16, low16, xtotal16, ytotal16;&lt;br /&gt;
   int temp4, total8;&lt;br /&gt;
   high16 = 0;&lt;br /&gt;
   low16 = 0;&lt;br /&gt;
   xtotal16 = 0;&lt;br /&gt;
   ytotal16 = 0;&lt;br /&gt;
   temp4 = 0;&lt;br /&gt;
   total8 = 0;&lt;br /&gt;
&lt;br /&gt;
   //get 10 bytes from the touchscreen (each touch signal is 10 bytes)&lt;br /&gt;
   for (i=1;i&amp;lt;=10;++i)&lt;br /&gt;
   {&lt;br /&gt;
      touchscreen_rcx[i] = getc();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //find the first instance of 0xD8 (start of each signal)&lt;br /&gt;
   gotD8 = 0;&lt;br /&gt;
   j = 1;&lt;br /&gt;
   while(gotD8==0)&lt;br /&gt;
   {&lt;br /&gt;
      if((touchscreen_rcx[j] == 0xD8))&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //j is the location of 0xD8&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         j = j+1;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      if(j==9)&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //didnt find it, dont loop forever&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   pos[1] = touchscreen_rcx[j+1]; //xlow, bits: 0 X6 X5 X4 X3 X2 X1 X0 (see touchscreen datasheet for FT response))&lt;br /&gt;
   pos[2] = touchscreen_rcx[j+2]; //xhigh, bits: 0 X13 X12 X11 X10 X9 X8 X7&lt;br /&gt;
   pos[3] = touchscreen_rcx[j+3]; //ylow, bits: 0 Y6 Y5 Y4 Y3 Y2 Y1 Y0&lt;br /&gt;
   pos[4] = touchscreen_rcx[j+4]; //yhigh, bits: 0 Y13 Y12 Y11 Y10 Y9 Y8 Y7&lt;br /&gt;
&lt;br /&gt;
   //make the x&lt;br /&gt;
   temp4 = pos[2];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0X13X12X11 X10X9X8X7&lt;br /&gt;
   low16 = pos[1]; //make low16= 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   xtotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00X13X12 X11X10X9X8 X7000 0000 with 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
   x_pos = xtotal16; //x_pos=00X13X12 X11X10X9X8 X7X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   //make the y&lt;br /&gt;
   temp4 = pos[4];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0Y13Y12Y11 Y10Y9Y8Y7&lt;br /&gt;
   low16 = pos[3]; //make low16= 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
&lt;br /&gt;
   ytotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00Y13Y12 Y11Y10Y9Y8 Y7000 0000 with 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
   y_pos = ytotal16;             //x_pos=00Y13Y12 Y11Y10Y9Y8 Y7Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Experimental Notes ==&lt;br /&gt;
&lt;br /&gt;
A vibration is felt when a finger is moved along the touchscreen. Since the finger activates the touchscreen by drawing current and acting as a capacitor, we think that the slight vibrations that are felt are due to the current being drawn through the finger.&lt;br /&gt;
&lt;br /&gt;
When two fingers touch the screen at the same time, the output is the average of the two sets of coordinates. For example, if a finger is placed at X:0 Y:0 and another is placed on X: 16000 Y: 16000, the output is X: 8000 Y: 8000. We see the same behavior as we put more fingers on the screen at different locations; the output is the average of all the location coordinates. This can even be seen if only one finger is touching it; depending on how much of the finger is touching the screen, the output changes to get the center of the contact point.&lt;br /&gt;
&lt;br /&gt;
The reason why a finger works with the touchscreen is that the finger exhibits capacitive qualities. The human body has charge that can draw current from the touchscreen. When someone touches the screen some of the charge on the surface is transferred to the person creating a drop in the charge on the screen.  The relative difference in charge from each of the corners of the screen is calculated and a location is the output.  We suspect that other materials that can draw current, such as a piece of fruit might also work.http://computer.howstuffworks.com/question716.htm&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10600</id>
		<title>Interfacing with a touchscreen</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10600"/>
		<updated>2009-02-12T06:34:16Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Experimental Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
Interface the PIC with a surplus touchscreen from the LIMS lab and display (x,y) data on an LCD screen (see, e.g., [[C Example: Serial LCD]] or [[C Example: Parallel Interfacing with LCDs]]) or a PC (e.g., matlab or hyperterminal).&lt;br /&gt;
&lt;br /&gt;
Spec sheet: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/]&lt;br /&gt;
(Use the last .pdf under Reference Materials)&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:touchscreen|thumb|200px|How a touchscreen works [http://www.touchscreenguide.com/]|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of the project is to interface the PIC18F4520 with the 3M EX II 7720SC capacitive touchscreen. The spec sheet is located here: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/] (Use the last .pdf under Reference Materials). In addition, when a finger makes contact with the touchscreen, the X-Y coordinates will be displayed on a JHD 162A Parallel LCD (see [[C Example: Parallel Interfacing with LCDs]]).&lt;br /&gt;
&lt;br /&gt;
There are many different types of touchscreen technologies. The one used below is a capacitive touchscreen. A capacitive touchscreen is usually coated in a charge storing material, such as indium tin oxide. Voltage is applied to each corner of the glass screen and electrodes are spread uniformly throughout the screen. Capacitive touchscreens are only responsive to finger touch which draw current from each side of the screen. The controller will then calculate the X-Y position of the finger from the current. &lt;br /&gt;
&lt;br /&gt;
Advantages of the touchscreen are high touch resolution, high image clarity, and is not affected by dirt, grease, or moisture. However it can only be activated by the touch of something conductive, such as one&#039;s finger. [http://www.touchscreens.com/intro-touchtypes-capacitive.html]&lt;br /&gt;
&lt;br /&gt;
On this page you will find the steps to implement the touchscreen interface on your own. This includes the code, circuit diagram, and other notes about creating the interface.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Circuit ==&lt;br /&gt;
[[image:lcd_circuit|thumb|300px|Circuit schematic of connections between PIC, LCD, MAX232 and touchscreen|right]]&lt;br /&gt;
[[image:photo_lcd_circuit|thumb|300px|Photo of circuit|right]]&lt;br /&gt;
&lt;br /&gt;
The image on the right is the circuit schematic showing the connections between all the components. An actual picture of the circuit is also shown.&lt;br /&gt;
&lt;br /&gt;
The chips required for implementing this circuit are:&amp;lt;br&amp;gt;&lt;br /&gt;
1) PIC 18F4520&amp;lt;br&amp;gt;&lt;br /&gt;
2) MAX232N Dual EIA-232 Driver/Receiver &amp;lt;br&amp;gt;&lt;br /&gt;
3) EXII 7720SC (touchscreen controller chip)&amp;lt;br&amp;gt;&lt;br /&gt;
4) JHD 162A Parallel LCD&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
&lt;br /&gt;
Note:  When wiring the touchscreen you have a couple of options.  The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC.  If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable.  This can be down with a wire stripper and soldering.  The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
The file &amp;quot;flex_lcd.c&amp;quot; is required in order for the PIC to communicate with the LCD. The code for the file can be found here: [[C Example: Parallel Interfacing with LCDs]]&lt;br /&gt;
&lt;br /&gt;
The PIC first transmits a &amp;quot;Format Tablet&amp;quot; command to the touchscreen chip, which tells the touchscreen what to transmit back to the PIC. When a finger makes contact with the touchscreen, the chip sends back a 10-byte string of hex values with the X and Y coordinates embedded in the first 5 bytes. This 10-byte string is processed by the PIC, which extracts the X and Y coordinates, converts them to int16 format, and outputs the numbers to the LCD.&lt;br /&gt;
&lt;br /&gt;
The format of each touch signal returned from the touchscreen controller can be found on Table 8 (page 27) of the [http://multimedia.mmm.com/mws/mediawebserver.dyn?6666660Zjcf6lVs6EVs66SBhjCOrrrrQ-| EXII 7720SC spec sheet]. The code takes bits 0-13 of the X and Y parts of the signal (X0 - X13 and Y0 - Y13) and combines them into int16 variables x_pos and y_pos, which are displayed on the LCD.&lt;br /&gt;
&lt;br /&gt;
Remember to change the baud rate in the code to 9600 baud, since this is the rate used by the touchscreen chip.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
touchscreen.c&lt;br /&gt;
Chris Chow, Anup Tapase, Lingyu Xie&lt;br /&gt;
Interface PIC with capacitive touchscreen and display X-Y coordinates on LCD&lt;br /&gt;
Feb 12, 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#use rs232(baud=9600, UART1)      // hardware UART; uses  RC6/TX and RC7/RX&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
&lt;br /&gt;
int j;&lt;br /&gt;
int16 x_pos, y_pos;&lt;br /&gt;
&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos);&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
&lt;br /&gt;
   //command Format Tablet: &amp;quot;&amp;lt;SOH&amp;gt;FT&amp;lt;CR&amp;gt;&amp;quot; sent to touchscreen via RC6/TX pin&lt;br /&gt;
   putc(0x01);&lt;br /&gt;
   putc(0x46);&lt;br /&gt;
   putc(0x54);&lt;br /&gt;
   putc(0x0D);&lt;br /&gt;
&lt;br /&gt;
   while (TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      //get the finger position relative to the touchscreen in 16-bit int format&lt;br /&gt;
      get_screen_pos(x_pos, y_pos);&lt;br /&gt;
&lt;br /&gt;
      printf(lcd_putc,&amp;quot;\fX: %Lu\n&amp;quot;,x_pos); //output &amp;quot;X: &amp;lt;x_pos&amp;gt;&amp;quot; to first line of LCD&lt;br /&gt;
      printf(lcd_putc,&amp;quot;Y: %Lu&amp;quot;,y_pos);     //output &amp;quot;Y: &amp;lt;y_pos&amp;gt;&amp;quot; to second line of LCD&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Function adapted from Nick Marchuk&#039;s IR touchscreen code&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos)&lt;br /&gt;
{&lt;br /&gt;
   int i, gotD8, j;&lt;br /&gt;
   int touchscreen_rcx[20];&lt;br /&gt;
   int pos[5];&lt;br /&gt;
   int16 high16, low16, xtotal16, ytotal16;&lt;br /&gt;
   int temp4, total8;&lt;br /&gt;
   high16 = 0;&lt;br /&gt;
   low16 = 0;&lt;br /&gt;
   xtotal16 = 0;&lt;br /&gt;
   ytotal16 = 0;&lt;br /&gt;
   temp4 = 0;&lt;br /&gt;
   total8 = 0;&lt;br /&gt;
&lt;br /&gt;
   //get 10 bytes from the touchscreen (each touch signal is 10 bytes)&lt;br /&gt;
   for (i=1;i&amp;lt;=10;++i)&lt;br /&gt;
   {&lt;br /&gt;
      touchscreen_rcx[i] = getc();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //find the first instance of 0xD8 (start of each signal)&lt;br /&gt;
   gotD8 = 0;&lt;br /&gt;
   j = 1;&lt;br /&gt;
   while(gotD8==0)&lt;br /&gt;
   {&lt;br /&gt;
      if((touchscreen_rcx[j] == 0xD8))&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //j is the location of 0xD8&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         j = j+1;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      if(j==9)&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //didnt find it, dont loop forever&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   pos[1] = touchscreen_rcx[j+1]; //xlow, bits: 0 X6 X5 X4 X3 X2 X1 X0 (see touchscreen datasheet for FT response))&lt;br /&gt;
   pos[2] = touchscreen_rcx[j+2]; //xhigh, bits: 0 X13 X12 X11 X10 X9 X8 X7&lt;br /&gt;
   pos[3] = touchscreen_rcx[j+3]; //ylow, bits: 0 Y6 Y5 Y4 Y3 Y2 Y1 Y0&lt;br /&gt;
   pos[4] = touchscreen_rcx[j+4]; //yhigh, bits: 0 Y13 Y12 Y11 Y10 Y9 Y8 Y7&lt;br /&gt;
&lt;br /&gt;
   //make the x&lt;br /&gt;
   temp4 = pos[2];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0X13X12X11 X10X9X8X7&lt;br /&gt;
   low16 = pos[1]; //make low16= 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   xtotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00X13X12 X11X10X9X8 X7000 0000 with 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
   x_pos = xtotal16; //x_pos=00X13X12 X11X10X9X8 X7X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   //make the y&lt;br /&gt;
   temp4 = pos[4];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0Y13Y12Y11 Y10Y9Y8Y7&lt;br /&gt;
   low16 = pos[3]; //make low16= 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
&lt;br /&gt;
   ytotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00Y13Y12 Y11Y10Y9Y8 Y7000 0000 with 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
   y_pos = ytotal16;             //x_pos=00Y13Y12 Y11Y10Y9Y8 Y7Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Experimental Notes ==&lt;br /&gt;
&lt;br /&gt;
A vibration is felt when a finger is moved along the touchscreen. Since the finger activates the touchscreen by drawing current and acting as a capacitor, we think that the slight vibrations that are felt are due to the current being drawn through the finger.&lt;br /&gt;
&lt;br /&gt;
When two fingers touch the screen at the same time, the output is the average of the two sets of coordinates. For example, if a finger is placed at X:0 Y:0 and another is placed on X: 16000 Y: 16000, the output is X: 8000 Y: 8000. We see the same behavior as we put more fingers on the screen at different locations; the output is the average of all the location coordinates. This can even be seen if only one finger is touching it; depending on how much of the finger is touching the screen, the output changes to get the center of the contact point.&lt;br /&gt;
&lt;br /&gt;
The reason why a finger works with the touchscreen is that the finger exhibits capacitive qualities. The human body has charge that can draw current from the touchscreen. When someone touches the screen some of the charge on the surface is transferred to the person creating a drop in the charge on the screen.  The relative difference in charge from each of the corners of the screen is calculated and a location is the output.  We suspect that other materials that can draw current, such as a piece of fruit might also work.&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10597</id>
		<title>Interfacing with a touchscreen</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Interfacing_with_a_touchscreen&amp;diff=10597"/>
		<updated>2009-02-12T06:29:51Z</updated>

		<summary type="html">&lt;p&gt;Chris Chow: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Original Assignment ==&lt;br /&gt;
&lt;br /&gt;
Interface the PIC with a surplus touchscreen from the LIMS lab and display (x,y) data on an LCD screen (see, e.g., [[C Example: Serial LCD]] or [[C Example: Parallel Interfacing with LCDs]]) or a PC (e.g., matlab or hyperterminal).&lt;br /&gt;
&lt;br /&gt;
Spec sheet: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/]&lt;br /&gt;
(Use the last .pdf under Reference Materials)&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:touchscreen|thumb|200px|How a touchscreen works [http://www.touchscreenguide.com/]|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of the project is to interface the PIC18F4520 with the 3M EX II 7720SC capacitive touchscreen. The spec sheet is located here: [http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/Solutions/Electronics/EXII-Controller/] (Use the last .pdf under Reference Materials). In addition, when a finger makes contact with the touchscreen, the X-Y coordinates will be displayed on a JHD 162A Parallel LCD (see [[C Example: Parallel Interfacing with LCDs]]).&lt;br /&gt;
&lt;br /&gt;
There are many different types of touchscreen technologies. The one used below is a capacitive touchscreen. A capacitive touchscreen is usually coated in a charge storing material, such as indium tin oxide. Voltage is applied to each corner of the glass screen and electrodes are spread uniformly throughout the screen. Capacitive touchscreens are only responsive to finger touch which draw current from each side of the screen. The controller will then calculate the X-Y position of the finger from the current. &lt;br /&gt;
&lt;br /&gt;
Advantages of the touchscreen are high touch resolution, high image clarity, and is not affected by dirt, grease, or moisture. However it can only be activated by the touch of something conductive, such as one&#039;s finger. [http://www.touchscreens.com/intro-touchtypes-capacitive.html]&lt;br /&gt;
&lt;br /&gt;
On this page you will find the steps to implement the touchscreen interface on your own. This includes the code, circuit diagram, and other notes about creating the interface.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Circuit ==&lt;br /&gt;
[[image:lcd_circuit|thumb|300px|Circuit schematic of connections between PIC, LCD, MAX232 and touchscreen|right]]&lt;br /&gt;
[[image:photo_lcd_circuit|thumb|300px|Photo of circuit|right]]&lt;br /&gt;
&lt;br /&gt;
The image on the right is the circuit schematic showing the connections between all the components. An actual picture of the circuit is also shown.&lt;br /&gt;
&lt;br /&gt;
The chips required for implementing this circuit are:&amp;lt;br&amp;gt;&lt;br /&gt;
1) PIC 18F4520&amp;lt;br&amp;gt;&lt;br /&gt;
2) MAX232N Dual EIA-232 Driver/Receiver &amp;lt;br&amp;gt;&lt;br /&gt;
3) EXII 7720SC (touchscreen controller chip)&amp;lt;br&amp;gt;&lt;br /&gt;
4) JHD 162A Parallel LCD&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The PIC communicates with the touchscreen through the MAX232N chip. The MAX232N chip regulates the voltage of the input(RXD pin 3) and output(TXD pin 2) of the EXII 7720SC touchscreen chip(between -5V and +5V) to make it between 0 and +5V, since this is the signal range that is accepted by the PIC.&lt;br /&gt;
&lt;br /&gt;
The +5V supply voltages and ground in the circuit can be connected to PIC +5V and ground.&lt;br /&gt;
&lt;br /&gt;
A 10K potentiometer is used to adjust the contrast of the LCD.&lt;br /&gt;
&lt;br /&gt;
The LCD displays X and Y coordinates starting from X:0 Y:0 to about X:16383 Y:16383 (this is when all the bits of X and Y are 1: 0011 1111 1111 1111). This means the touchscreen has 14-bit resolution. The origin is at the bottom left of the touchscreen as oriented in the photo on the right.&lt;br /&gt;
&lt;br /&gt;
Note:  When wiring the touchscreen you have a couple of options.  The first option is to buy the appropriate connecting cables for the EXII 7720SC chip to interface with a PIC.  If this is not a feasible option then a second option would be to take spare rainbow ribbon cable and fashion your own connecting cable.  This can be down with a wire stripper and soldering.  The circuit pictured here is an example of the second option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
The file &amp;quot;flex_lcd.c&amp;quot; is required in order for the PIC to communicate with the LCD. The code for the file can be found here: [[C Example: Parallel Interfacing with LCDs]]&lt;br /&gt;
&lt;br /&gt;
The PIC first transmits a &amp;quot;Format Tablet&amp;quot; command to the touchscreen chip, which tells the touchscreen what to transmit back to the PIC. When a finger makes contact with the touchscreen, the chip sends back a 10-byte string of hex values with the X and Y coordinates embedded in the first 5 bytes. This 10-byte string is processed by the PIC, which extracts the X and Y coordinates, converts them to int16 format, and outputs the numbers to the LCD.&lt;br /&gt;
&lt;br /&gt;
The format of each touch signal returned from the touchscreen controller can be found on Table 8 (page 27) of the [http://multimedia.mmm.com/mws/mediawebserver.dyn?6666660Zjcf6lVs6EVs66SBhjCOrrrrQ-| EXII 7720SC spec sheet]. The code takes bits 0-13 of the X and Y parts of the signal (X0 - X13 and Y0 - Y13) and combines them into int16 variables x_pos and y_pos, which are displayed on the LCD.&lt;br /&gt;
&lt;br /&gt;
Remember to change the baud rate in the code to 9600 baud, since this is the rate used by the touchscreen chip.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
touchscreen.c&lt;br /&gt;
Chris Chow, Anup Tapase, Lingyu Xie&lt;br /&gt;
Interface PIC with capacitive touchscreen and display X-Y coordinates on LCD&lt;br /&gt;
Feb 12, 2009&lt;br /&gt;
*/&lt;br /&gt;
#include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
#use delay(clock=40000000)&lt;br /&gt;
#use rs232(baud=9600, UART1)      // hardware UART; uses  RC6/TX and RC7/RX&lt;br /&gt;
#include &amp;quot;flex_lcd.c&amp;quot;             //must include in order to output to LCD&lt;br /&gt;
&lt;br /&gt;
int j;&lt;br /&gt;
int16 x_pos, y_pos;&lt;br /&gt;
&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos);&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   lcd_init();  // Always call this first.&lt;br /&gt;
&lt;br /&gt;
   //command Format Tablet: &amp;quot;&amp;lt;SOH&amp;gt;FT&amp;lt;CR&amp;gt;&amp;quot; sent to touchscreen via RC6/TX pin&lt;br /&gt;
   putc(0x01);&lt;br /&gt;
   putc(0x46);&lt;br /&gt;
   putc(0x54);&lt;br /&gt;
   putc(0x0D);&lt;br /&gt;
&lt;br /&gt;
   while (TRUE)&lt;br /&gt;
   {&lt;br /&gt;
      //get the finger position relative to the touchscreen in 16-bit int format&lt;br /&gt;
      get_screen_pos(x_pos, y_pos);&lt;br /&gt;
&lt;br /&gt;
      printf(lcd_putc,&amp;quot;\fX: %Lu\n&amp;quot;,x_pos); //output &amp;quot;X: &amp;lt;x_pos&amp;gt;&amp;quot; to first line of LCD&lt;br /&gt;
      printf(lcd_putc,&amp;quot;Y: %Lu&amp;quot;,y_pos);     //output &amp;quot;Y: &amp;lt;y_pos&amp;gt;&amp;quot; to second line of LCD&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Function adapted from Nick Marchuk&#039;s IR touchscreen code&lt;br /&gt;
void get_screen_pos(int16&amp;amp; x_pos, int16&amp;amp; y_pos)&lt;br /&gt;
{&lt;br /&gt;
   int i, gotD8, j;&lt;br /&gt;
   int touchscreen_rcx[20];&lt;br /&gt;
   int pos[5];&lt;br /&gt;
   int16 high16, low16, xtotal16, ytotal16;&lt;br /&gt;
   int temp4, total8;&lt;br /&gt;
   high16 = 0;&lt;br /&gt;
   low16 = 0;&lt;br /&gt;
   xtotal16 = 0;&lt;br /&gt;
   ytotal16 = 0;&lt;br /&gt;
   temp4 = 0;&lt;br /&gt;
   total8 = 0;&lt;br /&gt;
&lt;br /&gt;
   //get 10 bytes from the touchscreen (each touch signal is 10 bytes)&lt;br /&gt;
   for (i=1;i&amp;lt;=10;++i)&lt;br /&gt;
   {&lt;br /&gt;
      touchscreen_rcx[i] = getc();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //find the first instance of 0xD8 (start of each signal)&lt;br /&gt;
   gotD8 = 0;&lt;br /&gt;
   j = 1;&lt;br /&gt;
   while(gotD8==0)&lt;br /&gt;
   {&lt;br /&gt;
      if((touchscreen_rcx[j] == 0xD8))&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //j is the location of 0xD8&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         j = j+1;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      if(j==9)&lt;br /&gt;
      {&lt;br /&gt;
         gotD8 = 1; //didnt find it, dont loop forever&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   pos[1] = touchscreen_rcx[j+1]; //xlow, bits: 0 X6 X5 X4 X3 X2 X1 X0 (see touchscreen datasheet for FT response))&lt;br /&gt;
   pos[2] = touchscreen_rcx[j+2]; //xhigh, bits: 0 X13 X12 X11 X10 X9 X8 X7&lt;br /&gt;
   pos[3] = touchscreen_rcx[j+3]; //ylow, bits: 0 Y6 Y5 Y4 Y3 Y2 Y1 Y0&lt;br /&gt;
   pos[4] = touchscreen_rcx[j+4]; //yhigh, bits: 0 Y13 Y12 Y11 Y10 Y9 Y8 Y7&lt;br /&gt;
&lt;br /&gt;
   //make the x&lt;br /&gt;
   temp4 = pos[2];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0X13X12X11 X10X9X8X7&lt;br /&gt;
   low16 = pos[1]; //make low16= 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   xtotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00X13X12 X11X10X9X8 X7000 0000 with 0000 0000 0X6X5X4 X3X2X1X0&lt;br /&gt;
   x_pos = xtotal16; //x_pos=00X13X12 X11X10X9X8 X7X6X5X4 X3X2X1X0&lt;br /&gt;
&lt;br /&gt;
   //make the y&lt;br /&gt;
   temp4 = pos[4];&lt;br /&gt;
   high16 = temp4; //make high16= 0000 0000 0Y13Y12Y11 Y10Y9Y8Y7&lt;br /&gt;
   low16 = pos[3]; //make low16= 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
&lt;br /&gt;
   ytotal16 = low16|(high16&amp;lt;&amp;lt;7); //OR 00Y13Y12 Y11Y10Y9Y8 Y7000 0000 with 0000 0000 0Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
   y_pos = ytotal16;             //x_pos=00Y13Y12 Y11Y10Y9Y8 Y7Y6Y5Y4 Y3Y2Y1Y0&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Experimental Notes ==&lt;br /&gt;
&lt;br /&gt;
A vibration is felt when a finger is moved along the touchscreen. Since the finger activates the touchscreen by drawing current and acting as a capacitor, we think that the slight vibrations that are felt are due to the current being drawn through the finger.&lt;br /&gt;
&lt;br /&gt;
When two fingers touch the screen at the same time, the output is the average of the two sets of coordinates. For example, if a finger is placed at X:0 Y:0 and another is placed on X: 16000 Y: 16000, the output is X: 8000 Y: 8000. We see the same behavior as we put more fingers on the screen at different locations; the output is the average of all the location coordinates. This can even be seen if only one finger is touching it; depending on how much of the finger is touching the screen, the output changes to get the center of the contact point.&lt;br /&gt;
&lt;br /&gt;
The reason why a finger works with the touchscreen is that the finger exhibits capacitive qualities. The human body has charge that can draw current from the touchscreen. We suspect that other materials that can draw current, such as a piece of fruit might also work.&lt;/div&gt;</summary>
		<author><name>Chris Chow</name></author>
	</entry>
</feed>