Wednesday, October 20, 2004

Lab 6 0.20.04 - MIDI

IDI output requires a PIC program stating which note to repeat on the synthesizer. I used the basic circuit from the lab.

DEFINE OSC 20
DEFINE HSER_RCSTA 90h ' enable the receive register
DEFINE HSER_TXSTA 20h ' enable the transmit register
DEFINE HSER_BAUD 31250 ' set the baud rate

main:
' noteon channel 1, middle A, middle velocity
hserout [$90, $45,$40]
pause 1000

' noteoff channel 1, middle A
hserout [$80, $45, $00]
goto main

IDI output requires a PIC program stating which note to repeat on the synthesizer. I used the basic circuit from the lab.

DEFINE OSC 20
DEFINE HSER_RCSTA 90h ' enable the receive register
DEFINE HSER_TXSTA 20h ' enable the transmit register
DEFINE HSER_BAUD 31250 ' set the baud rate

main:
' noteon channel 1, middle A, middle velocity
hserout [$90, $45,$40]
pause 1000

' noteoff channel 1, middle A
hserout [$80, $45, $00]
goto main

IDI output requires a PIC program stating which note to repeat on the synthesizer. I used the basic circuit from the lab.

DEFINE OSC 20
DEFINE HSER_RCSTA 90h ' enable the receive register
DEFINE HSER_TXSTA 20h ' enable the transmit register
DEFINE HSER_BAUD 31250 ' set the baud rate

main:
' noteon channel 1, middle A, middle velocity
hserout [$90, $45,$40]
pause 1000

' noteoff channel 1, middle A
hserout [$80, $45, $00]
goto main

Note the 20 Mhz clock on the chip - this is required for MIDI. Another very important fact for PIC BASIC PRO - set the oscillator to HS (High Speed), otherwise the MIDI won't work.



This is the sythesizer I used - it worked after a couple of tries. The knob on the right sets the instrument. To test the synthesizer, press the tone button on the pad to get a tone.


Lab 5 10.20.04 - Analogue Input through to Serial Processing

Norretranders, User Illusion, ch. 6, "The Bandwidth of Consciousness" deals with human brain cell capacity to process information from the outside world. I'm unclear on the point of this reading but I get the sense that it's part scientific, part qualitative. The argument goes that we cannot possibly register everything in our sensory environment so the brain has to decipher messages in a complex fashion.

Here is a connector schematic from Tom Igoe's site to solder a serial connection.




For the lab assignment, I hooked up 2 potentiometers to a PIC, using the BASIC program from the serial lab. Here is the processing code to vary amplitude of the sine waves:


/* Serial call-and-response
by Tom Igoe (with adjustments by Dan)

Sends a byte out the serial port, and reads 3 bytes in.
sets background color, x location and rotation of a rect

Updated October 12, 2004
*/

int bkcolor; // background color
int[] serialStuff = new int[3]; // where we'll put what we receive
int serialCount = 0; // a count of how many bytes we receive
int xpos; // x location of rectangle
int rot; // rotation of rectangle
//BFont font;

void setup() {
//begin serial communication
beginSerial();
size(640, 240);
// font = loadFont("Garamond-Bold.vlw.gz");

//start off our call and response by sending 65;
serialWrite(65);
}

void loop() {
println(xpos);
//draw background with red value from sensor
background(bkcolor,bkcolor,bkcolor);
//textFont(font, 44);
float xoff = 0.0;

background(153,51,0);
stroke(255,255,255);
xoff = xoff + .25;
float n = noise(xoff) * 1000;
float a = 60.0;
float inc = TWO_PI/18.0;



for(int i=0; i<900; i=i+10)
{
line(i+400, bkcolor, i, +noise(xoff)*sin(a)*xpos);
// line(i+400, random(int(height)), i+400, +noise(xoff)*sin(a)*800.0);
a = a + inc/5;
}

}

void serialEvent() {
// add the latest byte from the serial port to array:
serialStuff[serialCount] = serial;
serialCount++;

// if we have 3 things set our variables:
if (serialCount > 2 ) {
bkcolor = serialStuff[0];
xpos = serialStuff[1];
rot = serialStuff[2];
// clear the string when we're done, and ask for more:
serialCount = 0;
// send a capital A to request new sensor readings:
serialWrite(65);
}
}

Here is the PIC code from Wlodek's Journal for Serial Output:

PIC CODE

'****************************************************************
'* Author : wk372 *
'* Date : 10/20/2004 *
'****************************************************************

txPin var portc.6
rxPin var portc.7
grLed var portd.0
ylLed Var portd.1

output grled
output ylLed
output txpin
input rxpin

inputVar VAR byte
pot1 VAR WORD ' Create variable to store result pot1
pot2 VAR WORD ' Create variable to store result pot2

' 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 10 ' Set sampling time in uS

TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result

'light green LED to know program is working

high grled
pause 300
low grled
pause 150
high grled

PAUSE 500 ' Wait .5 second

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

main:

'Yellow LED to know program is running

low ylled

ADCIN 0, pot1 'potentiometer1 variable
ADCIN 1, pot2 'potentiometer2 variable
pot1 = pot1/4 'divide the value because it's too big
pot2 = pot2/4 'divide the value because it's too big

'----------------------
' THE LISTENING CODE - puts message into inputVar
serin2 rxpin, 16468, [inputVar] 'listening for processing signal

high ylled

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

serout2 txpin, 16468, [pot1,pot2] 'talk to processing

ENDif

goto main









Processing accepts serial data from the PIC, so I used a program with a Sine function and varied the function parameters according to input from the potentiometers.

As a side note, I am working with Wlodek to parse sound data from the Sonia plug-in into Processing.

For the Lab assignment, Java-based processing receives serial input from the PIC. Here is a photo of two potentiometers controlling a Processing assignment.



The two potentiometers control extremities on a Sine curve.

Here is a photo of the output to Processing

Wednesday, October 13, 2004

Lab 4 0.13.04 Documentation and Reading

Donald A. Norman's "The Psychopathology of Everyday Things" addresses the issue of bad design and how to improve it. Although some of the examples are dated, the points made are still valid. I still haven't figured out how to open the pcomp Shop door. The picture of "Carelman's Coffeepot for Masochists" is cool. We've all seen sadistic products before: "surround sound" amplifier buttons, trojan horse shareware which doesn't work, etc.

Norman says an important consideration is visibility and natural, i.e. intuitive design. He states that "when simple things need pictures, labels, or instructions, the design has failed." I couldn't agree more. Normal also states that designers need to consider the user's psychology. In conclusion, he states that clever design can help reduce complexity in (technological) products.

Wednesday, October 06, 2004

Lab 3 10.06.04 - Analogue Output

Group Project with Chia Hao, please use this link for a full description of the Weathervane.



The reading was "Chapter One: What exactly is interactivity" by Chris Crawford. Crawford makes the case for interactivity and defines what it as a conversation. Crawford writes that you need two actors for interaction - these actors think, listen, and speak. Crawford defines activities such as reading as not interactive. He is heavy handed in his conclusion because linear art forms like books and movies can be the genesis of interactivity and discussion. Crawford cites an example from Greek antiquity to support his claim that the spoken word is better than the written. The conclusion addresses "web" generation and interaction designers and draws the distinction between UI designers and human factors.

The lab assignment was to hook up output to a servo motor. I still need to try audio output with a potentiometer. The main difficulty with the servo motor was ensuring that connections were solid on the Radio Shack breadboard and the servo wires which are really thin.

Here is the code to turn the servo to it's maximum position and start again:


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:
'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

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

GoTo main