Tuesday, December 14, 2004

Coffeetable Project

For my final PComp project I worked on a coffeetable built from printers that I found on the streets of New York. Check it out.

http://www.base2john.com/itp/coffeetable/

Saturday, December 11, 2004

Radio project

Chia H and I took an old radio and attempted to make it a history machine full of campaign commericals from Presidental elections.

Thursday, October 21, 2004

Shoe Pictures



Wednesday, October 20, 2004

PIC Shoe Code

input portc.7
INPUT portb.7
output portc.6
inputVar VAR byte
pot1 VAR WORD ' Create variable to store result
pot2 VAR WORD
buttonVar VAR WORD


' POTENTIOMETER SETUP
' Define ADCIN parameters
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS


TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
PAUSE 500 ' Wait .5 second


'-------------------------------------------------------


main:
ADCIN 0, pot1 'potentiometer variable
ADCIN 1, pot2 'potentiometer variable
pot1 = pot1/4 'divide the value because it's too big
pot2 = pot2/4


'----------------------
' THE LISTENING CODE - puts message into inputVar
serin2 portc.7, 16468, [inputVar] 'listening for potentiometer value
if portb.7 = 1 then
    buttonVar = 1
else
    buttonVar = 0
endif


if inputVar=65 then ' if received message is 65, then respond to processing


'usage: serout2 dataPin, mode, [data]
serout2 portc.6, 16468, [pot1,pot2,buttonVar] 'talk to processing
ENDif


goto main


nodata:
return

Processing Shoe Code

float[] data = new float[3]; // create 2 space data array. 1) Potentiometer and 2) photocell
int index=0;
float xpos,ypos;
int bck;

int[] dotsXpos = new int[30];
int[] dotsYpos = new int[30];
int dots;

void setup() {
background(0);
size(305,305);
beginSerial(); //begin serial communication thing
serialWrite(65); //talk to PIC . like saying hello
}

void loop() {

fill(0,140,140);
noStroke();
ellipse(xpos,ypos,3,3);

for (int i=0;i if ((dotsXpos[i] != 0) && (dotsYpos[i] != 0)) {
fill(255,255,0);
noStroke();
ellipse(dotsXpos[i],dotsYpos[i],10,10);
}
}

if (bck==1) {
dotsXpos[dots] = int(xpos);
dotsYpos[dots] = int(ypos);

if (dots>30) {

dots= 0;
}
else {
dots = dots++;
}
}
}

void serialEvent() { //automatic serial listener
data[index] = serial; // save messages to data array
index=index+1; // increment serial counter

if (index==3) { // both messages received
ypos = 255 - float(data[0]); // rename the first message to xpos
xpos = float(data[1]);
bck = int(data[2]); //save photocell value
serialWrite(65); // responsd back to PIC
index = 0; // reset serial counter to zero
}

}

Sunday, October 17, 2004

serial and processing code

PROCESSING CODE

float[] data = new float[2]; // create 2 space data array. 1) Potentiometer and 2) photocell
int index=0;
float xpos;
int bck;

void setup() {
size(255,255);
beginSerial(); //begin serial communication thing
serialWrite(65); //talk to PIC . like saying hello
}

void loop() {
background(bck);
fill(0,0,244);
ellipse(xpos, 100, 50,50); //movable circle

}

void serialEvent() { //automatic serial listener
data[index] = serial; // save messages to data array
index=index+1; // increment serial counter

if (index==2) { // both messages received

xpos = float(data[0]); // rename the first message to xpos
bck = int(data[1]); //save photocell value
serialWrite(65); // responsd back to PIC
index = 0; // reset serial counter to zero
}

}



'----------------------------------------
PIC CODE


input portc.7
output portc.6
inputVar VAR byte
sensorValue VAR WORD ' Create variable to store result
photoValue VAR WORD

' POTENTIOMETER SETUP
' Define ADCIN parameters
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS

TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
PAUSE 500 ' Wait .5 second

'-------------------------------------------------------

