Physical Computing, spring 2006


Lab 1: Electronics

Sai and I met and with suggestions from Rob Faludi we soldered the power and ground wires to the power connector and plugged this is to the power supply. LED's lit up!! Here are pictures with the LED's on and off:

The first experiment we used a switch, the second I was able to light up two LED's on the board, but because they each require about 2.5V and I was using a 5V regulator only two lit up at once. It was also important to use the 'A comes before C' mnemonic to remember that the anode gets the energy first and flows to the cathode.

I was able to then use a photocell and a potentiometer as variable resisters with two LEDs?. And figured out the difference between serial and parallel----visibly as parallel can power many more LEDs? than serial which can only support 2 LEDs? simultaneously.

For my 'creative' switch, I used a wheel and a spring as the power and an open/exposed ground wire connected to the breadboard. Each time the wheel spun and connected to the ground the green LEDs? would light up. Often this was a flickering light, and the sound of the spring hitting the spokes of the wheel made an interesting sound. Here are two pictures:

Lab 2: Digital I/O

I wired my breadboard including jumping the power and ground to the other side allowing for more options. For 'smoothinn' I included capacitors: 1 where power comes in, 1 on the bus where power is coming out and two at the side of the PIC chip. I was able to program the PIC chip but got an error initially because it was not set for my particular PIC chip. Once this was fixed I had no problem programming the chip. First part of the lab, I got the chip plugged into the board and blinked my LED. Here are two pictures:

Here is a combo of the second and third parts of the lab, using a switch to control two separate couples of ports using one LED each. I was hoping to include a little video here, but it seems to be too big to upload. I also forgot to grab my code, I'll try to include if I can get into the firmware lab before class.

Attach:lab2_Medium.mov

Here is the code: input portd.2 output portd.1 output portd.0 output portd.3 output portc.4 main

	if portd.2 = 1 then ' if the switch is closed on pin RB0?
		goto sausage' set pin RD1? low
	else
		goto patty	' set RD1? high 
	endif 

sausage:

	high portd.0
	pause 500
	low portd.0
	high portd.1
	pause 500
	LOW portd.1

return

patty:

    HIGH portd.3
    pause 500
    low portd.3
    high portc.4
    pause 500
    LOW portc.4
    Return


Lab3 I tried running the following code initially to be sure that I could read serial input from the POT to the computer and nothing happened. Any thoughts?

' 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 4 ' 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, 
                               ' with linefeed and carriage return (10, 13)	

GoTo? main ' Do it forever


Here is my code for Week 3! I finally got it to work! I'll post video of my six LEDs? lighting up with the potentiometer. Things to always do: blinky (to make sure that the chip is okay), put an on/off switch up at power so you don't have to keep plugging the board.

DEFINE OSC 4

DEFINE ADC_BITS 8 DEFINE ADC_CLOCK 3 'inside of the chip DEFINE ADC_SAMPLEuS 20

INPUT PORTA.0 OUTPUT portc.0 OUTPUT portc.1 output portc.2 output portc.3 OUTPUT portc.4 OUTPUT portc.5

ADCON1? = %00000010 '% means binary notation or base two - counting system -

adcVar var byte

main:

adcin 0,adcvar 'adcin = analog to digital convertor in '0 = go to channel 0 (pin an0) and tell me how much electricity you see 'adcVar = the numbers are going to be between 0 - 255

if adcvar > 10 and adcvar < 25 then portc = %00000001

ENDIF

IF adcVar > 24 AND adcVAR < 40 THEN portc = %00000011

ENDIF

IF adcVar > 39 AND adcVar < 55 THEN portc = %00000111

ENDIf?

IF adcVar > 54 AND adcVar < 60 THEN portc = %00001111

ENdif?

IF adcVar > 59 AND adcVar < 75 THEN portc = %00011111

endif

IF adcVar > 74 AND adcVar < 90 THEN portc = %00111111

endif

serout2 PORTC.6, 16468, [DEC ADCvar?, 13, 10] ' print it to serial out, ' with linefeed and carriage return (10, 13)

goto main

Attach:file.ext Δ


Lab 4: I got my audio jack soldered and ready to go, but when it came time to run the program I was unsure about the wiring for the board and did not want to blow up anything. I borrowed speakers from the ER but they were not 8ohm speakers which is what the circuit diagram was intended for. I can probably solve this tomorrow. Realization: don't worry just plug stuff in and try it. This method works well.

Update: I got the audio output working from the microchip working: here's the code: define osc 4 Start: output portd.2

'declare an array of 26 word variables ie pitch: pitch var word(26)

'declare other variables: note var byte thisNote var word

