Wednesday, September 30, 2009

Lab 2: Theramin

Checkout the Video of "Mary Had a Little Lamb" on our electric instrument programmed on an Arduino MEGA board.


We have a small pressure pad that acts as a volume pedal, and we can select predefined tones from the knob (potentiometer). The tones were defined as the one octave scale in the natural key of C (see code below). The potentiometer sensor produces an analog input to our Arduino board, and the Arduino board was programmed to produce a digital output corresponding to the frequency of the note. The volume pedal is in series with the speaker.

We noticed the pedal was a create user-interface. It provided smooth, continuous feedback and was very easy to operate. Although we didn't get around to it, it could make a good controller for pitch due to it's continuous response to force (although sustaining extreme notes requiring high force input may be uncomfortable).

Here's a schematic of our instrument:


Here's the code we programmed into the Arduino, based on Arduino's Melody example:
/* Melody
* (cleft) 2005 D. Cuartielles for K3
* Modified by Andrew Rohr, Anish Joshi, Michael Woon
*
* This example uses a piezo speaker to play melodies. It sends
* a square wave of the appropriate frequency to the piezo, generating
* the corresponding tone.
*
* The calculation of the tones is made following the mathematical
* operation:
*
* timeHigh = period / 2 = 1 / (2 * toneFrequency)
*
* where the different tones are described as in the table:
*
* note frequency period timeHigh
* c 261 Hz 3830 1915
* d 294 Hz 3400 1700
* e 329 Hz 3038 1519
* f 349 Hz 2864 1432
* g 392 Hz 2550 1275
* a 440 Hz 2272 1136
* b 493 Hz 2028 1014
* C 523 Hz 1912 956
*
* http://www.arduino.cc/en/Tutorial/Melody
*/

#include

int tone=0;
int addr = 0;
int speakerPin = 9;
int ledPin = 13;
int sensorPin = 0; //Analog Input ~0-5V
float sensorValue = 0;
char n = 'c';
char n1='c';

int length = 15; // the number of notes
float prevval=0;
float val=0;
int j=2;

void setup() {
pinMode(speakerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(sensorPin, INPUT);
}

void loop() {


sensorValue = analogRead(sensorPin)/100;

if(prevval!=sensorValue)
{
EEPROM.write(addr,sensorValue);
addr=addr+1;
}


if(addr == 512)
addr=0;

if (sensorValue <= 1){ n1 = 'c'; digitalWrite(ledPin,HIGH); //playNote(n); } if (sensorValue > 1 && sensorValue <= 2){ digitalWrite(ledPin,LOW); n1 = 'd'; //playNote(n); } if (sensorValue > 2 && sensorValue <= 3){ n1 = 'e'; digitalWrite(ledPin,HIGH); //playNote(n); } if (sensorValue > 3 && sensorValue <= 4){ n1 = 'f'; digitalWrite(ledPin,LOW); //playNote(n); } if (sensorValue > 4 && sensorValue <= 5){ n1 = 'g'; digitalWrite(ledPin,HIGH); // playNote(n); } if (sensorValue > 5 && sensorValue <= 6){ n1 = 'a'; digitalWrite(ledPin,LOW); // playNote(n); } if (sensorValue > 6 && sensorValue <= 7){ n1 = 'b'; digitalWrite(ledPin,HIGH); //playNote(n); } if (sensorValue > 7 && sensorValue <= 8){ n1 = 'C'; digitalWrite(ledPin,LOW); //playNote(n); } char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' }; int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 }; n=n1; // play the tone corresponding to the note name for (int i = 0; i < tone="tones[i];" j="2;">0)
{
int sensor = 0;
sensor=analogRead(sensorPin);
if(sensorValue!=sensor)
j=-1;
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(speakerPin, LOW);
delayMicroseconds(tone);

}

}

}

n1 ='d';
prevval=sensorValue;
}

n1 ='d';
prevval=sensorValue;
}

Lab 2: Labview I/O

Working with the Labview portion of the lab required the configuration of analog inputs along with both analog and digital outputs. A couple pictures along with videos are located below serving as simple examples to our accomlishments with the Labview interface.



The figure directly below exemplifies three important concepts. Using the DAQ Assistant block in Labview, analog I/O along with digital output was configured. Refering to the figure, the bottom lop represents analog input to the NI-PCI-6230. A wave from was generated to verify the functionality of the analog input. The while loop in the upper left corner of the figure indicates the setup used to control digital output with the flip of a toggle switch in Labviews virtual interface. The while loop in the upper right corner of the figure indicates analog output from Labview. In this instance we simply generated a sine wave to verify functionality of the analog output DAQ Assistant.