main:
ADCIN 0, sensorValue 'potentiometer variable
ADCIN 1, photoValue 'photocell
sensorValue = sensorValue/4 'divide the value because it's too big

'----------------------
' THE LISTENING CODE - puts message into inputVar
serin2 portc.7, 16468, [inputVar] 'listening for potentiometer value

if inputVar=65 then ' if received message is 65, then respond to processing
gosub blink 'blink LED
'usage: serout2 dataPin, mode, [data]
serout2 portc.6, 16468, [sensorValue,photoValue] 'talk to processing
ENDif

goto main


blink:
high portd.2
pause 250
low portd.2
pause 250
return

nodata:
return

Wednesday, October 13, 2004

Servo control not sooo bad but...

Ok, so on Friday night I began testing out the servo motor more. I got the motor to move both from a program and from a potentiometer.

After taking the code from the website to make the servo move to the left then to the right I wanted to add in some buttons to control the direction. This took some figuring out but eventually I understood that the pulsewidth that the PIC is sending out must stay between two constants: minPulse and maxPulse. While I'm not totally sure if this is correct but pretending the pulseWidth is a degree element 0 degrees to 200 degrees (more like 180) it was easier to see how the variable referred to position.

here's the code for the button servo action.

===========================================

INPUT portd.1
INPUT portd.0
OUTPUT portc.3

start:

pulseWidth VAR BYTE
' set up constants with the minimum and maximum pulsewidths
minPulse CON 50
maxPulse CON 250
' set up a constant with the time between pulses:
refreshPeriod CON 20

' set an initial pulsewidth:
pulseWidth = minPulse

main:
' change the angle for the next time around:
IF (pulseWidth <= maxPulse) AND (portd.1=1) THEN
pulseWidth = pulseWidth+1
GOSUB move
HIGH portd.2
ELSE
pulseWidth = pulseWidth
LOW portd.2
ENDIF

' change the angle for the next time around:
IF (pulseWidth >= minPulse) AND (portd.0=1) THEN
pulseWidth = pulseWidth-1
GOSUB move
HIGH portd.3
ELSE
pulseWidth = pulseWidth
LOW portd.3
ENDIF
GOTO main

move:
'take the output pin low so we can pulse it high
LOW PORTC.3
' pulse the pin
PULSOUT PORTC.3, pulseWidth
' pause for as long as needed:
PAUSE refreshPeriod
RETURN


===========================================
and a button servo picture.



I got the code for the servo to be controlled by a potentiometer and tried it out.
===========================================


' Define ADCIN parameters
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS

sensorValue VAR WORD ' Create variable to store result

TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
PAUSE 500 ' Wait .5 second

pulseRange VAR WORD
pulseWidth VAR BYTE
' set up constants with the minimum and maximum pulsewidths
minPulse CON 50
maxPulse CON 250
' set up a constant with the time between pulses:
refreshPeriod CON 20

' set an initial pulsewidth:
pulseWidth = minPulse
pulseRange = maxPulse - minPulse

main:
ADCIN 0, sensorValue
'take the output pin low so we can pulse it high
LOW PORTC.3
' pulse the pin
PULSOUT PORTC.3, pulseWidth
' pause for as long as needed:
PAUSE refreshPeriod


pulseWidth = minPulse + (pulseRange * (sensorValue/10)) / 100

' change the angle for the next time around:
'IF pulseWidth > maxPulse Then
' pulseWidth = minPulse
'Else
' pulseWidth = pulseWidth + 1
'Endif

GOTO main

==========================================




I have another project from sustainable energy that I am working on that involves solar panels. I will post some information about that later on but think about charging a capacitor from a solar panel and then releasing it when it reaches a desired voltage. It makes a project very organic in the sense that it totally depends on the sun for life. I think these will make incredibly interesting opportunities for advocating alternative energies.

See you all in class.

Monday, October 11, 2004

The completed broccoli bot

