<?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=DerekSiegal</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=DerekSiegal"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php/Special:Contributions/DerekSiegal"/>
	<updated>2026-04-26T18:38:47Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.9</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=18200</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=18200"/>
		<updated>2010-03-19T17:02:53Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Electrical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
The triggering method adopts a similar method that is used in archery. The trigger plate is moved forward until it latches into the launching plate by simply pressing into it. This is done with a fence-like latch that can be found on most backyard fences. The trigger plate then is pulled back by the motor to the desired position. When the fridge has been correctly aimed and cocked, a single solenoid pulls up on a string, opening the latch, and releasing the launch plate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
=== Wiring a desktop power supply ===&lt;br /&gt;
&lt;br /&gt;
The information involving wiring your own power supply can be seen at this website:&lt;br /&gt;
&lt;br /&gt;
http://web2.murraystate.edu/andy.batts/ps/powersupply.htm&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
[[Image:27_Circuit_Diagram.jpg|thumb|600px|The entire circuit diagram.|center]]&lt;br /&gt;
&lt;br /&gt;
If the above picture of the circuit diagram is too blurry, and a closer inspection is required, download the schematic file (in PCB artist) by clicking [[Media:Final_Circuit.zip|HERE]].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;br /&gt;
&lt;br /&gt;
= Video Demonstration=&lt;br /&gt;
&lt;br /&gt;
The following video demonstrates the launching aspect of the fridge. The video shows the trigger plate moving forward, locking into the launching plate, moving backwards to a specified spot, and then lifting up to the desired firing angle.&lt;br /&gt;
&lt;br /&gt;
link: http://www.youtube.com/watch?v=d2ejxXBUAxE&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17913</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17913"/>
		<updated>2010-03-19T02:59:01Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
The triggering method adopts a similar method that is used in archery. The trigger plate is moved forward until it latches into the launching plate by simply pressing into it. This is done with a fence-like latch that can be found on most backyard fences. The trigger plate then is pulled back by the motor to the desired position. When the fridge has been correctly aimed and cocked, a single solenoid pulls up on a string, opening the latch, and releasing the launch plate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
[[Image:27_Circuit_Diagram.jpg|thumb|600px|The entire circuit diagram.|center]]&lt;br /&gt;
&lt;br /&gt;
If the above picture of the circuit diagram is too blurry, and a closer inspection is required, download the schematic file (in PCB artist) by clicking [[Media:Final_Circuit.zip|HERE]].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;br /&gt;
&lt;br /&gt;
= Video Demonstration=&lt;br /&gt;
&lt;br /&gt;
The following video demonstrates the launching aspect of the fridge. The video shows the trigger plate moving forward, locking into the launching plate, moving backwards to a specified spot, and then lifting up to the desired firing angle.&lt;br /&gt;
&lt;br /&gt;
link: http://www.youtube.com/watch?v=d2ejxXBUAxE&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17851</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17851"/>
		<updated>2010-03-19T00:33:32Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Launcher Assembly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
The triggering method adopts a similar method that is used in archery. The trigger plate is moved forward until it latches into the launching plate by simply pressing into it. This is done with a fence-like latch that can be found on most backyard fences. The trigger plate then is pulled back by the motor to the desired position. When the fridge has been correctly aimed and cocked, a single solenoid pulls up on a string, opening the latch, and releasing the launch plate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
[[Image:27_Circuit_Diagram.jpg|thumb|600px|The entire circuit diagram.|center]]&lt;br /&gt;
&lt;br /&gt;
If the above picture of the circuit diagram is too blurry, and a closer inspection is required, download the schematic file (in PCB artist) by clicking [[Media:Final_Circuit.zip|HERE]].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17850</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17850"/>
		<updated>2010-03-19T00:33:21Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Parts List */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
The triggering method adopts a similar method that is used in archery. The trigger plate is moved forward until it latches into the launching plate by simply pressing into it. This is done with a fence-like latch that can be found on most backyard fences. The trigger plate then is pulled back by the motor to the desired position. When the fridge has been correctly aimed and cocked, a single solenoid pulls up on a string, opening the latch, and releasing the launch plate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
[[Image:27_Circuit_Diagram.jpg|thumb|600px|The entire circuit diagram.|center]]&lt;br /&gt;
&lt;br /&gt;
If the above picture of the circuit diagram is too blurry, and a closer inspection is required, download the schematic file (in PCB artist) by clicking [[Media:Final_Circuit.zip|HERE]].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17161</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17161"/>
		<updated>2010-03-17T01:15:27Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Triggering the Launch Plate/Firing the Can */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
The triggering method adopts a similar method that is used in archery. The trigger plate is moved forward until it latches into the launching plate by simply pressing into it. This is done with a fence-like latch that can be found on most backyard fences. The trigger plate then is pulled back by the motor to the desired position. When the fridge has been correctly aimed and cocked, a single solenoid pulls up on a string, opening the latch, and releasing the launch plate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II **INSERT MOTOR SPECIFICS** stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
[[Image:27_Circuit_Diagram.jpg|thumb|600px|The entire circuit diagram.|center]]&lt;br /&gt;
&lt;br /&gt;
If the above picture of the circuit diagram is too blurry, and a closer inspection is required, download the schematic file (in PCB artist) by clicking [[Media:Final_Circuit.zip|HERE]].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17160</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17160"/>
		<updated>2010-03-17T01:15:11Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Triggering the Launch Plate/Firing the Can */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
The triggering method adopts a similar method that is used in archery. The trigger plate is moved forward until it latches into the launching plate by simply pressing into it. This is done with a fence-like latch that can be found on most backyard fences. The trigger plate then is pulled back by the motor to the desired position. When the fridge has been correctly aimed and cocked, a single solenoid pulls up on a string, opening the latch, and releasing the launch plate.&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II **INSERT MOTOR SPECIFICS** stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
[[Image:27_Circuit_Diagram.jpg|thumb|600px|The entire circuit diagram.|center]]&lt;br /&gt;
&lt;br /&gt;
If the above picture of the circuit diagram is too blurry, and a closer inspection is required, download the schematic file (in PCB artist) by clicking [[Media:Final_Circuit.zip|HERE]].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17159</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17159"/>
		<updated>2010-03-17T01:14:51Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Triggering the Launch Plate/Firing the Can */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