The front panel of labview is shown below. The generated sine wave can be seen, and it's characteristics such as frequency and amplitude can be controlled by the user. The toggle switch controls the on/off capability of the digital output. A blinking LED in the video below shows the user toggling the switch back and fourth controlling the LED to turn off and on.





In the video below labview was programmed to output an analog signal which the team used to power a speaker.





Analog signals from the potentiometer and photo cell were also input into Labview to gain an additional understanding of how to control analog inputs.


Monday, September 28, 2009

Lab 2 - Servo motor control using Aruduino

We were able to successfully control the servo motor using the melody program found under examples on the Arduino website. A video demonstrating this statement is below.

Lab 2 - Sensor to Arduino board interface

Tasks one through four have been completed.

Simple circuits have been designed for each sensor in order to connect the sensor to the arduino board. Sensor functionality was tested and verified. From there the digital signals from each sensor; hall effect, FSR, photocell, and potointerrupter were all taken into the ardino board, and having the ability to affect the blinking LED ensured us of a working sensor to arduino board interface utilizing both digital inputs and digital outputs on the board.

Bringing in analog signals to the arduino board from the petentiometer, the photoresister (configured as a voltage divider), and the hall effect sensor was a simple task. However, understanding how to use EEPROM to write and read accross the serial port has been challenging. We currently are able to write data. Then we have separately run the EEPROM read script in order to obtain values stored in the boards internal memory.

A video of the potentiometer controlling the LED is below as an example of our progress.



Lab 2 Group Members

Lab 2 Group 5 team members included:

Anish Joshi
Andrew Rohr
Michael Woon

Wednesday, September 23, 2009

Lab 1 - Our device as a Musical Instrument

The device we created does indeed function as a musical instrument as it outputs sound based on human input. However, the device left much to be desired. First, the variable resistor only had a fixed range and therefore only allowed a distinct range of sound to be produced by the circuit. Also, since the slider had a short stroke, it was very difficult to make very small changes in output pitch. Additionally, because the slider was continuous, it was difficult to arrive at the same location consistently. This made the output sound different every time.

Hearing the final device perform as it was intended was somewhat rewarding, though. Knowing that we made a circuit that worked as we desired provided positive re-enforcement towards our knowledge base. Additionally, it exposed some of the uses these types of circuits can have when they are integrated with each other.

We realize that in future work that the interface between the device and the human will be just as important as the circuit itself. This device showed this principle because it was an awkward device to manipulate and use. While it did perform its function well, its form was neglected. This will be an important part of the final project.

Lab 1: Slideophone-The Required Blog Write-up Bit

In addition to being a tremendously expressive musical instrument, the Slideophone (aptly named after its ingenious sliding potentiometer interface and robust clarity of sound) provides great utility to any band in need of that special kind of sound reminiscent of a baby's scream mixed with a little southern twang. And for the one time price of $1152 (3 grad students @ $32/hr (stipend & tuition) * 12 hours (class & lab)), it had better have a great deal of value. If bleeding ear-drums could stand, the Slideophone's performance would receive a standing ovation.

So come on down to the Mechatronics lab when you can witness a miracle (it actually was successfully created), and see the satisfied smiles on our faces as we are no doubt rewarded with great honors--or at least an A.

Lab 1: Putting it all together

We now have an oscillator and a switching mechanism to power a speaker based on some information logic. We may now combine them to turn the oscillating information signals coming from the timer circuit into a sound emanating from the speakers. As a quick note, this alternation is necessary, as if a constant voltage was applied to the speaker, the voice-coil would move to a single position. However, if this signal is turned on and off, the the position of the coil (and therefore the woofer) will alternate between rest and the position at which the "solenoid" of the voice-coil moves the woofer. This alternation creates waves in the air which vibrate in our ears, sending neural spikes into our brain, and these spikes in the brain miraculously are experiences as the aforementioned pretty pretty music.

Of course, sometimes, especially at the frequencies coming out of our speaker, it was more closely experienced simply as "spikes" in the brain.

Although we believe we could wire the output information signal directly to the base of the transistor, it seemed a good idea to keep some of the functionality of the two mechanical switches we wired up in the first part of the experiment and use one of them as an on/off switch. We therefore had two options for our final circuit. In one version, the output of the timer circuit was plugged into the base of the transistor, and the logic was taken completely out. In another, we supply the timer output as one of the switched inputs in our mess of nor-gates so that the circuit needs both a mechanical switch and a high output from the timer to turn on the speaker.