So my first Physical computing project is finished. Last Wednesday we presented it to the class. As a review , the project proposed was suppose to enhance or change a space. We picked a supermarket and eventually made it to the idea that a talking piece of broccoli would be a nice enhancement for a shopping experience.

Purchased items include

Teenage Mutant Ninja turtle - Toys'R Us - $8
Felt - Canal Street - ~$10
Balloons - Party City - $5

5V Relay - Radio Shack - $3
Candy Corn (container) - CVS - $.99 (switch)

The project was a good experience for the first one, I really appreciated getting feedback from others and their ideas for it. While time constraints made it impossible to adjust this project I will be sure to talk up my ideas earlier on to get to use some people's ideas.

Lamar and I had both pleasant and stressful moments getting this to work. It's good to take breaks, walk away and just not think about certain pieces of the puzzle. And when all else fails ask Todd!

Here's a picture of the completed switch


On the top left is the homemade switch from a candy corn container, two metal threaded rods and a metal ball. The ball uses the two rods as contacts and becomes a rocker bumpin switch. The PIC is able to determine if the switch is open or closed and control the tape recorder from that contact. Here's a closer look.


A closer view of the breadboard is easier to follow so look at this.

On the bottom right of the board you'll see the typical 5V regulator we have been using in class since the beginning. The bottom bus has 5V in it and powers the switch (currently out of the picture) and the PIC. On the top bus is the power for the tape player - at the top left of the board we made an adjustable voltage regulator and this was described earlier - basically the adjusted voltage on the top bus is 3.7 V and this was enough to power the cassette recorder.

Using two 9V batteries we tested the voltages again and then we went to construct the broccoli. First blow up the bop bag. Next cover it in green felt and then balloons. Place board and tape player in the head region.
Enjoy these.





We didn't get permission to test the broccoli in the grocery store and I still think we should have just ran in and took the photos and left but something was in the air those last nights telling me to behave. So we took it out on the streets and had some people touch it.

The basic problems:
Interface - no one has really been standing next to a 33" tall vegetable before and they certainly don't want to break it and or knock it over. People need to know what they can and can't interact with, the broco gave mixed emotions and some people were just avoiding it. certainly no interaction from avoidance....or is there?

Listening - so if a piece of broccoli was going to talk to you would you listen? how is it going to be relevant? do you think you would respond back? Then what? If the broccoli had a large knowledge about a supermarket like where to get certain foods or products then the broco bot might help people shop - but that's what clerks are for too.

Having to do it again I think I would make the broccoli bigger and more durable. It's current size would be slayed by a normal shopping cart. I think there needs to be more affordance for people to know how to use it and probably not a sign like Andrew said. Could it constantly sway or bop back and forth to get people's attention and then use a proximity meter to know when to start talking?

I'm happy with the work, but I'm happier now because I know more technology and code to do more interesting things. but yea, baby steps.

Lata,

Saturday, October 02, 2004

code for PIC

main:

if portc.3 = 0 then
high porta.0
pause 10000
low porta.0
endif
goto main

this looks for an open switch and then turns pin A0 HIGH for 10,000 milliseconds. While the pin is HIGH the relay is closed and current flows for 10 seconds.

Candy Corn Switch

Yesterday we made a switch out of a candy corn cylinder from CVS pharmacy. Placing two parallel metal screws through the container the metal ball would close the switch when both contacts (screws) were touched. If bumped the ball rolls forward off the contacts and the switch is closed. This is where we will program in some logic to use the open switch to play the tape player for a few seconds.

All in all the switch isn't pretty but it works - no real need for asthetics because it will be hidden inside the head of the broccoli.


Will post pictures later.

----------------------------------------------------
Building the circuit.

We built a circuit with 2 different voltages on 2 separate buses. 1 with 3.7volts from the adjustable voltage regulator and the other bus with regular 5V. We discussed the situation and knew that we must keep the buses separate all the time and the closest they can get is at the reed relay. We programmed the PIC and then set up the relay and after some simple debugging we had the switch controlling the power of the tape recorder.

