<?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=HenryRandolph</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=HenryRandolph"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php/Special:Contributions/HenryRandolph"/>
	<updated>2026-05-04T12:39:27Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_transistor_circuit.png&amp;diff=17780</id>
		<title>File:Wiitar transistor circuit.png</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_transistor_circuit.png&amp;diff=17780"/>
		<updated>2010-03-18T17:25:32Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: uploaded a new version of &amp;quot;Image:Wiitar transistor circuit.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17743</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17743"/>
		<updated>2010-03-18T10:37:16Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* PIC Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Strummer|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s great that the computer can monitor the accelerometer, but we need to set thresholds so that the stummer knows when to activate.  The if loops below do just that.&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
WIUSE_USING_ACC(wm) will return 0 if the accelerometer is disabled or 1 if the accelerometer is enabled.  Assuming the accelerometer is enabled, the code will monitor the accelerometer and not do anything until the wiimote is tilted above 50 degress or below -100 degrees.  The accelerometers report absolute values.  That is, the closer you tilt the wiimote upwards to vertical, the more positive the numbers become.  The thresholds we set were determined from just playing around with the wiimote.  When the wiimote passes one of these thresholds, the character &amp;quot;S&amp;quot; is sent to the PIC.  When the wiimote is brought back to roughly a horizontal position, the computer sends the character &amp;quot;T&amp;quot; to the PIC.  These values will all make sense when the PIC code is discussed.  Note that there are two different pitch values.  There is an absolute pitch value and a corrected pitch value.  The corrected pitch value can be changed by altering the sensitivity in the wiiuse.h file.  We did not bother to do this, as the sensitivity was fine.&lt;br /&gt;
&lt;br /&gt;
Writing to the PIC involved sending data via an RS232 cable through a COM port.  The process involved in writing to a COM port in a Windows environment is cumbersome to say the least.  (Aggravatingly, this whole process could have been avoided if a UNIX based OS was used, as all the COM port information is kept in the dev folder.  Unfortunately, the wiiuse code does not work on UNIX systems because of its dependency on .dll files).  The steps to send data through a COM port are &lt;br /&gt;
&lt;br /&gt;
*Create a handle to point to the serial port&lt;br /&gt;
*Initialize the serial port&lt;br /&gt;
*Open the serial port&lt;br /&gt;
*Write the data to the serial port&lt;br /&gt;
*Send the data&lt;br /&gt;
*Close the port&lt;br /&gt;
&lt;br /&gt;
The portions of the code that do this are scattered throughout the entire wiiuse.c file.  But the most important chucks of the code are&lt;br /&gt;
&lt;br /&gt;
 	HANDLE serial_port;				/* Handle to the serial port */&lt;br /&gt;
 	long baud_rate = 9600;		    /* Specified baud rate */&lt;br /&gt;
 	char port_name[] = &amp;quot;COM7:&amp;quot;;		/* Name of the serial port */  &lt;br /&gt;
 &lt;br /&gt;
  //Initialize Serial Port ------------------------------------------------------------&lt;br /&gt;
 	&lt;br /&gt;
 	/* Open up a handle to the serial port */&lt;br /&gt;
 	serial_port = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);&lt;br /&gt;
 &lt;br /&gt;
 	/* Make sure port was opened */&lt;br /&gt;
 	if (serial_port == INVALID_HANDLE_VALUE)&lt;br /&gt;
 	{&lt;br /&gt;
 		fprintf(stderr, &amp;quot;Error opening port\n&amp;quot;);&lt;br /&gt;
 		CloseHandle(serial_port);&lt;br /&gt;
 		exit(0);&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	/* Set up the serial port */&lt;br /&gt;
 	set_up_serial_port(serial_port, baud_rate);&lt;br /&gt;
 	&lt;br /&gt;
 //End Serial Port Initialization ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
These commands are all located at the beginning of main().&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The WriteFIle() function has several inputs, all of which are unnecessarily confusing.&lt;br /&gt;
&lt;br /&gt;
 WriteFile(&lt;br /&gt;
   __in         HANDLE hFile,&lt;br /&gt;
   __in         LPCVOID lpBuffer,&lt;br /&gt;
   __in         DWORD nNumberOfBytesToWrite,&lt;br /&gt;
   __out_opt    LPDWORD lpNumberOfBytesWritten,&lt;br /&gt;
   __inout_opt  LPOVERLAPPED lpOverlapped&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
*HANDLE hFile: hFile is the handle that points to the COM port.  In our case it&#039;s called &amp;quot;serial_port&amp;quot;&lt;br /&gt;
*LPCVOID lpBuffer: lpBuffer is a pointer to the buffer containing the data that&#039;s to be written.  In our case it&#039;s &amp;quot;buttonPressed&amp;quot; or &amp;quot;motor_signal&amp;quot; depending on the application&lt;br /&gt;
*DWORD nNumberOfBytesToWrite: The number of bytes to be written to the device.  Since we&#039;re sending characters, it&#039;s 1 byte and the variable is &amp;quot;sizeof(char)&amp;quot;&lt;br /&gt;
*LPDWORD lpNumberOfBytesWritten: A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.  In our case it&#039;s just &amp;quot;&amp;amp;bytes_written&amp;quot;&lt;br /&gt;
*The rest of the parameters are just NULL because they aren&#039;t used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PIC Code====&lt;br /&gt;
The code for the PIC is not as complicated as the wii code.  Basically, all the PIC needs to do is monitor a UART port and based on the data it receives either set digital outputs to HI or LOW.  The UART stuff is all handled by an ISR, and interrupt service routine.  &lt;br /&gt;
&lt;br /&gt;
 // UART 2 interrupt handler and is set at priority 7&lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl7) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data = ReadUART2(); // Read data in the UART&lt;br /&gt;
 		&lt;br /&gt;
 		if(data == &#039;A&#039;)&lt;br /&gt;
 		{	&lt;br /&gt;
 			mLED_0_On();&lt;br /&gt;
 			PIN_D4 = 1;&lt;br /&gt;
 			PIN_D3 = 1;&lt;br /&gt;
 			PIN_D10 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;B&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_1_On();&lt;br /&gt;
 			PIN_D8 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 			PIN_D11 = 1;&lt;br /&gt;
  		}&lt;br /&gt;
      		else if(data == &#039;D&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_2_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;L&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;S&#039; &amp;amp;&amp;amp; dummy == 1) &lt;br /&gt;
 		// When the first &amp;quot;S&amp;quot; is sent to the PIC, the dummy variable resets, so the sturmmer doesn&#039;t constantly strum.&lt;br /&gt;
 		// We only want the strummer to strum once and this is what the code does. &lt;br /&gt;
 		{&lt;br /&gt;
 			DIRECTION_PIN = 0;&lt;br /&gt;
 			ENABLE_PIN = 1;&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 			dummy = 2;&lt;br /&gt;
 		}	&lt;br /&gt;
 &lt;br /&gt;
 		else if(data == &#039;N&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_0_Off();&lt;br /&gt;
 			mLED_1_Off();&lt;br /&gt;
 			mLED_2_Off();&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 			PIN_D11 = 0;&lt;br /&gt;
 			PIN_D3 = 0;&lt;br /&gt;
 			PIN_D4 = 0;&lt;br /&gt;
 			PIN_D10 = 0;&lt;br /&gt;
 			PIN_D9 = 0;&lt;br /&gt;
 			PIN_D8 = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;T&#039;)&lt;br /&gt;
 		// Resest the dummy variable when the Wiimote is brought to horizontal so the user can strum the guitar again.&lt;br /&gt;
 		{&lt;br /&gt;
 			dummy = 1;&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	// We don&#039;t care about TX interrupts&lt;br /&gt;
 	if(mU2TXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 }  &lt;br /&gt;
&lt;br /&gt;
The code may look long, but the theory behind it is very simple.  Depending on what character is read from the UART, some pins will ether be HI or LOW.  For example, when the &amp;quot;A&amp;quot; character is read from the UART, pins D4, D3, D10 and D9 are all depressed.  The layout of the solenoids make the correspond to a G chord.  When the user releases the &amp;quot;A&amp;quot; button, the character &amp;quot;N&amp;quot; is sent.  Looking at the if branch for that character, it is evident that everything turns off.  Indeed the character &amp;quot;N&amp;quot; is like our &amp;quot;off&amp;quot; switch.&lt;br /&gt;
&lt;br /&gt;
One minor detail to the code involves the strummer.  The computer is monitoring the wiimote all the time, so when the accelerometer is engaged data is constantly being streamed to the PIC.  When the user brings the wiimote into the &amp;quot;strumming zone&amp;quot; lots and lots of characters are sent to the PIC.  We don&#039;t want this.  We only want the PIC to react after the first &amp;quot;S&amp;quot; is sent.  To solve this problem we use a dummy variable, aptly called &amp;quot;dummy.&amp;quot;  This variable is initially set at 1.  When the first &amp;quot;S&amp;quot; is sent to the PIC, the IF loop corresponding to character &amp;quot;S&amp;quot; is executed.  But note that &amp;quot;dummy&amp;quot; is set to 2.  Only when the user brings the wiimote back to horizontal does the dummy variable get rest back to 1 (the IF branch that corresponds to this is the one with IF data = &#039;T&#039;).  Thus moving the wiimote like you would strum an actual guitar translates to the strummer only playing intermittently, simulating a guitar.  This was tested pretty rigorously and seemed to work pretty well, though sometimes the &amp;quot;T&amp;quot; wouldn&#039;t get sent and thus the strummer would not strum.   &lt;br /&gt;
&lt;br /&gt;
For reasons not known, the Delayms() function (included in LCD.h) did not work with our code.  Thus we made our own.  This delay function counts NOPs instead of using a dummy counter variable.  The code for this can be seen below.&lt;br /&gt;
&lt;br /&gt;
 //********************** Counts &amp;quot;Nops&amp;quot; so that we can use them as a delay function, instead of the Delayms function built into &amp;quot;LCD.h&amp;quot;.&lt;br /&gt;
 void Delayms( unsigned t)&lt;br /&gt;
 // This uses Timer 1, can be changed to another timer. Assumes FPB = SYS_FREQ&lt;br /&gt;
 {&lt;br /&gt;
 	int i=0;&lt;br /&gt;
     for (i=0;i&amp;lt;t;i++)&lt;br /&gt;
     {  // t x 1ms loop&lt;br /&gt;
         Nop();&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The only code that is in main() involves monitoring the hall sensor.  One pin, A10, was coded as a digital input and is connected from the output of the voltage comparator.  Recall, when the hall sensor is on, the comparator outputs HI and when the hall sensor is off, the comparator outputs LOW.  &lt;br /&gt;
&lt;br /&gt;
 		// Interrupt to control the CN pin to stop the bar with the hall Effects sensor when it goes low to high&lt;br /&gt;
 		if(INPUT_A10 == 1)&lt;br /&gt;
 		{	&lt;br /&gt;
 			DIRECTION_PIN = 1; // When the Hall Effects sesnsor gets tripped, delay and reverse the motor by the following commands&lt;br /&gt;
 			Delayms(200000);   // Delay&lt;br /&gt;
 			DIRECTION_PIN = 0; // Reverse the motor&lt;br /&gt;
 			ENABLE_PIN = 0;    // Brake the motor&lt;br /&gt;
 			&lt;br /&gt;
 		}&lt;br /&gt;
&lt;br /&gt;
This IF loop brakes the motor after the hall sensor is tripped.  The set up of our strummer has the strummer end up in roughly the same place every time.  The weight of the strummer is unbalanced due to the magnet at one end and thus after the motor brakes, it settles down to approximately the same place.&lt;br /&gt;
&lt;br /&gt;
====To Sum Up====&lt;br /&gt;
To sum up, the functionality of the code follows these steps:&lt;br /&gt;
&lt;br /&gt;
*When a user presses a button or tilts the wiimote, characters are sent via RS232 to the PIC&lt;br /&gt;
*The PIC reads the UART port and depending on what the character is, sets particular pins high or low&lt;br /&gt;
*Moving the wiimote in a strumming fashion simulates a guitar because the PIC only reacts to some of the accelerometer data it receives&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17742</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17742"/>
		<updated>2010-03-18T10:33:23Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* PIC Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Strummer|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s great that the computer can monitor the accelerometer, but we need to set thresholds so that the stummer knows when to activate.  The if loops below do just that.&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
WIUSE_USING_ACC(wm) will return 0 if the accelerometer is disabled or 1 if the accelerometer is enabled.  Assuming the accelerometer is enabled, the code will monitor the accelerometer and not do anything until the wiimote is tilted above 50 degress or below -100 degrees.  The accelerometers report absolute values.  That is, the closer you tilt the wiimote upwards to vertical, the more positive the numbers become.  The thresholds we set were determined from just playing around with the wiimote.  When the wiimote passes one of these thresholds, the character &amp;quot;S&amp;quot; is sent to the PIC.  When the wiimote is brought back to roughly a horizontal position, the computer sends the character &amp;quot;T&amp;quot; to the PIC.  These values will all make sense when the PIC code is discussed.  Note that there are two different pitch values.  There is an absolute pitch value and a corrected pitch value.  The corrected pitch value can be changed by altering the sensitivity in the wiiuse.h file.  We did not bother to do this, as the sensitivity was fine.&lt;br /&gt;
&lt;br /&gt;
Writing to the PIC involved sending data via an RS232 cable through a COM port.  The process involved in writing to a COM port in a Windows environment is cumbersome to say the least.  (Aggravatingly, this whole process could have been avoided if a UNIX based OS was used, as all the COM port information is kept in the dev folder.  Unfortunately, the wiiuse code does not work on UNIX systems because of its dependency on .dll files).  The steps to send data through a COM port are &lt;br /&gt;
&lt;br /&gt;
*Create a handle to point to the serial port&lt;br /&gt;
*Initialize the serial port&lt;br /&gt;
*Open the serial port&lt;br /&gt;
*Write the data to the serial port&lt;br /&gt;
*Send the data&lt;br /&gt;
*Close the port&lt;br /&gt;
&lt;br /&gt;
The portions of the code that do this are scattered throughout the entire wiiuse.c file.  But the most important chucks of the code are&lt;br /&gt;
&lt;br /&gt;
 	HANDLE serial_port;				/* Handle to the serial port */&lt;br /&gt;
 	long baud_rate = 9600;		    /* Specified baud rate */&lt;br /&gt;
 	char port_name[] = &amp;quot;COM7:&amp;quot;;		/* Name of the serial port */  &lt;br /&gt;
 &lt;br /&gt;
  //Initialize Serial Port ------------------------------------------------------------&lt;br /&gt;
 	&lt;br /&gt;
 	/* Open up a handle to the serial port */&lt;br /&gt;
 	serial_port = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);&lt;br /&gt;
 &lt;br /&gt;
 	/* Make sure port was opened */&lt;br /&gt;
 	if (serial_port == INVALID_HANDLE_VALUE)&lt;br /&gt;
 	{&lt;br /&gt;
 		fprintf(stderr, &amp;quot;Error opening port\n&amp;quot;);&lt;br /&gt;
 		CloseHandle(serial_port);&lt;br /&gt;
 		exit(0);&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	/* Set up the serial port */&lt;br /&gt;
 	set_up_serial_port(serial_port, baud_rate);&lt;br /&gt;
 	&lt;br /&gt;
 //End Serial Port Initialization ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
These commands are all located at the beginning of main().&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The WriteFIle() function has several inputs, all of which are unnecessarily confusing.&lt;br /&gt;
&lt;br /&gt;
 WriteFile(&lt;br /&gt;
   __in         HANDLE hFile,&lt;br /&gt;
   __in         LPCVOID lpBuffer,&lt;br /&gt;
   __in         DWORD nNumberOfBytesToWrite,&lt;br /&gt;
   __out_opt    LPDWORD lpNumberOfBytesWritten,&lt;br /&gt;
   __inout_opt  LPOVERLAPPED lpOverlapped&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
*HANDLE hFile: hFile is the handle that points to the COM port.  In our case it&#039;s called &amp;quot;serial_port&amp;quot;&lt;br /&gt;
*LPCVOID lpBuffer: lpBuffer is a pointer to the buffer containing the data that&#039;s to be written.  In our case it&#039;s &amp;quot;buttonPressed&amp;quot; or &amp;quot;motor_signal&amp;quot; depending on the application&lt;br /&gt;
*DWORD nNumberOfBytesToWrite: The number of bytes to be written to the device.  Since we&#039;re sending characters, it&#039;s 1 byte and the variable is &amp;quot;sizeof(char)&amp;quot;&lt;br /&gt;
*LPDWORD lpNumberOfBytesWritten: A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.  In our case it&#039;s just &amp;quot;&amp;amp;bytes_written&amp;quot;&lt;br /&gt;
*The rest of the parameters are just NULL because they aren&#039;t used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PIC Code====&lt;br /&gt;
The code for the PIC is not as complicated as the wii code.  Basically, all the PIC needs to do is monitor a UART port and based on the data it receives either set digital outputs to HI or LOW.  The UART stuff is all handled by an ISR, and interrupt service routine.  &lt;br /&gt;
&lt;br /&gt;
 // UART 2 interrupt handler and is set at priority 7&lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl7) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data = ReadUART2(); // Read data in the UART&lt;br /&gt;
 		&lt;br /&gt;
 		if(data == &#039;A&#039;)&lt;br /&gt;
 		{	&lt;br /&gt;
 			mLED_0_On();&lt;br /&gt;
 			PIN_D4 = 1;&lt;br /&gt;
 			PIN_D3 = 1;&lt;br /&gt;
 			PIN_D10 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;B&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_1_On();&lt;br /&gt;
 			PIN_D8 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 			PIN_D11 = 1;&lt;br /&gt;
  		}&lt;br /&gt;
      		else if(data == &#039;D&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_2_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;L&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;S&#039; &amp;amp;&amp;amp; dummy == 1) &lt;br /&gt;
 		// When the first &amp;quot;S&amp;quot; is sent to the PIC, the dummy variable resets, so the sturmmer doesn&#039;t constantly strum.&lt;br /&gt;
 		// We only want the strummer to strum once and this is what the code does. &lt;br /&gt;
 		{&lt;br /&gt;
 			DIRECTION_PIN = 0;&lt;br /&gt;
 			ENABLE_PIN = 1;&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 			dummy = 2;&lt;br /&gt;
 		}	&lt;br /&gt;
 &lt;br /&gt;
 		else if(data == &#039;N&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_0_Off();&lt;br /&gt;
 			mLED_1_Off();&lt;br /&gt;
 			mLED_2_Off();&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 			PIN_D11 = 0;&lt;br /&gt;
 			PIN_D3 = 0;&lt;br /&gt;
 			PIN_D4 = 0;&lt;br /&gt;
 			PIN_D10 = 0;&lt;br /&gt;
 			PIN_D9 = 0;&lt;br /&gt;
 			PIN_D8 = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;T&#039;)&lt;br /&gt;
 		// Resest the dummy variable when the Wiimote is brought to horizontal so the user can strum the guitar again.&lt;br /&gt;
 		{&lt;br /&gt;
 			dummy = 1;&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	// We don&#039;t care about TX interrupts&lt;br /&gt;
 	if(mU2TXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 }  &lt;br /&gt;
&lt;br /&gt;
The code may look long, but the theory behind it is very simple.  Depending on what character is read from the UART, some pins will ether be HI or LOW.  For example, when the &amp;quot;A&amp;quot; character is read from the UART, pins D4, D3, D10 and D9 are all depressed.  The layout of the solenoids make the correspond to a G chord.  When the user releases the &amp;quot;A&amp;quot; button, the character &amp;quot;N&amp;quot; is sent.  Looking at the if branch for that character, it is evident that everything turns off.  Indeed the character &amp;quot;N&amp;quot; is like our &amp;quot;off&amp;quot; switch.&lt;br /&gt;
&lt;br /&gt;
One minor detail to the code involves the strummer.  The computer is monitoring the wiimote all the time, so when the accelerometer is engaged data is constantly being streamed to the PIC.  When the user brings the wiimote into the &amp;quot;strumming zone&amp;quot; lots and lots of characters are sent to the PIC.  We don&#039;t want this.  We only want the PIC to react after the first &amp;quot;S&amp;quot; is sent.  To solve this problem we use a dummy variable, aptly called &amp;quot;dummy.&amp;quot;  This variable is initially set at 1.  When the first &amp;quot;S&amp;quot; is sent to the PIC, the IF loop corresponding to character &amp;quot;S&amp;quot; is executed.  But note that &amp;quot;dummy&amp;quot; is set to 2.  Only when the user brings the wiimote back to horizontal does the dummy variable get rest back to 1 (the IF branch that corresponds to this is the one with IF data = &#039;T&#039;).  Thus moving the wiimote like you would strum an actual guitar translates to the strummer only playing intermittently, simulating a guitar.  This was tested pretty rigorously and seemed to work pretty well, though sometimes the &amp;quot;T&amp;quot; wouldn&#039;t get sent and thus the strummer would not strum.   &lt;br /&gt;
&lt;br /&gt;
For reasons not known, the Delayms() function (included in LCD.h) did not work with our code.  Thus we made our own.  This delay function counts NOPs instead of using a dummy counter variable.  The code for this can be seen below.&lt;br /&gt;
&lt;br /&gt;
 //********************** Counts &amp;quot;Nops&amp;quot; so that we can use them as a delay function, instead of the Delayms function built into &amp;quot;LCD.h&amp;quot;.&lt;br /&gt;
 void Delayms( unsigned t)&lt;br /&gt;
 // This uses Timer 1, can be changed to another timer. Assumes FPB = SYS_FREQ&lt;br /&gt;
 {&lt;br /&gt;
 	int i=0;&lt;br /&gt;
     for (i=0;i&amp;lt;t;i++)&lt;br /&gt;
     {  // t x 1ms loop&lt;br /&gt;
         Nop();&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The only code that is in main() involves monitoring the hall sensor.  One pin, A10, was coded as a digital input and is connected from the output of the voltage comparator.  Recall, when the hall sensor is on, the comparator outputs HI and when the hall sensor is off, the comparator outputs LOW.  &lt;br /&gt;
&lt;br /&gt;
 		// Interrupt to control the CN pin to stop the bar with the hall Effects sensor when it goes low to high&lt;br /&gt;
 		if(INPUT_A10 == 1)&lt;br /&gt;
 		{	&lt;br /&gt;
 			DIRECTION_PIN = 1; // When the Hall Effects sesnsor gets tripped, delay and reverse the motor by the following commands&lt;br /&gt;
 			Delayms(200000);   // Delay&lt;br /&gt;
 			DIRECTION_PIN = 0; // Reverse the motor&lt;br /&gt;
 			ENABLE_PIN = 0;    // Brake the motor&lt;br /&gt;
 			&lt;br /&gt;
 		}&lt;br /&gt;
&lt;br /&gt;
This IF loop brakes the motor after the hall sensor is tripped.  The set up of our strummer has the strummer end up in roughly the same place every time.  The weight of the strummer is unbalanced due to the magnet at one end and thus after the motor brakes, it settles down to approximately the same place.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17741</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17741"/>
		<updated>2010-03-18T10:32:45Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* PIC Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Strummer|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s great that the computer can monitor the accelerometer, but we need to set thresholds so that the stummer knows when to activate.  The if loops below do just that.&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
WIUSE_USING_ACC(wm) will return 0 if the accelerometer is disabled or 1 if the accelerometer is enabled.  Assuming the accelerometer is enabled, the code will monitor the accelerometer and not do anything until the wiimote is tilted above 50 degress or below -100 degrees.  The accelerometers report absolute values.  That is, the closer you tilt the wiimote upwards to vertical, the more positive the numbers become.  The thresholds we set were determined from just playing around with the wiimote.  When the wiimote passes one of these thresholds, the character &amp;quot;S&amp;quot; is sent to the PIC.  When the wiimote is brought back to roughly a horizontal position, the computer sends the character &amp;quot;T&amp;quot; to the PIC.  These values will all make sense when the PIC code is discussed.  Note that there are two different pitch values.  There is an absolute pitch value and a corrected pitch value.  The corrected pitch value can be changed by altering the sensitivity in the wiiuse.h file.  We did not bother to do this, as the sensitivity was fine.&lt;br /&gt;
&lt;br /&gt;
Writing to the PIC involved sending data via an RS232 cable through a COM port.  The process involved in writing to a COM port in a Windows environment is cumbersome to say the least.  (Aggravatingly, this whole process could have been avoided if a UNIX based OS was used, as all the COM port information is kept in the dev folder.  Unfortunately, the wiiuse code does not work on UNIX systems because of its dependency on .dll files).  The steps to send data through a COM port are &lt;br /&gt;
&lt;br /&gt;
*Create a handle to point to the serial port&lt;br /&gt;
*Initialize the serial port&lt;br /&gt;
*Open the serial port&lt;br /&gt;
*Write the data to the serial port&lt;br /&gt;
*Send the data&lt;br /&gt;
*Close the port&lt;br /&gt;
&lt;br /&gt;
The portions of the code that do this are scattered throughout the entire wiiuse.c file.  But the most important chucks of the code are&lt;br /&gt;
&lt;br /&gt;
 	HANDLE serial_port;				/* Handle to the serial port */&lt;br /&gt;
 	long baud_rate = 9600;		    /* Specified baud rate */&lt;br /&gt;
 	char port_name[] = &amp;quot;COM7:&amp;quot;;		/* Name of the serial port */  &lt;br /&gt;
 &lt;br /&gt;
  //Initialize Serial Port ------------------------------------------------------------&lt;br /&gt;
 	&lt;br /&gt;
 	/* Open up a handle to the serial port */&lt;br /&gt;
 	serial_port = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);&lt;br /&gt;
 &lt;br /&gt;
 	/* Make sure port was opened */&lt;br /&gt;
 	if (serial_port == INVALID_HANDLE_VALUE)&lt;br /&gt;
 	{&lt;br /&gt;
 		fprintf(stderr, &amp;quot;Error opening port\n&amp;quot;);&lt;br /&gt;
 		CloseHandle(serial_port);&lt;br /&gt;
 		exit(0);&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	/* Set up the serial port */&lt;br /&gt;
 	set_up_serial_port(serial_port, baud_rate);&lt;br /&gt;
 	&lt;br /&gt;
 //End Serial Port Initialization ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
These commands are all located at the beginning of main().&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The WriteFIle() function has several inputs, all of which are unnecessarily confusing.&lt;br /&gt;
&lt;br /&gt;
 WriteFile(&lt;br /&gt;
   __in         HANDLE hFile,&lt;br /&gt;
   __in         LPCVOID lpBuffer,&lt;br /&gt;
   __in         DWORD nNumberOfBytesToWrite,&lt;br /&gt;
   __out_opt    LPDWORD lpNumberOfBytesWritten,&lt;br /&gt;
   __inout_opt  LPOVERLAPPED lpOverlapped&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
*HANDLE hFile: hFile is the handle that points to the COM port.  In our case it&#039;s called &amp;quot;serial_port&amp;quot;&lt;br /&gt;
*LPCVOID lpBuffer: lpBuffer is a pointer to the buffer containing the data that&#039;s to be written.  In our case it&#039;s &amp;quot;buttonPressed&amp;quot; or &amp;quot;motor_signal&amp;quot; depending on the application&lt;br /&gt;
*DWORD nNumberOfBytesToWrite: The number of bytes to be written to the device.  Since we&#039;re sending characters, it&#039;s 1 byte and the variable is &amp;quot;sizeof(char)&amp;quot;&lt;br /&gt;
*LPDWORD lpNumberOfBytesWritten: A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.  In our case it&#039;s just &amp;quot;&amp;amp;bytes_written&amp;quot;&lt;br /&gt;
*The rest of the parameters are just NULL because they aren&#039;t used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PIC Code====&lt;br /&gt;
The code for the PIC is not as complicated as the wii code.  Basically, all the PIC needs to do is monitor a UART port and based on the data it receives either set digital outputs to HI or LOW.  The UART stuff is all handled by an ISR, and interrupt service routine.  &lt;br /&gt;
&lt;br /&gt;
 // UART 2 interrupt handler and is set at priority 7&lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl7) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data = ReadUART2(); // Read data in the UART&lt;br /&gt;
 		&lt;br /&gt;
 		if(data == &#039;A&#039;)&lt;br /&gt;
 		{	&lt;br /&gt;
 			mLED_0_On();&lt;br /&gt;
 			PIN_D4 = 1;&lt;br /&gt;
 			PIN_D3 = 1;&lt;br /&gt;
 			PIN_D10 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;B&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_1_On();&lt;br /&gt;
 			PIN_D8 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 			PIN_D11 = 1;&lt;br /&gt;
  		}&lt;br /&gt;
      		else if(data == &#039;D&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_2_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;L&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;S&#039; &amp;amp;&amp;amp; dummy == 1) &lt;br /&gt;
 		// When the first &amp;quot;S&amp;quot; is sent to the PIC, the dummy variable resets, so the sturmmer doesn&#039;t constantly strum.&lt;br /&gt;
 		// We only want the strummer to strum once and this is what the code does. &lt;br /&gt;
 		{&lt;br /&gt;
 			DIRECTION_PIN = 0;&lt;br /&gt;
 			ENABLE_PIN = 1;&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 			dummy = 2;&lt;br /&gt;
 		}	&lt;br /&gt;
 &lt;br /&gt;
 		else if(data == &#039;N&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_0_Off();&lt;br /&gt;
 			mLED_1_Off();&lt;br /&gt;
 			mLED_2_Off();&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 			PIN_D11 = 0;&lt;br /&gt;
 			PIN_D3 = 0;&lt;br /&gt;
 			PIN_D4 = 0;&lt;br /&gt;
 			PIN_D10 = 0;&lt;br /&gt;
 			PIN_D9 = 0;&lt;br /&gt;
 			PIN_D8 = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;T&#039;)&lt;br /&gt;
 		// Resest the dummy variable when the Wiimote is brought to horizontal so the user can strum the guitar again.&lt;br /&gt;
 		{&lt;br /&gt;
 			dummy = 1;&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	// We don&#039;t care about TX interrupts&lt;br /&gt;
 	if(mU2TXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 }  &lt;br /&gt;
&lt;br /&gt;
The code may look long, but the theory behind it is very simple.  Depending on what character is read from the UART, some pins will ether be HI or LOW.  For example, when the &amp;quot;A&amp;quot; character is read from the UART, pins D4, D3, D10 and D9 are all depressed.  The layout of the solenoids make the correspond to a G chord.  When the user releases the &amp;quot;A&amp;quot; button, the character &amp;quot;N&amp;quot; is sent.  Looking at the if branch for that character, it is evident that everything turns off.  Indeed the character &amp;quot;N&amp;quot; is like our &amp;quot;off&amp;quot; switch.&lt;br /&gt;
&lt;br /&gt;
One minor detail to the code involves the strummer.  The computer is monitoring the wiimote all the time, so when the accelerometer is engaged data is constantly being streamed to the PIC.  When the user brings the wiimote into the &amp;quot;strumming zone&amp;quot; lots and lots of characters are sent to the PIC.  We don&#039;t want this.  We only want the PIC to react after the first &amp;quot;S&amp;quot; is sent.  To solve this problem we use a dummy variable, aptly called &amp;quot;dummy.&amp;quot;  This variable is initially set at 1.  When the first &amp;quot;S&amp;quot; is sent to the PIC, the IF loop corresponding to character &amp;quot;S&amp;quot; is executed.  But note that &amp;quot;dummy&amp;quot; is set to 2.  Only when the user brings the wiimote back to horizontal does the dummy variable get rest back to 1 (the IF branch that corresponds to this is the one with IF data = &#039;T&#039;).  Thus moving the wiimote like you would strum an actual guitar translates to the strummer only playing intermittently, simulating a guitar.  This was tested pretty rigorously and seemed to work pretty well, though sometimes the &amp;quot;T&amp;quot; wouldn&#039;t get sent and thus the strummer would not strum.   &lt;br /&gt;
&lt;br /&gt;
For reasons not know, the Delayms() function built into LCD.h did not work with our code.  Thus we made our own.  This delay function counts NOPs instead of using a dummy counter variable.  The code for this can be seen below.&lt;br /&gt;
&lt;br /&gt;
 //********************** Counts &amp;quot;Nops&amp;quot; so that we can use them as a delay function, instead of the Delayms function built into &amp;quot;LCD.h&amp;quot;.&lt;br /&gt;
 void Delayms( unsigned t)&lt;br /&gt;
 // This uses Timer 1, can be changed to another timer. Assumes FPB = SYS_FREQ&lt;br /&gt;
 {&lt;br /&gt;
 	int i=0;&lt;br /&gt;
     for (i=0;i&amp;lt;t;i++)&lt;br /&gt;
     {  // t x 1ms loop&lt;br /&gt;
         Nop();&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The only code that is in main() involves monitoring the hall sensor.  One pin, A10, was coded as a digital input and is connected from the output of the voltage comparator.  Recall, when the hall sensor is on, the comparator outputs HI and when the hall sensor is off, the comparator outputs LOW.  &lt;br /&gt;
&lt;br /&gt;
 		// Interrupt to control the CN pin to stop the bar with the hall Effects sensor when it goes low to high&lt;br /&gt;
 		if(INPUT_A10 == 1)&lt;br /&gt;
 		{	&lt;br /&gt;
 			DIRECTION_PIN = 1; // When the Hall Effects sesnsor gets tripped, delay and reverse the motor by the following commands&lt;br /&gt;
 			Delayms(200000);   // Delay&lt;br /&gt;
 			DIRECTION_PIN = 0; // Reverse the motor&lt;br /&gt;
 			ENABLE_PIN = 0;    // Brake the motor&lt;br /&gt;
 			&lt;br /&gt;
 		}&lt;br /&gt;
&lt;br /&gt;
This IF loop brakes the motor after the hall sensor is tripped.  The set up of our strummer has the strummer end up in roughly the same place every time.  The weight of the strummer is unbalanced due to the magnet at one end and thus after the motor brakes, it settles down to approximately the same place.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17740</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17740"/>
		<updated>2010-03-18T10:23:29Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Strumming Bridge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Strummer|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s great that the computer can monitor the accelerometer, but we need to set thresholds so that the stummer knows when to activate.  The if loops below do just that.&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
WIUSE_USING_ACC(wm) will return 0 if the accelerometer is disabled or 1 if the accelerometer is enabled.  Assuming the accelerometer is enabled, the code will monitor the accelerometer and not do anything until the wiimote is tilted above 50 degress or below -100 degrees.  The accelerometers report absolute values.  That is, the closer you tilt the wiimote upwards to vertical, the more positive the numbers become.  The thresholds we set were determined from just playing around with the wiimote.  When the wiimote passes one of these thresholds, the character &amp;quot;S&amp;quot; is sent to the PIC.  When the wiimote is brought back to roughly a horizontal position, the computer sends the character &amp;quot;T&amp;quot; to the PIC.  These values will all make sense when the PIC code is discussed.  Note that there are two different pitch values.  There is an absolute pitch value and a corrected pitch value.  The corrected pitch value can be changed by altering the sensitivity in the wiiuse.h file.  We did not bother to do this, as the sensitivity was fine.&lt;br /&gt;
&lt;br /&gt;
Writing to the PIC involved sending data via an RS232 cable through a COM port.  The process involved in writing to a COM port in a Windows environment is cumbersome to say the least.  (Aggravatingly, this whole process could have been avoided if a UNIX based OS was used, as all the COM port information is kept in the dev folder.  Unfortunately, the wiiuse code does not work on UNIX systems because of its dependency on .dll files).  The steps to send data through a COM port are &lt;br /&gt;
&lt;br /&gt;
*Create a handle to point to the serial port&lt;br /&gt;
*Initialize the serial port&lt;br /&gt;
*Open the serial port&lt;br /&gt;
*Write the data to the serial port&lt;br /&gt;
*Send the data&lt;br /&gt;
*Close the port&lt;br /&gt;
&lt;br /&gt;
The portions of the code that do this are scattered throughout the entire wiiuse.c file.  But the most important chucks of the code are&lt;br /&gt;
&lt;br /&gt;
 	HANDLE serial_port;				/* Handle to the serial port */&lt;br /&gt;
 	long baud_rate = 9600;		    /* Specified baud rate */&lt;br /&gt;
 	char port_name[] = &amp;quot;COM7:&amp;quot;;		/* Name of the serial port */  &lt;br /&gt;
 &lt;br /&gt;
  //Initialize Serial Port ------------------------------------------------------------&lt;br /&gt;
 	&lt;br /&gt;
 	/* Open up a handle to the serial port */&lt;br /&gt;
 	serial_port = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);&lt;br /&gt;
 &lt;br /&gt;
 	/* Make sure port was opened */&lt;br /&gt;
 	if (serial_port == INVALID_HANDLE_VALUE)&lt;br /&gt;
 	{&lt;br /&gt;
 		fprintf(stderr, &amp;quot;Error opening port\n&amp;quot;);&lt;br /&gt;
 		CloseHandle(serial_port);&lt;br /&gt;
 		exit(0);&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	/* Set up the serial port */&lt;br /&gt;
 	set_up_serial_port(serial_port, baud_rate);&lt;br /&gt;
 	&lt;br /&gt;
 //End Serial Port Initialization ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
These commands are all located at the beginning of main().&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The WriteFIle() function has several inputs, all of which are unnecessarily confusing.&lt;br /&gt;
&lt;br /&gt;
 WriteFile(&lt;br /&gt;
   __in         HANDLE hFile,&lt;br /&gt;
   __in         LPCVOID lpBuffer,&lt;br /&gt;
   __in         DWORD nNumberOfBytesToWrite,&lt;br /&gt;
   __out_opt    LPDWORD lpNumberOfBytesWritten,&lt;br /&gt;
   __inout_opt  LPOVERLAPPED lpOverlapped&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
*HANDLE hFile: hFile is the handle that points to the COM port.  In our case it&#039;s called &amp;quot;serial_port&amp;quot;&lt;br /&gt;
*LPCVOID lpBuffer: lpBuffer is a pointer to the buffer containing the data that&#039;s to be written.  In our case it&#039;s &amp;quot;buttonPressed&amp;quot; or &amp;quot;motor_signal&amp;quot; depending on the application&lt;br /&gt;
*DWORD nNumberOfBytesToWrite: The number of bytes to be written to the device.  Since we&#039;re sending characters, it&#039;s 1 byte and the variable is &amp;quot;sizeof(char)&amp;quot;&lt;br /&gt;
*LPDWORD lpNumberOfBytesWritten: A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.  In our case it&#039;s just &amp;quot;&amp;amp;bytes_written&amp;quot;&lt;br /&gt;
*The rest of the parameters are just NULL because they aren&#039;t used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PIC Code====&lt;br /&gt;
The code for the PIC is not as complicated as the wii code.  Basically, all the PIC needs to do is monitor a UART port and based on the data it receives either set digital outputs to HI or LOW.  The UART stuff is all handled by an ISR, and interrupt service routine.  &lt;br /&gt;
&lt;br /&gt;
 // UART 2 interrupt handler and is set at priority 7&lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl7) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data = ReadUART2(); // Read data in the UART&lt;br /&gt;
 		&lt;br /&gt;
 		if(data == &#039;A&#039;)&lt;br /&gt;
 		{	&lt;br /&gt;
 			mLED_0_On();&lt;br /&gt;
 			PIN_D4 = 1;&lt;br /&gt;
 			PIN_D3 = 1;&lt;br /&gt;
 			PIN_D10 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;B&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_1_On();&lt;br /&gt;
 			PIN_D8 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 			PIN_D11 = 1;&lt;br /&gt;
  		}&lt;br /&gt;
      		else if(data == &#039;D&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_2_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;L&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;S&#039; &amp;amp;&amp;amp; dummy == 1) &lt;br /&gt;
 		// When the first &amp;quot;S&amp;quot; is sent to the PIC, the dummy variable resets, so the sturmmer doesn&#039;t constantly strum.&lt;br /&gt;
 		// We only want the strummer to strum once and this is what the code does. &lt;br /&gt;
 		{&lt;br /&gt;
 			DIRECTION_PIN = 0;&lt;br /&gt;
 			ENABLE_PIN = 1;&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 			dummy = 2;&lt;br /&gt;
 		}	&lt;br /&gt;
 &lt;br /&gt;
 		else if(data == &#039;N&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_0_Off();&lt;br /&gt;
 			mLED_1_Off();&lt;br /&gt;
 			mLED_2_Off();&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 			PIN_D11 = 0;&lt;br /&gt;
 			PIN_D3 = 0;&lt;br /&gt;
 			PIN_D4 = 0;&lt;br /&gt;
 			PIN_D10 = 0;&lt;br /&gt;
 			PIN_D9 = 0;&lt;br /&gt;
 			PIN_D8 = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;T&#039;)&lt;br /&gt;
 		// Resest the dummy variable when the Wiimote is brought to horizontal so the user can strum the guitar again.&lt;br /&gt;
 		{&lt;br /&gt;
 			dummy = 1;&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	// We don&#039;t care about TX interrupts&lt;br /&gt;
 	if(mU2TXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 }  &lt;br /&gt;
&lt;br /&gt;
The code may look long, but the theory behind it is very simple.  Depending on what character is read from the UART, some pins will ether be HI or LOW.  For example, when the &amp;quot;A&amp;quot; character is read from the UART, pins D4, D3, D10 and D9 are all depressed.  The layout of the solenoids make the correspond to a G chord.  When the user releases the &amp;quot;A&amp;quot; button, the character &amp;quot;N&amp;quot; is sent.  Looking at the if branch for that character, it is evident that everything turns off.  Indeed the character &amp;quot;N&amp;quot; is like our &amp;quot;off&amp;quot; switch.  &lt;br /&gt;
&lt;br /&gt;
For reasons not know, the Delayms() function built into LCD.h did not work with our code.  Thus we made our own.  This delay function counts NOPs instead of using a dummy counter variable.  The code for this can be seen below.&lt;br /&gt;
&lt;br /&gt;
 //********************** Counts &amp;quot;Nops&amp;quot; so that we can use them as a delay function, instead of the Delayms function built into &amp;quot;LCD.h&amp;quot;.&lt;br /&gt;
 void Delayms( unsigned t)&lt;br /&gt;
 // This uses Timer 1, can be changed to another timer. Assumes FPB = SYS_FREQ&lt;br /&gt;
 {&lt;br /&gt;
 	int i=0;&lt;br /&gt;
     for (i=0;i&amp;lt;t;i++)&lt;br /&gt;
     {  // t x 1ms loop&lt;br /&gt;
         Nop();&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The only code that is in main() involves monitoring the hall sensor.  One pin, A10, was coded as a digital input and is connected from the output of the voltage comparator.  Recall, when the hall sensor is on, the comparator outputs HI and when the hall sensor is off, the comparator outputs LOW.  &lt;br /&gt;
&lt;br /&gt;
 		// Interrupt to control the CN pin to stop the bar with the hall Effects sensor when it goes low to high&lt;br /&gt;
 		if(INPUT_A10 == 1)&lt;br /&gt;
 		{	&lt;br /&gt;
 			DIRECTION_PIN = 1; // When the Hall Effects sesnsor gets tripped, delay and reverse the motor by the following commands&lt;br /&gt;
 			Delayms(200000);   // Delay&lt;br /&gt;
 			DIRECTION_PIN = 0; // Reverse the motor&lt;br /&gt;
 			ENABLE_PIN = 0;    // Brake the motor&lt;br /&gt;
 			&lt;br /&gt;
 		}&lt;br /&gt;
&lt;br /&gt;
This if loop brakes the motor after the hall sensor is tripped.  The set up of our strummer has the strummer end up in roughly the same place every time.  The weight of the strummer is unbalanced due to the magnet at one end and thus after the motor brakes, it settles down to approximately the same place.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17739</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17739"/>
		<updated>2010-03-18T10:22:56Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* PIC Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s great that the computer can monitor the accelerometer, but we need to set thresholds so that the stummer knows when to activate.  The if loops below do just that.&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
WIUSE_USING_ACC(wm) will return 0 if the accelerometer is disabled or 1 if the accelerometer is enabled.  Assuming the accelerometer is enabled, the code will monitor the accelerometer and not do anything until the wiimote is tilted above 50 degress or below -100 degrees.  The accelerometers report absolute values.  That is, the closer you tilt the wiimote upwards to vertical, the more positive the numbers become.  The thresholds we set were determined from just playing around with the wiimote.  When the wiimote passes one of these thresholds, the character &amp;quot;S&amp;quot; is sent to the PIC.  When the wiimote is brought back to roughly a horizontal position, the computer sends the character &amp;quot;T&amp;quot; to the PIC.  These values will all make sense when the PIC code is discussed.  Note that there are two different pitch values.  There is an absolute pitch value and a corrected pitch value.  The corrected pitch value can be changed by altering the sensitivity in the wiiuse.h file.  We did not bother to do this, as the sensitivity was fine.&lt;br /&gt;
&lt;br /&gt;
Writing to the PIC involved sending data via an RS232 cable through a COM port.  The process involved in writing to a COM port in a Windows environment is cumbersome to say the least.  (Aggravatingly, this whole process could have been avoided if a UNIX based OS was used, as all the COM port information is kept in the dev folder.  Unfortunately, the wiiuse code does not work on UNIX systems because of its dependency on .dll files).  The steps to send data through a COM port are &lt;br /&gt;
&lt;br /&gt;
*Create a handle to point to the serial port&lt;br /&gt;
*Initialize the serial port&lt;br /&gt;
*Open the serial port&lt;br /&gt;
*Write the data to the serial port&lt;br /&gt;
*Send the data&lt;br /&gt;
*Close the port&lt;br /&gt;
&lt;br /&gt;
The portions of the code that do this are scattered throughout the entire wiiuse.c file.  But the most important chucks of the code are&lt;br /&gt;
&lt;br /&gt;
 	HANDLE serial_port;				/* Handle to the serial port */&lt;br /&gt;
 	long baud_rate = 9600;		    /* Specified baud rate */&lt;br /&gt;
 	char port_name[] = &amp;quot;COM7:&amp;quot;;		/* Name of the serial port */  &lt;br /&gt;
 &lt;br /&gt;
  //Initialize Serial Port ------------------------------------------------------------&lt;br /&gt;
 	&lt;br /&gt;
 	/* Open up a handle to the serial port */&lt;br /&gt;
 	serial_port = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);&lt;br /&gt;
 &lt;br /&gt;
 	/* Make sure port was opened */&lt;br /&gt;
 	if (serial_port == INVALID_HANDLE_VALUE)&lt;br /&gt;
 	{&lt;br /&gt;
 		fprintf(stderr, &amp;quot;Error opening port\n&amp;quot;);&lt;br /&gt;
 		CloseHandle(serial_port);&lt;br /&gt;
 		exit(0);&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	/* Set up the serial port */&lt;br /&gt;
 	set_up_serial_port(serial_port, baud_rate);&lt;br /&gt;
 	&lt;br /&gt;
 //End Serial Port Initialization ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
These commands are all located at the beginning of main().&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The WriteFIle() function has several inputs, all of which are unnecessarily confusing.&lt;br /&gt;
&lt;br /&gt;
 WriteFile(&lt;br /&gt;
   __in         HANDLE hFile,&lt;br /&gt;
   __in         LPCVOID lpBuffer,&lt;br /&gt;
   __in         DWORD nNumberOfBytesToWrite,&lt;br /&gt;
   __out_opt    LPDWORD lpNumberOfBytesWritten,&lt;br /&gt;
   __inout_opt  LPOVERLAPPED lpOverlapped&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
*HANDLE hFile: hFile is the handle that points to the COM port.  In our case it&#039;s called &amp;quot;serial_port&amp;quot;&lt;br /&gt;
*LPCVOID lpBuffer: lpBuffer is a pointer to the buffer containing the data that&#039;s to be written.  In our case it&#039;s &amp;quot;buttonPressed&amp;quot; or &amp;quot;motor_signal&amp;quot; depending on the application&lt;br /&gt;
*DWORD nNumberOfBytesToWrite: The number of bytes to be written to the device.  Since we&#039;re sending characters, it&#039;s 1 byte and the variable is &amp;quot;sizeof(char)&amp;quot;&lt;br /&gt;
*LPDWORD lpNumberOfBytesWritten: A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.  In our case it&#039;s just &amp;quot;&amp;amp;bytes_written&amp;quot;&lt;br /&gt;
*The rest of the parameters are just NULL because they aren&#039;t used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PIC Code====&lt;br /&gt;
The code for the PIC is not as complicated as the wii code.  Basically, all the PIC needs to do is monitor a UART port and based on the data it receives either set digital outputs to HI or LOW.  The UART stuff is all handled by an ISR, and interrupt service routine.  &lt;br /&gt;
&lt;br /&gt;
 // UART 2 interrupt handler and is set at priority 7&lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl7) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data = ReadUART2(); // Read data in the UART&lt;br /&gt;
 		&lt;br /&gt;
 		if(data == &#039;A&#039;)&lt;br /&gt;
 		{	&lt;br /&gt;
 			mLED_0_On();&lt;br /&gt;
 			PIN_D4 = 1;&lt;br /&gt;
 			PIN_D3 = 1;&lt;br /&gt;
 			PIN_D10 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;B&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_1_On();&lt;br /&gt;
 			PIN_D8 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 			PIN_D11 = 1;&lt;br /&gt;
  		}&lt;br /&gt;
      		else if(data == &#039;D&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_2_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;L&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;S&#039; &amp;amp;&amp;amp; dummy == 1) &lt;br /&gt;
 		// When the first &amp;quot;S&amp;quot; is sent to the PIC, the dummy variable resets, so the sturmmer doesn&#039;t constantly strum.&lt;br /&gt;
 		// We only want the strummer to strum once and this is what the code does. &lt;br /&gt;
 		{&lt;br /&gt;
 			DIRECTION_PIN = 0;&lt;br /&gt;
 			ENABLE_PIN = 1;&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 			dummy = 2;&lt;br /&gt;
 		}	&lt;br /&gt;
 &lt;br /&gt;
 		else if(data == &#039;N&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_0_Off();&lt;br /&gt;
 			mLED_1_Off();&lt;br /&gt;
 			mLED_2_Off();&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 			PIN_D11 = 0;&lt;br /&gt;
 			PIN_D3 = 0;&lt;br /&gt;
 			PIN_D4 = 0;&lt;br /&gt;
 			PIN_D10 = 0;&lt;br /&gt;
 			PIN_D9 = 0;&lt;br /&gt;
 			PIN_D8 = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;T&#039;)&lt;br /&gt;
 		// Resest the dummy variable when the Wiimote is brought to horizontal so the user can strum the guitar again.&lt;br /&gt;
 		{&lt;br /&gt;
 			dummy = 1;&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	// We don&#039;t care about TX interrupts&lt;br /&gt;
 	if(mU2TXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 }  &lt;br /&gt;
&lt;br /&gt;
The code may look long, but the theory behind it is very simple.  Depending on what character is read from the UART, some pins will ether be HI or LOW.  For example, when the &amp;quot;A&amp;quot; character is read from the UART, pins D4, D3, D10 and D9 are all depressed.  The layout of the solenoids make the correspond to a G chord.  When the user releases the &amp;quot;A&amp;quot; button, the character &amp;quot;N&amp;quot; is sent.  Looking at the if branch for that character, it is evident that everything turns off.  Indeed the character &amp;quot;N&amp;quot; is like our &amp;quot;off&amp;quot; switch.  &lt;br /&gt;
&lt;br /&gt;
For reasons not know, the Delayms() function built into LCD.h did not work with our code.  Thus we made our own.  This delay function counts NOPs instead of using a dummy counter variable.  The code for this can be seen below.&lt;br /&gt;
&lt;br /&gt;
 //********************** Counts &amp;quot;Nops&amp;quot; so that we can use them as a delay function, instead of the Delayms function built into &amp;quot;LCD.h&amp;quot;.&lt;br /&gt;
 void Delayms( unsigned t)&lt;br /&gt;
 // This uses Timer 1, can be changed to another timer. Assumes FPB = SYS_FREQ&lt;br /&gt;
 {&lt;br /&gt;
 	int i=0;&lt;br /&gt;
     for (i=0;i&amp;lt;t;i++)&lt;br /&gt;
     {  // t x 1ms loop&lt;br /&gt;
         Nop();&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The only code that is in main() involves monitoring the hall sensor.  One pin, A10, was coded as a digital input and is connected from the output of the voltage comparator.  Recall, when the hall sensor is on, the comparator outputs HI and when the hall sensor is off, the comparator outputs LOW.  &lt;br /&gt;
&lt;br /&gt;
 		// Interrupt to control the CN pin to stop the bar with the hall Effects sensor when it goes low to high&lt;br /&gt;
 		if(INPUT_A10 == 1)&lt;br /&gt;
 		{	&lt;br /&gt;
 			DIRECTION_PIN = 1; // When the Hall Effects sesnsor gets tripped, delay and reverse the motor by the following commands&lt;br /&gt;
 			Delayms(200000);   // Delay&lt;br /&gt;
 			DIRECTION_PIN = 0; // Reverse the motor&lt;br /&gt;
 			ENABLE_PIN = 0;    // Brake the motor&lt;br /&gt;
 			&lt;br /&gt;
 		}&lt;br /&gt;
&lt;br /&gt;
This if loop brakes the motor after the hall sensor is tripped.  The set up of our strummer has the strummer end up in roughly the same place every time.  The weight of the strummer is unbalanced due to the magnet at one end and thus after the motor brakes, it settles down to approximately the same place.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17738</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17738"/>
		<updated>2010-03-18T10:14:45Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s great that the computer can monitor the accelerometer, but we need to set thresholds so that the stummer knows when to activate.  The if loops below do just that.&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
WIUSE_USING_ACC(wm) will return 0 if the accelerometer is disabled or 1 if the accelerometer is enabled.  Assuming the accelerometer is enabled, the code will monitor the accelerometer and not do anything until the wiimote is tilted above 50 degress or below -100 degrees.  The accelerometers report absolute values.  That is, the closer you tilt the wiimote upwards to vertical, the more positive the numbers become.  The thresholds we set were determined from just playing around with the wiimote.  When the wiimote passes one of these thresholds, the character &amp;quot;S&amp;quot; is sent to the PIC.  When the wiimote is brought back to roughly a horizontal position, the computer sends the character &amp;quot;T&amp;quot; to the PIC.  These values will all make sense when the PIC code is discussed.  Note that there are two different pitch values.  There is an absolute pitch value and a corrected pitch value.  The corrected pitch value can be changed by altering the sensitivity in the wiiuse.h file.  We did not bother to do this, as the sensitivity was fine.&lt;br /&gt;
&lt;br /&gt;
Writing to the PIC involved sending data via an RS232 cable through a COM port.  The process involved in writing to a COM port in a Windows environment is cumbersome to say the least.  (Aggravatingly, this whole process could have been avoided if a UNIX based OS was used, as all the COM port information is kept in the dev folder.  Unfortunately, the wiiuse code does not work on UNIX systems because of its dependency on .dll files).  The steps to send data through a COM port are &lt;br /&gt;
&lt;br /&gt;
*Create a handle to point to the serial port&lt;br /&gt;
*Initialize the serial port&lt;br /&gt;
*Open the serial port&lt;br /&gt;
*Write the data to the serial port&lt;br /&gt;
*Send the data&lt;br /&gt;
*Close the port&lt;br /&gt;
&lt;br /&gt;
The portions of the code that do this are scattered throughout the entire wiiuse.c file.  But the most important chucks of the code are&lt;br /&gt;
&lt;br /&gt;
 	HANDLE serial_port;				/* Handle to the serial port */&lt;br /&gt;
 	long baud_rate = 9600;		    /* Specified baud rate */&lt;br /&gt;
 	char port_name[] = &amp;quot;COM7:&amp;quot;;		/* Name of the serial port */  &lt;br /&gt;
 &lt;br /&gt;
  //Initialize Serial Port ------------------------------------------------------------&lt;br /&gt;
 	&lt;br /&gt;
 	/* Open up a handle to the serial port */&lt;br /&gt;
 	serial_port = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);&lt;br /&gt;
 &lt;br /&gt;
 	/* Make sure port was opened */&lt;br /&gt;
 	if (serial_port == INVALID_HANDLE_VALUE)&lt;br /&gt;
 	{&lt;br /&gt;
 		fprintf(stderr, &amp;quot;Error opening port\n&amp;quot;);&lt;br /&gt;
 		CloseHandle(serial_port);&lt;br /&gt;
 		exit(0);&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	/* Set up the serial port */&lt;br /&gt;
 	set_up_serial_port(serial_port, baud_rate);&lt;br /&gt;
 	&lt;br /&gt;
 //End Serial Port Initialization ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
These commands are all located at the beginning of main().&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The WriteFIle() function has several inputs, all of which are unnecessarily confusing.&lt;br /&gt;
&lt;br /&gt;
 WriteFile(&lt;br /&gt;
   __in         HANDLE hFile,&lt;br /&gt;
   __in         LPCVOID lpBuffer,&lt;br /&gt;
   __in         DWORD nNumberOfBytesToWrite,&lt;br /&gt;
   __out_opt    LPDWORD lpNumberOfBytesWritten,&lt;br /&gt;
   __inout_opt  LPOVERLAPPED lpOverlapped&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
*HANDLE hFile: hFile is the handle that points to the COM port.  In our case it&#039;s called &amp;quot;serial_port&amp;quot;&lt;br /&gt;
*LPCVOID lpBuffer: lpBuffer is a pointer to the buffer containing the data that&#039;s to be written.  In our case it&#039;s &amp;quot;buttonPressed&amp;quot; or &amp;quot;motor_signal&amp;quot; depending on the application&lt;br /&gt;
*DWORD nNumberOfBytesToWrite: The number of bytes to be written to the device.  Since we&#039;re sending characters, it&#039;s 1 byte and the variable is &amp;quot;sizeof(char)&amp;quot;&lt;br /&gt;
*LPDWORD lpNumberOfBytesWritten: A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.  In our case it&#039;s just &amp;quot;&amp;amp;bytes_written&amp;quot;&lt;br /&gt;
*The rest of the parameters are just NULL because they aren&#039;t used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PIC Code====&lt;br /&gt;
The code for the PIC is not as complicated as the wii code.  Basically, all the PIC needs to do is monitor a UART port and based on the data it receives either set digital outputs to HI or LOW.  The UART stuff is all handled by an ISR, and interrupt service routine.  &lt;br /&gt;
&lt;br /&gt;
 // UART 2 interrupt handler and is set at priority 7&lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl7) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data = ReadUART2(); // Read data in the UART&lt;br /&gt;
 		&lt;br /&gt;
 		if(data == &#039;A&#039;)&lt;br /&gt;
 		{	&lt;br /&gt;
 			mLED_0_On();&lt;br /&gt;
 			PIN_D4 = 1;&lt;br /&gt;
 			PIN_D3 = 1;&lt;br /&gt;
 			PIN_D10 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;B&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_1_On();&lt;br /&gt;
 			PIN_D8 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 			PIN_D11 = 1;&lt;br /&gt;
  		}&lt;br /&gt;
      		else if(data == &#039;D&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_2_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;L&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;S&#039; &amp;amp;&amp;amp; dummy == 1) &lt;br /&gt;
 		// When the first &amp;quot;S&amp;quot; is sent to the PIC, the dummy variable resets, so the sturmmer doesn&#039;t constantly strum.&lt;br /&gt;
 		// We only want the strummer to strum once and this is what the code does. &lt;br /&gt;
 		{&lt;br /&gt;
 			DIRECTION_PIN = 0;&lt;br /&gt;
 			ENABLE_PIN = 1;&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 			dummy = 2;&lt;br /&gt;
 		}	&lt;br /&gt;
 &lt;br /&gt;
 		else if(data == &#039;N&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_0_Off();&lt;br /&gt;
 			mLED_1_Off();&lt;br /&gt;
 			mLED_2_Off();&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 			PIN_D11 = 0;&lt;br /&gt;
 			PIN_D3 = 0;&lt;br /&gt;
 			PIN_D4 = 0;&lt;br /&gt;
 			PIN_D10 = 0;&lt;br /&gt;
 			PIN_D9 = 0;&lt;br /&gt;
 			PIN_D8 = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;T&#039;)&lt;br /&gt;
 		// Resest the dummy variable when the Wiimote is brought to horizontal so the user can strum the guitar again.&lt;br /&gt;
 		{&lt;br /&gt;
 			dummy = 1;&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	// We don&#039;t care about TX interrupts&lt;br /&gt;
 	if(mU2TXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 }  &lt;br /&gt;
&lt;br /&gt;
The code may look long, but the theory behind it is very simple.  Depending on what character is read from the UART, some pins will ether be HI or LOW.  For example, when the &amp;quot;A&amp;quot; character is read from the UART, pins D4, D3, D10 and D9 are all depressed.  The layout of the solenoids make the correspond to a G chord.  When the user releases the &amp;quot;A&amp;quot; button, the character &amp;quot;N&amp;quot; is sent.  Looking at the if branch for that character, it is evident that everything turns off.  Indeed the character &amp;quot;N&amp;quot; is like our &amp;quot;off&amp;quot; switch.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17737</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17737"/>
		<updated>2010-03-18T10:14:00Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Computer Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s great that the computer can monitor the accelerometer, but we need to set thresholds so that the stummer knows when to activate.  The if loops below do just that.&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
WIUSE_USING_ACC(wm) will return 0 if the accelerometer is disabled or 1 if the accelerometer is enabled.  Assuming the accelerometer is enabled, the code will monitor the accelerometer and not do anything until the wiimote is tilted above 50 degress or below -100 degrees.  The accelerometers report absolute values.  That is, the closer you tilt the wiimote upwards to vertical, the more positive the numbers become.  The thresholds we set were determined from just playing around with the wiimote.  When the wiimote passes one of these thresholds, the character &amp;quot;S&amp;quot; is sent to the PIC.  When the wiimote is brought back to roughly a horizontal position, the computer sends the character &amp;quot;T&amp;quot; to the PIC.  These values will all make sense when the PIC code is discussed.  Note that there are two different pitch values.  There is an absolute pitch value and a corrected pitch value.  The corrected pitch value can be changed by altering the sensitivity in the wiiuse.h file.  We did not bother to do this, as the sensitivity was fine.&lt;br /&gt;
&lt;br /&gt;
Writing to the PIC involved sending data via an RS232 cable through a COM port.  The process involved in writing to a COM port in a Windows environment is cumbersome to say the least.  (Aggravatingly, this whole process could have been avoided if a UNIX based OS was used, as all the COM port information is kept in the dev folder.  Unfortunately, the wiiuse code does not work on UNIX systems because of its dependency on .dll files).  The steps to send data through a COM port are &lt;br /&gt;
&lt;br /&gt;
*Create a handle to point to the serial port&lt;br /&gt;
*Initialize the serial port&lt;br /&gt;
*Open the serial port&lt;br /&gt;
*Write the data to the serial port&lt;br /&gt;
*Send the data&lt;br /&gt;
*Close the port&lt;br /&gt;
&lt;br /&gt;
The portions of the code that do this are scattered throughout the entire wiiuse.c file.  But the most important chucks of the code are&lt;br /&gt;
&lt;br /&gt;
 	HANDLE serial_port;				/* Handle to the serial port */&lt;br /&gt;
 	long baud_rate = 9600;		    /* Specified baud rate */&lt;br /&gt;
 	char port_name[] = &amp;quot;COM7:&amp;quot;;		/* Name of the serial port */  &lt;br /&gt;
 &lt;br /&gt;
  //Initialize Serial Port ------------------------------------------------------------&lt;br /&gt;
 	&lt;br /&gt;
 	/* Open up a handle to the serial port */&lt;br /&gt;
 	serial_port = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);&lt;br /&gt;
 &lt;br /&gt;
 	/* Make sure port was opened */&lt;br /&gt;
 	if (serial_port == INVALID_HANDLE_VALUE)&lt;br /&gt;
 	{&lt;br /&gt;
 		fprintf(stderr, &amp;quot;Error opening port\n&amp;quot;);&lt;br /&gt;
 		CloseHandle(serial_port);&lt;br /&gt;
 		exit(0);&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	/* Set up the serial port */&lt;br /&gt;
 	set_up_serial_port(serial_port, baud_rate);&lt;br /&gt;
 	&lt;br /&gt;
 //End Serial Port Initialization ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
These commands are all located at the beginning of main().&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The WriteFIle() function has several inputs, all of which are unnecessarily confusing.&lt;br /&gt;
&lt;br /&gt;
 WriteFile(&lt;br /&gt;
   __in         HANDLE hFile,&lt;br /&gt;
   __in         LPCVOID lpBuffer,&lt;br /&gt;
   __in         DWORD nNumberOfBytesToWrite,&lt;br /&gt;
   __out_opt    LPDWORD lpNumberOfBytesWritten,&lt;br /&gt;
   __inout_opt  LPOVERLAPPED lpOverlapped&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
*HANDLE hFile: hFile is the handle that points to the COM port.  In our case it&#039;s called &amp;quot;serial_port&amp;quot;&lt;br /&gt;
*LPCVOID lpBuffer: lpBuffer is a pointer to the buffer containing the data that&#039;s to be written.  In our case it&#039;s &amp;quot;buttonPressed&amp;quot; or &amp;quot;motor_signal&amp;quot; depending on the application&lt;br /&gt;
*DWORD nNumberOfBytesToWrite: The number of bytes to be written to the device.  Since we&#039;re sending characters, it&#039;s 1 byte and the variable is &amp;quot;sizeof(char)&amp;quot;&lt;br /&gt;
*LPDWORD lpNumberOfBytesWritten: A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.  In our case it&#039;s just &amp;quot;&amp;amp;bytes_written&amp;quot;&lt;br /&gt;
*The rest of the parameters are just NULL because they aren&#039;t used.&lt;br /&gt;
&lt;br /&gt;
====PIC Code====&lt;br /&gt;
The code for the PIC is not as complicated as the wii code.  Basically, all the PIC needs to do is monitor a UART port and based on the data it receives either set digital outputs to HI or LOW.  The UART stuff is all handled by an ISR, and interrupt service routine.  &lt;br /&gt;
&lt;br /&gt;
 // UART 2 interrupt handler and is set at priority 7&lt;br /&gt;
 void __ISR(_UART2_VECTOR, ipl7) IntUart2Handler(void)&lt;br /&gt;
 {&lt;br /&gt;
 	// Is this an RX interrupt?&lt;br /&gt;
 	if(mU2RXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 		// Clear the RX interrupt Flag&lt;br /&gt;
 	    mU2RXClearIntFlag();&lt;br /&gt;
 &lt;br /&gt;
 		data = ReadUART2(); // Read data in the UART&lt;br /&gt;
 		&lt;br /&gt;
 		if(data == &#039;A&#039;)&lt;br /&gt;
 		{	&lt;br /&gt;
 			mLED_0_On();&lt;br /&gt;
 			PIN_D4 = 1;&lt;br /&gt;
 			PIN_D3 = 1;&lt;br /&gt;
 			PIN_D10 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;B&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_1_On();&lt;br /&gt;
 			PIN_D8 = 1;&lt;br /&gt;
 			PIN_D9 = 1;&lt;br /&gt;
 			PIN_D11 = 1;&lt;br /&gt;
  		}&lt;br /&gt;
      		else if(data == &#039;D&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_2_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;L&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;S&#039; &amp;amp;&amp;amp; dummy == 1) &lt;br /&gt;
 		// When the first &amp;quot;S&amp;quot; is sent to the PIC, the dummy variable resets, so the sturmmer doesn&#039;t constantly strum.&lt;br /&gt;
 		// We only want the strummer to strum once and this is what the code does. &lt;br /&gt;
 		{&lt;br /&gt;
 			DIRECTION_PIN = 0;&lt;br /&gt;
 			ENABLE_PIN = 1;&lt;br /&gt;
 			mLED_3_On();&lt;br /&gt;
 			dummy = 2;&lt;br /&gt;
 		}	&lt;br /&gt;
 &lt;br /&gt;
 		else if(data == &#039;N&#039;)&lt;br /&gt;
 		{&lt;br /&gt;
 			mLED_0_Off();&lt;br /&gt;
 			mLED_1_Off();&lt;br /&gt;
 			mLED_2_Off();&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 			PIN_D11 = 0;&lt;br /&gt;
 			PIN_D3 = 0;&lt;br /&gt;
 			PIN_D4 = 0;&lt;br /&gt;
 			PIN_D10 = 0;&lt;br /&gt;
 			PIN_D9 = 0;&lt;br /&gt;
 			PIN_D8 = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else if(data == &#039;T&#039;)&lt;br /&gt;
 		// Resest the dummy variable when the Wiimote is brought to horizontal so the user can strum the guitar again.&lt;br /&gt;
 		{&lt;br /&gt;
 			dummy = 1;&lt;br /&gt;
 			mLED_3_Off();&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	// We don&#039;t care about TX interrupts&lt;br /&gt;
 	if(mU2TXGetIntFlag())&lt;br /&gt;
 	{&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 }  &lt;br /&gt;
&lt;br /&gt;
The code may look long, but the theory behind it is very simple.  Depending on what character is read from the UART, some pins will ether be HI or LOW.  For example, when the &amp;quot;A&amp;quot; character is read from the UART, pins D4, D3, D10 and D9 are all depressed.  The layout of the solenoids make the correspond to a G chord.  When the user releases the &amp;quot;A&amp;quot; button, the character &amp;quot;N&amp;quot; is sent.  Looking at the if branch for that character, it is evident that everything turns off.  Indeed the character &amp;quot;N&amp;quot; is like our &amp;quot;off&amp;quot; switch.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17736</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17736"/>
		<updated>2010-03-18T10:07:04Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Computer Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s great that the computer can monitor the accelerometer, but we need to set thresholds so that the stummer knows when to activate.  The if loops below do just that.&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
WIUSE_USING_ACC(wm) will return 0 if the accelerometer is disabled or 1 if the accelerometer is enabled.  Assuming the accelerometer is enabled, the code will monitor the accelerometer and not do anything until the wiimote is tilted above 50 degress or below -100 degrees.  The accelerometers report absolute values.  That is, the closer you tilt the wiimote upwards to vertical, the more positive the numbers become.  The thresholds we set were determined from just playing around with the wiimote.  When the wiimote passes one of these thresholds, the character &amp;quot;S&amp;quot; is sent to the PIC.  When the wiimote is brought back to roughly a horizontal position, the computer sends the character &amp;quot;T&amp;quot; to the PIC.  These values will all make sense when the PIC code is discussed.  Note that there are two different pitch values.  There is an absolute pitch value and a corrected pitch value.  The corrected pitch value can be changed by altering the sensitivity in the wiiuse.h file.  We did not bother to do this, as the sensitivity was fine.&lt;br /&gt;
&lt;br /&gt;
Writing to the PIC involved sending data via an RS232 cable through a COM port.  The process involved in writing to a COM port in a Windows environment is cumbersome to say the least.  (Aggravatingly, this whole process could have been avoided if a UNIX based OS was used, as all the COM port information is kept in the dev folder.  Unfortunately, the wiiuse code does not work on UNIX systems because of its dependency on .dll files).  The steps to send data through a COM port are &lt;br /&gt;
&lt;br /&gt;
*Create a handle to point to the serial port&lt;br /&gt;
*Initialize the serial port&lt;br /&gt;
*Open the serial port&lt;br /&gt;
*Write the data to the serial port&lt;br /&gt;
*Send the data&lt;br /&gt;
*Close the port&lt;br /&gt;
&lt;br /&gt;
The portions of the code that do this are scattered throughout the entire wiiuse.c file.  But the most important chucks of the code are&lt;br /&gt;
&lt;br /&gt;
 	HANDLE serial_port;				/* Handle to the serial port */&lt;br /&gt;
 	long baud_rate = 9600;		    /* Specified baud rate */&lt;br /&gt;
 	char port_name[] = &amp;quot;COM7:&amp;quot;;		/* Name of the serial port */  &lt;br /&gt;
 &lt;br /&gt;
  //Initialize Serial Port ------------------------------------------------------------&lt;br /&gt;
 	&lt;br /&gt;
 	/* Open up a handle to the serial port */&lt;br /&gt;
 	serial_port = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);&lt;br /&gt;
 &lt;br /&gt;
 	/* Make sure port was opened */&lt;br /&gt;
 	if (serial_port == INVALID_HANDLE_VALUE)&lt;br /&gt;
 	{&lt;br /&gt;
 		fprintf(stderr, &amp;quot;Error opening port\n&amp;quot;);&lt;br /&gt;
 		CloseHandle(serial_port);&lt;br /&gt;
 		exit(0);&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	/* Set up the serial port */&lt;br /&gt;
 	set_up_serial_port(serial_port, baud_rate);&lt;br /&gt;
 	&lt;br /&gt;
 //End Serial Port Initialization ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
These commands are all located at the beginning of main().&lt;br /&gt;
&lt;br /&gt;
The WriteFIle() function has several inputs, all of which are unnecessarily confusing.&lt;br /&gt;
&lt;br /&gt;
 WriteFile(&lt;br /&gt;
   __in         HANDLE hFile,&lt;br /&gt;
   __in         LPCVOID lpBuffer,&lt;br /&gt;
   __in         DWORD nNumberOfBytesToWrite,&lt;br /&gt;
   __out_opt    LPDWORD lpNumberOfBytesWritten,&lt;br /&gt;
   __inout_opt  LPOVERLAPPED lpOverlapped&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
*HANDLE hFile: hFile is the handle that points to the COM port.  In our case it&#039;s called &amp;quot;serial_port&amp;quot;&lt;br /&gt;
*LPCVOID lpBuffer: lpBuffer is a pointer to the buffer containing the data that&#039;s to be written.  In our case it&#039;s &amp;quot;buttonPressed&amp;quot; or &amp;quot;motor_signal&amp;quot; depending on the application&lt;br /&gt;
*DWORD nNumberOfBytesToWrite: The number of bytes to be written to the device.  Since we&#039;re sending characters, it&#039;s 1 byte and the variable is &amp;quot;sizeof(char)&amp;quot;&lt;br /&gt;
*LPDWORD lpNumberOfBytesWritten: A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.  In our case it&#039;s just &amp;quot;&amp;amp;bytes_written&amp;quot;&lt;br /&gt;
*The rest of the parameters are just NULL because they aren&#039;t used.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17735</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17735"/>
		<updated>2010-03-18T09:56:23Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Computer Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s great that the computer can monitor the accelerometer, but we need to set thresholds so that the stummer knows when to activate.  The if loops below do just that.&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
WIUSE_USING_ACC(wm) will return 0 if the accelerometer is disabled or 1 if the accelerometer is enabled.  Assuming the accelerometer is enabled, the code will monitor the accelerometer and not do anything until the wiimote is tilted above 50 degress or below -100 degrees.  The accelerometers report absolute values.  That is, the closer you tilt the wiimote upwards to vertical, the more positive the numbers become.  The thresholds we set were determined from just playing around with the wiimote.  When the wiimote passes one of these thresholds, the character &amp;quot;S&amp;quot; is sent to the PIC.  When the wiimote is brought back to roughly a horizontal position, the computer sends the character &amp;quot;T&amp;quot; to the PIC.  These values will all make sense when the PIC code is discussed.  Note that there are two different pitch values.  There is an absolute pitch value and a corrected pitch value.  The corrected pitch value can be changed by altering the sensitivity in the wiiuse.h file.  We did not bother to do this, as the sensitivity was fine.&lt;br /&gt;
&lt;br /&gt;
Writing to the PIC involved sending data via an RS232 cable through a COM port.  The process involved in writing to a COM port in a Windows environment is cumbersome to say the least.  (Aggravatingly, this whole process could have been avoided if a UNIX based OS was used, as all the COM port information is kept in the dev folder.  Unfortunately, the wiiuse code does not work on UNIX systems because of its dependency on .dll files).  The steps to send data through a COM port are &lt;br /&gt;
&lt;br /&gt;
*Create a handle to point to the serial port&lt;br /&gt;
*Initialize the serial port&lt;br /&gt;
*Open the serial port&lt;br /&gt;
*Write the data to the serial port&lt;br /&gt;
*Send the data&lt;br /&gt;
*Close the port&lt;br /&gt;
&lt;br /&gt;
The portions of the code that do this are scattered throughout the entire wiiuse.c file.  But the most important chucks of the code are&lt;br /&gt;
&lt;br /&gt;
 	HANDLE serial_port;				/* Handle to the serial port */&lt;br /&gt;
 	long baud_rate = 9600;		    /* Specified baud rate */&lt;br /&gt;
 	char port_name[] = &amp;quot;COM7:&amp;quot;;		/* Name of the serial port */  &lt;br /&gt;
 &lt;br /&gt;
  //Initialize Serial Port ------------------------------------------------------------&lt;br /&gt;
 	&lt;br /&gt;
 	/* Open up a handle to the serial port */&lt;br /&gt;
 	serial_port = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);&lt;br /&gt;
 &lt;br /&gt;
 	/* Make sure port was opened */&lt;br /&gt;
 	if (serial_port == INVALID_HANDLE_VALUE)&lt;br /&gt;
 	{&lt;br /&gt;
 		fprintf(stderr, &amp;quot;Error opening port\n&amp;quot;);&lt;br /&gt;
 		CloseHandle(serial_port);&lt;br /&gt;
 		exit(0);&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	/* Set up the serial port */&lt;br /&gt;
 	set_up_serial_port(serial_port, baud_rate);&lt;br /&gt;
 	&lt;br /&gt;
 //End Serial Port Initialization ----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
These commands are all located at the beginning of main().&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17734</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17734"/>
		<updated>2010-03-18T09:48:44Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s great that the computer can monitor the accelerometer, but we need to set thresholds so that the stummer knows when to activate.  The if loops below do just that.&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
WIUSE_USING_ACC(wm) will return 0 if the accelerometer is disabled or 1 if the accelerometer is enabled.  Assuming the accelerometer is enabled, the code will monitor the accelerometer and not do anything until the wiimote is tilted above 50 degress or below -100 degrees.  The accelerometers report absolute values.  That is, the closer you tilt the wiimote upwards to vertical, the more positive the numbers become.  The thresholds we set were determined from just playing around with the wiimote.  When the wiimote passes one of these thresholds, the character &amp;quot;S&amp;quot; is sent to the PIC.  When the wiimote is brought back to roughly a horizontal position, the computer sends the character &amp;quot;T&amp;quot; to the PIC.  These values will all make sense when the PIC code is discussed.  Note that there are two different pitch values.  There is an absolute pitch value and a corrected pitch value.  The corrected pitch value can be changed by altering the sensitivity in the wiiuse.h file.  We did not bother to do this, as the sensitivity was fine.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17733</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17733"/>
		<updated>2010-03-18T09:48:14Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Computer Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
Each portion of this will now be discussed in detail.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s great that the computer can monitor the accelerometer, but we need to set thresholds so that the stummer knows when to activate.  The if loops below do just that.&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
WIUSE_USING_ACC(wm) will return 0 if the accelerometer is disabled or 1 if the accelerometer is enabled.  Assuming the accelerometer is enabled, the code will monitor the accelerometer and not do anything until the wiimote is tilted above 50 degress or below -100 degrees.  The accelerometers report absolute values.  That is, the closer you tilt the wiimote upwards to vertical, the more positive the numbers become.  The thresholds we set were determined from just playing around with the wiimote.  When the wiimote passes one of these thresholds, the character &amp;quot;S&amp;quot; is sent to the PIC.  When the wiimote is brought back to roughly a horizontal position, the computer sends the character &amp;quot;T&amp;quot; to the PIC.  These values will all make sense when the PIC code is discussed.  Note that there are two different pitch values.  There is an absolute pitch value and a corrected pitch value.  The corrected pitch value can be changed by altering the sensitivity in the wiiuse.h file.  We did not bother to do this, as the sensitivity was fine.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17732</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17732"/>
		<updated>2010-03-18T09:38:35Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
Each portion of this will now be discussed in detail.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 // If the accelerometer is active, print the appropriate angles.  We only used pitch in our code, but if you want to use the other&lt;br /&gt;
 // orientations, uncomment them.  &lt;br /&gt;
 	if (WIIUSE_USING_ACC(wm)){&lt;br /&gt;
 		//printf(&amp;quot;wiimote roll  = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.roll, wm-&amp;gt;orient.a_roll);&lt;br /&gt;
 		printf(&amp;quot;wiimote pitch = %f [%f]\n&amp;quot;, wm-&amp;gt;orient.pitch, wm-&amp;gt;orient.a_pitch);&lt;br /&gt;
 		//printf(&amp;quot;wiimote yaw   = %f \n&amp;quot;, wm-&amp;gt;orient.yaw);&lt;br /&gt;
 		&lt;br /&gt;
 		// If the Wiimote is tilted beyond 50 degrees or -100 degrees, then send data to the PIC, indicating that we want the motor to spin&lt;br /&gt;
 		if((wm-&amp;gt;orient.pitch &amp;gt; 50) | (wm-&amp;gt;orient.pitch &amp;lt;-100)){&lt;br /&gt;
             motor_signal = &#039;S&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends the data&lt;br /&gt;
             printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Once Wiimote has been brought back to horizontal, the system has been &amp;quot;reset&amp;quot; and the user can restrum the guitar&lt;br /&gt;
 		else if((wm-&amp;gt;orient.pitch &amp;gt; -25) &amp;amp; (wm-&amp;gt;orient.pitch &amp;lt; 25)){&lt;br /&gt;
 			motor_signal = &#039;T&#039;;&lt;br /&gt;
 			WriteFile(serial_port, &amp;amp;motor_signal, sizeof(char), &amp;amp;bytes_written, NULL); // Sends a &amp;quot;reset&amp;quot; message&lt;br /&gt;
 			printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, motor_signal);&lt;br /&gt;
 				// Prints a message to indicate successful data transmission&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17731</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17731"/>
		<updated>2010-03-18T09:37:05Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Computer Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
Each portion of this will now be discussed in detail.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|wiimote pitch orientation|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17730</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17730"/>
		<updated>2010-03-18T09:36:24Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Computer Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
Each portion of this will now be discussed in detail.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|200px|center]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_wiimote_pitch.png&amp;diff=17729</id>
		<title>File:Wiitar wiimote pitch.png</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_wiimote_pitch.png&amp;diff=17729"/>
		<updated>2010-03-18T09:35:44Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17728</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17728"/>
		<updated>2010-03-18T09:35:06Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Computer Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
Each portion of this will now be discussed in detail.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the code does not monitor accelerometer values.  This is simply to conserve battery life.  If we want to monitor the accelerometers in the wiimote, all we need to do is press the TWO button.  &lt;br /&gt;
&lt;br /&gt;
 // Accelerometer Info: Pressing two will tell the Wii Mote that we are interested in movement	&lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 0);&lt;br /&gt;
 &lt;br /&gt;
 // Accelerometer Info: Pressing one will tell the Wiimote athat we are no longer interested in movement.  This may&lt;br /&gt;
 // be useful for conserving batterly life.  &lt;br /&gt;
 	if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))&lt;br /&gt;
 		wiiuse_motion_sensing(wm, 1);&lt;br /&gt;
&lt;br /&gt;
IS_JUST_PRESSED is another built in function.  This function changes based on the button that was just pressed.  In this case, we are using the ONE and TWO buttons to toggle the accelerometer.  For our project, we only used pitch.  The image below shows what orientation of the wiimote pitch corresponds to. &lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar wiimote pitch.png|thumb|300px|]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17727</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17727"/>
		<updated>2010-03-18T09:20:55Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Computer Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
Each portion of this will now be discussed in detail.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17726</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17726"/>
		<updated>2010-03-18T09:20:44Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Computer Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
Each portion of this will now be discussed in detail.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  Finally, it prints a message indicating successful data transmission.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
 A similar function is used when users release a button.  &lt;br /&gt;
&lt;br /&gt;
 //If a button is released, print it and send 0 to PIC&lt;br /&gt;
 	if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A Released.\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;N&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_RELEASED is another built in function.  We need these statements so that the PIC knows that the &amp;quot;A&amp;quot; button is not being pressed anymore.  This portion of the code prints a message when a user releases a button and sends the character &amp;quot;N&amp;quot; to the PIC via RS232 and then prints a message indicating successful data transmission.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17725</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17725"/>
		<updated>2010-03-18T09:17:03Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Computer Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
Each portion of this will now be discussed in detail.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
The first part of the computer code deals with buttons being pressed on the wiimote.  Each time a user presses a button, it constitutes as an event.  Unintuitively, when a user releases a button, that also constitutes an event. &lt;br /&gt;
 &lt;br /&gt;
 // If a button is pressed, report it and send appropriate signal to PIC&lt;br /&gt;
  printf(&amp;quot;\n\n--- EVENT [id %i] ---\n&amp;quot;, wm-&amp;gt;unid);&lt;br /&gt;
 	if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)){&lt;br /&gt;
 		printf(&amp;quot;A pressed\n&amp;quot;);&lt;br /&gt;
 		buttonPressed = &#039;A&#039;;&lt;br /&gt;
 		WriteFile(serial_port, &amp;amp;buttonPressed, sizeof(char), &amp;amp;bytes_written, NULL);&lt;br /&gt;
 		printf(&amp;quot;%d bytes (char = %c) successfully transferred to PIC!\n&amp;quot;, (int) bytes_written, buttonPressed);&lt;br /&gt;
&lt;br /&gt;
IS_PRESSED is a built in function in the wiiuse.h file that lets you point directly to the various button.  This part of the code says if a user presses the &amp;quot;A&amp;quot; button, print a message saying so and then send the character &amp;quot;A&amp;quot; to the PIC.  The WriteFile function will be discussed in detail later.  Several of these if statements are in wiiuse.c, specific to every button on the wiimote.  For our code, we only use buttons A, B, 1 and 2.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17724</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17724"/>
		<updated>2010-03-18T09:11:20Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  The transmit code runs on the PIC and the wiiuse code runs on the PC.  The structure of the code is as follows: &lt;br /&gt;
&lt;br /&gt;
*An event occurs on the wiimote.  This can be a change in the accelerometer orientation, a button pressed or a button released&lt;br /&gt;
*The computer recognizes this event and sends a character to the PIC via RS232&lt;br /&gt;
*The PIC receives the signal and either activates digital out puts or spins the motor.&lt;br /&gt;
&lt;br /&gt;
Each portion of this will now be discussed in detail.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Main_transmit.c&amp;diff=17723</id>
		<title>File:Main transmit.c</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Main_transmit.c&amp;diff=17723"/>
		<updated>2010-03-18T09:04:37Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Main_wiiuse.c&amp;diff=17722</id>
		<title>File:Main wiiuse.c</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Main_wiiuse.c&amp;diff=17722"/>
		<updated>2010-03-18T09:03:51Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17721</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17721"/>
		<updated>2010-03-18T09:00:26Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
====Overview====&lt;br /&gt;
The code used for the Wiitar is relatively simple.  The wiimote talks to the computer through [[Media:Main_wiiuse.c|wiiuse.c]].  The computer then talks to the PIC using [[Media:Main_transmit.c|transmit.c]].  &lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=17720</id>
		<title>ME 333 final projects</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=17720"/>
		<updated>2010-03-18T08:57:06Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Remote Controlled Wiitar */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See the &#039;&#039;&#039;[[ME 333 end of course schedule]]&#039;&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Final projects for ME 333 in years 2000-2007 can be found&lt;br /&gt;
&#039;&#039;&#039;[http://lims.mech.northwestern.edu/~design/mechatronics/ here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ME 333 Final Projects 2010 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== [[Sample Project Title]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
&lt;br /&gt;
You can copy and paste this wiki code to start your wiki page (but don&#039;t erase this code).  Then replace this text with your own.  A few sentences describing what your project does, with a link to a youtube video.  Look at other final project wiki pages for ideas, but see [[ME 333 end of course schedule]] for more information on what should be included on your wiki page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Furuta Pendulum]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Picture 1.png|thumb|150px|Furuta Pendulum|right]]&lt;br /&gt;
&lt;br /&gt;
The Furuta pendulum, so named because it was first developed by Katsuhisa Furuta, is a rotational inverted pendulum.  In other words, the horizontal arm, which rotates in the horizontal plane, drives the movement of the vertical arm, which is free to rotate in the vertical plane.  Out objective was to build a Furuta pendulum that would hold the vertical arm up, as you can see from the [http://www.youtube.com/watch?v=7DtFLKgNUk4 demonstration video].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Music from the Heart -- Music Suit]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Music from the heart overview.jpg|thumb|150px|The &amp;quot;music suit&amp;quot; on James, with heart rate detector on his finger.|right]]&lt;br /&gt;
&lt;br /&gt;
This project attempted to create a natural form of musical expression by connecting sensors to the body. Six tilt switches were attached to the wrist, ankles, and shoulders, each controlling a single pitch from the [http://en.wikipedia.org/wiki/Pentatonic_scale pentatonic scale]. The heart beat was obtained using [http://en.wikipedia.org/wiki/Photoplethysmograph photoplethysmography] on the user&#039;s finger, and this signal was used to strike a drum in sync with the heart beat.&lt;br /&gt;
&lt;br /&gt;
For a video demonstration, click [http://www.youtube.com/watch?v=YyipByy7m6I here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Conservation of Angular Momentum Locomotion Robot (Fluffbot)]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Isometric view of Fluffbot guts.jpg|thumb|150px|The Fluffbot without Fluff.|right]]&lt;br /&gt;
&lt;br /&gt;
Cute fluffy robot that uses conservation of angular momentum to move forward and backward. The robot&#039;s momentum wheel accelerates in the floor-plane. The robot&#039;s net angular momentum must remain zero-- a steering wheel guides the Fluffbot to accelerate in the opposite direction. This moves the robot forward in a curved path. The momentum wheel and steering wheel then change direction of acceleration. This repeated process moves the Fluffbot forward in a sinusoidal path.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Differential Drive Mobile Robot]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to create a small differential drive mobile robot that would act as a low cost replacement for the popular E-Puck Robot.  The robot uses hybrid stepper motors to allow it to track its position through odometry, has a laser cut acrylic chassis for easy replication and replacement, and a 1500 mAh, 13.2V battery pack for long run time.  The robot also uses the NU32 board for its control logic and a XBee chip for communication.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Ferrofluid Art Display]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Place holder text for caption .|right]]&lt;br /&gt;
&lt;br /&gt;
A little blurb about our Ferrofluid Art Display will go here. Just a few sentences talking about blah blah lkasjdfal hfalsdjh.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Can Launching Fridge]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of the can launching fridge was to create a fridge that would, when initiated by either a remote control or a wired push button, automatically load, aim, and fire a can to multiple predetermined locations. The fridge uses a combination of stepper motors, a DC motor, and solenoids to create the ultimate mix of convenience, fun, and refreshment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[High Speed Motor Control]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:2dofArmSetUp.jpg|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
The project suggested was to design a system for high speed motor control using the PIC 32. To demonstrate the motor control, a two degree of freedom (2-DOF) parallelogram robot arm was designed to follow paths specified in a MATLAB gui.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Variable Frequency Electrosense]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:TR_JP_PP-sensor.jpg|thumb|150px|Variable Frequency Electrosense|right]]&lt;br /&gt;
&lt;br /&gt;
Our objective was to build upon existing research being done at Northwestern utilizing Electrosense technology by testing if information can be derived from varying the emitter frequency. We sought to send sinusoidal waves at discrete frequencies between 100 Hz and 10 kHz and to read in the sensed wave using a PIC 32’s ADC. We then sent the gathered information to a PC for plotting and analysis. By mounting the sensor on a one dimensional linear actuator we are able to gather additional data about objects and perform object detection and identification algorithms. While our initial results have revealed exciting trends, farther research is necessary before any significant conclusions can be made. A [http://www.youtube.com/watch?v=PJY097L2m1M video] of the project is available on YouTube.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Remote Controlled Wiitar]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Wiitar.jpg|thumb|150px|Guitar Controlled by a wiimote: The Wiitar!|right]]&lt;br /&gt;
This project uses an array of solenoids to depress stings on the neck of a guitar.  A motor over the strings of the guitar turns an arm which strums the instrument, playing the chord depressed by the solenoids.  The system is controlled by a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[6-DOF PPOD]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
The PPOD-mini is a miniaturized version of the Programmable Part-feeding Oscillatory Device ([http://lims.mech.northwestern.edu/projects/frictioninducedforcefields/index.htm PPOD]) found in the Laboratory for Intelligent Mechanical Systems (LIMS).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Butterfly Rolling Manipulation]] ===&lt;br /&gt;
[[Image:Butterflyteampic.jpg|right|upright=1.3|thumb|Butterfly Project at Mechatronics Fair]]&lt;br /&gt;
The Butterfly emulates contact juggling by the stabilization of dynamic rolling.  The apparatus rolls a cylinder by rotating the &amp;quot;hand&amp;quot; using a specific trajectory and is able to move the cylinder from one side to the other without losing contact. A video of the Butterfly captured in high speed can be found [http://www.youtube.com/watch?v=dtYv3qNz_LI here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Haptic Gaming System]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Haptikos.jpg|thumb|150px|Haptic Robot.|right]]&lt;br /&gt;
&lt;br /&gt;
An interactive gaming system  that allows the user to physically feel a virtual world. The player controls the cursor by moving the red joystick. Two games were created to test the feedback system. The first is a side-scroller in which you avoid hitting moving blocks. The second involves feeling out the virtual shape with nothing other than a blue position dot and a blank screen. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ME 333 Final Projects 2009 ==&lt;br /&gt;
&lt;br /&gt;
=== [[Mozart&#039;s Right Hand]] ===&lt;br /&gt;
[[Image:mrh_box.JPG|thumb|150px|Mozart&#039;s Right Hand|right]]&lt;br /&gt;
Mozart&#039;s Right Hand is a musical instrument capable of playing two full octaves of the [http://en.wikipedia.org/wiki/Diatonic_scale Diatonic Scale.]  The user wears a glove on his right hand and uses motions of the hand and fingers to create different notes that are played with a speaker.  The pitch of the note is controlled by the orientation of the user&#039;s hand as he rotates it ether from the wrist, the elbow, or the shoulder.  The LCD on the front of the box tells the user the pitch that corresponds to his or her current hand orientation.  When the user touches together his thumb and index finger, the speaker plays the tone.  A [http://www.youtube.com/watch?v=vec-W4QeHQU video] of Mozart&#039;s Right Hand in action is available on YouTube.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chosen the OUTSTANDING PROJECT by the students of ME 333.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Persistence-of-Vision Display]] ===&lt;br /&gt;
[[Image:Persistence of Vison Display|right|thumb|150px]]&lt;br /&gt;
This is a fully customizable display implemented using the concept of Persistence of Vision. User-specified images (and even moving images) were displayed by rotating a column of LEDs at speeds faster than 300rpm. Each individual LED was modeled as a row of pixels. Conversely, the rotational position of the panel of LEDs represented the pixel columns of the display; the time interval and rotational speed determined the width of the pixel columns. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Rock Paper Scissors Machine]] ===&lt;br /&gt;
[[Image:rps whole thing.JPG|thumb|150px|Rock Paper Scissors Machine|right]]&lt;br /&gt;
A machine that will play a fully functioning, intuitive game of [http://en.wikipedia.org/wiki/Rock-paper-scissors Rock/Paper/Scissors] (abbreviated as RPS) with a user. The machine is represented by a human-like hand, capable of seperate and independant wrist, arm, finger and thumb motion. The players&#039; hand goes into a glove equipped with flex sensors, which wirelessly transmits data to the machine based on what the player chose. The machine then reads this data, randomly chooses a throw of its own, and displays what the machine threw, what the human threw, total win/loss/tie info, and winner/loser both on an [http://en.wikipedia.org/wiki/Lcd LCD] screen and in the form of a thumbs up/down/side motion. Video of the machine in action can be found [http://www.youtube.com/watch?v=xbLNBSTTrcE here.]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Three-speaker Chladni Patterns]] ===&lt;br /&gt;
[[Image:chladni_660hz|right|thumb|150px]]&lt;br /&gt;
This project uses three speakers to generate shapes on a circular aluminum plate depending on which frequency the speakers are playing at. Once the speakers hit a resonant frequency of the plate, salt migrates to the nodes (zero amplitude) regions of the plate to form distinct patterns.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Basketball]] ===&lt;br /&gt;
[[Image:Mechatronics2009Bball|right|thumb|150px]]&lt;br /&gt;
This project consists of a throwing arm propelled by a Pittman motor is mounted on a turntable and throws the ball into the &amp;quot;hoop.&amp;quot; The hoop is wrapped in reflective tape and an IR emitter, receiver pair is used to sense where the IR is reflected most (the hoop with highly reflective tape). An ultrasonic sensor then pings the hoop for the distance of the hoop. With this information, the arm is able to &amp;quot;make a basket.&amp;quot; A video can be found [http://www.youtube.com/watch?v=Y466dzP-qiY here].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Robot Drummer]] ===&lt;br /&gt;
[[Image:Robot_Drummer.jpg|thumb|400pix|right|Robot Drummer]]&lt;br /&gt;
The Robot Drummer is a device that demonstrates high-speed motor control by being able to drum when given commands.  Through an RS232 cable, Matlab sends commands to a &amp;quot;master&amp;quot; PIC.  The master then sends the commands to two &amp;quot;slave&amp;quot; PICs through I2C communication.  The slaves take the commands and implement PID control of the motors.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Automated Fish Refuge]] ===&lt;br /&gt;
[[Image:Entire Fish Refuge|right|thumb|200px]]&lt;br /&gt;
The automated fish refuge allows for the controlled movement of a fish refuge with the goal of recording specific behavior.  The mechanical design is completely adjustable and allows adjustable degrees of oscillating movement and orientation of the refuge.  The program is primarily in MATLAB for ease of use and the velocity profile can be a sine, square, triangle, or any function that the user inputs. [http://www.youtube.com/watch?v=wGOKujMhN88 Check out the video!]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Marionette]] ===&lt;br /&gt;
[[Image: MarionettePicForIntro.JPG|right|thumb]] The Marionette Project focused on using RC Servos to make a puppet that would do a dance with the press of a button.  There were 5 different dances programmed for the marionette, showcasing different styles of movement.  The movement had 2 degrees of freedom thanks to using 5 bar linkages and 2 RC servos for each arm.  Two more RC Servos were used on the back of the marionette to create the appearance of leg movement.  The movements included a Hula dance, Jumping Jacks, and even some moves right out of Saturday Night Fever.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Monkeybot]] ===&lt;br /&gt;
[[Image:monkeybot_pic|thumb|right|200px|Monkeybot]]&lt;br /&gt;
The monkeybot is a swinging robot capable of moving side to side and climbing.  It consists of a two link, double pendulum system with an electro-magnet on each end.  At the pivot is a DC motor, which provides an input torque and allows the swinging system to gain energy and climb.  Check out the video of the monkeybot climbing [http://www.youtube.com/watch?v=TA2VcH_GDJ0 here] and a later brachiation video [http://www.youtube.com/watch?v=0hfwJEVQyeQ&amp;amp;feature=related here].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[PPOD-mini:  6-DOF Shaker]] ===&lt;br /&gt;
[[Image:PPOD_mini.JPG|thumb|200x200 px|right|PPOD-mini 6-DOF Shaker]]&lt;br /&gt;
The PPOD-mini is a miniaturized version of the Programmable Part-feeding Oscillatory Device ([http://lims.mech.northwestern.edu/projects/frictioninducedforcefields/index.htm PPOD]) found in the Laboratory for Intelligent Mechanical Systems (LIMS) at Northwestern. The PPOD-mini utilizes six speakers that act like actuators. The speakers are connected to a acrylic plate via flexures of tygon and iron. In its current implementation, the phase of the speakers can be controlled independently, giving the device six degrees of freedom. The movement of objects placed on the acrylic plate can be controlled by changing the phases of the speakers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Automated Xylophone]] ===&lt;br /&gt;
[[Image:AutomatedXylophonePicture1.jpg|thumb|200x200 px|right|Automated Xylophone]]&lt;br /&gt;
The Automated Xylophone controls several solenoids which hit various pitches on an actual xylophone based on the note selected.  The device has two main modes: using the keypad, a user can choose to either play notes in real time or store songs to be played back later.  A video of the Automated Xylophone playing in real time mode can be found [http://www.youtube.com/watch?v=_ubpAEyq9kg here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Vision-based Cannon]] ===&lt;br /&gt;
[[Image:SM_Gun_Camera_PIC_Setup.JPG|thumb|200x200 px|right|Vision-based Cannon]]&lt;br /&gt;
This project uses a webcam and Matlab to analyze an image and direct a modified USB Missile Launcher to fire at targets found in the image.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ME 333 Final Projects 2008 ==&lt;br /&gt;
&lt;br /&gt;
=== [[IR Tracker]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:IR_Tracker_Main.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
The IR Tracker (aka &amp;quot;Spot&amp;quot;) is a device that follows a moving infrared light. It continuously detects the position of an infrared emitter in two axes, and then tracks the emitter with a laser. [[Media:MT_MS_AZ_TrackerVideo.mp4|See Spot Run.]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chosen the OUTSTANDING PROJECT by the students of ME 333.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Robot Snake]] ===&lt;br /&gt;
[[Image:HLSSnakeMain.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
This remote control robotic snake uses servo motors with a traveling sine wave motion profile to mimic serpentine motion.  The robotic snake is capable of moving forward, left, right and in reverse.   &lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=r_GOOFLnI6w Video of the robot snake]&lt;br /&gt;
&lt;br /&gt;
Featured on [http://blog.makezine.com/archive/2009/03/well_documented_robotic_snake.html Makezine.com].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Programmable Stiffness Joint]] === &lt;br /&gt;
&lt;br /&gt;
[[Image:SteelToePic2.jpg|thumb|200px|The &#039;Steel Toe&#039; programmable stiffness joint|right]]&lt;br /&gt;
&lt;br /&gt;
The Programmable Stiffness Joint varies rotational stiffness as desired by the user.  It is the first step in modeling the mechanical impedance of the human ankle joint (both stiffness and damping) for the purpose of determining the respective breakdown of the two properties over the gait cycle.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== [[Magnetic based sample purification]] ===&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;
=== [[Continuously Variable Transmission]] ===&lt;br /&gt;
&lt;br /&gt;
[[image:CVT_system.JPG|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
This prototype is a proof of concept model of a variable ratio transmission to be implemented in the 2008-2009 Formula SAE competition vehicle.  The gear ratio is determined by the distances between the pulley halves which are controllable electronically.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Granular Flow Rotating Sphere]] ===&lt;br /&gt;
[[Image:Team-21-main-picture.JPG|right|thumb|200px]]&lt;br /&gt;
This device will be used to study the granular flow of particles within a rotating sphere. The sphere is filled with grains of varying size and then rotated about two different axes according to a series of position and angular velocity inputs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Vibratory Clock]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Vibratory_Clock.jpg|right|thumb|Vibratory Clock|200px]]&lt;br /&gt;
&lt;br /&gt;
The Vibratory Clock allows a small object to act as an hour &amp;quot;hand&amp;quot; on a horizontal circular platform that is actuated from underneath by three speakers.  The object slides around the circular platform, impelled by friction forces due to the vibration.  [http://www.youtube.com/watch?v=KhgTNCfdwZw Check it out!]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[WiiMouse]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:HPIM1027.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
The WiiMouse is a handheld remote that can be used to move a cursor on a windows-based PC, via accelerometer input captured through device movement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Intelligent Oscillation Controller]] ===&lt;br /&gt;
&lt;br /&gt;
[[image:ME333_learning_oscillator.jpg|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
This device &amp;quot;learns&amp;quot; a forcing function that is applied to a spring and mass system to match an arbitrary, periodic acceleration profile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Baseball]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Baseball_Playfield.jpg|Sweet Baseball Game|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
An interactive baseball game inspired by pinball, featuring pitching, batting, light up bases and a scoreboard to keep track of the game.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Ball Balancing Challenge]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Ballbalancechallenge.JPG|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
An interactive game involving ball balancing on a touchscreen with touchscreen feedback and joystick action. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=17719</id>
		<title>ME 333 final projects</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=17719"/>
		<updated>2010-03-18T08:56:41Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Remote Controlled Wiitar */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See the &#039;&#039;&#039;[[ME 333 end of course schedule]]&#039;&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Final projects for ME 333 in years 2000-2007 can be found&lt;br /&gt;
&#039;&#039;&#039;[http://lims.mech.northwestern.edu/~design/mechatronics/ here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ME 333 Final Projects 2010 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== [[Sample Project Title]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
&lt;br /&gt;
You can copy and paste this wiki code to start your wiki page (but don&#039;t erase this code).  Then replace this text with your own.  A few sentences describing what your project does, with a link to a youtube video.  Look at other final project wiki pages for ideas, but see [[ME 333 end of course schedule]] for more information on what should be included on your wiki page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Furuta Pendulum]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Picture 1.png|thumb|150px|Furuta Pendulum|right]]&lt;br /&gt;
&lt;br /&gt;
The Furuta pendulum, so named because it was first developed by Katsuhisa Furuta, is a rotational inverted pendulum.  In other words, the horizontal arm, which rotates in the horizontal plane, drives the movement of the vertical arm, which is free to rotate in the vertical plane.  Out objective was to build a Furuta pendulum that would hold the vertical arm up, as you can see from the [http://www.youtube.com/watch?v=7DtFLKgNUk4 demonstration video].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Music from the Heart -- Music Suit]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Music from the heart overview.jpg|thumb|150px|The &amp;quot;music suit&amp;quot; on James, with heart rate detector on his finger.|right]]&lt;br /&gt;
&lt;br /&gt;
This project attempted to create a natural form of musical expression by connecting sensors to the body. Six tilt switches were attached to the wrist, ankles, and shoulders, each controlling a single pitch from the [http://en.wikipedia.org/wiki/Pentatonic_scale pentatonic scale]. The heart beat was obtained using [http://en.wikipedia.org/wiki/Photoplethysmograph photoplethysmography] on the user&#039;s finger, and this signal was used to strike a drum in sync with the heart beat.&lt;br /&gt;
&lt;br /&gt;
For a video demonstration, click [http://www.youtube.com/watch?v=YyipByy7m6I here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Conservation of Angular Momentum Locomotion Robot (Fluffbot)]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Isometric view of Fluffbot guts.jpg|thumb|150px|The Fluffbot without Fluff.|right]]&lt;br /&gt;
&lt;br /&gt;
Cute fluffy robot that uses conservation of angular momentum to move forward and backward. The robot&#039;s momentum wheel accelerates in the floor-plane. The robot&#039;s net angular momentum must remain zero-- a steering wheel guides the Fluffbot to accelerate in the opposite direction. This moves the robot forward in a curved path. The momentum wheel and steering wheel then change direction of acceleration. This repeated process moves the Fluffbot forward in a sinusoidal path.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Differential Drive Mobile Robot]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to create a small differential drive mobile robot that would act as a low cost replacement for the popular E-Puck Robot.  The robot uses hybrid stepper motors to allow it to track its position through odometry, has a laser cut acrylic chassis for easy replication and replacement, and a 1500 mAh, 13.2V battery pack for long run time.  The robot also uses the NU32 board for its control logic and a XBee chip for communication.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Ferrofluid Art Display]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Place holder text for caption .|right]]&lt;br /&gt;
&lt;br /&gt;
A little blurb about our Ferrofluid Art Display will go here. Just a few sentences talking about blah blah lkasjdfal hfalsdjh.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Can Launching Fridge]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of the can launching fridge was to create a fridge that would, when initiated by either a remote control or a wired push button, automatically load, aim, and fire a can to multiple predetermined locations. The fridge uses a combination of stepper motors, a DC motor, and solenoids to create the ultimate mix of convenience, fun, and refreshment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[High Speed Motor Control]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:2dofArmSetUp.jpg|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
The project suggested was to design a system for high speed motor control using the PIC 32. To demonstrate the motor control, a two degree of freedom (2-DOF) parallelogram robot arm was designed to follow paths specified in a MATLAB gui.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Variable Frequency Electrosense]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:TR_JP_PP-sensor.jpg|thumb|150px|Variable Frequency Electrosense|right]]&lt;br /&gt;
&lt;br /&gt;
Our objective was to build upon existing research being done at Northwestern utilizing Electrosense technology by testing if information can be derived from varying the emitter frequency. We sought to send sinusoidal waves at discrete frequencies between 100 Hz and 10 kHz and to read in the sensed wave using a PIC 32’s ADC. We then sent the gathered information to a PC for plotting and analysis. By mounting the sensor on a one dimensional linear actuator we are able to gather additional data about objects and perform object detection and identification algorithms. While our initial results have revealed exciting trends, farther research is necessary before any significant conclusions can be made. A [http://www.youtube.com/watch?v=PJY097L2m1M video] of the project is available on YouTube.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Remote Controlled Wiitar]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Wiitar.jpg|thumb|150px|Guitar Controlled by a wiimote: The Wiitarn.|right]]&lt;br /&gt;
This project uses an array of solenoids to depress stings on the neck of a guitar.  A motor over the strings of the guitar turns an arm which strums the instrument, playing the chord depressed by the solenoids.  The system is controlled by a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[6-DOF PPOD]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
The PPOD-mini is a miniaturized version of the Programmable Part-feeding Oscillatory Device ([http://lims.mech.northwestern.edu/projects/frictioninducedforcefields/index.htm PPOD]) found in the Laboratory for Intelligent Mechanical Systems (LIMS).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Butterfly Rolling Manipulation]] ===&lt;br /&gt;
[[Image:Butterflyteampic.jpg|right|upright=1.3|thumb|Butterfly Project at Mechatronics Fair]]&lt;br /&gt;
The Butterfly emulates contact juggling by the stabilization of dynamic rolling.  The apparatus rolls a cylinder by rotating the &amp;quot;hand&amp;quot; using a specific trajectory and is able to move the cylinder from one side to the other without losing contact. A video of the Butterfly captured in high speed can be found [http://www.youtube.com/watch?v=dtYv3qNz_LI here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Haptic Gaming System]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Haptikos.jpg|thumb|150px|Haptic Robot.|right]]&lt;br /&gt;
&lt;br /&gt;
An interactive gaming system  that allows the user to physically feel a virtual world. The player controls the cursor by moving the red joystick. Two games were created to test the feedback system. The first is a side-scroller in which you avoid hitting moving blocks. The second involves feeling out the virtual shape with nothing other than a blue position dot and a blank screen. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ME 333 Final Projects 2009 ==&lt;br /&gt;
&lt;br /&gt;
=== [[Mozart&#039;s Right Hand]] ===&lt;br /&gt;
[[Image:mrh_box.JPG|thumb|150px|Mozart&#039;s Right Hand|right]]&lt;br /&gt;
Mozart&#039;s Right Hand is a musical instrument capable of playing two full octaves of the [http://en.wikipedia.org/wiki/Diatonic_scale Diatonic Scale.]  The user wears a glove on his right hand and uses motions of the hand and fingers to create different notes that are played with a speaker.  The pitch of the note is controlled by the orientation of the user&#039;s hand as he rotates it ether from the wrist, the elbow, or the shoulder.  The LCD on the front of the box tells the user the pitch that corresponds to his or her current hand orientation.  When the user touches together his thumb and index finger, the speaker plays the tone.  A [http://www.youtube.com/watch?v=vec-W4QeHQU video] of Mozart&#039;s Right Hand in action is available on YouTube.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chosen the OUTSTANDING PROJECT by the students of ME 333.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Persistence-of-Vision Display]] ===&lt;br /&gt;
[[Image:Persistence of Vison Display|right|thumb|150px]]&lt;br /&gt;
This is a fully customizable display implemented using the concept of Persistence of Vision. User-specified images (and even moving images) were displayed by rotating a column of LEDs at speeds faster than 300rpm. Each individual LED was modeled as a row of pixels. Conversely, the rotational position of the panel of LEDs represented the pixel columns of the display; the time interval and rotational speed determined the width of the pixel columns. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Rock Paper Scissors Machine]] ===&lt;br /&gt;
[[Image:rps whole thing.JPG|thumb|150px|Rock Paper Scissors Machine|right]]&lt;br /&gt;
A machine that will play a fully functioning, intuitive game of [http://en.wikipedia.org/wiki/Rock-paper-scissors Rock/Paper/Scissors] (abbreviated as RPS) with a user. The machine is represented by a human-like hand, capable of seperate and independant wrist, arm, finger and thumb motion. The players&#039; hand goes into a glove equipped with flex sensors, which wirelessly transmits data to the machine based on what the player chose. The machine then reads this data, randomly chooses a throw of its own, and displays what the machine threw, what the human threw, total win/loss/tie info, and winner/loser both on an [http://en.wikipedia.org/wiki/Lcd LCD] screen and in the form of a thumbs up/down/side motion. Video of the machine in action can be found [http://www.youtube.com/watch?v=xbLNBSTTrcE here.]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Three-speaker Chladni Patterns]] ===&lt;br /&gt;
[[Image:chladni_660hz|right|thumb|150px]]&lt;br /&gt;
This project uses three speakers to generate shapes on a circular aluminum plate depending on which frequency the speakers are playing at. Once the speakers hit a resonant frequency of the plate, salt migrates to the nodes (zero amplitude) regions of the plate to form distinct patterns.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Basketball]] ===&lt;br /&gt;
[[Image:Mechatronics2009Bball|right|thumb|150px]]&lt;br /&gt;
This project consists of a throwing arm propelled by a Pittman motor is mounted on a turntable and throws the ball into the &amp;quot;hoop.&amp;quot; The hoop is wrapped in reflective tape and an IR emitter, receiver pair is used to sense where the IR is reflected most (the hoop with highly reflective tape). An ultrasonic sensor then pings the hoop for the distance of the hoop. With this information, the arm is able to &amp;quot;make a basket.&amp;quot; A video can be found [http://www.youtube.com/watch?v=Y466dzP-qiY here].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Robot Drummer]] ===&lt;br /&gt;
[[Image:Robot_Drummer.jpg|thumb|400pix|right|Robot Drummer]]&lt;br /&gt;
The Robot Drummer is a device that demonstrates high-speed motor control by being able to drum when given commands.  Through an RS232 cable, Matlab sends commands to a &amp;quot;master&amp;quot; PIC.  The master then sends the commands to two &amp;quot;slave&amp;quot; PICs through I2C communication.  The slaves take the commands and implement PID control of the motors.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Automated Fish Refuge]] ===&lt;br /&gt;
[[Image:Entire Fish Refuge|right|thumb|200px]]&lt;br /&gt;
The automated fish refuge allows for the controlled movement of a fish refuge with the goal of recording specific behavior.  The mechanical design is completely adjustable and allows adjustable degrees of oscillating movement and orientation of the refuge.  The program is primarily in MATLAB for ease of use and the velocity profile can be a sine, square, triangle, or any function that the user inputs. [http://www.youtube.com/watch?v=wGOKujMhN88 Check out the video!]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Marionette]] ===&lt;br /&gt;
[[Image: MarionettePicForIntro.JPG|right|thumb]] The Marionette Project focused on using RC Servos to make a puppet that would do a dance with the press of a button.  There were 5 different dances programmed for the marionette, showcasing different styles of movement.  The movement had 2 degrees of freedom thanks to using 5 bar linkages and 2 RC servos for each arm.  Two more RC Servos were used on the back of the marionette to create the appearance of leg movement.  The movements included a Hula dance, Jumping Jacks, and even some moves right out of Saturday Night Fever.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Monkeybot]] ===&lt;br /&gt;
[[Image:monkeybot_pic|thumb|right|200px|Monkeybot]]&lt;br /&gt;
The monkeybot is a swinging robot capable of moving side to side and climbing.  It consists of a two link, double pendulum system with an electro-magnet on each end.  At the pivot is a DC motor, which provides an input torque and allows the swinging system to gain energy and climb.  Check out the video of the monkeybot climbing [http://www.youtube.com/watch?v=TA2VcH_GDJ0 here] and a later brachiation video [http://www.youtube.com/watch?v=0hfwJEVQyeQ&amp;amp;feature=related here].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[PPOD-mini:  6-DOF Shaker]] ===&lt;br /&gt;
[[Image:PPOD_mini.JPG|thumb|200x200 px|right|PPOD-mini 6-DOF Shaker]]&lt;br /&gt;
The PPOD-mini is a miniaturized version of the Programmable Part-feeding Oscillatory Device ([http://lims.mech.northwestern.edu/projects/frictioninducedforcefields/index.htm PPOD]) found in the Laboratory for Intelligent Mechanical Systems (LIMS) at Northwestern. The PPOD-mini utilizes six speakers that act like actuators. The speakers are connected to a acrylic plate via flexures of tygon and iron. In its current implementation, the phase of the speakers can be controlled independently, giving the device six degrees of freedom. The movement of objects placed on the acrylic plate can be controlled by changing the phases of the speakers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Automated Xylophone]] ===&lt;br /&gt;
[[Image:AutomatedXylophonePicture1.jpg|thumb|200x200 px|right|Automated Xylophone]]&lt;br /&gt;
The Automated Xylophone controls several solenoids which hit various pitches on an actual xylophone based on the note selected.  The device has two main modes: using the keypad, a user can choose to either play notes in real time or store songs to be played back later.  A video of the Automated Xylophone playing in real time mode can be found [http://www.youtube.com/watch?v=_ubpAEyq9kg here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Vision-based Cannon]] ===&lt;br /&gt;
[[Image:SM_Gun_Camera_PIC_Setup.JPG|thumb|200x200 px|right|Vision-based Cannon]]&lt;br /&gt;
This project uses a webcam and Matlab to analyze an image and direct a modified USB Missile Launcher to fire at targets found in the image.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ME 333 Final Projects 2008 ==&lt;br /&gt;
&lt;br /&gt;
=== [[IR Tracker]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:IR_Tracker_Main.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
The IR Tracker (aka &amp;quot;Spot&amp;quot;) is a device that follows a moving infrared light. It continuously detects the position of an infrared emitter in two axes, and then tracks the emitter with a laser. [[Media:MT_MS_AZ_TrackerVideo.mp4|See Spot Run.]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chosen the OUTSTANDING PROJECT by the students of ME 333.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Robot Snake]] ===&lt;br /&gt;
[[Image:HLSSnakeMain.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
This remote control robotic snake uses servo motors with a traveling sine wave motion profile to mimic serpentine motion.  The robotic snake is capable of moving forward, left, right and in reverse.   &lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=r_GOOFLnI6w Video of the robot snake]&lt;br /&gt;
&lt;br /&gt;
Featured on [http://blog.makezine.com/archive/2009/03/well_documented_robotic_snake.html Makezine.com].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Programmable Stiffness Joint]] === &lt;br /&gt;
&lt;br /&gt;
[[Image:SteelToePic2.jpg|thumb|200px|The &#039;Steel Toe&#039; programmable stiffness joint|right]]&lt;br /&gt;
&lt;br /&gt;
The Programmable Stiffness Joint varies rotational stiffness as desired by the user.  It is the first step in modeling the mechanical impedance of the human ankle joint (both stiffness and damping) for the purpose of determining the respective breakdown of the two properties over the gait cycle.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== [[Magnetic based sample purification]] ===&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;
=== [[Continuously Variable Transmission]] ===&lt;br /&gt;
&lt;br /&gt;
[[image:CVT_system.JPG|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
This prototype is a proof of concept model of a variable ratio transmission to be implemented in the 2008-2009 Formula SAE competition vehicle.  The gear ratio is determined by the distances between the pulley halves which are controllable electronically.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Granular Flow Rotating Sphere]] ===&lt;br /&gt;
[[Image:Team-21-main-picture.JPG|right|thumb|200px]]&lt;br /&gt;
This device will be used to study the granular flow of particles within a rotating sphere. The sphere is filled with grains of varying size and then rotated about two different axes according to a series of position and angular velocity inputs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Vibratory Clock]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Vibratory_Clock.jpg|right|thumb|Vibratory Clock|200px]]&lt;br /&gt;
&lt;br /&gt;
The Vibratory Clock allows a small object to act as an hour &amp;quot;hand&amp;quot; on a horizontal circular platform that is actuated from underneath by three speakers.  The object slides around the circular platform, impelled by friction forces due to the vibration.  [http://www.youtube.com/watch?v=KhgTNCfdwZw Check it out!]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[WiiMouse]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:HPIM1027.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
The WiiMouse is a handheld remote that can be used to move a cursor on a windows-based PC, via accelerometer input captured through device movement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Intelligent Oscillation Controller]] ===&lt;br /&gt;
&lt;br /&gt;
[[image:ME333_learning_oscillator.jpg|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
This device &amp;quot;learns&amp;quot; a forcing function that is applied to a spring and mass system to match an arbitrary, periodic acceleration profile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Baseball]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Baseball_Playfield.jpg|Sweet Baseball Game|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
An interactive baseball game inspired by pinball, featuring pitching, batting, light up bases and a scoreboard to keep track of the game.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Ball Balancing Challenge]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Ballbalancechallenge.JPG|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
An interactive game involving ball balancing on a touchscreen with touchscreen feedback and joystick action. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=17718</id>
		<title>ME 333 final projects</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=17718"/>
		<updated>2010-03-18T08:56:00Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Remote Controlled Wiitar */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See the &#039;&#039;&#039;[[ME 333 end of course schedule]]&#039;&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Final projects for ME 333 in years 2000-2007 can be found&lt;br /&gt;
&#039;&#039;&#039;[http://lims.mech.northwestern.edu/~design/mechatronics/ here]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ME 333 Final Projects 2010 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== [[Sample Project Title]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
&lt;br /&gt;
You can copy and paste this wiki code to start your wiki page (but don&#039;t erase this code).  Then replace this text with your own.  A few sentences describing what your project does, with a link to a youtube video.  Look at other final project wiki pages for ideas, but see [[ME 333 end of course schedule]] for more information on what should be included on your wiki page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Furuta Pendulum]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Picture 1.png|thumb|150px|Furuta Pendulum|right]]&lt;br /&gt;
&lt;br /&gt;
The Furuta pendulum, so named because it was first developed by Katsuhisa Furuta, is a rotational inverted pendulum.  In other words, the horizontal arm, which rotates in the horizontal plane, drives the movement of the vertical arm, which is free to rotate in the vertical plane.  Out objective was to build a Furuta pendulum that would hold the vertical arm up, as you can see from the [http://www.youtube.com/watch?v=7DtFLKgNUk4 demonstration video].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Music from the Heart -- Music Suit]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Music from the heart overview.jpg|thumb|150px|The &amp;quot;music suit&amp;quot; on James, with heart rate detector on his finger.|right]]&lt;br /&gt;
&lt;br /&gt;
This project attempted to create a natural form of musical expression by connecting sensors to the body. Six tilt switches were attached to the wrist, ankles, and shoulders, each controlling a single pitch from the [http://en.wikipedia.org/wiki/Pentatonic_scale pentatonic scale]. The heart beat was obtained using [http://en.wikipedia.org/wiki/Photoplethysmograph photoplethysmography] on the user&#039;s finger, and this signal was used to strike a drum in sync with the heart beat.&lt;br /&gt;
&lt;br /&gt;
For a video demonstration, click [http://www.youtube.com/watch?v=YyipByy7m6I here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Conservation of Angular Momentum Locomotion Robot (Fluffbot)]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Isometric view of Fluffbot guts.jpg|thumb|150px|The Fluffbot without Fluff.|right]]&lt;br /&gt;
&lt;br /&gt;
Cute fluffy robot that uses conservation of angular momentum to move forward and backward. The robot&#039;s momentum wheel accelerates in the floor-plane. The robot&#039;s net angular momentum must remain zero-- a steering wheel guides the Fluffbot to accelerate in the opposite direction. This moves the robot forward in a curved path. The momentum wheel and steering wheel then change direction of acceleration. This repeated process moves the Fluffbot forward in a sinusoidal path.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Differential Drive Mobile Robot]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to create a small differential drive mobile robot that would act as a low cost replacement for the popular E-Puck Robot.  The robot uses hybrid stepper motors to allow it to track its position through odometry, has a laser cut acrylic chassis for easy replication and replacement, and a 1500 mAh, 13.2V battery pack for long run time.  The robot also uses the NU32 board for its control logic and a XBee chip for communication.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Ferrofluid Art Display]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Place holder text for caption .|right]]&lt;br /&gt;
&lt;br /&gt;
A little blurb about our Ferrofluid Art Display will go here. Just a few sentences talking about blah blah lkasjdfal hfalsdjh.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Can Launching Fridge]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of the can launching fridge was to create a fridge that would, when initiated by either a remote control or a wired push button, automatically load, aim, and fire a can to multiple predetermined locations. The fridge uses a combination of stepper motors, a DC motor, and solenoids to create the ultimate mix of convenience, fun, and refreshment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[High Speed Motor Control]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:2dofArmSetUp.jpg|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
The project suggested was to design a system for high speed motor control using the PIC 32. To demonstrate the motor control, a two degree of freedom (2-DOF) parallelogram robot arm was designed to follow paths specified in a MATLAB gui.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Variable Frequency Electrosense]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:TR_JP_PP-sensor.jpg|thumb|150px|Variable Frequency Electrosense|right]]&lt;br /&gt;
&lt;br /&gt;
Our objective was to build upon existing research being done at Northwestern utilizing Electrosense technology by testing if information can be derived from varying the emitter frequency. We sought to send sinusoidal waves at discrete frequencies between 100 Hz and 10 kHz and to read in the sensed wave using a PIC 32’s ADC. We then sent the gathered information to a PC for plotting and analysis. By mounting the sensor on a one dimensional linear actuator we are able to gather additional data about objects and perform object detection and identification algorithms. While our initial results have revealed exciting trends, farther research is necessary before any significant conclusions can be made. A [http://www.youtube.com/watch?v=PJY097L2m1M video] of the project is available on YouTube.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Remote Controlled Wiitar]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Wiitar.jpg|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
This project uses an array of solenoids to depress stings on the neck of a guitar.  A motor over the strings of the guitar turns an arm which strums the instrument, playing the chord depressed by the solenoids.  The system is controlled by a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[6-DOF PPOD]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Persistence of Vison Display|thumb|150px|Project photo caption.|right]]&lt;br /&gt;
The PPOD-mini is a miniaturized version of the Programmable Part-feeding Oscillatory Device ([http://lims.mech.northwestern.edu/projects/frictioninducedforcefields/index.htm PPOD]) found in the Laboratory for Intelligent Mechanical Systems (LIMS).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Butterfly Rolling Manipulation]] ===&lt;br /&gt;
[[Image:Butterflyteampic.jpg|right|upright=1.3|thumb|Butterfly Project at Mechatronics Fair]]&lt;br /&gt;
The Butterfly emulates contact juggling by the stabilization of dynamic rolling.  The apparatus rolls a cylinder by rotating the &amp;quot;hand&amp;quot; using a specific trajectory and is able to move the cylinder from one side to the other without losing contact. A video of the Butterfly captured in high speed can be found [http://www.youtube.com/watch?v=dtYv3qNz_LI here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Haptic Gaming System]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Haptikos.jpg|thumb|150px|Haptic Robot.|right]]&lt;br /&gt;
&lt;br /&gt;
An interactive gaming system  that allows the user to physically feel a virtual world. The player controls the cursor by moving the red joystick. Two games were created to test the feedback system. The first is a side-scroller in which you avoid hitting moving blocks. The second involves feeling out the virtual shape with nothing other than a blue position dot and a blank screen. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ME 333 Final Projects 2009 ==&lt;br /&gt;
&lt;br /&gt;
=== [[Mozart&#039;s Right Hand]] ===&lt;br /&gt;
[[Image:mrh_box.JPG|thumb|150px|Mozart&#039;s Right Hand|right]]&lt;br /&gt;
Mozart&#039;s Right Hand is a musical instrument capable of playing two full octaves of the [http://en.wikipedia.org/wiki/Diatonic_scale Diatonic Scale.]  The user wears a glove on his right hand and uses motions of the hand and fingers to create different notes that are played with a speaker.  The pitch of the note is controlled by the orientation of the user&#039;s hand as he rotates it ether from the wrist, the elbow, or the shoulder.  The LCD on the front of the box tells the user the pitch that corresponds to his or her current hand orientation.  When the user touches together his thumb and index finger, the speaker plays the tone.  A [http://www.youtube.com/watch?v=vec-W4QeHQU video] of Mozart&#039;s Right Hand in action is available on YouTube.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chosen the OUTSTANDING PROJECT by the students of ME 333.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Persistence-of-Vision Display]] ===&lt;br /&gt;
[[Image:Persistence of Vison Display|right|thumb|150px]]&lt;br /&gt;
This is a fully customizable display implemented using the concept of Persistence of Vision. User-specified images (and even moving images) were displayed by rotating a column of LEDs at speeds faster than 300rpm. Each individual LED was modeled as a row of pixels. Conversely, the rotational position of the panel of LEDs represented the pixel columns of the display; the time interval and rotational speed determined the width of the pixel columns. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Rock Paper Scissors Machine]] ===&lt;br /&gt;
[[Image:rps whole thing.JPG|thumb|150px|Rock Paper Scissors Machine|right]]&lt;br /&gt;
A machine that will play a fully functioning, intuitive game of [http://en.wikipedia.org/wiki/Rock-paper-scissors Rock/Paper/Scissors] (abbreviated as RPS) with a user. The machine is represented by a human-like hand, capable of seperate and independant wrist, arm, finger and thumb motion. The players&#039; hand goes into a glove equipped with flex sensors, which wirelessly transmits data to the machine based on what the player chose. The machine then reads this data, randomly chooses a throw of its own, and displays what the machine threw, what the human threw, total win/loss/tie info, and winner/loser both on an [http://en.wikipedia.org/wiki/Lcd LCD] screen and in the form of a thumbs up/down/side motion. Video of the machine in action can be found [http://www.youtube.com/watch?v=xbLNBSTTrcE here.]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Three-speaker Chladni Patterns]] ===&lt;br /&gt;
[[Image:chladni_660hz|right|thumb|150px]]&lt;br /&gt;
This project uses three speakers to generate shapes on a circular aluminum plate depending on which frequency the speakers are playing at. Once the speakers hit a resonant frequency of the plate, salt migrates to the nodes (zero amplitude) regions of the plate to form distinct patterns.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Basketball]] ===&lt;br /&gt;
[[Image:Mechatronics2009Bball|right|thumb|150px]]&lt;br /&gt;
This project consists of a throwing arm propelled by a Pittman motor is mounted on a turntable and throws the ball into the &amp;quot;hoop.&amp;quot; The hoop is wrapped in reflective tape and an IR emitter, receiver pair is used to sense where the IR is reflected most (the hoop with highly reflective tape). An ultrasonic sensor then pings the hoop for the distance of the hoop. With this information, the arm is able to &amp;quot;make a basket.&amp;quot; A video can be found [http://www.youtube.com/watch?v=Y466dzP-qiY here].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Robot Drummer]] ===&lt;br /&gt;
[[Image:Robot_Drummer.jpg|thumb|400pix|right|Robot Drummer]]&lt;br /&gt;
The Robot Drummer is a device that demonstrates high-speed motor control by being able to drum when given commands.  Through an RS232 cable, Matlab sends commands to a &amp;quot;master&amp;quot; PIC.  The master then sends the commands to two &amp;quot;slave&amp;quot; PICs through I2C communication.  The slaves take the commands and implement PID control of the motors.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Automated Fish Refuge]] ===&lt;br /&gt;
[[Image:Entire Fish Refuge|right|thumb|200px]]&lt;br /&gt;
The automated fish refuge allows for the controlled movement of a fish refuge with the goal of recording specific behavior.  The mechanical design is completely adjustable and allows adjustable degrees of oscillating movement and orientation of the refuge.  The program is primarily in MATLAB for ease of use and the velocity profile can be a sine, square, triangle, or any function that the user inputs. [http://www.youtube.com/watch?v=wGOKujMhN88 Check out the video!]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Marionette]] ===&lt;br /&gt;
[[Image: MarionettePicForIntro.JPG|right|thumb]] The Marionette Project focused on using RC Servos to make a puppet that would do a dance with the press of a button.  There were 5 different dances programmed for the marionette, showcasing different styles of movement.  The movement had 2 degrees of freedom thanks to using 5 bar linkages and 2 RC servos for each arm.  Two more RC Servos were used on the back of the marionette to create the appearance of leg movement.  The movements included a Hula dance, Jumping Jacks, and even some moves right out of Saturday Night Fever.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Monkeybot]] ===&lt;br /&gt;
[[Image:monkeybot_pic|thumb|right|200px|Monkeybot]]&lt;br /&gt;
The monkeybot is a swinging robot capable of moving side to side and climbing.  It consists of a two link, double pendulum system with an electro-magnet on each end.  At the pivot is a DC motor, which provides an input torque and allows the swinging system to gain energy and climb.  Check out the video of the monkeybot climbing [http://www.youtube.com/watch?v=TA2VcH_GDJ0 here] and a later brachiation video [http://www.youtube.com/watch?v=0hfwJEVQyeQ&amp;amp;feature=related here].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[PPOD-mini:  6-DOF Shaker]] ===&lt;br /&gt;
[[Image:PPOD_mini.JPG|thumb|200x200 px|right|PPOD-mini 6-DOF Shaker]]&lt;br /&gt;
The PPOD-mini is a miniaturized version of the Programmable Part-feeding Oscillatory Device ([http://lims.mech.northwestern.edu/projects/frictioninducedforcefields/index.htm PPOD]) found in the Laboratory for Intelligent Mechanical Systems (LIMS) at Northwestern. The PPOD-mini utilizes six speakers that act like actuators. The speakers are connected to a acrylic plate via flexures of tygon and iron. In its current implementation, the phase of the speakers can be controlled independently, giving the device six degrees of freedom. The movement of objects placed on the acrylic plate can be controlled by changing the phases of the speakers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Automated Xylophone]] ===&lt;br /&gt;
[[Image:AutomatedXylophonePicture1.jpg|thumb|200x200 px|right|Automated Xylophone]]&lt;br /&gt;
The Automated Xylophone controls several solenoids which hit various pitches on an actual xylophone based on the note selected.  The device has two main modes: using the keypad, a user can choose to either play notes in real time or store songs to be played back later.  A video of the Automated Xylophone playing in real time mode can be found [http://www.youtube.com/watch?v=_ubpAEyq9kg here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Vision-based Cannon]] ===&lt;br /&gt;
[[Image:SM_Gun_Camera_PIC_Setup.JPG|thumb|200x200 px|right|Vision-based Cannon]]&lt;br /&gt;
This project uses a webcam and Matlab to analyze an image and direct a modified USB Missile Launcher to fire at targets found in the image.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ME 333 Final Projects 2008 ==&lt;br /&gt;
&lt;br /&gt;
=== [[IR Tracker]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:IR_Tracker_Main.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
The IR Tracker (aka &amp;quot;Spot&amp;quot;) is a device that follows a moving infrared light. It continuously detects the position of an infrared emitter in two axes, and then tracks the emitter with a laser. [[Media:MT_MS_AZ_TrackerVideo.mp4|See Spot Run.]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chosen the OUTSTANDING PROJECT by the students of ME 333.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Robot Snake]] ===&lt;br /&gt;
[[Image:HLSSnakeMain.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
This remote control robotic snake uses servo motors with a traveling sine wave motion profile to mimic serpentine motion.  The robotic snake is capable of moving forward, left, right and in reverse.   &lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=r_GOOFLnI6w Video of the robot snake]&lt;br /&gt;
&lt;br /&gt;
Featured on [http://blog.makezine.com/archive/2009/03/well_documented_robotic_snake.html Makezine.com].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Programmable Stiffness Joint]] === &lt;br /&gt;
&lt;br /&gt;
[[Image:SteelToePic2.jpg|thumb|200px|The &#039;Steel Toe&#039; programmable stiffness joint|right]]&lt;br /&gt;
&lt;br /&gt;
The Programmable Stiffness Joint varies rotational stiffness as desired by the user.  It is the first step in modeling the mechanical impedance of the human ankle joint (both stiffness and damping) for the purpose of determining the respective breakdown of the two properties over the gait cycle.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== [[Magnetic based sample purification]] ===&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;
=== [[Continuously Variable Transmission]] ===&lt;br /&gt;
&lt;br /&gt;
[[image:CVT_system.JPG|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
This prototype is a proof of concept model of a variable ratio transmission to be implemented in the 2008-2009 Formula SAE competition vehicle.  The gear ratio is determined by the distances between the pulley halves which are controllable electronically.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Granular Flow Rotating Sphere]] ===&lt;br /&gt;
[[Image:Team-21-main-picture.JPG|right|thumb|200px]]&lt;br /&gt;
This device will be used to study the granular flow of particles within a rotating sphere. The sphere is filled with grains of varying size and then rotated about two different axes according to a series of position and angular velocity inputs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Vibratory Clock]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Vibratory_Clock.jpg|right|thumb|Vibratory Clock|200px]]&lt;br /&gt;
&lt;br /&gt;
The Vibratory Clock allows a small object to act as an hour &amp;quot;hand&amp;quot; on a horizontal circular platform that is actuated from underneath by three speakers.  The object slides around the circular platform, impelled by friction forces due to the vibration.  [http://www.youtube.com/watch?v=KhgTNCfdwZw Check it out!]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[WiiMouse]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:HPIM1027.jpg|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
The WiiMouse is a handheld remote that can be used to move a cursor on a windows-based PC, via accelerometer input captured through device movement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Intelligent Oscillation Controller]] ===&lt;br /&gt;
&lt;br /&gt;
[[image:ME333_learning_oscillator.jpg|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
This device &amp;quot;learns&amp;quot; a forcing function that is applied to a spring and mass system to match an arbitrary, periodic acceleration profile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Baseball]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Baseball_Playfield.jpg|Sweet Baseball Game|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
An interactive baseball game inspired by pinball, featuring pitching, batting, light up bases and a scoreboard to keep track of the game.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[Ball Balancing Challenge]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Ballbalancechallenge.JPG|right|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
An interactive game involving ball balancing on a touchscreen with touchscreen feedback and joystick action. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17717</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17717"/>
		<updated>2010-03-18T08:49:48Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Notes about Wiiuse */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;build options.  A dialog box will appear and click on the Linker Settings tab.  There is a link libraries window.  Click the add button and direct the program to look where the .dll file is.  When the program asks if you want to add it as a relative path, click No.  The .dll file should be linked to the project.  &lt;br /&gt;
&lt;br /&gt;
====Computer Code====&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17716</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17716"/>
		<updated>2010-03-18T08:36:05Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
&lt;br /&gt;
====Notes about Wiiuse====&lt;br /&gt;
The code used to talk to the Wii was downloaded and heavily modified from www.wiiuse.net.  The download section includes the wiiuse.h, a custom header file that formats all the outputs from the wiimote to easy to use functions.  That all can be downloaded [http://sourceforge.net/projects/wiiuse/files/ here].  Included in the zip file are the header file, and a few .dll files.  It&#039;s these dynamic link library files that prevent wiiuse from operating correctly on any UNIX system.  Code::Blocks makes it easy to link these files to a project.  Once a new project has been created, go to Project--&amp;gt;preferences.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17715</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17715"/>
		<updated>2010-03-18T08:31:13Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
There are two separate codes for the Wiitar.  One code runs on the laptop and is the interface between the wiimote and the PIC.  The IDE we use was Code::Blocks.  It&#039;s open source, multi-platform and very easy to learn.  It can be downloaded [http://www.codeblocks.org/downloads here].  This code connects the wiimote to the laptop.  Remember that the computer code will only work if there is bluetooth present on the laptop.  If the laptop does not have built in bluetooth, a bluetooth dongle may be used instead.&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17714</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17714"/>
		<updated>2010-03-18T08:27:32Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Hall Effect Sensor Circuit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM311D voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.datasheetcatalog.org/datasheet2/c/0hk0a528fi1yzjwj5rxkj21i4wwy.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17713</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17713"/>
		<updated>2010-03-18T08:26:04Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Parts List */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes (1N4003)&lt;br /&gt;
*Hall Effect Sensor (A3240LUA-T)&lt;br /&gt;
*NPN Darlington Pair Transistors (2N 6045)&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM2907-8 voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.national.com/ds/LM/LM2907.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_Strumming_Bridge.jpg&amp;diff=17712</id>
		<title>File:Wiitar Strumming Bridge.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_Strumming_Bridge.jpg&amp;diff=17712"/>
		<updated>2010-03-18T08:24:24Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17711</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17711"/>
		<updated>2010-03-18T08:24:10Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Strumming Bridge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
[[image:Wiitar Strumming Bridge.jpg|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM2907-8 voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.national.com/ds/LM/LM2907.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_Solenoid_Bridge.jpg&amp;diff=17710</id>
		<title>File:Wiitar Solenoid Bridge.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_Solenoid_Bridge.jpg&amp;diff=17710"/>
		<updated>2010-03-18T08:23:07Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17709</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17709"/>
		<updated>2010-03-18T08:22:42Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Solenoid Bridge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
[[image:Wiitar Solenoid Bridge.jpg|thumb|300px|Solenoid Bridge|right]]&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM2907-8 voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.national.com/ds/LM/LM2907.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17708</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17708"/>
		<updated>2010-03-18T08:10:37Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Solenoid Circuit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM2907-8 voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.national.com/ds/LM/LM2907.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17707</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17707"/>
		<updated>2010-03-18T08:09:48Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Hall Effect Sensor Circuit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor Circuit|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM2907-8 voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.national.com/ds/LM/LM2907.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_transistor_circuit.png&amp;diff=17706</id>
		<title>File:Wiitar transistor circuit.png</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_transistor_circuit.png&amp;diff=17706"/>
		<updated>2010-03-18T08:08:00Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17705</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17705"/>
		<updated>2010-03-18T08:07:47Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Solenoid Circuit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM2907-8 voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.national.com/ds/LM/LM2907.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar transistor circuit.png|thumb|300px|Circuit to drive Solenoids|right]]&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.  The output from the PIC was connected to the base of the transistor.  The solenoid was connected between power and the collector.  The emitter was grouned.  There is a 100 Ω resistor between the PIC and the base of the transistor to produce a voltage potential.  We used a 100 Ω resistor because we wanted as much current to go into the base as possible.  By Ohm&#039;s Law, the lower the resistance, the more current we could get into the base.  More current into the base means more current through the solenoid and thus more force by the solenoid. &lt;br /&gt;
&lt;br /&gt;
An important note is the suck up diode in parallel with the solenoid.  Remember, a solenoid is basically like an inductor.  When the voltage is shut off, the inductor still wants to emit current.  To prevent the transistor from being on, even after the PIC was outputting a LOW signal, a 1N4003 diode was placed in parallel with the solenoid.  &lt;br /&gt;
&lt;br /&gt;
Our Wiitar used 6 solenoids and thus this circuit was produced 6 times on our protoboard.       &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17704</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17704"/>
		<updated>2010-03-18T07:56:49Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Solenoid Circuit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM2907-8 voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.national.com/ds/LM/LM2907.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
&lt;br /&gt;
All the solenoids we used on the Wiitar are stocked in the mechatronics lab.  These solenoids are rated at +12 volts.  The power supply in our mechatronics kit could supply that voltage, but the PIC could not output enough current to drive the solenoids with enough force.  To overcome this, we used an NPN Darlington Pair transistor.  The part number is 2N6045 and its data sheet can be downloaded [http://pdf1.alldatasheet.com/datasheet-pdf/view/11497/ONSEMI/2N6045.html here].&lt;br /&gt;
&lt;br /&gt;
The circuit we used can be seen at the right.  Using the transistor to increase the current through the solenoid, we were able to successfully drive the solenoids with the PIC.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17703</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17703"/>
		<updated>2010-03-18T07:51:17Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Hall Effect Sensor Circuit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM2907-8 voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.national.com/ds/LM/LM2907.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17702</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17702"/>
		<updated>2010-03-18T07:51:09Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Hall Effect Sensor Circuit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM2907-8 voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.national.com/ds/LM/LM2907.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on (and thus when the magnet was near the hall sensor) and not the other way around.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17701</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17701"/>
		<updated>2010-03-18T07:50:42Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Hall Effect Sensor Circuit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Hall Effect Sensor|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM2907-8 voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.national.com/ds/LM/LM2907.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on and thus when the magnet was near the hall sensor and not the other way around.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_hall_effect_sensor.png&amp;diff=17700</id>
		<title>File:Wiitar hall effect sensor.png</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Wiitar_hall_effect_sensor.png&amp;diff=17700"/>
		<updated>2010-03-18T07:49:58Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17699</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17699"/>
		<updated>2010-03-18T07:49:36Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Motor Circuit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:wiitar.jpg|thumb|500px|Remote Controlled Wiitar|center]]&lt;br /&gt;
&lt;br /&gt;
==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]][[Image:George Randolph.jpg|thumb|100px|George Randolph|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
====Hall Effect Sensor Circuit====&lt;br /&gt;
We used a hall effect sensor to monitor the position of the strummer.  The concept behind a hall effect sensor is simple: it&#039;s a device that senses a change in magnetic fields.  So, if a magnet is waved across the sensor, it outputs varying voltages.  We put a pill magnet on one end of the strummer bar so when the motor spun, the hall effect sensor could detect the bar&#039;s rotation.  The hall effect sensor basically acted like an ultra-low encoder, but worked for our purposes.  The hall effect sensor was an A2340LUA-T which is stocked in the mechatronics lab.  Its data sheet can be found [http://www.allegromicro.com/en/Products/Part_Numbers/3240/3240.pdf here].&lt;br /&gt;
&lt;br /&gt;
[[image:Wiitar hall effect sensor.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The graphic at the right illustrates the circuit we used to hook up the hall sensor.  There is an LED and 1 KΩ in the hall sensor portion of the circuit.  This is just used as feedback.  When a magnet is in the vicinity of the sensor, the light will turn on.  If that doesn&#039;t happen, then the circuit is wired incorrectly.&lt;br /&gt;
&lt;br /&gt;
The circuit outputs HI when the hall sensor is engaged and LOW when not.  However, a hall effect sensor is an analog device.  We needed it to output either high or low and not voltages in between.  To solve this problem, we used a LM2907-8 voltage comparator.  This chip is basically a really fancy op-amp.  It&#039;s data sheet can be downloaded [http://www.national.com/ds/LM/LM2907.pdf here].  &lt;br /&gt;
&lt;br /&gt;
We used the comparator to compare the voltage coming from the hall sensor against some variable threshold which we set.  The inverting input of the comparator was connected to the output of the hall sensor and the noninverting input was connected to a 10 KΩ potentiometer.  By playing with the resistance of the potentiometer, we were able to set the comparator to the correct sensitivity level.  A pull up resistor was connected to the output so that the comparator had sensible outputs.  That is, we wanted the comparator to output HI when the LED was on and thus when the magnet was near the hall sensor and not the other way around.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Solenoid Circuit====&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17231</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17231"/>
		<updated>2010-03-17T05:29:39Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Strumming Bridge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]]&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[Image:George Randolph.jpg|thumb|100px|George Randolph|right]]&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the PIC, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17230</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17230"/>
		<updated>2010-03-17T05:29:21Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Results and Reflections */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]]&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[Image:George Randolph.jpg|thumb|100px|George Randolph|right]]&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the pic, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the PIC automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one PIC. We noticed that when the PIC was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the PIC board was shorting. When a new PIC was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our PIC using RS232 communication, and have the PIC depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17219</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17219"/>
		<updated>2010-03-17T03:57:05Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Motor Circuit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]]&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[Image:George Randolph.jpg|thumb|100px|George Randolph|right]]&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the pic, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The H-Bridge we used to drive the motor was an L293D.  It&#039;s data sheet can be found [http://focus.ti.com/lit/ds/symlink/l293d.pdf here]&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the pic automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one pic. We noticed that when the pic was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the pic board was shorting. When a new pic was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our pic using RS232 communication, and have the pic depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17218</id>
		<title>Remote Controlled Wiitar</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Remote_Controlled_Wiitar&amp;diff=17218"/>
		<updated>2010-03-17T03:50:16Z</updated>

		<summary type="html">&lt;p&gt;HenryRandolph: /* Motor Circuit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==== Team Members ====&lt;br /&gt;
&lt;br /&gt;
[[Image:Nathan Hirsch.Team15.2010.jpeg|thumb|100px|Nathan Hirsch|right]]&lt;br /&gt;
*Nathan Hirsch - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
[[Image:George Randolph.jpg|thumb|100px|George Randolph|right]]&lt;br /&gt;
*George Randolph - Mechanical Engineering - Class of 2010&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
[[image:Wiitar Overview Graphic.png|thumb|400px|Overview Graphic|right]]&lt;br /&gt;
&lt;br /&gt;
The goal of our project was to create a system that allows a user to use a remote control to play a guitar. The Remote Controlled Wiitar uses a Nintendo Wii Remote to control an array of solenoids and a motor that are capable of playing several different chords on a guitar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consisted of two major components.  The solenoid bridge, which was responsible for depressing strings on the neck of the guitar, and the strumming bridge, which was responsible for strumming the strings of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Solenoid Bridge ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoid bridge was constructed out of wood. Its table shape was designed to allow the neck of the guitar to fit under it, with enough clearance for several solenoids to be attached to the underside of the bridge.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brackets made of eighth inch aluminum sheet metal were fashioned to mount the solenoids on the bridge. The brackets also included holes where elastic cable was attached. The elastic cable retracted the solenoids when they were not powered. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solenoids were originally attached to bridge using nuts and bolts. Though this worked, it was difficult to attach the solenoids precisely enough to accurately depress the guitar strings. In the final design, Velcro was used instead of nuts and bolts. This allowed for more precise mounting of the solenoids on the solenoid bridge and facilitated easy reconfiguration of the solenoids into different chord shapes. A second solenoid bridge was added in the final design to allow additional notes to be fretted near the body of the guitar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Strumming Bridge ====&lt;br /&gt;
&lt;br /&gt;
The strumming bridge was also constructed out of wood. Two 2x4 legs were cut and connected at the top by a strip of plywood. The strumming bridge was designed to allow the body of the guitar to fit underneath, with enough clearance for a strumming arm to sweep across the strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The motor was attached at the center of the top of the strumming bridge using nuts and bolts. A thin plywood strip that served as a strummer was attached to the shaft of the motor using a set screw.  The circular motion of the motor caused the strummer to be closer to the guitar strings in the center than the guitar strings on the outside. For this reason, a rotational spring was attached to one side of the strummer which deflected as it swept across the springs resulting in an even strum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A hall effect sensor was mounted about six inches from the motor on the strumming bridge. A magnet was attached to the strummer that aligned with the hall effect sensor when the strummer was parallel to the ground. When these components were aligned, the hall effect sensor sent signals to the pic, providing feedback on the position of the strummer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Electrical Design ==&lt;br /&gt;
The circuity used to control the Wiitar is relatively simple.  The figure to the right shows the basic concept of our project.  The Wiimote communicates with a laptop via Bluetooth.  Whenever a user shakes the Wiimote or presses a button on the Wiimote, a signal is sent to the computer.  The computer then sends a message to the PIC via RS 232.  The PIC takes those signals and outputs voltages to control the solenoids or strum the guitar, depending on the signal from the Wiimote.&lt;br /&gt;
&lt;br /&gt;
====Parts List====&lt;br /&gt;
Fortunately, not very many electrical components are required to build the necessary circuitry to control the Wiitar.  The parts that are needed can all be found in the mechatronics lab.  &lt;br /&gt;
&lt;br /&gt;
They are:&lt;br /&gt;
*PIC 32 microcontroller&lt;br /&gt;
*100 Ω, 1 KΩ resistors and a 10 KΩ potentiometer&lt;br /&gt;
*0.1 uF capacitor&lt;br /&gt;
*LM311N voltage comparator&lt;br /&gt;
*L293D H-Bridge&lt;br /&gt;
*Diodes&lt;br /&gt;
*Hall Effect Sensor&lt;br /&gt;
*NPN Darlington Pair Transistors&lt;br /&gt;
*LEDs&lt;br /&gt;
*Wiimote&lt;br /&gt;
*Computer with Bluetooth&lt;br /&gt;
&lt;br /&gt;
====Motor Circuit====&lt;br /&gt;
[[image:Wiitar Motor Control Circuit.png|thumb|300px|Circuit Used To Drive Motor|right]]&lt;br /&gt;
The motor that drive the strummer is operated by the PIC.  The circuit to the right gives pin-outs and shows how to connect the motor to the PIC.  Three pins on the PIC are used.  A direction pin, an enable pin and a pin for PWM.  The following table shows how they are related&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
! style=&amp;quot;background:#efefef;&amp;quot; | Direction&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | PWM&lt;br /&gt;
!! style=&amp;quot;background:#efefef;&amp;quot; | Motion&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Brake&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || Forward&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || Reverse&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || Brake&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Results and Reflections ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When we first envisioned the Remote Controlled Wiitar, we wanted to create a system that could play many different chords and songs very easily. We originally wanted an array of eighteen solenoids (one for each string on the first three frets) that would allow us to play dozens of chords and thousands of songs. Our final project had only six solenoids and could play a grand total of three chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite a creating a system that was simpler than intended, our project was very successful. At the beginning of the quarter, we had limited knowledge of electronic circuitry, no knowledge of microcontrollers, and almost no experience programming in C. Using knowledge that we gained throughout the quarter, we were able to design and build a system that was fun for anyone to use and could control a guitar using a Wii Remote.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things that we could have done to improve our project. Perhaps the largest problem we encountered was the fact that the smallest solenoids available to us were too large to fit more than a couple solenoids per fret on the guitar. This was the main reason for the simplification of the solenoid array from eighteen solenoids to only six. To fix this problem, we could have positioned the solenoids away from the neck of the guitar and used a system of levers to push the guitar strings.  This would have allowed us to depress more strings and enabled us to play more chords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another improvement would be made to the strummer. We wanted to be able to strum the strings up and down, but our final system could only strum down (from the lowest string to the highest). This was primarily an issue of feedback. We decided early in our project that we did not need the resolution of an encoder to control the strumming bar, so we opted for a hall effect sensor instead. We quickly realized that there was significant overshoot when using the feedback from the hall effect sensor that prevented us from being able to strum the strings in both directions. Had we used an encoder, we would have had better control over the position of the strummer and we would have been able to strum both up and down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There was also talk of adding a &amp;quot;player piano&amp;quot; mode to our system. This mode would have had the pic automatically play a song using timed strums and chord changes without input from a Wii Remote. Due to a number of other issues we were having with our project, we did not have time to add the player piano mode. This would have been a great addition to the system that could have really demonstrated its capabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over the course of building our Wiitar, we burnt out one pic. We noticed that when the pic was powered on it was getting very hot, even when it was completely disconnected from the rest of our circuit. We could not find the cause of this, but we suspect that something on the pic board was shorting. When a new pic was placed into the circuit, the system returned to functioning properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Despite having little experience in electronic design or programming, most of our issues were a result of mechanical problems. The underlying circuitry and code functioned exactly as originally planned. Coding entirely in C, we were able to receive signals from a Wii Remote on a computer, relay those signals to our pic using RS232 communication, and have the pic depress appropriate guitar strings and strum a guitar. Learning how to do all of this and applying it to our project was our greatest success.&lt;/div&gt;</summary>
		<author><name>HenryRandolph</name></author>
	</entry>
</feed>