This seems a bit wasteful of an oscillating circuit that is working itself to death, even if the circuit is switched off and the speaker is not moving, but our final design represents only one possibility for a combination of the two circuits. In further labs, we will have more detailed requirements for the circuits and so a combination more fitting to that specific task may emerge.

Lab 1: Timing chip

The 555 timing chip is one of many which uses internal circuitry to produce high/low discrete alternating output signals at specific times. There are multiple ways of using the chip, but most involve creating a circuit around it which will exploit the voltage drops over resistors, and the time it takes for certain capacitors to charge.

The circuit we were interested was once which created an oscillating square-wave output. This is referred to in the data sheet as astable operation. We were able to adopt the circuit from the spec sheet without making very many changes to create a 1Hz proof-of-concept output signal, and then one of a much higher frequency to run the speaker. Below you can see the basic structure of the circuit, as referenced in the spec sheets and the specific values and calculations leading to the values we used for our final circuit (expansion on basic circuit diagram in previous blog):

(The image can be clicked to view in full resolution)

High and low times are a function of the two resistors, and a gain caused by the capacitor. The exact functions could again be found in the spec sheet, which we referred to to create an oscillating output at Hz.

One design consideration which played a major role was to use variable resistors as resitors A and B, instead of fixed ones. This meant that the capacitor could be used as a gain control to get the oscillation in the right range (1 Hz for testing on the oscilloscope and 10-20k times that for the speaker). Then, adjusting the two potentiometers would result in a change in the high time or the low time, and therefore the duty cycle and period. This combination of effects enabled us to create a sliding effect in the sound produced by the speakers.

As it pertains to the blog-question outlined in the lab hand-out, this variation of resistance translating to a variation in tone can easily be adapted into an human-machine interface for the musical instrument project. One simply has to decide on an interface. As lab 2 will no doubt show, there are a few ways to produce a variant resistance based on the forces applied (to the instrument) or the proximity one has to the instrument (theremin). Changes in these values will correspond to changes in pitch, which then can be exploited to play pretty pretty music.

Lab 1: LED Circuit

The first objective for Lab 1 was to design a circuit in which an LED illuminated only if two mechancial switches were closed. Our team intially thought to use a AND gate to accomplish this, however, the only logic gates available were NAND and NOR gates. We constructed the AND function out of three NOR gates as shown in the picture. Two pull-up resistors (5 Kohm) were used to supply high voltage to the NOR gates when the switches were closed. The output current from the logic gate went to the transistor base, which closed the switch and allowed the LED to light up.


Bench testing showed our LED worked well when 1.5V and 40mA was applied. Calculations for sizing resistors R3 and R4 was determined as shown in the schematic.


Lab 1 Team Members

Scott Bartkowiak
Brian Holcomb
Nathaniel Skinner

Wednesday, September 16, 2009

Lab 0: Final Lab Write-up

1)
The axiom discussed in class "There is more than one way to skin a cat" proved true on many fronts during this lab. Not only was there a wide range of shooting mechanisms displayed during the competition, but even the smallest details of design and construction could be changed to perform the same function while "making do" with the available materials. We tried our best to build the device with re-purposed or off-the-shelf parts rather than custom pieces, and this lead to many difficulties with operation. Each of our axles, gears, and bearings could have benefited greatly from custom machined parts, but to save time, money, and stay true to our view of the intent of the lab, all of these fittings were "close enough" but not exacting. The "slop" in the system lead to a lot of vibration and wobbling. At the ball interface, we were able to account for this by choosing spongy tires which would grip the ball even if the wheels were spinning slightly off-center. The drive motor, on the other hand, suffered heavily from the extra vibrations because it was not capable of providing the extra torque required to spin the system at high speeds. Thus, or design was able to effectively launch balls in a consistent manner, but not with the desired range because of a lack of angular velocity at the wheels. This illustrates the biggest lesson from Lab 0; that when performing "quick and dirty" rapid-prototyping, certain areas are worth spending extra time and effort on, while others can hacked together and made to perform just fine.

We had a lot of fun with this project. In the typical style of engineers, one of our favorite parts was taking apart the toy and playing around with the components. Another highlight was seeing the design come together and certain parts begin working properly. The first successful ping pong ball launch was also exciting. Of course, there were a few not-so-fun times; early problems were not discouraging, because the trouble-shooting process can be fun, but malfunctions or deterioration in performance in the late stages of testing were problematic because of the added pressure of the time constraint. Also, watching every one of our balls "almost" make it in the bucket without actually going in was frustrating, especially because we had had success in previous trials.