'scale: pitch(1) = 11 ' pitch(2) = 22 ' pitch(3) = 33 ' pitch(4) = 44 ' pitch(5) = 55 ' pitch(6) = 66 ' pitch(7) = 77 ' pitch(8) = 88 ' pitch(9) = 99 ' pitch(10) = 111' pitch(11) = 122 ' pitch(12) = 133 ' pitch(13) = 144 ' pitch(14) = 155 ' pitch(15) = 166 ' pitch(16) = 177 ' pitch(17) = 188 ' pitch(18) = 199 ' pitch(19) = 211 ' pitch(20) = 222 ' pitch(21) = 233 ' pitch(22) = 244 ' pitch(23) = 255 ' pitch(24) = 266 ' pitch(25) = 277 ' pitch(26) = 288 '

main: For note = 0 to 26 'so we put the pitch into normal word variable: thisNote = pitch(note) 'play note: freqout portd.2, 500, thisNote, thisNote next goto main

Here is my group's observation project for the tool. http://itp.nyu.edu/~ms1434/pcomp/index.php/ToolS06/Group1


Week 5: I got this code working with serial in although it would not print: 'guess again' Found out how easy it is to mess up the order of serial TX and RX. Also, it is not the best to solder in right angle headers to serial connector since this takes up a big chunk of breadboard space.

DEFINE OSC 4 myvar var byte inbyte var byte

OUTPUT PORTD.1

HIGH PORTD.1 PAUSE 500 LOW PORTD.1 PAUSE 500 HIGH PORTD.1 PAUSE 500 LOW PORTD.1 goto main

main:

serin2 portc.7, 16468, [inbyte]

    if inbyte = 65 then
        serout2 portc.6, 16468, ["you got me", 13, 10]
    else    
        serout2 portc.6, 16468, ["guess again", 13, 10]
    endif

goto main

Then I got this code working, there is a photo of my board below:

DEFINE OSC 4

DEFINE ADC_BITS 8 ' notice we use 8 bits so we can send just a byte DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEuS 20

ADCON1?? = %00000010 'this changes between 10 bit and 8 bit

TRISA = %11111111

GreenLed? var portd.1 YellowLed? var portd.0 txPin var portc.6 'this will be the pin that I transmit from rxPin var portc.7 'this will be the pin I receive on

output greenled output yellowled output txpin input rxpin

potVar var byte 'a variable to hold the adc value of my pot photoVar var byte 'holds the adc value of my photocell fsrVar var byte 'holds fsr value blinky var byte 'just a dummy variable to use when I want inbyte var byte 'this holds the data we get from the computer

for blinky = 0 to 5

    greenled = 1
    pause 200
    greenled = 0
    pause 400

next

main:

serin2 rxpin, 16468, [inbyte] 'here wait for a byte to come in at 9600baud

    high yellowled 'tells that you gor data
    if inbyte = 65 then
        high greenled 'tells that you got a 65
        adcin 0, photovar   'get adc value from channel 0 put in photovar
        adcin 1, potvar
        adcin 2, fsrvar
        serout2 txpin, 16468, [DEc? photovar, "is photoVar", dec potvar, "is potVar", dec fsrvar, "is fsrVar", 13, 10]
        'this sends out in binary the value of our analog inputs and a switch

        'serOUT2 tx, inv9600, [DEC outputData, " means...", outputData, " in ASCII",10]
    endif
    low yellowled
    low greenled

goto main


Got this code working with processing: DEFINE OSC 4

DEFINE ADC_BITS 10 ' we are going to get an adc value 0 - 1023 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEuS 20

ADCON1? = %10000010

TRISA = %11111111

GreenLed? var portd.1 ' was redLed YellowLed? var portd.0 'was blueRed Sw1 var portb.6 'this will be a switch??? txPin var portc.6 'this will be the pin that I transmit from rxPin var portc.7 'this will be the pin I receive on

output greenled output yellowled input sw1 ? output txpin input rxpin

potVar var word 'a variable to hold the adc value of my pot photoVar var word 'holds the adc value of my photocell blinky var byte 'just a dummy variable to use when I want inbyte var byte 'this holds the data we get from the computer

for blinky = 0 to 5

    greenled = 1
    pause 200
    greenled = 0
    pause 400

next

main:

serin2 rxpin, 16468, [inbyte] 'here wait for a byte to come in at 9600baud

    high yellowled 'tells that you gor data
    if inbyte = 65 then
        high greenled 'tells that you got a 65
        adcin 0, photovar   'get adc value from channel 0 put in photovar
        adcin 1, potvar
        serout2 txpin, 16468, [dec photovar, 44, dec potvar, 44, dec sw1,44, 13]
        'this sends out in ascii the value of my different variables and 
        'switch, delineated by 44s and ended by a 13
    endif
    low yellowled
    low greenled

goto main

Here is the processing code, photo and a little video documentation:

