Wednesday, February 18, 2009

Servo Lab

Giving my Mom a special shout out this week for helping me talk it out.

I am really interested in biophilic design. While this aesthetic has several different characteristics, I find natural light to be one of the most important
of the lot.
In urban environments natural light must be optimised for both plants and people.
The idea for this week was to build a device that measures the strongest light source, and then orients itself towards that brightest value.

The device itself was pretty straightforward:
  • A box for the Servo to sit in
  • A tube for the photo sensor
    (a small bit of sponge to mount the photo sensor)

  • a little wire to mount the tube onto the box



The majority of my tinkering was relegated to the code.

The first iteration was just creating a for loop that controlled the sweep of the servo.

#include // include the servo library

Servo servoMotor; // creates an instance of the servo object to control a servo

int servoPin = 9; // Control pin for servo motor, must be a PWM pin
// the value representing the angle of the servo


void setup()
{

servoMotor.attach(servoPin); // attaches the servo on pin 2 to the servo object

} //end setup

void loop()
{
for (int servoAng = 0; servoAng <= 180; servoAng++)
{
servoMotor.write(servoAng);
delay(15);
} //end for
// waits for the servo to get there
}// end loop

I continued adding pauses because I didn't want to be overwhelmed by sensor values. So I had the servo move in 10 degree increments. Then I was going to make a variable for each one (Ham fisted).



#include // include the servo library

Servo servoMotor; // creates an instance of the servo object to control a servo

int analogPin = 0; // the analog pin that the sensor is on

int analogValue = 0; // the value returned from the analog sensor

int servoPin = 9; // Control pin for servo motor, must be a PWM pin
// the value representing the angle of the servo


void setup()
{

servoMotor.attach(servoPin); // attaches the servo on pin 2 to the servo object

} //end setup

void loop()
{
int servoAng = 0;
int sensArray [18];
servoAng = 0;
servoMotor.write(servoAng);
sensArray[0] = analogValue;

delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[0] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[1] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[2] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[3] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[4] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[5] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[6] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[7] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[8] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[9] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[10] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[11] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[12] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[13] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[14] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[15] = analogValue;
delay(1000);

servoAng = servoAng + 10;
servoMotor.write(servoAng);
sensArray[16] = analogValue;
delay(1000);

/* for (int servoAng = 0; servoAng <= 180; servoAng = servoAng+10) { servoMotor.write(servoAng); delay(1000); // this value is important because there is a minimum time the servo needs to return to it's point of origin }end for delay(10000); // set this delay to control reevaluation interval }// end loop

Having already informed my lab partner Laura C. that I am to be beat about the head and shoulders for such madness, I realized I needed to rethink my plan.

I decided to use an Array, to store the analog value. Using the Servo Degree (degCount) as the driver of the element indexing. This saved me from having to negotiate a multi-dimensional array. I Got some much needed clarity from
Craig Kapp and came up with this:





#include // include the servo library

Servo servoMotor; // creates an instance of the servo object to control a servo

int analogPin = 0; // the analog pin that the sensor is on
int analogValue = 0; // the value returned from the analog sensor

int servoPin = 9; // Control pin for servo motor, must be a PWM pin
// the value representing the angle of the servo


void setup()
{

servoMotor.attach(servoPin); // attaches the servo on pin 2 to the servo object

} //end setup

void loop()
{
/* Survey */
int capAng[180]= {0};
int degCount;

for (int degCount = 0; degCount <= 180; degCount++) { servoMotor.write(degCount); capAng[degCount] = analogRead(analogPin); delay(15); } //end suurvey int brightVal=0; int brightestDeg=0; for (int degCount = 0; degCount <= 180; degCount++) { if(capAng[degCount] > brightVal)
{
brightVal= capAng[degCount];
brightestDeg= degCount;
}//end if that evaluates brightest value and corresponding Angle
}// end analysis for loop

servoMotor.write(brightestDeg);
delay(10000);
}// end Loop
















Wednesday, February 11, 2009

Electronics Lab

My Lab Partner this week was Laura Ciporen.

With 4 AA batteries before the voltage regulator: 5.48, with regulator: 4.46
With 12V power supply, before regulator: 17.13, with regulator: 5.01
12V, regulator, 220ohms resistor, 1 LED: voltage across the resistor: 3.15, voltage across the LED: 1.79 (when switch is off, all V=0)
  • 3LEDs in series: V across resistor: .12, across 1st LED:1.63, across 2nd LED: 1.63, across 3rd:1.62
  • 3LEDs in series, no resistor: 1.68, 1.68, 1.67
  • Amperage measurements, 2LEDs in series, 220ohm resistor 12v power, power regulator: second LED=4.83mA, 1st LED=4.81mA, resistor=4.84mA




  • 3LEDs in parallel: resistor=3.2, all 3 LEDs=1.71


Goofy problem: we were using a push button switch and thought we were using a momentary switch. When we plugged the LED in, it lit up and we were confused but then pushed the switch and it went off so all is right with the world.

Notes to us: We discovered that to measure the resistance of a resistor (or other component) you have to remove it from the circuit (no power connected).
NOTE:When measuring the voltage across components, place the leads of the volt meter on the actual components, not into the board ( yields a more consistent reading).

  • We tried adding a 4th LED in series but none lit up.
