Lazlo's Phy Comp Journal
[Most Recent Entries]
[Calendar View]
[Friends]
Below are the 9 most recent journal entries recorded in
phycomplr's LiveJournal:
| Wednesday, August 3rd, 2005 | | 5:56 pm |
Manual for the MIDI Gloves
The MIDI Glove's are music instruments that allow the user to play all 12 available notes, and pitches bend on them when used in combination with a MIDI synthesizer. The result is a musical instrument that is both easy to use and produces a visual performance for the audience when use. The glove (as seen on http://physical-computing.blogspot.com/) has three major components: 1. Left Glove The Left Glove is used to control which notes are being played by the user and also produces the visual feedback within the orb based on the note being played. The user pushes on the contacts on the orb to change the current note being produced by MIDI synthesizer. The thumb is used to switch from the current set of notes to the second set when pushed down. 2. Right Glove The Right Glove is used to control the pitch bending on the current note being played by aiming the glove towards or away from a source of light. In addition, the third sets of notes are accessed by triggering the thumb switch. 3. Control Box This is where the PIC is stored that contains all the data, and when the power input’s are located. Video will be available soon | | Tuesday, August 2nd, 2005 | | 6:04 pm |
THE FINAL VERSION OF CODE!?!?
Here is the current code used in the current version of our midi gloves, with pitch bending now. ---------------------------------------- -- 'MIDI Glove Alpha DEFINE OSC 20 '20mhz clock set DEFINE HSER_RCSTA 90h ' enable the receive register DEFINE HSER_TXSTA 20h ' enable the transmit register DEFINE HSER_BAUD 31250 ' set the baud rate ' 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 noteVar var byte TRISA = %11111111 ' Set PORTA to all input ADCON1 = %10000010 ' Set PORTA analog and right justify result switchA var portb.0 switchB VAR portb.1 switchC Var portb.2 switchD VAR portb.3 S1switch VAR portb.4 S2switch VAR portb.5 CaseVar VAR BYTE OldCaseVar VAR BYte OutputSound VAR BYTE PhotoCell VAR WORD SafeCell Var Byte Pause 500 ' Wait .5 second main: ADCIN PortA.0, PhotoCell SafeCell = PhotoCell / 2 HIGH PortD.2 IF(switchA = 1) THEN caseVar = casevar + 0 ENDIF IF(switchB = 1) THEN caseVar = casevar + 1 ENDIF IF(switchC = 1) THEN caseVar = casevar + 2 ENDIF IF(switchD = 1) THEN caseVar = casevar + 3 ENDIF IF(S1switch = 1) THEN caseVar = casevar + 4 ENDIF IF(S2switch = 1) THEN caseVar = casevar + 8 ENDIF SELECT CASE CaseVar CASE 0 OutputSound = 60 + Casevar CASE 1 OutputSound = 60 + Casevar CASE 2 OutputSound = 60 + Casevar CASE 3 OutputSound = 60 + Casevar CASE 4 OutputSound = 60 + Casevar CASE 5 OutputSound = 60 + Casevar CASE 6 OutputSound = 60 + Casevar CASE 7 OutputSound = 60 + Casevar CASE 8 OutputSound = 60 + Casevar CASE 9 OutputSound = 60 + Casevar CASE 10 OutputSound = 60 + Casevar CASE 11 OutputSound = 60 + Casevar CASE IS > 11 OUTPUtSound = 60 END SELECT HSEROUT [$90, OutputSound, $40] HSEROUT [$E0, $35, SafeCell] LOW PortD.2 PAUSE 500 if(caseVar != OldCaseVar) THEN HSEROUT [$90, 60 + OldCaseVar,$00] ENDIF OldCaseVar = CaseVar CaseVar = 0 goto main end | | Thursday, July 28th, 2005 | | 5:45 pm |
MIDI Glove (Center PIC Code)
The code towards the glove has finally begun to take shape, and here is the first working version of it. ---------------------------------------- ---------------------------------------- ------ 'MIDI Glove Alpha DEFINE OSC 20 '20mhz clock set DEFINE HSER_RCSTA 90h ' enable the receive register DEFINE HSER_TXSTA 20h ' enable the transmit register DEFINE HSER_BAUD 31250 ' set the baud rate ' 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 noteVar var byte TRISA = %11111111 ' Set PORTA to all input ADCON1 = %10000010 ' Set PORTA analog and right justify result switchA var portb.0 switchB VAR portb.1 switchC Var portb.2 switchD VAR portb.3 S1switch VAR portb.4 S2switch VAR portb.5 CaseVar VAR BYTE OldCaseVar VAR BYte OutputSound VAR BYTE Pause 500 ' Wait .5 second main: HIGH PortD.2 IF(switchA = 1) THEN caseVar = casevar + 0 ENDIF IF(switchB = 1) THEN caseVar = casevar + 1 ENDIF IF(switchC = 1) THEN caseVar = casevar + 2 ENDIF IF(switchD = 1) THEN caseVar = casevar + 3 ENDIF IF(S1switch = 1) THEN caseVar = casevar + 4 ENDIF IF(S2switch = 1) THEN caseVar = casevar + 8 ENDIF SELECT CASE CaseVar CASE 0 OutputSound = 60 + Casevar CASE 1 OutputSound = 60 + Casevar CASE 2 OutputSound = 60 + Casevar CASE 3 OutputSound = 60 + Casevar CASE 4 OutputSound = 60 + Casevar CASE 5 OutputSound = 60 + Casevar CASE 6 OutputSound = 60 + Casevar CASE 7 OutputSound = 60 + Casevar CASE 8 OutputSound = 60 + Casevar CASE 9 OutputSound = 60 + Casevar CASE 10 OutputSound = 60 + Casevar CASE 11 OutputSound = 60 + Casevar CASE IS > 11 OUTPUtSound = 60 END SELECT HSEROUT [$90, OutputSound, $40] LOW PortD.2 PAUSE 500 if(caseVar != OldCaseVar) THEN HSEROUT [$90, 60 + OldCaseVar,$00] ENDIF OldCaseVar = CaseVar CaseVar = 0 goto main end | | Thursday, July 21st, 2005 | | 8:41 am |
Mid-Term Code
The mid-term project is nice and set up as seen on Ellie's Site ( http://physical-computing.blogspot.com/), but below is the code for both processing and the PIC chip. ---------------------------------------- -------------------------- PIC CODE ---------------------------------------- -------------------------- DEFINE OSC 4 start: DEFINE ADC_BITS 10 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 10 TRISA = %11111111 adcon1 = 2 OUTPUT PortB.7 Output PortB.6 Input PortB.5 Input PortB.4 INPUT PortB.3 pause 500 Var1 VAR Byte Var2 Var Byte var3 Var Byte var4 VAR WORD var4Byte Var Byte varG VAR Word varFreq VAR WORD varLen VAR WORD main: 'HIGH Portb.7 ADCIN 0, var4 var4Byte = (var4/200 - 25) MIN 254 MAX 10 'SEROUT2 PortC.6, 16468, [DEC var4Byte, 13, 10] High Portb.7 '///Testing//// SERIN2 PortC.7, 16468, [varG] LOW portb.7 ADCIN 0, var4 '//////////////CHANGED BLOCK/////////////////////////////////// // 'var4Byte = (var4/100 - 280)MIN 254 MAx 10 //Commented Out 'if(var4 > 58000) then 'var4Byte = 254 'endif 'if((var4 > 35000)&&(var4 < 45000)) then 'var4Byte = 122 'endif 'if(var4 < 35000) then 'var4Byte = 20 'endif '//////////////END OF CHANGED///////////////////////////////// /////// IF(PortB.5 == 1) THEN var1 = 1 ELSE var1 = 2 ENDIF if(PortB.4 == 1) Then var2 = 4 varlen = var4byte ELSE Var2 = 3 ENDIF IF(PortB.3 == 1) THEN Var3 = 5 varFreq = var4Byte * 4 ELSE Var3 = 6 ENDIF SEROUT2 PortC.6, 16468, [DEC var1] SEROUT2 PortC.6, 16468, [DEC var2] SEROUT2 PortC.6, 16468, [DEC Var3] SEROUT2 PortC.6, 16468, [var4byte] IF(var1 == 1) THEN FREQOUT Portb.6, varLen, VarFreq ENDIF '///////////////////////////////////CHAN GED///////////////////////////////////// /////// goto main ---------------------------------------- ----------- Processing Code ---------------------------------------- ----------- import processing.serial.*; int bgcolor; //Background color int fgcolor = 255; // fill color Serial port; // the serial port int[] serialInArray = new int[6]; // where we'll put what we receive int serialCount = 0; // a count of how many bytes we receivez float xpos, ypos; // Starting position of the ball float nlength = 20; float clock; int clockCount = 0; boolean firstContact = false; // whether we've heard from the microcontroller void setup() { size(256, 256); // stage size noStroke(); // no border on the next thing drawn // Set the starting position of the ball (middle of the stage) xpos = width/2; ypos = height/2; // print a list of the serial ports, for debugging purposes: println(Serial.list()); /* I know that the first port in the serial list on my mac is always my Keyspan adaptor, so I open Serial.list()[0]. On Windows machines, this generally opens COM1. Open whatever port is the one you're using. */ port = new Serial(this, Serial.list()[0], 9600); port.write(65); // send a capital A to start the microcontroller sending fill(fgcolor); } void draw() { background(bgcolor); // Draw the shape // get any new serial data: while (port.available() > 0) { serialEvent(); // note that we heard from the microntroller: } // if there's no serial data, // send again until we get some. // (in case you tend to start Processing // before you start your external device): rect(xpos, ypos, nlength, 20); if (firstContact == false) { delay(300); port.write(65); } } void serialEvent() { processByte((char)port.read()); } void processByte(char inByte) { // add the latest byte from the serial port to array: serialInArray[serialCount] = inByte; serialCount++; clock = millis(); //println(inByte); // if we have 3 bytes: if (serialCount > 4 ) { //if(serialInArray[0] == 49) // { //while((millis() - clockCount) < nlength)//1 //{ // clockCount++; //} // } if(serialInArray[1] == 51)//3 { clockCount = 0; if(serialInArray[2] == 53) //5 { ypos = (float)serialInArray[3]; } else { xpos = (float)serialInArray[3]; } } else if(serialInArray[1] == 52)//4 { clockCount = 0; nlength = ((float)serialInArray[3]); } // send a capital A to request new sensor readings: // reset serialCount: serialCount = 0; } port.write(65); } | | Sunday, July 17th, 2005 | | 12:12 pm |
Processing Code
While the code isn't 100% fixed, the ball is finally being adjusted by variables, and should be done very soon. ---------------------------------------- Processing Code: import processing.serial.*; int bgcolor; //Background color int fgcolor = 255; // fill color Serial port; // the serial port int[] serialInArray = new int[6]; // where we'll put what we receive int serialCount = 0; // a count of how many bytes we receivez float xpos, ypos; // Starting position of the ball float nlength = 20; float clock; boolean firstContact = false; // whether we've heard from the microcontroller void setup() { size(256, 256); // stage size noStroke(); // no border on the next thing drawn // Set the starting position of the ball (middle of the stage) xpos = width/2; ypos = height/2; // print a list of the serial ports, for debugging purposes: println(Serial.list()); /* I know that the first port in the serial list on my mac is always my Keyspan adaptor, so I open Serial.list()[0]. On Windows machines, this generally opens COM1. Open whatever port is the one you're using. */ port = new Serial(this, Serial.list()[0], 9600); port.write(65); // send a capital A to start the microcontroller sending } void draw() { background(bgcolor); fill(fgcolor); // Draw the shape // get any new serial data: while (port.available() > 0) { serialEvent(); // note that we heard from the microntroller: } // if there's no serial data, // send again until we get some. // (in case you tend to start Processing // before you start your external device): if (firstContact == false) { delay(300); port.write(65); } } void serialEvent() { processByte((char)port.read()); } void processByte(char inByte) { // add the latest byte from the serial port to array: serialInArray[serialCount] = inByte; serialCount++; clock = millis(); //println(inByte); // if we have 3 bytes: if (serialCount > 5 ) { if(serialInArray[0] == 49) { while((millis() - clock) < nlength)//1 { for(int x = 0; x < 100000;x++); } println("hi"); } else if(serialInArray[1] == 51)//3 { if(serialInArray[2] == 53) //5 { xpos = (float)serialInArray[3]; } else { ypos = (float)serialInArray[3]; } } else if(serialInArray[1] == 52)//4 { nlength = (((float)serialInArray[3] * 100) + ((float)serialInArray[4] * 10) + ((float)serialInArray[5])); } // send a capital A to request new sensor readings: // reset serialCount: serialCount = 0; } ellipse(xpos, ypos, nlength, 20); port.write(65); } ---------------------------------------- ------------- PIC Code DEFINE OSC 4 start: DEFINE ADC_BITS 10 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 10 TRISA = %11111111 adcon1 = 2 OUTPUT PortB.7 Output PortB.6 Input PortB.5 Input PortB.4 INPUT PortB.3 pause 500 Var1 VAR Byte Var2 Var Byte var3 Var Byte var4 VAR WORD var4Byte Var Byte varG VAR Word varFreq VAR WORD varLen VAR WORD main: 'HIGH Portb.7 'ADCIN 0, var4 'var4 = (var4/100 - 280)MIN 254 MAx 10 'SEROUT2 PortC.6, 16468, [DEC var4, 13, 10] High Portb.7 SERIN2 PortC.7, 16468, [varG] LOW portb.7 ADCIN 0, var4 var4Byte = (var4/100 - 280)MIN 254 MAx 10 IF(PortB.5 == 1) THEN var1 = 2 ELSE var1 = 1 ENDIF if(PortB.4 == 1) Then var2 = 4 varlen = var4byte ELSE Var2 = 3 ENDIF IF(PortB.3 == 1) THEN Var3 = 5 varFreq = var4byte ELSE Var3 = 6 ENDIF SEROUT2 PortC.6, 16468, [DEC var1] SEROUT2 PortC.6, 16468, [DEC var2] SEROUT2 PortC.6, 16468, [DEC Var3] SEROUT2 PortC.6, 16468, [DEC var4byte] if(var1 == 1) THEN FREQOUT Portb.7, varFreq, Varlen ENDIF goto main | | Tuesday, July 12th, 2005 | | 12:01 am |
Lastest Code for a Music Making Machine
After playing around with FREQOUT and OSC settings (which have interesting sound effects when not paired with the correct Mhz Crystal, we have managed to make a half decent sound making machine. Video will hopefully be available shortly, but here is the code for now. ---------------------------------------- ---------------------------------------- ---------------------------------------- ----- DEFINE OSC 25 start: DEFINE ADC_BITS 10 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 10 TRISA = %11111111 adcon1 = 2 OUTPUT PortB.7 OUTPUT PortB.6 Input PortB.5 OUTPUT PortB.4 pause 500 WindL VAR WORD NoteA VAR WORD NoteB VAR Word Cnote VAR WORD main: High PortB.7 ADCIN 0, WindL 'Length ADCIN 2, NoteA 'First Note ADCIN 4, NoteB 'Second Note IF(PortB.5 = 1) Then '''''''''''''''''''''''''' WindL = (WindL - 30000)/4 Notea = (NoteA - 23000) FREQOUT Portb.6, 200, NoteA Serout2 portc.6, 16468, [ "NoteA: ", DEC NoteA, 13, 10] ENDIF 'serout2 portc.6, 16468, ["Photo0: ", Photo0, 10, 13, "Photo1: '",Photo1, 10, 13, "Photo2: ", Photo2, 10, 13, "Photo3: ", Photo3, '10,13, "Photo4: ", Photo4, 10, 13, "Photo5: ", Photo5, 10, 13, '"Photo6:", Photo6, 10, 13, "Photo7: ", Photo7, 10, 13] 'GOSUB showLight goto main | | Saturday, July 9th, 2005 | | 11:44 pm |
Last version of code
Here is the lastest version of the code for the music maker, using the photo cells as input devices (debug code is ' out) ---------------------------------------- ---------------------------------------- ---------------------------------------- - DEFINE OSC 4 start: DEFINE ADC_BITS 10 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 10 TRISA = %11111111 adcon1 = 2 OUTPUT PortB.7 OUTPUT PortB.6 OUTPUT PortB.5 OUTPUT PortB.4 pause 500 PhotoA VAR WORD Photo1 VAR WORD Photo2 VAR Word Photo3 VAR WORD Photo4 VAR WORD Photo5 VAR WORD Photo6 VAR WORD Photo7 VAR WORD value0 VAR WORD value1 VAR WORD value2 VAR WORD value3 VAR WORD value4 VAR WORD value5 VAR WORD value6 VAR WORD value7 VAR WORD main: High PortB.7 ADCIN 0, PhotoA '1st Cell 'ADCIN 1, Photo1 '2nd Cell 'ADCIN 2, Photo2 '3rd Cell 'ADCIN 3, Photo3 '4th Cell 'ADCIN 4, Photo4 '5th Cell 'ADCIN 5, Photo5 'Not used yet 'ADCIN 6, Photo6 'Not used yet 'ADCIN 7, Photo7 'Not used yet PhotoA = (PhotoA/200) - 50 PWM PortB.6,PhotoA,1 PWM PortB.7,PhotoA - 200,1 'If PhotoA < 35000 THEN 'LOw PortB.7 'PWM PORTB.6,200,500 'ENDIF 'Serout2 portc.6, 16468, ["PhotoA: ",DEC PhotoA, 13, 10] 'serout2 portc.6, 16468, ["Photo0: ", Photo0, 10, 13, "Photo1: ",Photo1, 10, 13, "Photo2: ", Photo2, 10, 13, "Photo3: ", Photo3, 10,13, "Photo4: ", Photo4, 10, 13, "Photo5: ", Photo5, 10, 13, "Photo6:", Photo6, 10, 13, "Photo7: ", Photo7, 10, 13] 'GOSUB showLight goto main showLight: 'Read in ADC values ADCIN 0, value0 'ADCIN 1, value1 'ADCIN 2, value2 'ADCIN 3, value3 'ADCIN 4, value4 'Value check Cell 0 IF value0 > 1000 Then HIGH PortB.7 ELSE LOW PortB.7 ENDIF IF value0 > 1500 Then High PortB.6 Else Low PortB.6 ENDIF IF value0 > 2000 Then High PortB.5 Else Low PortB.5 ENDIF IF value0 > 3000 Then High PortB.4 Else Low Portb.4 ENDIF 'Return to method calling showLight return | | Thursday, June 30th, 2005 | | 8:51 am |
"First" Breadboard
I have set up a breadboard the following: 1. A Capacitor - to regulate the power input. 2. A 5V Regulator - to take 12V to 5V DC. 3. Two Resistors - to not burn out the LEDs. 4. A Push Switch - to make it interactive. 5. A Photo Cell - to make the environment interact with it. 6. Two LED - to show the result of the system. *Hopefully I will get my digital camera working in the near future to take pictures of the progress. --Lazlo | | Wednesday, June 29th, 2005 | | 8:49 am |
First Post
I have set up this website to log the work I will be doing in the Physical Computing Class at NYU this summer. --Lazlo |
|