The triggering method adopts a similar method that is used in archery. The trigger plate is moved forward until it latches into the launching plate by simply pressing into it. This is done with a fence-like latch that can be found on most backyard fences. The trigger plate then is pulled back by the motor to the desired position. When the fridge has been correctly aimed and cocked, a single solenoid pulls up on a string, opening the latch, and releasing the launch plate. &lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II **INSERT MOTOR SPECIFICS** stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
[[Image:27_Circuit_Diagram.jpg|thumb|600px|The entire circuit diagram.|center]]&lt;br /&gt;
&lt;br /&gt;
If the above picture of the circuit diagram is too blurry, and a closer inspection is required, download the schematic file (in PCB artist) by clicking [[Media:Final_Circuit.zip|HERE]].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17158</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17158"/>
		<updated>2010-03-17T01:11:03Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Circuit Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II **INSERT MOTOR SPECIFICS** stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
[[Image:27_Circuit_Diagram.jpg|thumb|600px|The entire circuit diagram.|center]]&lt;br /&gt;
&lt;br /&gt;
If the above picture of the circuit diagram is too blurry, and a closer inspection is required, download the schematic file (in PCB artist) by clicking [[Media:Final_Circuit.zip|HERE]].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:Final_Circuit.zip&amp;diff=17157</id>
		<title>File:Final Circuit.zip</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:Final_Circuit.zip&amp;diff=17157"/>
		<updated>2010-03-17T01:10:22Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17156</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17156"/>
		<updated>2010-03-17T01:09:34Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Circuit Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II **INSERT MOTOR SPECIFICS** stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
[[Image:27_Circuit_Diagram.jpg|thumb|600px|The entire circuit diagram.|center]]&lt;br /&gt;
&lt;br /&gt;
If the above picture of the circuit diagram is too blurry, and a closer inspection is required, download the schematic file (in PCB artist) by clicking [[Media:Final Circuit.sch|HERE]].&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17154</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17154"/>
		<updated>2010-03-17T01:07:31Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Circuit Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II **INSERT MOTOR SPECIFICS** stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