// Original Example by Dan O'Sullivan (with apologies to Tom Igoe) // Heavy mods by Shawn V.

import processing.serial.*; // The import for the serial library

Serial myPort; // The serial port object

int slide; // A variable to hold our slider value int light; // A variable to hold our photocell value int button; // A variable to hold our button value

char DELIMITER = 44; char ENDLINE = '\r';

String savedSerialData = "";

void setup() {

  // List all the available serial ports: 
  println(Serial.list()); 

  size(600,600);

  // I know that the first port in the serial list on my mac 
  // is always my  Keyspan adaptor, so I open Serial.list()[0]. 
  // Open whatever port is the one you're using. 
  myPort = new Serial(this, Serial.list()[0], 9600); 

  //prime the pump in case your microcontroller is stuck in serin 
  myPort.write(65);

}

void draw() {

  background(0);

  fill(255,light,255);  // Use the photocell value to set our Blue fill

  if (button == 1) // If our button is pressed
  {
    ellipse(slide,100,100,100);  // Draw an elipse based on the slider value
  }
  else  // If our button is not pressed
  {
    rect(slide,100,100,100);  // Draw a rect based on the slider value
  }

}

// Our callback function for serial, gets executed whenever serial data is available void serialEvent(Serial p) {

  String serialData = myPort.readStringUntil(ENDLINE);

  if (serialData != null)
  {
    //println(serialData);
    String[] parsedSerialData = split(serialData, DELIMITER);

    //println(parsedSerialData.length);
    int[] serialDataInts =  int(parsedSerialData);
    if (serialDataInts.length >= 3)
    {
      light = serialDataInts[0];
      slide = serialDataInts[1];
      button = serialDataInts[2];
    }
    /*int servoRange = 250-65;//this is if you want to send servo data out
    float percentageAcross = mouseX/float(width);
    int servoOut = int(servoRange*percentageAcross) + 65;
    myPort.write(servoOut);
    */
    myPort.write(65);
  }

}


I spent all of this week on our tool project. Mostly this consisted of wiring and re-wiring an ISD 2590 chip in order to record and then have the capacity to playback audio from the PIC. Well, we're not exactly where we want to be just yet. But, I've learned an incredible amount about reading datasheets, calibrating sensors and code. Here are some tips for future reference: don't expect that the graphic representation is also a physical map. This chip gets numbered from bottom left up and then begins again at the bottom right up to the top right corner---not realizing this caused us 1 1/2 weeks of rewiring. Making sure that you understand a datasheet is the first and most important step in creating a new boards.

I spent Sunday running through this week's lab but don't have any code or documentation to post just yet. It was pretty clear. I will post more info on this later this week.


Lab 6: Servo and DC Motor Here is Michael Schneider's basic servo code that I got working with my servo motor. Attach:servo1 See this video to watch it go!!!

I encountered a problem with the connection between the female end of the servo cable and the male headers on the board. Luckily, Angela Pablo gave me some longer headers that allowed for a better connnection. I also spent a good two hours switching machines because their configurations were not correct. Patience is of the essence in troubleshooting.

Next I tried Carlyn's code to work a servo with analog input, this did not work. I think there is something up with my serial connection.


Lab 7: Midi Lab This week I spent mostly working on the tool project and being sick. Unfortunately, little visible physical progress was accomplished.


Week 8: Final Project

I have decided to focus on an assistive technology project that I have been working on as my final project. A group of us have been observing a young woman with Rhett's Syndrome.

  • Keys Design Elements as Described by Therapists: Repetition, Structure/Pattern, Observation/Documentation

  • Working Project Title: Audio Quilt

  • Population/Audience: Girl's with Rhett's Syndrome or for Pre/Non-Verbal Communication

  • Need Addressed: Sound-Based Encouragement for Expression/Intentional Communication through Touch

  • Description: A hanging large-scale quilted textile, with interchangeable (content) quilted sections that respond to touch with musical feedback. This can be used to develop interest and intentional response to narratives and other lessons which are already being used by therapists. This can be attached to a wall or draped over any surface, so that it can be used standing, seated or laying down. Unique aural feedback will be location specific to the individual sections that are triggered by the users touch.

  • Technologies Used: Simple switches will be quilted into large areas of fabric that will trigger musical feedback from either a hacked cd-player or more likely an isd chip. We are choosing to use sound feedback as Ysold seems especially responsive to this. Also, the device is to be used from a standing or seated position depending the fluctuations of her physical needs.

  • Materials Used: Fabric, conductive fabric, switches (homemade), thread, conductive thread, isd chips?, clear plastic pockets for interchangeable content or velcro, interchangeable narrative images on cards.

Project Wiki with Links project blog


Page last modified March 29, 2006, at 12:10 AM