We think this is because the minimum voltage required to light the red LEDs (the ones we were using) is 1.6 according to Mims.
  • Then we tried 3 green ones (min 2.2v) to test our hypothesis about the red ones and they did not light up.
  • Two green ones did. Confirming our theory.
The starting point for the LEDs to light up varies for LED color: 1.54 for red, 1.74 for yellow & green

Questions:
  • If we measure the voltage by putting the leads of the volt meter into the breadboard, what are we measuring?
  • When we do this and turn off the switch, the voltage across the resistor jumps to 3.64. That makes no sense to us.
  • When we were using the pot we were getting readings of 1.54 with the red LED. Then we switched to a yellow LED without touching the pot and got readings of 1.64. Why is that?
    -Different LEDs draw different amounts of current. So the Pot will draw have less Voltage to drop in it's resistor.

Wednesday, February 4, 2009

Observations

My partner for this was Andy Jordan

We left NYU around midday and went through Soho.

For the most part we saw people using phones, which at this point do not seem to require much concentration, it is something people do mindlessly. Clearly the goal is to contact people, which seems to happen effortlessly.
We went into the Apple Store where we saw people interacting with a variety of devices

Clock Radios: One person
Many of the people when interacting with them would often press the largest button on the device no matter what it did. "Eject, On/Off Volume". We both observed that they kind of "pecked" at them.
Wireless Checkout: Two people
Some Apple merchants were checking people out with there purchases. The transactions took about 120 seconds. I think it works well because the buyer does not have to make that trip to the Cashier. I can say for myself I have walked out of line (especially that line) several times putting my purchase back. This device helps to eliminate that impulse.

Genius Bar Line Queue: Multiple people
The line queue at the genius bar is managed by a sales associate armed with a laptop. users go to him and check in which takes about 10 seconds. This information is passed on the "Geniuses" which call up the people in the line. This allows people to queue in a more casual manner. Instead of having to physically stand in a line. They can mill about, saving energy.

Back on the street:
People listening to ipods and using their phones. Maybe it would be more interesting if people were lolly gagging in the warm weather but most people were moving about their business, not doing much

Week Two


Again my Partner this week was Laura Ciporen.

When we first reached out for this week's task we realized that our projects while different, could share identical code. We wanted to separate the analog values into ranges that would assign different outputs to each range.

In my case, I wanted to build a device that would measure the amount of finger pressure required to open a jar.

-A jar that is loose would register as Yellow.
-A jar that is the proper tightness would register as Green
-A jar that is too tight would glow Red.

Here is the code.

# define YelLED 2
# define GreLED 3
# define RedLED 4
# define HandSens 5
int HandVAL = 0;

void setup()
{
pinMode (YelLED,OUTPUT);
pinMode (GreLED,OUTPUT);
pinMode (RedLED,OUTPUT);
beginSerial(9600);
} //end setup

void loop()
{
HandVAL=analogRead(HandSens);
HandVAL=HandVAL/4; // converting value from 10bit to 8bit
Serial.println(HandVAL);
if (HandVAL <= 85)
{
analogWrite(YelLED,HandVAL+85);
digitalWrite(GreLED,LOW);
digitalWrite(RedLED,LOW);
}// end if
else if (HandVAL >= 85 && HandVAL <= 170)
{
digitalWrite(YelLED,LOW);
analogWrite(GreLED,HandVAL);
digitalWrite(RedLED,LOW);
}
else if (HandVAL >= 170)
{
digitalWrite(YelLED,LOW);
digitalWrite(GreLED,LOW);
analogWrite(RedLED,HandVAL);
}
else
{
digitalWrite(YelLED,HIGH);
digitalWrite(GreLED,HIGH);
digitalWrite(RedLED,HIGH);
}


delay(10);
}//end loop

You will see that we were hoping for each LED to ramp up in brightness as the analog value increased.
On our first observation the 1st LED in the analog range did not light up at all. The middle one seemed to show a visible varience in brightness and the third was bright with no ramping.
We realized that the by tying the output value to the sensor value HandVAL=analogRead(HandSens)
the lowest range would not be visible. So we added to the value
HandVAL+85
In an effort to "boost" it's brightness.

After further observation, it was determined that the lowest value LED did not even reach the threshold for lighting until the sensor was already through half of it's range. We tried remapping the values so that the threshold was the baseline.
This solution bore no fruit.
If the issue was one purely of computational origin the "boost" in the value should have resolved the issue. Since it did not, we began to look for other potential factors.

Since the LED was on a Digital Switch any brightness variance would need to be achieved using PWM. At the same time the LED has a minimum current (sustained current) to cross the junction within it.

We tried decoupling the 1:1 ratio of the sensor value to the LED output using various mathematical functions to try and give a better spread for the PWM but none of it seemed to produce any visible change in the brightness.

1- PWM is not good enough to display a difference?
2-perhaps there is a mathematical function that will solve this?

issue:
Middle LED seems to be the only with dynamic range (through very small)
1st and 3rd LEDs in series seem Binary.
How to Decouple brightness range from if/else switch range.
Hypotheses
1- PWM is not good enough to display a difference?
2-perhaps there is a mathematical function that will solve this?


Dap-O-Meter from Brian Jones on Vimeo.

FINAL

Untitled from Brian Jones on Vimeo.

Week One

I followed the schematic and everything flowed into place as planned. Laura and I then went over the project so that we knew HOW it worked. It was observed that what closed a circuit and what created a state change was different.
The next small modification was adding a blink to the red LED.