[[Image:27_Circuit_Diagram.jpg|thumb|600px|The entire circuit diagram.|center]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:27_Circuit_Diagram.jpg&amp;diff=17153</id>
		<title>File:27 Circuit Diagram.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:27_Circuit_Diagram.jpg&amp;diff=17153"/>
		<updated>2010-03-17T01:06:53Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:27_CircuitDiagram.pdf&amp;diff=17152</id>
		<title>File:27 CircuitDiagram.pdf</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:27_CircuitDiagram.pdf&amp;diff=17152"/>
		<updated>2010-03-17T01:05:57Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17151</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=17151"/>
		<updated>2010-03-17T01:05:44Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Circuit Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II **INSERT MOTOR SPECIFICS** stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
[[Image:27_CircuitDiagram.pdf|thumb|600px|The entire circuit diagram.|center]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=16826</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=16826"/>
		<updated>2010-03-15T06:59:51Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Can Launching Fridge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See the &amp;#039;&amp;#039;&amp;#039;[[ME 333 end of course schedule]]&amp;#039;&amp;#039;&amp;#039;.  &lt;br /&gt;
&lt;br /&gt;
Final projects for ME 333 in years 2000-2007 can be found&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;[http://lims.mech.northwestern.edu/~design/mechatronics/ here]&amp;#039;&amp;#039;&amp;#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;
=== [[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&amp;#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;
=== [[Conservation of Angular Momentum Locomotion Robot (Fluffbot)]] ===&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&amp;#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;
&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;
== ME 333 Final Projects 2009 ==&lt;br /&gt;
&lt;br /&gt;
=== [[Mozart&amp;#039;s Right Hand]] ===&lt;br /&gt;
[[Image:mrh_box.JPG|thumb|150px|Mozart&amp;#039;s Right Hand|right]]&lt;br /&gt;
Mozart&amp;#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&amp;#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&amp;#039;s Right Hand in action is available on YouTube.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Chosen the OUTSTANDING PROJECT by the students of ME 333.&amp;#039;&amp;#039;&amp;#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&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Chosen the OUTSTANDING PROJECT by the students of ME 333.&amp;#039;&amp;#039;&amp;#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 &amp;#039;Steel Toe&amp;#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>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=ME_333_final_projects&amp;diff=16825</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=16825"/>
		<updated>2010-03-15T06:57:26Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Can Launching Fridge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See the &amp;#039;&amp;#039;&amp;#039;[[ME 333 end of course schedule]]&amp;#039;&amp;#039;&amp;#039;.  &lt;br /&gt;
&lt;br /&gt;
Final projects for ME 333 in years 2000-2007 can be found&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;[http://lims.mech.northwestern.edu/~design/mechatronics/ here]&amp;#039;&amp;#039;&amp;#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;
=== [[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&amp;#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;
=== [[Conservation of Angular Momentum Locomotion Robot (Fluffbot)]] ===&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&amp;#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;
&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. &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;
== ME 333 Final Projects 2009 ==&lt;br /&gt;
&lt;br /&gt;
=== [[Mozart&amp;#039;s Right Hand]] ===&lt;br /&gt;
[[Image:mrh_box.JPG|thumb|150px|Mozart&amp;#039;s Right Hand|right]]&lt;br /&gt;
Mozart&amp;#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&amp;#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&amp;#039;s Right Hand in action is available on YouTube.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Chosen the OUTSTANDING PROJECT by the students of ME 333.&amp;#039;&amp;#039;&amp;#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&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Chosen the OUTSTANDING PROJECT by the students of ME 333.&amp;#039;&amp;#039;&amp;#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 &amp;#039;Steel Toe&amp;#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>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16823</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16823"/>
		<updated>2010-03-15T06:32:20Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Parts List */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II **INSERT MOTOR SPECIFICS** stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
&lt;br /&gt;
2x Limit switches&lt;br /&gt;
&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16822</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16822"/>
		<updated>2010-03-15T06:31:59Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Parts List */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
&lt;br /&gt;
2x Pacific Scientific PowerMax II **INSERT MOTOR SPECIFICS** stepper motors - $30.00 from ebay.com&lt;br /&gt;
&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
2x Limit switches&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95 &lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16821</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16821"/>
		<updated>2010-03-15T06:30:26Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
2 x Polyethylene cutting boards, 1/2” thickness - $11.99 each from Jewel&lt;br /&gt;
2x Low carbon steel rods, 1/4” diameter, 6’ length – part no. 8920K11, $3.26 each from McMaster Carr&lt;br /&gt;
2x Acetal pulley for XL – series timing belt for 1/4&amp;quot; &amp;amp; 3/8” belt width 1.13” OD, 14 teeth – part no. 57105K14, $7.51 each from McMaster Carr&lt;br /&gt;
1x trapezoidal tooth urethane timing belt, .2” pitch, trade SZ 140XL, 14” outer circle, 1/4&amp;quot; width – part no. 1679K124, $2.75 each from McMaster Carr&lt;br /&gt;
2x Zinc plated steel threaded rod, 3/8” -16 thread, 3’ length – part no. 98841A031, $2.83 each from McMaster Carr&lt;br /&gt;
1x Lubricated corrosion resistance galvanized turntable, galvanized 6.06” square – part no. 1544T1, $5.42 from McMaster Carr&lt;br /&gt;
2x Pacific Scientific PowerMax II **INSERT MOTOR SPECIFICS** stepper motors - $30.00 from ebay.com&lt;br /&gt;
1x generic DC motor w/ gearbox and 1/4&amp;quot; output shaft&lt;br /&gt;
1x Haier thermoelectric mini fridge&lt;br /&gt;
30 lb test, low stretch, low memory fishing line, musky-pro series, black&lt;br /&gt;
9x 3/4” OD, 1/4&amp;quot; ID ball bearings&lt;br /&gt;
1.25” OD aluminum bar stock, approx 1’ in length&lt;br /&gt;
4x 4” extension springs&lt;br /&gt;
3” PVC pipe, approx. 16” in length&lt;br /&gt;
Various wood:  3/4&amp;quot; and 1/4&amp;quot; plywood, 2’ x 4’ wooden beams for the base&lt;br /&gt;
3” OD, 1/4&amp;quot; ID rubber wheel&lt;br /&gt;
3x pull type solenoids&lt;br /&gt;
&lt;br /&gt;
= Electrical Design =&lt;br /&gt;
&lt;br /&gt;
The control system for our project was centered around a PIC32MX microcontroller in a NU32 breakout board designed and proved by Northwestern University. In total, the electrical system included six actuators and four sensors: two stepper motors, one DC motor, three solenoids, two limit switches, and two potentiometers.&lt;br /&gt;
&lt;br /&gt;
As described previously, stepper motors were used for the cocking mechanism and elevation winch so as to easily provide stationary holding torque necessary for both of these applications. These were each driven by two L293D dual H-bridges, with one chip driving each motor phase. This was done because we were unable to get reliable operation out of the larger available H-bridges, but a single L293D chip could not provide the amount of continuous current required by the motors. As shown in the circuit diagram, channels one and four as well as two and three were tied together to recreate one more robust H-bridge per chip. Similarly, the enable pins for all of the chips were tied together to allow the entire motor to enabled or disabled with one logic line. The DC motor was controlled similarly, though one L293D was sufficient to power its coil. The solenoids were wired with one NPN transistor each. However, it was discovered during testing that the current drawn by these transistors and H-bridges was enough to cause drops in the five volt logic supplied to the PIC, leading to a variety of inconsistencies in executing our control program. To address this problem, opto-isolators were added on all the digital output lines, and a separate logic supply was dedicated to the PIC. &lt;br /&gt;
&lt;br /&gt;
Because this project involved relatively high torques to accomplish the aiming motions described, we were wary of relying purely on open-loop positional control. Therefore, feedback sensors were required for each of the motions performed. First, a limit switch was added to the carriage plate such that it would be closed when the carriage made contact with the launch plate, indicating to the control system that the launch plate had been latched and the loading / cocking sequence could be initiated. Next, two sensors were used for control of the elevation function. As mentioned previously, a potentiometer was coupled to the horizontal pivot axle to give an analog feedback voltage dependent on elevation. However, as this system had a small amount of slip, a limit switch was also placed under the launcher assembly to indicate when the arm was in its lowest resting position. This was done so that the motor could be disabled when it had fully lowered the assembly, and the “home” position voltage could be reset to zero to eliminate error accumulation. Finally, a potentiometer was coupled vertically through the turntable for rotational feedback. This left only one degree of freedom to open-loop control: the linear cocking distance of the launcher. While this system was not ideal, it compensated for the fact that our motors were somewhat underpowered for this application. In the case of significant motor slip, the control system would eventually signal a launch at a lesser power rather than indefinitely attempting to retract the springs against too high a load.&lt;br /&gt;
&lt;br /&gt;
Due to the high current demands of running several motors and solenoids concurrently, a robust power supply was needed to run the electrical system. Even the bench top laboratory power supplies in the mechatronics lab were unable to fully power the largest solenoid in the project. The solution was to use a power supply taken from a laptop computer and modify it for use as a general DC power source. This method was ideal for two reasons: first, these power supplies are capable of sourcing very large currents at both five and twelve volts, and second, they are physically small enough to be attached to the designs, allowing the unit to function off of purely 120 volt AC power. For the specific procedure used to modify this power supply, see wiring a desktop power supply.&lt;br /&gt;
&lt;br /&gt;
===Parts List===&lt;br /&gt;
&lt;br /&gt;
3x 2N6045 NPN transistors – $0.81 each from Digi-Key&lt;br /&gt;
5x L293D dual H-Bridges - $3.92 each from Digi-Key&lt;br /&gt;
13x 4N27 opto-isolators - $0.59 each from Digi-Key&lt;br /&gt;
2x 10 kOhm potentiometers, 1/4&amp;quot; shaft&lt;br /&gt;
2x Limit switches&lt;br /&gt;
3x Solder-less bread boards&lt;br /&gt;
1x PIC32MX460F512L based NU32 microcontroller board&lt;br /&gt;
1x Desktop power supply  and related components – see page linked above for specifics&lt;br /&gt;
Simerec SIS-2 IR receiver (not implemented in prototype) - $9.95 &lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Results and Reflection =&lt;br /&gt;
&lt;br /&gt;
At the time of project demonstrations, we have succeeded in several of the goals of the project. Most significantly, each of the mechanical tasks inherent in our design worked in individual systems testing, and several of them had been combined into a logical sequence. Specifically, we were able to retract the launch plate, load a can, elevate the launcher assembly, and occasionally release the trigger. While those actions comprise the most precise and complicated tasks of the launch sequence, there are obviously several remaining functions that need to be added before the project can be successful as a whole. Namely, more reliable function is needed from the rotational aiming and trigger release mechanisms. Nevertheless, we’re confident that minor changes to the design will allow for complete functionality.&lt;br /&gt;
&lt;br /&gt;
There are several obvious next steps that will greatly improve on the current design. First and foremost, a more powerful stepper motor on the cocking mechanism would allow for both faster carriage speeds and more powerful springs. While we believe our current motor is sufficient for short launches, it doesn’t deliver sufficient power for reliable operation. This fault in the design was due to inconsistencies in the listed torque output given by the manufacturer. While the data sheet referenced a 24 V supply voltage, the motor itself is labeled with the test torque at 65 V. Seeing as our power supply is only able to supply significant power at 12 V, we are obviously getting far less torque than was expected when the motor was purchased for the project. Also regarding possible improvements to launch power, we experienced increasingly severe problems with the launch plate binding on the guide rods during trials. Seeing as this action was quite smooth when first assembled, we attribute this binding to degradation of the polyethylene plate by repeated sliding across the steel interface. We believe polishing the steel rods and adding sleeve bushings of a more durable and lubricated material would greatly improve the launch plate motion. The final change needed to the launcher assembly is the mounting system for the release solenoid. Currently, the solenoid is mounted vertically, such that it pulls a string through a hole on the carriage plate to rotate the sear and release the launch plate. While this system is adequate for opening the trigger under light loads, it introduces too much extra play and friction to be realistic for reliable release under higher force. However, we believe that by rotating solenoid 90o so that it pulls directly backwards it will be able to exert enough force to consistently release. The rotation system is the only other component of the design in need of fundamental mechanical changes. Namely, though our motor is capable of turning the whole refrigerator assembly over certain ranges, it struggles to at other times. This problem arises from the fact that the turntable bearing has significant play, allowing the whole refrigerator to rock or lean as it rotates. This presents two major difficulties: first, the friction wheel can momentarily lose contact with the lower plate, and second, there is a large increase is resistance experienced by the motor if the refrigerator leans in its direction. The latter, which causes the motor to become stuck until manually freed, is due to the fact that the friction wheel axle is currently suspended on one side in a 1/4&amp;quot; hole, and on the other in a hole cut to the diameter of the motor coupler. When significant normal force is exerted on the wheel, these interfaces bind, preventing the wheel from rotating. A simple fix is to add a third plate to the wheel housing inside of the motor coupler, and then to suspend the axle between two bearings, such that the motor coupler no longer makes direct contact with the wood motor mounting plate.&lt;br /&gt;
&lt;br /&gt;
In addition to these mechanical changes, a few minor electrical and procedural changes stand between our current prototype and a fully functioning product. First, we experienced several glitches associated with the elevation zeroing limit switch. This was due to mechanical failure of the switch, which when sticking would cause the PIC to override the potentiometer feedback and disengage the winch motor while the assembly was still elevated. To counter this, the switch needs to either be replaced by an actual lever switch in a different location, or the program changed to function purely off of potentiometer voltage as we had previously done. Next, we need to experiment with the timing of the loading solenoids to prevent cans from catching in the first stage before fully rolling into the waiting chamber. Finally, our initial plan was to have the launch sequence initiated by an IR remote control. However, following an error in processing, Sparkfun delivered the necessary parts two weeks after they were ordered. Fortunately, we built our current prototype in such a way that these components can quickly be integrated into the project. Specifically, and IR receiver will be wired to the Simerec SIS-2 programmable IR decoder, which “learns” the pulse train of two distinct remote commands, and then sets a corresponding pin high when they are recognized at a later time. By integrating this module into the place currently held by two push buttons, no significant changes need to be made to obtain a working wireless command system.&lt;br /&gt;
&lt;br /&gt;
If we were to do this project again, the major changes would be the ones already mentioned as next steps. As a team, we are confident that our design is sound and is capable of accomplishing the goals we had in mind when we began it. Our main complications and setbacks arouse from the fact that within already demanding time constraints and with a significant amount of mechanical tasks to accomplish before we could begin electrical testing, the smallest glitches became significant roadblocks to our progress. For example, the logic voltage noise that caused massive errors when trying to debug our program turned out to be a relatively straight forward problem to address. However, by the time we got far enough in testing our design to notice its effect – all systems had previously been observed to work indecently at this point – it was too late to find the answer to the problem by ourselves. In general, our group wasn’t held back by a lack of effort or time commitment, but frequently by recurrent setbacks that we weren’t expecting or prepared to handle. Though we were ultimately unable to get all the functions working by the demonstration deadline, we’re confident that we will finish the project soon on our own time, and could complete it within the deadline if we had to do it again knowing what we know now.&lt;br /&gt;
&lt;br /&gt;
Finally, we did in fact have some troubles with the PIC32 used for the project, burning out two of our three during testing. However, both of these were due to attaching inappropriate power to the board rather than any fault of the board’s design. The first occurred when a faulty power supply was connected to the board – it had been covered by another power supply so we didn’t see the warning written on the top. Similarly, the second was damaged when a miscommunication caused one the logic supply leads to be connected to the twelve volt motor supply instead. The only other problem we ran into was the board’s sensitivity to any noise on the logic supply voltage, though that may be common to all microcontrollers. Even before the noise caused the board to restart, it was causing unexpected errors in ADC function. With that in mind however, the board was reliable and accessible.&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16781</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16781"/>
		<updated>2010-03-15T02:26:06Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* C Program */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
         | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16780</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16780"/>
		<updated>2010-03-15T02:25:52Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* C Program */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
        | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16779</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16779"/>
		<updated>2010-03-15T02:25:17Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* C Program */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10 &lt;br /&gt;
 | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16778</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16778"/>
		<updated>2010-03-15T02:22:51Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Circuit Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Circuit Design =&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10          | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16777</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16777"/>
		<updated>2010-03-15T02:22:36Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Mechanical Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
= Mechanical Design =&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10          | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16776</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16776"/>
		<updated>2010-03-15T02:22:16Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
= C Program =&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10          | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16775</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16775"/>
		<updated>2010-03-15T02:16:00Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Fridge.jpg|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10          | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:27_Circuit.jpg&amp;diff=16774</id>
		<title>File:27 Circuit.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:27_Circuit.jpg&amp;diff=16774"/>
		<updated>2010-03-15T02:14:04Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16773</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16773"/>
		<updated>2010-03-15T02:13:53Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
[[Image:27_Circuit.jpg|thumb|150px|The actual circuit, made on a solderless breadboard.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10          | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16772</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16772"/>
		<updated>2010-03-15T02:08:56Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* C Program */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
 		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10          | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:27_Fridge_Full_Code.zip&amp;diff=16771</id>
		<title>File:27 Fridge Full Code.zip</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:27_Fridge_Full_Code.zip&amp;diff=16771"/>
		<updated>2010-03-15T02:08:17Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16770</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16770"/>
		<updated>2010-03-15T02:08:06Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* C Program */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
Download the full code [[Media:27_Fridge_Full_Code.zip|HERE]].&lt;br /&gt;
&lt;br /&gt;
The main control code can be found below:&lt;br /&gt;
&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //******************************* BEER LAUNCHING FRIDGE ********************************//&lt;br /&gt;
 //*******************************  ME 333 FINAL PROJECT ********************************//&lt;br /&gt;
 //*******************************    March 19, 2010     ********************************//&lt;br /&gt;
 //*******************************     Derek Siegal      ********************************//&lt;br /&gt;
 //*******************************    Leland Gossett     ********************************//&lt;br /&gt;
 //*******************************     Chris Semple      ********************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //****    This program receives a command (logic high on a CASE PIN) and then       ****//&lt;br /&gt;
 //****    determines which case and the physical location that case corresponds     ****//&lt;br /&gt;
 //****    to and then actuates three motors and three solenoids to do the           ****//&lt;br /&gt;
 //****    following:                                                                ****//&lt;br /&gt;
 //****        1) cock back a launch plate                                           ****//&lt;br /&gt;
 //****        2) rotate the fridge to a predetermined launch angle                  ****//&lt;br /&gt;
 //****        3) load a beer onto the launch pad                                    ****//&lt;br /&gt;
 //****        4) winch up a launch pad to a predetermined angle                     ****//&lt;br /&gt;
 //****        5) fire the beer by releasing the launch plate                        ****// &lt;br /&gt;
 //****        6) return to a home position and wait for another command             ****// &lt;br /&gt;
 //**************************************************************************************//&lt;br /&gt;
 //**************************************************************************************// &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- INCLUDES ------------------------------------------------------- &lt;br /&gt;
 #include &amp;quot;HardwareProfile.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;HardwareProfile_NU32.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;plib.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;string.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;LCD.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;motor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Compiler.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- DEFINED CONSTANTS -------------------------------------------------------&lt;br /&gt;
 #define ANGLE2VALUE (3.3*1024/270/2)&lt;br /&gt;
 #define UP 1&lt;br /&gt;
 #define DOWN (-1)&lt;br /&gt;
 #define LEFT  1&lt;br /&gt;
 #define RIGHT (-1)	&lt;br /&gt;
 #define NONE  0			// NMotor Error&lt;br /&gt;
 #define FORWARD 1&lt;br /&gt;
 #define BACKWARD (-1)&lt;br /&gt;
 #define YES 1&lt;br /&gt;
 #define NO 0&lt;br /&gt;
 #define DC_STOP_POINT  (0 * ANGLE2VALUE)&lt;br /&gt;
 #define UP_SPEED        200  &lt;br /&gt;
 #define DOWN_SPEED      300 &lt;br /&gt;
 #define FORWARD_SPEED   500&lt;br /&gt;
 #define BACKWARD_SPEED_FAST  350&lt;br /&gt;
 #define BACKWARD_SPEED_SLOW  150&lt;br /&gt;
 #define START_SPEED		     25&lt;br /&gt;
 #define HOME 0&lt;br /&gt;
 #define STEPS_TO_INCHES  3200&lt;br /&gt;
 &lt;br /&gt;
 //--------------------- GLOBAL VARIABLES -------------------------------------------------------&lt;br /&gt;
 int motor1_phase;			// Winching Motor&lt;br /&gt;
 int motor2_phase;			// Cocking Motor&lt;br /&gt;
 int Per1; 					// Winching Motor&lt;br /&gt;
 int Per2;					// Cocking Motor  &lt;br /&gt;
 &lt;br /&gt;
 unsigned short int elevations[3];			// vector of possible elevations, like [FLAT 15 35]&lt;br /&gt;
 short int rotations[3];						// vector of possible rotations, like [STRAIGHT 15 -15] &lt;br /&gt;
 unsigned short int powers[3];				// vector of possible launch strengths, like [NONE 4inches 6inches] &lt;br /&gt;
 unsigned short int positions[2];			// [rotation; elevation]&lt;br /&gt;
 signed short int home_position[2];			// initial potentiometer readings at startup for elevation and rotation&lt;br /&gt;
 &lt;br /&gt;
 signed int errors[3];			// sign of the error [rotation; elevation] if the target is up, the error indicates up&lt;br /&gt;
 int error_mag[3];				// magnitude of the error&lt;br /&gt;
 int scenario = -1;				// which location do i want the beer at&lt;br /&gt;
 int step_counter = 0;			// how many steps has the cocking motor taken&lt;br /&gt;
 int quit = 0;					// am i ready to quit?&lt;br /&gt;
 int isLatched = NO;				// YES (1) if the launch plate and cocking carriage are coupled&lt;br /&gt;
 int step_counter2 = 0;			// For 2nd stepper, CURRENTLY NOT USED&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //--------------------- Function Declarations -------------------------------------------------------&lt;br /&gt;
 void fillCases();				// Fill elevations, rotations and powers vectors&lt;br /&gt;
 void homePositionFill();		// Fills home_position&lt;br /&gt;
 void getPositions();			// Get current elevation and rotation, then set error and error_mag&lt;br /&gt;
 void getScenario();				// Program sits in this function until triggered to provide beer&lt;br /&gt;
 void loadBeer();				// Trigger solenoid to allow one beer out onto launcher&lt;br /&gt;
 void fire();					// Trigger firing solenoid&lt;br /&gt;
 void loadChamber();				// Trigger large solenoid to allow one beer into storage chamber&lt;br /&gt;
 void return_home();				// sets elevation to flat, rotation to straight&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //------------------ MAIN FUNCTION -----------------------------------------------------------------&lt;br /&gt;
 int main()&lt;br /&gt;
 {	&lt;br /&gt;
 	// Initialize the PIC&lt;br /&gt;
 	mInitAllLEDs();						// Flash to show startup&lt;br /&gt;
 	homePositionFill();					// Find Home position&lt;br /&gt;
 	fillCases();						// Fill positions and elevations&lt;br /&gt;
 	InitMotor1();						// Initialize Motor 1&lt;br /&gt;
 	InitMotor2();						// Initialize Motor 2&lt;br /&gt;
 	InitDCMotors();						// Intialize DC Motors&lt;br /&gt;
 	InitSolenoids();					// Initialize the solenoids&lt;br /&gt;
 	motor1_phase = 0;					// Start at 0&lt;br /&gt;
 	motor2_phase = 0;					// Start at 0&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	while (1) 			// Infinite Loop&lt;br /&gt;
 	{&lt;br /&gt;
 		scenario = -1;&lt;br /&gt;
 		CASE_1 == 0;&lt;br /&gt;
 		CASE_2 == 0;&lt;br /&gt;
 		&lt;br /&gt;
 		// Determine Case&lt;br /&gt;
 		while (scenario == -1)&lt;br /&gt;
 		{&lt;br /&gt;
 			getScenario();		// CALL EVENT occurs here&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		// Enable Interupts&lt;br /&gt;
 		INTEnableSystemMultiVectoredInt();&lt;br /&gt;
 		mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 		mT2SetIntPriority( 6); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 		mT2ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 		mT2IntEnable( 1);		// enable timer2 interrupts &lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 		// Start Motors&lt;br /&gt;
 		getPositions();  											// Get the current position and errors&lt;br /&gt;
 		Turn(errors[0]);											// start turning the fridge&lt;br /&gt;
 		Per2 = (80000000/START_SPEED)/256-1;						// start the motor at a slow speed to engage lead screw drive&lt;br /&gt;
 		OpenTimer2(T2_ON | T2_PS_1_256 | T2_SOURCE_INT, Per2);		// start cocking motor&lt;br /&gt;
 		Delayms(50);												// delay then:&lt;br /&gt;
 		Per2 = (80000000/FORWARD_SPEED)/256-1;						// calculate new speed&lt;br /&gt;
 		WritePeriod2(Per2);											// speed up the motor&lt;br /&gt;
 &lt;br /&gt;
 		while(errors[2] != NONE)  // while launcher isn&amp;#039;t cocked&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions();						// get current error&lt;br /&gt;
 			if (errors[0] == NONE) 	Brake();	// if it&amp;#039;s in position, stop the motor&lt;br /&gt;
 			if (errors[2] == NONE) 				// same here&lt;br /&gt;
 			{								&lt;br /&gt;
 				CloseTimer2();					// stop the interrupt&lt;br /&gt;
 				motor2_enable = 0;				// this wasn&amp;#039;t working very well, so&lt;br /&gt;
 				StepMotor2(6);					// this line was added&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		loadBeer();			// Load a beer&lt;br /&gt;
 		Delayms(1500);		// Wait to let it settle&lt;br /&gt;
 		&lt;br /&gt;
 		motor1_enable = 1;											// Enable winching motor&lt;br /&gt;
 		Per1 = (80000000/UP_SPEED)/256-1;							// Calculate winching speed&lt;br /&gt;
 		OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);		// Start the motor&lt;br /&gt;
 &lt;br /&gt;
 		while (errors[1] == UP)   // While Winching UP&lt;br /&gt;
 		{&lt;br /&gt;
 			getPositions(); 							// Get current position and error&lt;br /&gt;
 			if (errors[1] == NONE)	CloseTimer3();		// stop stepping when its in position&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 		fire();					// Fire the beer&lt;br /&gt;
 		Delayms(3000);			// Wait a bit&lt;br /&gt;
 &lt;br /&gt;
 		step_counter = 0;		// Reset step counter to 0&lt;br /&gt;
 		return_home();			// Go to home position&lt;br /&gt;
 		loadChamber();			// Load chamber&lt;br /&gt;
 &lt;br /&gt;
 		// Turn off all LEDS&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;
 &lt;br /&gt;
		// Turn on LED 0 to indicate ready to fire again&lt;br /&gt;
 		mLED_0_On();&lt;br /&gt;
 		isLatched = NO;&lt;br /&gt;
 	}  // End of infinte while loop&lt;br /&gt;
 &lt;br /&gt;
 } // end of main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //-------------------------------- INTERRUPTS --------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 // WINCHING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_3_VECTOR, ipl7) T3Interrupt( void) &lt;br /&gt;
 {&lt;br /&gt;
 	motor1_phase += errors[1];&lt;br /&gt;
 	step_counter2 ++; &lt;br /&gt;
 	if (motor1_phase &amp;gt; 3) motor1_phase = 0;&lt;br /&gt;
 	else if (motor1_phase &amp;lt; 0) motor1_phase = 3;&lt;br /&gt;
 	StepMotor1(motor1_phase);&lt;br /&gt;
 	mT3ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // COCKING MOTOR&lt;br /&gt;
 void __ISR( _TIMER_2_VECTOR, ipl6) T2Interrupt( void)&lt;br /&gt;
  {&lt;br /&gt;
 	if (isLatched == YES) step_counter ++;&lt;br /&gt;
 	motor2_phase += errors[2];&lt;br /&gt;
 	if (motor2_phase &amp;gt; 3) motor2_phase = 0;&lt;br /&gt;
 	else if (motor2_phase &amp;lt; 0) motor2_phase = 3;&lt;br /&gt;
 	StepMotor2(motor2_phase);&lt;br /&gt;
 	mT2ClearIntFlag();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //----------------------------------- INITIALIZING FUNCTIONS -----------------------------&lt;br /&gt;
 void homePositionFill()  // OPEN THE ADC AND STORE CURRENT VOLTAGES AS THE &amp;#039;HOME READING&amp;#039;&lt;br /&gt;
 {&lt;br /&gt;
 	CloseADC10();&lt;br /&gt;
 &lt;br /&gt;
 				// Turn module on | output in integer | trigger mode auto | enable  autosample&lt;br /&gt;
 	#define PARAM1  ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON&lt;br /&gt;
 &lt;br /&gt;
 		// ADC ref external    | disable offset test    | enable scan mode | perform 2 samples | use one buffer | use MUXA mode&lt;br /&gt;
     	#define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF&lt;br /&gt;
 &lt;br /&gt;
 	// 				  use ADC internal clock | set sample time&lt;br /&gt;
 	#define PARAM3  ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15&lt;br /&gt;
 &lt;br /&gt;
 					// set AN4 and AN5&lt;br /&gt;
 	#define PARAM4	ENABLE_AN4_ANA | ENABLE_AN5_ANA&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// do not assign channels to scan&lt;br /&gt;
 	#define PARAM5	SKIP_SCAN_AN0 | SKIP_SCAN_AN1 | SKIP_SCAN_AN2 | SKIP_SCAN_AN3 | SKIP_SCAN_AN6 | SKIP_SCAN_AN7 | SKIP_SCAN_AN8 | SKIP_SCAN_AN9 | SKIP_SCAN_AN10          | SKIP_SCAN_AN11 | SKIP_SCAN_AN12 | SKIP_SCAN_AN13 | SKIP_SCAN_AN14 | SKIP_SCAN_AN15&lt;br /&gt;
  &lt;br /&gt;
 	SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF); // use ground as the negative reference&lt;br /&gt;
 	OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using parameter define above&lt;br /&gt;
 	EnableADC10(); // Enable the ADC&lt;br /&gt;
 &lt;br /&gt;
 	while ( ! mAD1GetIntFlag() ) { } // wait for the first conversion to complete so there will be valid data in ADC result registers&lt;br /&gt;
 &lt;br /&gt;
 	mInitAllLEDs();&lt;br /&gt;
 &lt;br /&gt;
 	home_position[0] = ReadADC10(0);&lt;br /&gt;
 	home_position[1] = ReadADC10(1);&lt;br /&gt;
 &lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ASSIGN STANDARD POSITIONS&lt;br /&gt;
 void fillCases()&lt;br /&gt;
 {&lt;br /&gt;
 	rotations[HOME] = home_position[0];								// Sets straight to startup position&lt;br /&gt;
 	rotations[1] = (float) 10 *  ANGLE2VALUE + home_position[0];	// rotations[1] = 10 degrees left&lt;br /&gt;
 	rotations[2] = (float) -10 * ANGLE2VALUE + home_position[0];	// rotations[2] = 10 degrees right	&lt;br /&gt;
 	elevations[HOME] = home_position[1];							// Sets flat to startup position&lt;br /&gt;
 	elevations[1] = (float) 5 *  ANGLE2VALUE + home_position[1];	// elevations[1] = 5 degrees up&lt;br /&gt;
 	elevations[2] = (float) 15 *  ANGLE2VALUE + home_position[1];	// elevations[2] = 15 degrees up	&lt;br /&gt;
 	powers[HOME] = 0;		// not cocked back&lt;br /&gt;
 	powers[1] = 6 * STEPS_TO_INCHES;		// powers[1] = 6 inches&lt;br /&gt;
 	powers[2] = 7 * STEPS_TO_INCHES;		// powers[2] = 7 inches&lt;br /&gt;
 }  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // -------------------------------------- LOCATING FUNCTIONS --------------------------------&lt;br /&gt;
 void getPositions()&lt;br /&gt;
 {&lt;br /&gt;
 	// Get current position&lt;br /&gt;
 	positions[0] = ReadADC10(0);&lt;br /&gt;
 	positions[1] = ReadADC10(1);&lt;br /&gt;
 	&lt;br /&gt;
 	// Calculate error magnitude&lt;br /&gt;
 	error_mag[0] = positions[0] - rotations[scenario];&lt;br /&gt;
 	error_mag[1] = positions[1] - elevations[scenario];&lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for rotational motor&lt;br /&gt;
 	if (abs(error_mag[0]) &amp;lt; DC_STOP_POINT)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = NONE;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = LEFT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[0] &amp;gt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[0] = RIGHT;&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 	// Set motor direction for winching motor&lt;br /&gt;
 	if (abs(error_mag[1]) == 0) errors[1] = NONE;&lt;br /&gt;
 	else if (error_mag[1] &amp;lt; 0) &lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = UP;&lt;br /&gt;
 	}&lt;br /&gt;
 	else if (error_mag[1] &amp;gt; 0)&lt;br /&gt;
 	{&lt;br /&gt;
 		errors[1] = DOWN;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	&lt;br /&gt;
 	// Set motor direction for cocking motor&lt;br /&gt;
 	if (isLatched == NO) // if plates arent attached, move forward until they are&lt;br /&gt;
 	{&lt;br /&gt;
 		if (LatchSwitch == 0) 	errors[2] = FORWARD;&lt;br /&gt;
 		else if (LatchSwitch == 1)&lt;br /&gt;
 		{&lt;br /&gt;
 			isLatched = YES;&lt;br /&gt;
 			Per2 = (80000000/BACKWARD_SPEED_FAST)/256-1;&lt;br /&gt;
 			WritePeriod2(Per2);&lt;br /&gt;
 			errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	else // if they are latched, count steps backward and compare&lt;br /&gt;
 	{&lt;br /&gt;
 		error_mag[2] = step_counter - powers[scenario];&lt;br /&gt;
 		if (error_mag[2] == 0) &lt;br /&gt;
 		{&lt;br /&gt;
 			errors[2] = 0;&lt;br /&gt;
 		}&lt;br /&gt;
 		else&lt;br /&gt;
 		{&lt;br /&gt;
 		 	errors[2] = BACKWARD;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void getScenario() // get &amp;#039;beer me&amp;#039; command and determine position&lt;br /&gt;
 {	&lt;br /&gt;
 &lt;br /&gt;
 	while (scenario == -1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (CASE_1 == 1) scenario = 1;&lt;br /&gt;
 		else if (CASE_2 == 1) scenario = 2;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 // ---------------------- END OF SEQUENCE FUNCTIONS --------------------------------------&lt;br /&gt;
 void return_home()&lt;br /&gt;
 {&lt;br /&gt;
 	// Set scenario to home and compute error&lt;br /&gt;
 	scenario = HOME;	&lt;br /&gt;
 	getPositions();&lt;br /&gt;
 	&lt;br /&gt;
 	// START WINCHING DOWN&lt;br /&gt;
 	Per1 = (80000000/DOWN_SPEED)/256-1;&lt;br /&gt;
 	mT3SetIntPriority( 7); 	// set Timer3 Interrupt Priority&lt;br /&gt;
 	mT3ClearIntFlag(); 		// clear interrupt flag&lt;br /&gt;
 	mT3IntEnable( 1);		// enable timer3 interrupts ?&lt;br /&gt;
 	OpenTimer3(T3_ON | T3_PS_1_256 | T3_SOURCE_INT, Per1);&lt;br /&gt;
 	&lt;br /&gt;
 	while (errors[1] != NONE) // STOP WHEN IT GETS THERE&lt;br /&gt;
 	{&lt;br /&gt;
 		if (errors[0] == NONE) Brake();&lt;br /&gt;
 		if (ElevSwitch == 1) &lt;br /&gt;
 		{&lt;br /&gt;
 			CloseTimer3();&lt;br /&gt;
 			motor1_enable = 0;&lt;br /&gt;
 			StepMotor1(6);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16769</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16769"/>
		<updated>2010-03-15T01:48:08Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16768</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16768"/>
		<updated>2010-03-15T01:47:30Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|left]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16767</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16767"/>
		<updated>2010-03-15T01:46:24Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|center]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|left]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16766</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16766"/>
		<updated>2010-03-15T01:44:50Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|300px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|300px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|left]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|left]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16765</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16765"/>
		<updated>2010-03-15T01:44:33Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|225px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|225px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|left]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|left]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16761</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16761"/>
		<updated>2010-03-15T01:43:24Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|left]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|left]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16760</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16760"/>
		<updated>2010-03-15T01:43:01Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16759</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16759"/>
		<updated>2010-03-15T01:42:05Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16757</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16757"/>
		<updated>2010-03-15T01:39:08Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|right]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16755</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16755"/>
		<updated>2010-03-15T01:38:12Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
== Launcher Assembly ==&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|left]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&lt;br /&gt;
== Triggering the Launch Plate/Firing the Can==&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&lt;br /&gt;
== Controlling the Launch Angle ==&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&lt;br /&gt;
== Controlling the Direction ==&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&lt;br /&gt;
== The Magazine ==&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|left]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16752</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16752"/>
		<updated>2010-03-15T01:36:53Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|left]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|left]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16750</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16750"/>
		<updated>2010-03-15T01:35:51Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: /* Launcher Assembly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|200px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|200px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|left]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16749</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16749"/>
		<updated>2010-03-15T01:35:34Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|175px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|175px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|left]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16748</id>
		<title>Can Launching Fridge</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=Can_Launching_Fridge&amp;diff=16748"/>
		<updated>2010-03-15T01:35:04Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The can launching fridge is a fully automated and self contained unit designed to dispense and throw a can to a predetermined location when commanded by the user. The concept was inspired by a project done by John W. Cornwell of Duke University.&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Derek Siegal (Mechanical Engineering, Class of 2010)&lt;br /&gt;
* Chris Semple (Mechanical Engineering, Class of 2011)&lt;br /&gt;
* Leland Gossett (Biomedical Engineering, Class of 2011)&lt;br /&gt;
&lt;br /&gt;
== Mechanical Design ==&lt;br /&gt;
&lt;br /&gt;
Our design consists of three main components in addition to the refrigerator: a rotating base and stand, a launcher assembly, and an internal magazine for dispensing cans. It was decided early in the design process that we preferred a spring powered linear launch mechanism to the catapult system employed by the example mentioned above. This was for several reasons. Most importantly, this system allows for control of three parameters – launch direction, elevation angle, and power – for precise tuning and variability of the launch sequence.&lt;br /&gt;
&lt;br /&gt;
=== Launcher Assembly ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Launcher.jpg|thumb|150px|Launcher assembly attached to side of fridge.|right]]&lt;br /&gt;
[[Image:27_Belt.jpg|thumb|150px|Stepper motor is attached to a timing belt drive that pulls back the launching plate.|left]]&lt;br /&gt;
&lt;br /&gt;
The launcher assembly is built around a polyethylene front plate connected by four steel guide rods to a box in the rear that serves as a motor mount and housing for a timing belt drive. This motor, in our case a **INSERT MOTOR SPECIFICS** stepper motor was used to turn two lead screws that run parallel and outside of the guide rods. A steel carriage plate is threaded onto these lead screws to create a linear drive capable of running the length of the assembly. In order to get smooth and reliable motion from the lead-screw drive, the alignment of the carriage had to be adjustable and the rotation had to be unimpeded. This was accomplished by machining aluminum couplers that were 3/8” - 16 threaded female on one end and exposed 1/4” rod on the other to insert into bearings. This allowed for the threaded rods to be threaded into or out of the couplers for alignment purposes, while still maintaining a constant available length. Under this was suspended half of a PVC pipe that supports the can to be launched. Finally, a launch plate is mounted on the guide rods such that it can slide freely over the pipe and these rods in the direction of launch. In action, the carriage brings forward a trigger which locks onto the rear of the launch plate. Having done so, it retracts a preset distance to store energy in the springs, and finally releases the trigger to launch the can.&lt;br /&gt;
&lt;br /&gt;
=== Triggering the Launch Plate/Firing the Can===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Trigger.jpg|thumb|150px|Plate is triggered with a solenoid.|right]]&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Launch Angle ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Winch.jpg|thumb|150px|Stepper motor powers a winch that lifts the launch assembly about a pivot point.|right]]&lt;br /&gt;
&lt;br /&gt;
The whole launch assembly is mounted to the side of the refrigerator with a rear pivot point to allow cans to be gravity fed into the top of it. The launch angle is adjusted by angling this whole assembly upwards with a winch mounted on the top of the refrigerator. Though the motor for this winch was also a stepper motor, we decided to use a potentiometer for positional feedback to prevent accumulation of error through subsequent runs.&lt;br /&gt;
&lt;br /&gt;
=== Controlling the Direction ===&lt;br /&gt;
&lt;br /&gt;
[[Image:27_Wheel.jpg|thumb|150px|DC motor turns a friction wheel that changes that direction of the fridge.|right]]&lt;br /&gt;
&lt;br /&gt;
Next, a system was needed to aim the direction of launch. This is accomplished in our design by mounting the entire refrigerator on top of a turntable. This consists of a Lazy Susan bearing bolted between two plates. The first of which was bolted to the bottom of the refrigerator, while the second was elevated off the ground by a wooden frame to help reduce power required for reasonable launch trajectories.  Rotation was achieved by a friction wheel driven by a small DC motor attached to the outside of the turntable plate. As with the launcher assembly, position was determined by coupling a potentiometer between the two plates.&lt;br /&gt;
&lt;br /&gt;
=== The Magazine ===&lt;br /&gt;
[[Image:27_Magazine.jpg|thumb|150px|Steel magazine inside fridge allows gravity feeding into the launcher assembly.|right]]&lt;br /&gt;
[[Image:27_Solenoid.jpg|thumb|150px|Airlock system using solenoids controls the flow of the cans.|right]]&lt;br /&gt;
&lt;br /&gt;
Finally, a magazine was built to feed cans into the launching tube. Placing a premium on capacity, we decided to utilize a gravity fed system essentially consisting of parallel angled plates that act as shelves for cans to rest on as they progressively feed towards an opening cut out of the refrigerator wall.  All of the upper plates were cut shorter than the bottom-most one, so that a space is left for cans to roll onto the lowest plate and eventually out the opening. This magazine was welded together out of plate steel, and features a two stage loading gate. The first uses a relatively powerful and long draw solenoid that is able to overcome the friction inherent in supporting the weight of a full magazine of cans, while the second is much lighter and is positioned at the opening for the final release. This design was motivated by two considerations: first, that a single gate system would require significant tuning to time the release of only a single can, and second, that cans would potentially feed at different speeds depending on the amount of cans loaded at any given point. By using a two stage system, only enough space is permitted for one can to roll past stage one while it is open, and once stage two opens, the can will be released from a consistent distance to prevent irregularities in the sequence.&lt;br /&gt;
&lt;br /&gt;
== Circuit Design ==&lt;br /&gt;
&lt;br /&gt;
== C Program ==&lt;br /&gt;
&lt;br /&gt;
== Future Design Considerations ==&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:27_Solenoid.jpg&amp;diff=16747</id>
		<title>File:27 Solenoid.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:27_Solenoid.jpg&amp;diff=16747"/>
		<updated>2010-03-15T01:34:41Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:27_Magazine.jpg&amp;diff=16745</id>
		<title>File:27 Magazine.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:27_Magazine.jpg&amp;diff=16745"/>
		<updated>2010-03-15T01:34:28Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:27_Wheel.jpg&amp;diff=16743</id>
		<title>File:27 Wheel.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:27_Wheel.jpg&amp;diff=16743"/>
		<updated>2010-03-15T01:34:16Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:27_Winch.jpg&amp;diff=16742</id>
		<title>File:27 Winch.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:27_Winch.jpg&amp;diff=16742"/>
		<updated>2010-03-15T01:34:02Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=File:27_Trigger.jpg&amp;diff=16741</id>
		<title>File:27 Trigger.jpg</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=File:27_Trigger.jpg&amp;diff=16741"/>
		<updated>2010-03-15T01:28:29Z</updated>

		<summary type="html">&lt;p&gt;DerekSiegal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>DerekSiegal</name></author>
	</entry>
</feed>