2)
Brainstorming was an interesting process for us, because when we obtained our toy it was not evident which components would be relevant to the task at hand. In fact, we first assumed that we would probably have to use the springs in the pedals to create a sort of catapult design. However, disassembly revealed an electric motor and a full complement of gears, so we had to change our train of thoughts to incorporate motorized designs, which we of course ultimately picked. Our discussion focused both on simplicity and repeatability. A simple device is not only faster to design and assemble, but also has fewer pieces that could break or malfunction and also fewer weak links. Knowing that we would be aiming for small stationary targets, the ability to shoot a series of balls within a small cluster was extremely important. Thus, we wanted to come up with a design that would contact the ball at the same position with the same speed every time.

3)
The most robust aspect of our design turned out to be the tires, as discussed in #1 above. We did not have a single issue with the ball not being pulled through the gap no matter what was going on in the rest of the system. We could say that the motor was the least robust part of the device because it did not have enough power, but the root issue was the reducing play where the axles met the foam walls and also the wheel hub. Vibrations here caused problems with gear meshing, range and consistency.

4)
Mechatronically, our design was oriented more toward the mechanical side, so a lack of experience with mechatronics was never really an issue. The one problem we had with the electronics was the destruction of a potentiometer because we put too much power through it. This could have been avoided with more experience in using pots in high-power systems.

Monday, September 14, 2009

Lab 0: Progress and Successful Launch

The pitching-machine idea was chosen because we decided it gave us the best chance for a successful device given the materials we had to work with. The design consists of two wheels positioned with just enough space for a ping-pong to squeeze through; one wheel will be driven by the motor and the other will be free-spinning. When a ball is introduced, the driven wheel will accelerate it through the gap and propel the ball outward. This is a proven design used in baseball pitching machines and tennis ball throwing machines.

We had a suitable motor and gears to configure a system capable of high angular velocities, however we needed to purchase wheels to contact the ball. We found a set of rubber tires mounted on plastic rims intended for use in a toy car. The sticky, spongy rubber was perfect to grip the balls.

We used the base from our pedal set as the base for our launcher. Foam core was used to create vertical walls, between which our wheels would be mounted. Gears were selected for maximum speed; the motor was fitted to turn the largest gear directly, which then turned the smallest gear which was fixed to the tire.




Axles for each of the wheels were inserted through the foam core, with washers glued to the board to provide a rigid hole and prevent enlargement. The motor was mounted near the top of the device by re-purposing a bearing sleeve which happened to fit the motor case perfectly. The other end of the large gear was supported loosely by a round metal band. Because the shaft of the gear is roughly square at this end, this fitting causes some vibration, but does an adequate job nonetheless. We wired the motor up with a simple push-on push-off switch and a potentiometer taken from the petal setup to control motor speed. We spliced into the device's DC converter and used it to power the motor. We quickly realized that the potentiometer was meant for low-power use, as we burned it up and had to remove it from our setup. Finally, we added a curved ramp to feed ping pong balls into the rotating wheels.


The device successfully launches ping pong balls, though not with great range or accuracy. The vibrations in not-quite-matched wheels/gears and axles, causes a lot for frictional torque and slows the motor. We plan, at this point, is to "one-hop" or bounce the balls into the buckets, which this device is more than capable of doing.

Videos to follow once Vista realizes that a device can have both pics and vids on one device at the same time...

Sunday, September 13, 2009

Lab 0: Supplies and list of design ideas

Team 5 acquried a steering wheel and foot petal, which would be used to simulate a driving experience for a c0mputer game. Once dissected, two springs and two potentiometers were found in the foot petal casing. The casing itself could also be used as a sturdy base to a ping pong launching mechanism. Critical components found inside the steering wheel assembly included a single DC motor.



Post toy dissection, four design ideas were brainstormed:

- A traditional catapult possibly using the spring(s) and/or the DC motor
- A mechanism that would resemble a pitching machine from a batting cage, utilizing the DC motor
- A plunger that would actuate once the ping pong ball was loaded and directly project the ball after being hit, most likely using the springs from the toy and maybe even incorporating the DC motor as well.
- A type or swinging arm assembly using the DC motor that would directly project the ball after being hit. A ball could be loaded every revolution made by the arm if desired.

Mechatronic systems design

This blog is a journal of progress (or non-progress :) ) of work on each of the Mechatronics projects given as a part of graduate course work at the University of Michigan. The first project is to make a ping pong ball shooter out of entrails of one of the toys that uses electro-mechanical components. The team members for this project are as follows:


1. Piyush Soni
2. Eric Nauli Sihite
3. Cameron Graybeal
4. Andrew Rohr

Cheers!!

The posts will follow soon..