Class.Mjh348 History
Hide minor edits - Show changes to output
Changed lines 149-150 from:
[[
to:
http://itp.nyu.edu/~mjh348/classes/images/sensorworkshop/processing01a.gif
http://itp.nyu.edu/~mjh348/classes/images/sensorworkshop/processing01b.gif | Image 2
http://itp.nyu.edu/~mjh348/classes/images/sensorworkshop/processing01b.gif | Image 2
Changed lines 11-12 from:
Following are the codes I used in this week's assignment [[http://stage.itp.nyu.edu/~mjh348/classes/sensorworkshop.html: | easier to read version]]
to:
Following are the codes I used in this week's assignment ([[http://stage.itp.nyu.edu/~mjh348/classes/sensorworkshop.html | easier to read version]]):
Changed lines 11-12 from:
Following are the codes I used in this week's assignment:
to:
Following are the codes I used in this week's assignment [[http://stage.itp.nyu.edu/~mjh348/classes/sensorworkshop.html: | easier to read version]]
Changed lines 105-150 from:
to:
Goto main
'''Datalogger - Ellipse''' - ''Processing Code''
import processing.serial.*;\\
Serial myPort;\\
int serial = 1; // data from serial port\\
void setup () {\\
size(300, 300);\\
println(Serial.list());\\
myPort = new Serial(this, Serial.list()[0], 9600);\\
background(255);\\
noFill();\\
stroke (200);\\
ellipse (150, 150, 50, 50);\\
ellipse (150, 150, 100, 100);\\
ellipse (150, 150, 150, 150);\\
ellipse (150, 150, 200, 200);\\
ellipse (150, 150, 250, 250);\\
}\\
void draw () {\\
if (myPort.available() > 0) {\\
serial = myPort.read();\\
serialEvent();\\
}\\
}\\
void serialEvent () {\\
background(255);\\
fill(serial, serial/3, 100);\\
stroke (0);\\
ellipse(150, 150, serial, serial);\\
noFill();\\
stroke (200);\\
ellipse (150, 150, 50, 50);\\
ellipse (150, 150, 100, 100);\\
ellipse (150, 150, 150, 150);\\
ellipse (150, 150, 200, 200);\\
ellipse (150, 150, 250, 250);\\
println (serial);\\
}\\
[[http://itp.nyu.edu/~mjh348/classes/images/sensorworkshop/processing01a.gif | Image 1]]
[[http://itp.nyu.edu/~mjh348/classes/images/sensorworkshop/processing01b.gif | Image 2]]
'''Datalogger - Ellipse''' - ''Processing Code''
import processing.serial.*;\\
Serial myPort;\\
int serial = 1; // data from serial port\\
void setup () {\\
size(300, 300);\\
println(Serial.list());\\
myPort = new Serial(this, Serial.list()[0], 9600);\\
background(255);\\
noFill();\\
stroke (200);\\
ellipse (150, 150, 50, 50);\\
ellipse (150, 150, 100, 100);\\
ellipse (150, 150, 150, 150);\\
ellipse (150, 150, 200, 200);\\
ellipse (150, 150, 250, 250);\\
}\\
void draw () {\\
if (myPort.available() > 0) {\\
serial = myPort.read();\\
serialEvent();\\
}\\
}\\
void serialEvent () {\\
background(255);\\
fill(serial, serial/3, 100);\\
stroke (0);\\
ellipse(150, 150, serial, serial);\\
noFill();\\
stroke (200);\\
ellipse (150, 150, 50, 50);\\
ellipse (150, 150, 100, 100);\\
ellipse (150, 150, 150, 150);\\
ellipse (150, 150, 200, 200);\\
ellipse (150, 150, 250, 250);\\
println (serial);\\
}\\
[[http://itp.nyu.edu/~mjh348/classes/images/sensorworkshop/processing01a.gif | Image 1]]
[[http://itp.nyu.edu/~mjh348/classes/images/sensorworkshop/processing01b.gif | Image 2]]
Added lines 51-105:
'''Sending only Peak Values''' - ''PIC code''\\
define OSC 4\\
DEFINE ADC_BITS 10 \\
DEFINE ADC_CLOCK 3 \\
DEFINE ADC_SAMPLEUS 20 \\
PeakValue var word\\
SensorValue var word\\
LastSensorValue var word\\
Threshold var word\\
Noise var word\\
PeakValueB var byte\\
tx var portc.6\\
rx var portc.7\\
n9600 con 16468
Threshold = 50 \\
PeakValue = 0\\
noise = 5 \\
TRISA = %11111111\\
ADCON1 = %10000010 \\
Main:\\
high portb.0\\
ADCin 0, sensorValue\\
' check to see that it's above the threshold:\\
If sensorValue >= threshold + noise then \\
' if it's greater than the last reading,\\
' then make it our current peak:\\
If sensorValue >= lastSensorValue + Noise then\\
PeakValue = sensorValue\\
endif\\
' if the sensorValue is not above the threshold,\\
' then the last peak value we got would be the actual peak:\\
Else\\
If peakValue >= threshold then \\
' this is the final peak value; take action\\
PeakValueB = peakvalue/4\\
serout2 tx, n9600, [peakValueB]\\
endif \\
' reset peakValue, since we've finished with this peak:\\
peakValue = 0\\
Endif\\
low portb.0\\
' store the current sensor value for the next loop:\\
lastSensorValue = sensorValue\\
pause 50\\
Goto main
Changed lines 41-43 from:
to:
SensorValueB = SensorValue/4\\
Changed lines 41-43 from:
SensorValueB = SensorValue/4\\
to:
->SensorValueB = SensorValue/4\\
Changed lines 40-43 from:
ADCin 0, SensorValue \\
SensorValueB = SensorValue/4\\
to:
ADCin 0, SensorValue\\
SensorValueB = SensorValue/4\\
SensorValueB = SensorValue/4\\
Changed line 40 from:
ADCin 0, SensorValue\\
to:
ADCin 0, SensorValue \\
Changed lines 18-19 from:
DEFINE ADC_SAMPLEUS 20\\
to:
DEFINE ADC_SAMPLEUS 20
Added line 23:
Added line 27:
Added line 33:
Added line 37:
Added line 43:
Added line 46:
Changed lines 15-43 from:
define OSC 4
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 20
SensorValue var word
SensorValueB var Byte
tx var portc.6
rx var portc.7
n9600 con 16468
Threshold = 30
PeakValue = 0
noise = 5
TRISA = %11111111
ADCON1 = %10000010
Main:
high portb.0
ADCin 0,SensorValue
SensorValueB = SensorValue/4
serout2 tx, n9600, [SensorValueB]
low portb.0
pause 50
Gotomain
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 20
SensorValue var word
SensorValueB var Byte
tx var portc.6
rx var portc.7
n9600 con 16468
Threshold = 30
PeakValue = 0
noise = 5
TRISA = %11111111
ADCON1 = %10000010
Main:
high portb.0
ADCin 0,
SensorValueB = SensorValue/4
serout2 tx, n9600, [SensorValueB]
low portb.0
pause 50
Goto
to:
define OSC 4\\
DEFINE ADC_BITS 10\\
DEFINE ADC_CLOCK 3\\
DEFINE ADC_SAMPLEUS 20\\
SensorValue var word\\
SensorValueB var Byte\\
tx var portc.6\\
rx var portc.7\\
n9600 con 16468\\
Threshold = 30\\
PeakValue = 0\\
noise = 5\\
TRISA = %11111111\\
ADCON1 = %10000010\\
Main:\\
high portb.0\\
ADCin 0, SensorValue\\
SensorValueB = SensorValue/4\\
serout2 tx, n9600, [SensorValueB]\\
low portb.0\\
pause 50\\
Goto main\\
DEFINE ADC_BITS 10\\
DEFINE ADC_CLOCK 3\\
DEFINE ADC_SAMPLEUS 20\\
SensorValue var word\\
SensorValueB var Byte\\
tx var portc.6\\
rx var portc.7\\
n9600 con 16468\\
Threshold = 30\\
PeakValue = 0\\
noise = 5\\
TRISA = %11111111\\
ADCON1 = %10000010\\
Main:\\
high portb.0\\
ADCin 0, SensorValue\\
SensorValueB = SensorValue/4\\
serout2 tx, n9600, [SensorValueB]\\
low portb.0\\
pause 50\\
Goto main\\
Changed lines 9-43 from:
to:
I wanted to depart from the green and black horizontal scrolling mountains I so closely associate with computer-ness. I ended up using circles that grow as sensor data increases (turning a pot, pushing on an FSR, bending a flex sensor, et cetera). I also mapped the color of the circle to reflect the changing sensor levels. For reference, I added markers every 50 steps. Right now, the color changes with the growing circles but i would like to change it to reflect something different (like magnitude of change in peak value or an additional sensor's reading).
Following are the codes I used in this week's assignment:
'''Sending All Sensor Data''' - ''PIC Code''
define OSC 4
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 20
SensorValue var word
SensorValueB var Byte
tx var portc.6
rx var portc.7
n9600 con 16468
Threshold = 30
PeakValue = 0
noise = 5
TRISA = %11111111
ADCON1 = %10000010
Main:
high portb.0
ADCin 0, SensorValue
SensorValueB = SensorValue/4
serout2 tx, n9600, [SensorValueB]
low portb.0
pause 50
Goto main
Following are the codes I used in this week's assignment:
'''Sending All Sensor Data''' - ''PIC Code''
define OSC 4
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 20
SensorValue var word
SensorValueB var Byte
tx var portc.6
rx var portc.7
n9600 con 16468
Threshold = 30
PeakValue = 0
noise = 5
TRISA = %11111111
ADCON1 = %10000010
Main:
high portb.0
ADCin 0, SensorValue
SensorValueB = SensorValue/4
serout2 tx, n9600, [SensorValueB]
low portb.0
pause 50
Goto main
Changed lines 1-9 from:
to:
Communicating with Processing through a PIC has been something i have loathed (and avoided) ever since first trying about a year ago. Today I still don't enjoy the process, I can say, with confidence, that it is something I am comfortable in doing...
Why the turnaround? Simply, because it was something I had to do.
While the assignment was not aking for much, it took several days (4) of banging my head against the wall for it to sink in. I basically took the code samples Tom provided, used a basic potentiometer as a sensor, and tried to get those to work properly. Once those codes worked, I started to add bells and whistles.
After successfully implementing Tom's Processing Datalogger, I repurposed it to suit my whims.
I wanted to depart from the green and black horizontal scrolling mountains I so closely associate with computer-ness. I ended up using circles that grow as sensor data increases (turning a pot, pushing on an FSR, bending a flex sensor, et cetera). I also mapped the color of the circle to reflect the changing sensor levels. For reference, I added markers every 50 steps. Right now, the color changes with the growing circles but i would like to change it to reflect something different (like magnitude of change in peak value or an additional sensor's reading).
Why the turnaround? Simply, because it was something I had to do.
While the assignment was not aking for much, it took several days (4) of banging my head against the wall for it to sink in. I basically took the code samples Tom provided, used a basic potentiometer as a sensor, and tried to get those to work properly. Once those codes worked, I started to add bells and whistles.
After successfully implementing Tom's Processing Datalogger, I repurposed it to suit my whims.
I wanted to depart from the green and black horizontal scrolling mountains I so closely associate with computer-ness. I ended up using circles that grow as sensor data increases (turning a pot, pushing on an FSR, bending a flex sensor, et cetera). I also mapped the color of the circle to reflect the changing sensor levels. For reference, I added markers every 50 steps. Right now, the color changes with the growing circles but i would like to change it to reflect something different (like magnitude of change in peak value or an additional sensor's reading).