Tuesday, April 15, 2008

flex sensors don't solder


So for our wearable computing project I was planning on using two flex sensors to measure how straight someone's back was. Using this information you could have a tiny led that would light up on a person's wrist near their watch whenever they did not have proper posture.
they were loose so the professor suggested soldering for the finished project. I successfully soldered both of the sensors to the wires, or so I thought. After placing the sensors I put the shirt on. When I hooked the arduino board up to my laptop I was getting no values from the sensors. When I took the shirt off this is what I saw. ForI ended up taping sensors to the wires for the first iteration of the project comparison a 'good' sensor looks like this.


Now although this happened to both of them the other one was in slightly better shape. So I attempted to superglue the wiring to it. This was by far not my best idea.

The results don't look that bad. However they do not get any consistent reading. This has led me to realize that it is a good thing I do software for a living

Tuesday, March 25, 2008

code for dead reckoning

Here is the code to get raw print outs of the change in acceleration over the course of a second. The results are a little jittery but are roughly correct

/*
* Accelerometer dead reckoning
* by Arthur Johnston and Ryan Galgon
*
* Takes the acceleromter values and calculates the dead reckoning
* how far it has gone
*code assumes you are not moving in
*Sol-3 gravity at approximately 1 atmosphere, code is not guaranteed
*for non-standard operation or even standard operation
*/
//pins to get input from
int x = 0; // select the input pin for the potentiometer
int y = 1;
int z = 2; // variable to store the value coming from the sensor
int st=4;
//global value storage
int oldval[]={0,0,0};
int val[]={0,0,0};
//distances
//THESE MUST BE CHANGED TO int if anything but a second is
//used as the period
int xd=0;
int yd=0;
int zd=0;
//time period in microseconds don't forget to change multiplier
int period=1000;
//time period in seconds
int multiplier=1;
//ignore changes in acceleration under this value
int ignore=1;

//initial acceleration, these may not be needed
int ix;
int iy;
int iz;

//current speeds, these may not be needed.
int xs=0;
int ys=0;
int zs=0;
void setup() {
Serial.begin(9600);
//initializes position
oldval[0] = analogRead(x); // read the value from the sensor
oldval[1] = analogRead(y); // read the value from the sensor
oldval[2] = analogRead(z); // read the value from the sensor
//initilize all these speeds, code assumes you are not moving in
//Sol-3 gravity at approximately 1 atmosphere, code is not guaranteed
//for non-standard operation or even standard operation
ix=oldval[0];
iy=oldval[1];
iz=oldval[2];

}

void loop() {
val[0] = analogRead(x); // read the value from the sensor
val[1] = analogRead(y); // read the value from the sensor
val[2] = analogRead(z); // read the value from the sensor
print_out_raw();
calculate_speed_change();
calculate_position_change();
print_out_initial();
oldval[0]=val[0];
oldval[1]=val[1];
oldval[2]=val[2];
delay(period);
}
/* Since acceleration is the derivative of speed this code is actually
lying. using the equation acceleration=((speed0+speed1)/delta t)
and rewriting it gets the equation
speed1=(acceleration*delta t)+speed0, which is what we use*/
void calculate_speed_change(){

xs=xs + ((val[0]-oldval[0])/ignore)*ignore *multiplier;
ys=ys + ((val[1]-oldval[1])/ignore)*ignore *multiplier;
zs=zs + ((val[2]-oldval[2])/ignore)*ignore *multiplier;
//xs=xs + ((val[0]-iz)/ignore)*ignore *multiplier;
//ys=ys + ((val[1]-iy)/ignore)*ignore *multiplier;
//zs=zs + ((val[2]-iz)/ignore)*ignore *multiplier;
print_out_speed();
}

void print_out_speed(){
Serial.print("speed ");
Serial.print(xs,DEC);
Serial.print(" ");
Serial.print(ys,DEC);
Serial.print(" ");
Serial.println(zs,DEC);
}

void calculate_position_change(){
xd=xd+xs;
yd=yd+ys;
zd=zd+zs;
//xd=xd + ((xs)/ignore)*ignore *multiplier;
//yd=yd + ((ys)/ignore)*ignore *multiplier;
//zd=zd + ((zs)/ignore)*ignore *multiplier;
print_out_position();
}

void print_out_position(){
Serial.print("position ");
Serial.print(xd,DEC);
Serial.print(" ");
Serial.print(yd,DEC);
Serial.print(" ");
Serial.println(zd,DEC);
}


void print_out_raw(){
Serial.print("absolute ");
Serial.print(val[0]);
Serial.print(" ");
Serial.print(val[1]);
Serial.print(" ");
Serial.println(val[2]);
Serial.print("relative ");
Serial.print(val[0]-oldval[0]);
Serial.print(" ");
Serial.print(val[1]-oldval[1]);
Serial.print(" ");
Serial.println(val[2]-oldval[2]);
}


void print_out_initial(){
Serial.print("initial ");
Serial.print(ix,DEC);
Serial.print(" ");
Serial.print(iy,DEC);
Serial.print(" ");
Serial.println(iz,DEC);
}

Sunday, March 23, 2008

Fun with the accelerometer and headers

So while working with are accelerometer I discovered after a significant amount of trial and error that the header we were using to connect the breakout board to the breadboard was not giving a good connection. This meant that the reason we were getting 'wonky' values was because we were not getting any response. So now that there are real values to work with I can start playing around.

Wednesday, March 19, 2008

Blink Project




For the blink project we simply had to create a LED that blinks based on both digital and analog inputs. To do this I used a digital switch and a thermostat. The digital switch determined if the LED could even be on, that was a hard control.
The temperature control actually was a problem at first. I wanted the the LED to blink based on the change in temperature. Unfortunately the change in temperature was very low so it had to be scaled so that the amount of time the LED was on was noticeable. I also found that the project worked better when I took the ambient temperature at boot up and based all of the changes in temperature off of that. It can all be seen in the code.
The second main problem was more of a logistics problem. I foolishly did not cut a long enough piece of wire for power, although this did not cause a huge problem it made my wiring more confused. As you can see in the picture it looks like there is no power running from the board.

The main things I learned from this first project are that:
1. Hardware takes longer than software
2. Bring enough supplies for the project
3. Temperature sensors are not as much fun as I though

Friday, March 14, 2008

first week

So in the first week of Physical Computing we learned about basic electronics (which was helpful since the last time I did any was high school) and how to use our Arduino boards for programming projects. We also reviewed Ohm's law which reminded me of a problem I once spent about 4 hours on without any results. Class was interesting and I already have an idea for the wearable computing project, which involves using the Arduino board to correct posture.