Tuesday, September 29, 2009

Sensors... So how do I know that you see the same blue as I see?

David Maiden Mueller
Colin Foe Parker
Yashar Ganjeh
Tim Stutz

Lab three is all about the glorious world of sensors, microprocessor integration, and even delving a little into the world of labView. We were given a Button, Pot, Photoresistor, Force Sensing Resistor, Photo interruptor, Hall Effect Sensor, LED's, a speaker, and a Hobby Servo and told to go to town. I mean, not literally town... because that is quite a walk.... but rather go play/build/tinker/learn. The end goal? Build a electronic musical instrument of some form that uses an Analog sensor for pitch and some other sensor for either articulation or volume. There were a few waypoints along the way.... 1. Read all the sensors as Digital Inputs in the Arduino. 2. Drive LED's off an Arduino GPIO. 3. Read Analog signals using the Arduino. 4. Run a Servo. 5. Play with LabView and try to do the same things again. So we weren't COMPLETELY unsupervised....
So, we met on Thursday all gungho and ready to start and build. Instead, we spent an hour and a half trying to rebuild what we had done the week before. As with all things... all four of us had built the previous weeks lab circuit differently. And everyone wanted to know WHY people chose which resistors or placed what parts where. So, we talked it out and eventually reached an amalgamation of different designs. Now it was time to actually start working on the lab. We went through the data sheets and laid out circuit diagrams for all the individual components. (Refer to Figures 1 through 3)


Figure 1: Circuit Layout
Figure 2: Circuit Layout
Figure 3: Circuit Layout
With this data, we were prepped to tackle sensor integration with the Arduino. We wrote a simple program that would take in sensor values. The system would the light up a LED if on. The code also saved the gpio value into the EEPROM and when all 512 memory locations were filled would dump the values onto the serial port. The code follows.

#include

int SensorPin = 52;
int LEDPIN = 13;
int Value;
int addr;

void setup(){
Serial.begin(9600);
pinMode(SensorPin,INPUT);
pinMode(LEDPIN,OUTPUT);
}

void loop(){
Value = digitalRead(SensorPin);
digitalWrite(LEDPIN,Value);
EEPROM.write(addr,Value);
if (addr == 512){
addr = 0;
while (addr <>
Value =EEPROM.read(addr);
Serial.println(Value, DEC);
addr = addr + 1;
}
addr = 0;
}
addr++;
delay(20);
}

This code worked for all digital pins. We then did the same test with an analog input. We used the same code with an exception of switching the "int SensorPin = 52;" to "int SensorPin = 0;" and the "Value= digitalRead(SensorPin)" to "Value = analogRead(SensorPin)'. As expected, the led did not light up unless the analog signal was truthfully 0. But all the rest of the components worked like a charm. :) The following graph shows the analog output of the arduino after 500 time steps.


Our next task was to get the servo up and running. The great thing about the arduino is that all the hard stuff is already done for us. We don't have to go through all the ports searching for the pwm output timers, or set up clocks to output at the right frequencies, or figure out how to scale the pwm duty cycle to get the servo running. Instead, all we have to do is "#include " set up a class and then tell the servo what to do. We got it up and running in <>

#include
#include

int SensorPin = 0;
int LEDPIN = 13;
int Value;
int addr;
Servo Servo1;
int i;

void setup(){
Serial.begin(9600);
Servo1.attach(12);
// pinMode(SensorPin,INPUT);
pinMode(LEDPIN,OUTPUT);
}


void loop(){
Value = analogRead(SensorPin);
digitalWrite(LEDPIN,Value);
EEPROM.write(addr,Value);
if (addr == 512){
addr = 0;
while (addr <>
Value =EEPROM.read(addr);
Serial.println(Value, DEC);
addr = addr + 1;
}
addr = 0;
}
addr++;
if (i > 5) {
Servo1.write(255);
}
else {
Servo1.write(0);
}
if (i==10){
i=0;
}
i++;
delay(100);
}

Our final task was to make a musical instrument of some form. We immediately decided make something that resembled a thermin. (I guess we aren't all that inventive...) However, we added a little twist. We would use the Hall Effect Sensor to control the pitch of the sound. We attached the Hall Effect sensor to an analog input of the Arduino. We would measure the value and using a gpio bitbang an output signal resembling a pwm. David devised a cool way to augment the signal to give it the traditional 8 bit Mario Kart video game sound that we all grew up with. The arduino output signal was then fed into a Nand gate in addition to an input from the photo interrupter. The result was fed into the NPN BJT and controlled a speaker output. The result? We developed a really cool electric instrument that augmented frequency by moving a magnet and controlled articulation with a blocker in the photo interrupter. Tim became pretty adept at making some hip tunes. Watch the embedded video below!!!


The code is following.....

const int sensorPin = 2; // pin that the sensor is attached to
const int ledPin = 22; // pin that the LED is attached to
const int outputOne = 24;
const int sensorGate = 52;
int outVal = 0; // value of the output
// variables:
int sensorValue = 0; // the sensor value
int sensorMin = 1023; // minimum sensor value
int sensorMax = 0; // maximum sensor value
int time = 1;
double frequency = 1;

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(outputOne, OUTPUT);
pinMode(sensorGate, INPUT);
// turn on LED to signal the start of the calibration period:
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);