Today, saturday, we will clean up the board's wiring and test it out with 2 9V batteries.

Wednesday, September 29, 2004

Babysteps to the Broccoli bot

Hello.

On Saturday Lamar and I got to work on one of essential parts of our project. The project involves enhancing or changing the space at the supermarket. After observing the location we found that the most evident activity was the cart's role in shopping. Carts always tend to avoid each other and the people pushing them also avoid crashing into shelves, end displays and shoppers. Would it be possible to use the cart to enhance the environment ?

Jumping ahead, after a few ideas we decided that a giant inflatable piece of broccoli in the vegetable aisle would be a nice addition to a sometimes quiet environment. The broccoli would be a dressed up inflatable clown and when bumped by a cart would tell shoppers fun broccoli facts and cooking tips.

Now to talk about parts and construction needs.
1) inflatable clown was found on froogle at a kids store for $6.55 (plus $5 shipping, ugh) http://www.kidsurplus.com. Fedex delivered the clown yesterday but to whom I don't know. Kid Surplus's customer service is on the case now. Hopefully I'll have it by Monday night.

2) Felt - purchased down on one of the many fabric stores near canal and broadway. $6/yard^2.
3) Relay switch - 5V reed switch from radio shack - be persistent with the staff there they may try to tell you that they're out of parts.

other parts: breadboard, PIC 18F452, microcassette recorder and adjustable voltage regulator.

The adjustable voltage regulator was a new combination of components we learned about from Todd and was used to power the microcassette recorder. The way the the action will project will work is :

1) cart bumps broccoli
2) a switch is activated - tells PIC to turn on the microcassette recorder
3) PIC keeps the tape playing for about 15 to 20 seconds.

The microcassette recorder will be run off a relay switch, controlled by the PIC because a normal switch will won't be able to hold for a set amount of time. No big deal.

Next the idea came to me that the cassette recorder only needed 3 volts to run. it only had 2 AA batteries. would it possible to run the cassette player off the PIC's power from a pin that is turned on - it's output is 5V! Just to keep you all from wasting your own time, no you can't run a 3V cassette player off a 5V output pin from a PIC...simply because of the amps involved in starting and moving the player's tiny motor.

Here's a picture of the voltage regulator that we built. parts include a L3M17 voltage regualtor, trim pot, and 330 ohm resistor.





The main purpose of this setup was to give the cassette player the right voltage and amps that it needed. I'm still not entirely sure of the physics but the trim pot was adjusted with a screwdriver and measured with a multimeter. The voltage we were looking for was 3 - 3.5V. We set it to 3.5. After testing the new current on the player it worked. horrah!

Next step was to connect the player to the relay, and connect the relay to the PIC. This was a troubled spot because the relay we had was a piece of crap. the legs were too small and didn't sit in the breadboard. We went to radioshack and got a good reed relay the same as we saw in class. In a matter of 5 minutes after getting back to ITP we had that relay working with the PIC controlling the relay, the relay switching the player.

After the pleasure of our little hack subsided we called it a day. Some things still needed are the clown switch that activates when bumped by the cart or person. I am thinking that we need a small metal BB and some wires. As the clown sits still, the BB will have the switch closed, sitting on top of 2 wires. When the clown is bumped the BB rolls off the wires and now the switch is OPEN. The PIC will quickly see that the switch is open and turn the player on for a set amount of time. The BB will return to the dimple it nests in and the switch will close again, this happens as the clowns slowly settles down. The player is not controlled by the BB switch but is working from the PIC.

more later, hopefully when the clown comes in.

Thursday, September 23, 2004

Analog input with the PIC

I'm working on the analog input with the PIC controller right now. This is interesting - thinking of all the applications that use this type of control, potentiometers are in stero volume and tuning knobs, in flex sensors and in measuring temperature.

I hooked up a potentiometer to my PIC at RA0 which is the second pin on the top left of the chip - just under the 10K resistor. There is also a serial cable connected to the computer to display the value of the potentiometer or any variable resistor. Displaying from 0 to 1023 you can use this variable to control other elements on the board.