// calibrate during the first five seconds
while (millis() <>
sensorValue = analogRead(sensorPin);

// record the maximum sensor value
if (sensorValue > sensorMax) {
sensorMax = sensorValue;
}

// record the minimum sensor value
if (sensorValue <>
sensorMin = sensorValue;
}
}

// signal the end of the calibration period
digitalWrite(13, LOW);
Serial.begin(9600);
}

void loop() {
// read the sensor:
sensorValue = analogRead(sensorPin);

// apply the calibration to the sensor reading
sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255);

// in case the sensor value is outside the range seen during calibration
sensorValue = constrain(sensorValue, 0, 255);

// fade the LED using the calibrated value:
//analogWrite(ledPin, sensorValue);
time = sensorValue*15;
//Serial.print("Sensor Value: ");
//Serial.print(sensorValue);
//Serial.print(" Time: ");
//Serial.print(time);
//Serial.print(" Frequency: ");
//Serial.println(frequency);
digitalWrite(outputOne, digitalRead(sensorGate));
for(int i=0; i<25;>
digitalWrite(ledPin, HIGH);
//outVal = digitalRead(ledPin);
//Serial.println(outVal);
delayMicroseconds(time);
digitalWrite(ledPin, LOW);
//outVal = digitalRead(ledPin);
//Serial.println(outVal);
delayMicroseconds(time);
}
}

The final aspect of our lab was to play with LabView.... After trying to figure out which computer actually had working DAQ's, what the difference was between a waveform graph and waveform chart, and what sampling frequency we wanted we were able to develop a while loop that sampled data the voltage out of a power supply and displayed it onto the computer screen. We added some buttons to light up software LED's and display funky stuff. All in all, the LabView part was just to get acquainted with the DAQ and the graphical programming layout.

So I guess thats all folks! Lab 3 was fun. And brought back good memories of nintendo games!

New Lab, New Challenges, New team

The team members for Lab 2 are:

Colin Foe Parker
Yashar Ganjeh
Tim Stutz
David Maiden Mueller

Wednesday, September 23, 2009

Lab 1 - Introduction to Circuits

Team Members

Kevin Melotti
John George
Frank Sandner

Voltage Regulator - Logic Chip - Load (LED)

The voltage regulator provides a constant output voltage of 5V independent of its input voltage. We used a DC power supply to feed the voltage regulator. Its input voltage can vary between 6.7V and 35V. With this established power supply we fed a NOR gate (DM47LS02) (Vcc). Due to the maximum input current of 8mA stated in the data sheet, we used a pull-up resistor to limit the current in this circuit. An adequate value for this resistor is
Rpullup = U/I = 5V/8mA = 0.625kOhms.
We chose a value of 15kOhms which gave good results and makes sure that the chip won't suffer from a too high current. At the same time we ensure a low input current IB for the transistor.
This current can be calculated with the measured output voltage at the gate of Vgate, out = 4.6V
IB=4.6V/15kOhms=0.3mA.
The transistor subsequently turns on a second circuit with a different power supply and an LED as load. The same resistor R=15kOhms limits the current in this circle to 0.3mA which is sufficient to turn on an LED.
The LED turns on when both switches are pressed, because the the input voltage is equal to ground Vinput=Vground. In a next step we connected both of the input ports which made the NOR gate work as a NOT gate.
For the next task we replaced the LED with a pager motor. Hence this one needs more current to work, we replaced the resistor in the second circuit with a 5.6kOhms.




Timer Chip - Oscilloscope

In order to obtain a square wave, we built up an astable timer circuit. The circuit diagram is shown in the next figure.


The frequency of the tone can now be determined by the following formula:
We used potentiometers for the resistors so the tone is adjustable by hand. Although it's quite difficult to hit special frequencies with it.

Tuesday, September 15, 2009

Lab 0 - Ping Pong Shooter

1. Problem Definition

Before beginning any design process we clarified the task and any job the machine would have to fulfill. In a short sentence the task can be described as to build a machine which moves at least 10 ping pong balls in 40 seconds into one of a several buckets, which are located at a distance ranging between two and five meters. The material for the construction is taken out of a toy containing a DC motor and additionally purchased on campus shops. The time for the construction is limited to one week.