Later on I replaced the potentiometer with a photocell and had to add a 10k resistor with it to keep the current smooth. still not sure what that means. The resistor and a leg of the photocell was plugged into RA0 and the second leg of the photocell was plugged into ground.



The code I was working on was a distance location system. If nothing obstructed the light then the green LED stayed on. If a shadow or hand came into view of the photocell the yellow light would turn on (green off). If the shadow/hand got to close the red light turns on, and if impact occurs the red LED blinks.




here is the code.

'------------------------------------------------------------
' PicBasic Pro program to display result of
' 10-bit A/D conversion through serial at 9600 baud
'
' Connect analog input to channel-0 (RA0)

' Define ADCIN parameters
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS

ADCvar VAR WORD ' Create variable to store result

TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
Pause 500 ' Wait .5 second

main:
ADCIN 0, ADCvar ' Read channel 0 to adval
serout2 PORTC.6, 16468, [DEC ADCvar, 13, 10] ' print it to serial out,

'determine the analog input and control the LEDs
SELECT CASE ADCvar
CASE IS > 820 'blink red led
high portd.6
pause 250
low portd.6
pause 250
low portd.5
low portd.4
CASE IS > 680 'turn on red led
high portd.6
low portd.5
low portd.4
CASE IS > 575 'turn on yellow led
low portd.6
high portd.5
low portd.4
CASE else ' keep green led on
low portd.6
low portd.5
high portd.4

END SELECT

'Button Code here
if portb.0 = 1 then ' if the switch is closed on pin RB0
low portd.0 ' set pin RD1 low
else
high portd.0 ' set RD1 high
SEROUT2 portc.6, 16468, ["Hello World!", 13, 10]
endif
GoTo main
'-------------------------------------------------------------------

The difficulties today came from the BASIC programming language. I ended up finding the error. After using IF THEN statements I decided to test out the SELECT CASE statement and use it instead. I forgot to remove the THEN statement and the compiler caught it. After referencing the manual I found my error. Compile then Programmer then test and hoorah!

It's simple enough. I'm going to look for a simple device to attach but will keep the board as is until class. Also bought some more jameco products so I'll have more to play with, the flex sensor should come next week.

Wednesday, September 22, 2004

Updated code.

In class right now and just learned that the code for the serial communications was a bit jumbled. I have the new code now and will change it tonight.

if you can't wait to see the code here you go:
SEROUT2 portc.6, 16468, ["Hello World!", 13,10]

the 13, 10 was switched previously. here is the website for serial communication with the PIC - http://stage.itp.tsoa.nyu.edu/%7Etigoe/pcomp/code/archives/000568.shtml

mr. board meet mr. computer

output from my serial communication test is a success. soldered the headers to the serial piece. check this out...

Hello Wo2ld!
Hell/ World!
HòHello WoòHello World!
Hello World!
€‹ë ºHª±±½World!
Hello World!
Hell World!
HelloÿWorld!
ello WoRld!
HÉllo World!
Hello World!
HËllo ׽ɱ‘…
Hello World!
ý

here's the code.

'---------------------------------------------------------
input portb.0
output portd.0
OUTPUT portc.6

main:
if portb.0 = 1 then ' if the switch is closed on pin RB0
low portd.0 ' set pin RD1 low
else
high portd.0 ' set RD1 high
SEROUT2 portc.6, 16468, ["Hello World!", 10, 13]
endif

goto main
'---------------------------------------------------------

Hello world indeed. not sure why the characters are goofy but it works. next i'm going to wire my pants to talk to my shoes and my shoes to talk to the floor. it's gonna be great.

Saturday, September 18, 2004

Blinkie and the Pic

18F452, sort of rolls off your tongue however it's bit intimidating at first. it's just a black little piece of plastic and metal, perhaps there's more inside the electronic insect. I have programmed Basic stamps before and I was just as anxious about the first success as getting the PIC to work.

Here's a quick run through of the events that occurred:
Thursday, September 16th
- 9:45AM Fedex arrives with free sample chips from MicroChip(.com)
- 2:30PM Get PIC programmer and set up in Lab
- 3:05PM First LED is blinking from the simple program on the chip.

Now that the first program is working and I understand the process of getting the code onto the chip I am much more comfortable with the needed technical knowledge.

The first program was to make an LED blink. Here's the code

'---------------------------------------------------------
main:
high portd.0 'turn LED on
pause 500 'wait half second
low portd.0 'turn LED off
pause 500 'wait another half second
goto main 'loop
'---------------------------------------------------------

The code wasn't new to me but the process of using a programming environment, compiling and then writing the program to the chip was. After writing to the chip, removing it from the cradle and placing it correctly onto the breadboard was an extra step that the Basic stamp avoided.

here are some pictures of the final products.




After getting the LED to blink I added a switch to the circuit. If the button was pressed, pin B.0, the LED, pin D.0 would turn on. If released the LED would turn off. here is the code...

'---------------------------------------------------------
input portb.0
output portd.0

main:
if portb.0 = 1 then ' if the switch is closed on pin RB0
low portd.0 ' set pin RD1 low
else
high portd.0 ' set RD1 high
endif
goto main
'---------------------------------------------------------


After the switch worked I decided to stop there. I will probably do more this weekend, play with some sensors and variable resistors.

Oh, yea, ArtBot is this weekend. get there.

Monday, September 13, 2004

First lab - getting the breadboard to work

OK, so the first lab went really well. It was all very satisfying even if some experiments did not work out completely. I was in the lab, playing, for about 3 hours on Monday afternoon. My first job was to get the power adaptor plug soldered and working. Todd was giving a quick demonstration and I watched his soldering techniques carefully... shouldn't be too difficult. So the iron is hot and ready, I tin the tip of the iron with solder and quickly sponge it. ok, all's good so far. Now i'm trying to get the solder onto the wires of the adaptor and this turned out to several attempts and about a half hour till I was satisfied.

The best tip I discovered when heating and applying solder is to get the components hot then touch the solder with the heat. When a drip connects the pieces together, slowly pet the droplet with the tip and edge of the iron, it really smoothed out the last spots I was fixing. Here is a picture of the adaptor with wire soldered.


Next was time to test the power. I put a 5V voltage regulator on the board, with some jumpers going to the bus runs. I had a LED and resistor to verify power. And tada!


I decided to make the breadboard look nice and neat the entire time. So I started to trim the jumpers down and place the power test LED at the bottom of the board.


The rest of the time in the lab I spent playing around rearranging and finding misc. electronics to plug into the board. The first test was the LED chaingang. 2 LED's worked in serial, 3 didn't.


I soldered my Potentiometer with the Red (power), Green (data), black (ground) and plugged it into the board to vary the resistance of my LED. Once I got the correct RGB wiring and not RBG the poteniometer was easy to use.


Next I replaced the Potentiometer with a photoresistor. I like the photoresistors, I think I will explore them more later - perhaps to detect shadows and shapes of shadows.


After some searching the junk shelf I found a little speaker, a noisemaker. Similar to the annoying sound of a smoke detector, the potentiometer made it a little fun -like a poorly made guitar.


Found a momentary switch/button on the shelf and replaced the potentiometer. I made a little horn.


Towards the end of the experimenting I found an old Microsoft mouse which I quickly chopped the end off of to see what wires lay inside. There were 5 - red, black, white, blue and orange. I hooked up the red and black to the power and ground then took all the wires from the blue, white and orange and twisted them together to make them share their juice. My multimeter found 5V at the red and black connection but nothing happened elsewhere. It would have been neat to use the mouse to vary the resistance and make the noisemaker play. I'll google microsoft mouse wiring right now and see if I can find anything.

Wednesday, September 08, 2004

Test Post

mm, electrons!