2. Divide the Task into Subfunctions

In the next step the main function of moving the ball over a certain distance was divided into subfunctions in order to find appropriate solutions for each task in the ensuing brainstorming. The subfunctions can be defined as:
-Carrying/preserving of the balls
-Triggered grabbing of each ball
-Mechaniscm of moving the balls (e.g. by shooting)
-Specifying direction/trajectory of the balls
-Switch to start machine
-Automatisation of each consecutive process

3. Brainstorming

During a brainstorming among our four teammembers we found several solutions for each of the previously defined tasks.
Due to the fact that the ball must hit a bucket the only considered way of transportation is shooting it, there where no other possibilities coming up during brainstorming. Therefore several approaches were found:
i. Shooting the ball by expanding a previously loaded spring. The spring would be loaded by a DC motor.
-Loading of the spring by a rotating plate which contains catches that load and unload the spring continually
-Loading of the spring by coiling up a fishing line with the motor. The force application point of the translationally guided hammer will be switched from one hook to another while shooting the balls consecutively.
ii. Shooting the ball by hitting it with a continously rotating puncher propelled by a DC motor.
iii. Shooting the ball by pinching it between two rotating wheels with a soft/adhesive surface.
iv. Shooting the ball by hitting it with an translatory oscilating hammer which is powered by a DC motor with an excentrically fixed plate.
v. Shooting the ball with swinging hammer

For the way of grabbing and providing the balls the following options have been elaborated:
i. Dropping the balls downwards (by gravitation)
-controlled by electromechanical sensor
-controlled by photoelectric sensor
-releasing the balls from their container by a rotating plate wich is provided with several holes.
ii. Moving the balls with a conveyor belt

Loading of the spring in (i) by a clutch which engages and disengages the spring from the motor alternately.Second way of loading and unloading the spring in (i). Fixing point of fishing wire at puncher jumps from nail at the right to the left, triggered through stationary ramp.

Approach described in (ii) - a hammer is driven by a rotating wheel connected to the motorConnection between punching mechanism and hopper with triggered dropping of balls


Pursued Solution

The first solution we aimed at was the loading of a spring with the motor and several gears which slow down its angular speed and increase its momentum.
It became clear that the thereby achieved momentum didn't suffice to load a spring adequately. This fact was very surprising considering that the gear transmission ratio was very high and the spring easily loadable by hand. Another problem was the great friction between hammer and guide which lead to too small impact on the ball.
Due to the nonexistance of other motors/gears another solution was chosen: The ball should be shot by a continously rotating puncher. This solution seemed to be easier to realize and first trials showed promising results.
After we had many mechanically interesting ideas this one seemed to be very conventional but it lead better to the aimed goal.





Pros and Cons of our final design

Cons

  • Final design overestimated the distance and size of buckets
  • Overshot buckets, no time to adjust input voltage
  • Exact aiming is still a problem.
  • The continuously dropping balls get stuck from time to time and need to be moved by hand.

Pros

  • Great distance out of very small motors, very efficient design
  • Good repeatability
  • Adequate load for toy motor
  • Adjustable launch pad
  • Hopper connected to launch pad, hence feeding of the balls is no problem when adjusting shooting angle
Designing Process

First of all a platform with an adjustable angle was prepared. This platform should bear any kind of shooting mechanism we would design later on. In a next step the motor was placed and the attached wing fixed to its axle. We found out that the balls rolling down in opposite direction of their destination is most efficient. Optimizing the shape of the hammer and with it the angle of impact improved the results. The wing was changed from foam to wood due to stability and was provided with several weights (bolts, washers) in order to store more energy in the rotation and thus increasing the impetus.
The balls should be carried by a container and dropped to its track to the puncher. The triggering is realized through a rotating plate with a clearance below the container. The flight distance can be adjusted by varying the voltage of the DC motor. Therefore a voltage divide was assembled due to the minimum value of 6V provided by the power supply.
Finally the whole construction was stabilized by different gussets in order to reduce vibrations. Nevertheless some kind of vibration is useful to keep the dropping of the balls running.

Generally it can be said that we had many creative ideas during brainstorming but eventually had to simplify them as much as possible due to limited ressources with respect to facilities, tools, materials and time.







Conclusion

After finishing this first lab we realized that our procedure was not sufficient enough during the first days. Instead of experimenting with different approaches directly we spent much time drawing sketches and composing drafts. Eventually it can be said that a second brainstorming after a possible solution is roughly figured out makes a lot of sense. Hence no time is wasted by elaborating digressive manners.

Monday, September 14, 2009

Team Members

Scott Bartkowiak
Daniel Dimoski
Michael Luginbill
Frank Sandner