Friday, April 25, 2008

PIR + SLR Camera







Arduino code.
int servoPin = 2;     // Control pin for servo motor
int minPulse = 500;   // Minimum servo position
int maxPulse = 1200;  // Maximum servo position
int pulse = 0;        // Amount to pulse the servo
int calibrationTime = 30; 

long lastPulse = 0;    // the time in milliseconds of the last pulse
int refreshTime = 20; // the time needed in between pulses

int analogValue = 0;  // the value returned from the analog sensor
int analogPin = 0;    // the analog pin that the sensor's on
int ledPin = 13;

void setup() {
  pinMode(servoPin, OUTPUT);  // Set servo pin as an output pin
  pulse = minPulse;           // Set the motor position value to the minimum
  Serial.begin(9600);
    Serial.print("calibrating sensor ");
  for(int i = 0; i <>
    Serial.print(".");
    delay(1000);
     }
  Serial.println(" done");
  Serial.println("SENSOR ACTIVE");
  delay(50);         // Set the motor position value to the minimum

}

void loop() {
  analogValue = analogRead(analogPin);      // read the analog input
  Serial.println (analogValue);
  
  pulse = (analogValue * 200)/10 + minPulse;    // convert the analog value
                                            // to a range between minPulse
                                            // and maxPulse. 
//Serial.println(pulse);
  // pulse the servo again if rhe refresh time (20 ms) have passed:
  if (millis() - lastPulse >= refreshTime) {
    digitalWrite(servoPin, HIGH);   // Turn the motor on
    delayMicroseconds(pulse);       // Length of the pulse sets the motor position
    digitalWrite(servoPin, LOW);    // Turn the motor off
    
    digitalWrite(ledPin, HIGH);   
    delayMicroseconds(pulse);      
    digitalWrite(ledPin, LOW);
    
    lastPulse = millis();           // save the time of the last pulse
  }
}


Friday, April 4, 2008

Sensor Report

PIR(Passive InfraRed) sensor



What is PIR sensor?

Infrared radiation exists in the electromagnetic spectrum at a wavelength that is longer than visible light. It cannot be seen but it can be detected. Objects that generate heat also generate infrared radiation and those objects include animals and the human body whose radiation is strongest at a wavelength of 9.4um. Infrared in this range will not pass through many types of material that pass visible light such as ordinary window glass and plastic. However it will pass through, with some attenuation, material that is opaque to visible light such as germanium and silicon. An unprocessed silicon wafer makes a good IR window in a weatherproof enclosure for outdoor use. It also provides additional filtering for light in the visible range.


The PIR Sensor detects motion up to 20 feet away by using a Fresnel lens and infrared-sensitive element to detect changing patterns of passive infrared emitted by objects in its vicinity.



How does PIR sensor work as a motion detecting sensor?


An IR emitting body moving across the front of a sensor will expose first one, then both and then the other sensor element.


The output signal waveform shows that first a positive, then zero and then a negative transition results.


There are many different ways to create a motion sensor. Motion is detected when an infrared emitting source with one temperature, such as a human body, passes in front of a source with another temperature, such as a wall.


Design


Through the front of the sensor, known as the sensor face. At the core of a PIR is a solid state sensor or set of sensors, made from approximately 1/4 inches square of natural or artificial pyroelectric materials, usually in the form of a thin film, out of gallium nitride (GaN), caesium nitrate (CsNO3), polyvinyl fluorides, derivatives of phenylpyrazine, and cobalt phthalocyanine. (See pyroelectric crystals.) Lithium tantalate (LiTaO3) is a crystal exhibiting both piezoelectric and pyroelectric properties.

The Fresnel lens


A Fresnel lens is a Plano Convex lens that has been collapsed on itself to form a flat lens that retains its optical characteristics but is much thinner and therefore has less absorption loss.


A Fresnel lens is usually thin and flexible and is about 0.015 inch (0.38mm) thick with grooves molded into one surface. The groove side of the lens usually faces the PIR sensor.

A Fresnel lens both captures more IR radiation and focuses it to a small point. This focal point moves across the sensor as the IR source moves and exposes one element at a time. A Fresnel lens can extend detection range to about 100 feet.



Products Circuit



DATA SHEET

www.futurlec.com/PIR_Module_B.shtml

Sample Code 

www.arduino.cc/playground/Code/PIRsense


Working Video



Commercial Uses

Security system

Lighting system


NOTE

Because the sensor is passive, it relies on an infrared signature (heat) from the object to be monitored so only warm-bodied items (relative to the ambient temperature of the room) can be detected. For example, people and animals can be detected but a ball would not -unless it was noticeably warmer or colder than the ambient temperature.


Sensor Product Company

 You can buy assemble or separately.

http://www.parallax.com/Store/Sensors/ObjectDetection/tabid/176/CategoryID/36/List/0/Level/a/ProductID/83/Default.aspx?SortField=ProductName%2cProductName

http://www.hvwtech.com/products_view.asp?ProductID=270

http://optoelectronics.perkinelmer.com/

http://www.futurlec.com/PIR_Sensors.shtml



Additional info


en.wikipedia.org/wiki/Passive_infrared_sensor

www.glolab.com/index.html

www.gadgetshack.com/motionsensor.html


Friday, March 21, 2008

Data logging

I try to data log with Do son chip and Micro SD card.


First I try to make and save data at SD card from potentiometer.



I can save data easily at computer by processing, but it seem not the exactly same data at Arduino.

It looked like a kind of BYTE , HEX problem.




After I saved a file used processing, I couldn't nothing to do with.

I try to save at SD card, but I failed to save.

I used all of sample code at class wiki.


Those are result files


All of text files are meaningless.


http://itp.nyu.edu/physcomp/sensors/Code/4dSystemsByte

from this code.


1. http://itp.nyu.edu/~sk2745/sensor/3.TXT

2. http://itp.nyu.edu/~sk2745/sensor/1.TXT



Arduino
Code.
//-------------------------------
byte fileCounter = 5 ;
byte sensorCounter = 0;
boolean done = false;
void setup(){
pinMode(11,OUTPUT);
Serial.begin(19200);
// have device warm up
delay(1000);
// send two Carraige Returns to AutoSet Baudrate
Serial.print('\r',BYTE);
Serial.print('\r',BYTE);
delay(1000);
Serial.print('q',BYTE);
Serial.print('\r',BYTE);
delay(1000);
setupFile();
delay(1000);
}
void loop(){
if(!done){
if(sensorCounter <>
byte analog = analogRead(0) / 4;
Serial.print("w #1 2"); // send 2 bytes (one is the sensor number,one is the \n for reading later)
Serial.print('\r',BYTE);
delay(1000);
Serial.print(analog,BYTE);
Serial.print('\n',BYTE);
Serial.print('\r',BYTE);
sensorCounter++;
} else {
digitalWrite(11,HIGH);
done = true;
}
}
delay(1000);
}
void setupFile(){
Serial.print("ow A:\\DATA");
Serial.print(fileCounter,DEC);
Serial.print(".TXT");
Serial.print('\r',BYTE); // CR to send message
}
//------------------------------------------------------------------------


from this code.


3. http://itp.nyu.edu/~sk2745/sensor/DATA3.TXT

4. http://itp.nyu.edu/~sk2745/sensor/DATA5.TXT




Problem
1: How to save exactly right serial data to computer and micro SD card

2: How to read data inside micro SD card

3: Is it possible to use Arduino as a serial to usb device?

Sunday, March 2, 2008

Datasheet Report:

Datasheet Report

LHI878 - LHi 878 Standard Dual Element Detector
http://optoelectronics.perkinelmer.com/

Human and animal emitte infraed light which range is 9.4uM.
The LHi 878 can detect 8~14uM infraed light.

The LHi 878 pyroelectric infrared-detector series are the standard dual element design recommended for all variants of motion control. They include a dual element pyro-electric ceramic with FET in source follower connection. The LHi 878 is available as TO-5 housing with standard infrared filter. It provides for high responsivity with excellent common mode performance (match). RF improved options are available.

*view*
D- supply a voltage to 'Drain'
s - get the signal from the 'Source' which require a load resistor which is recommended to 47 kohm
g - supply GND

*how work*
*configuration*


Datasheet:
click the image



Question.
How can I work with this sensor at Arduino?
Do I have to make some citcuit or something?











Sunday, February 24, 2008

Sensors and Time



Sensors & Time - Graphing, visualizing and characterizing sensor behavior.

Two potentiometer and one photo sell sensors.



Arduino Code

int sensorPin1 = 4; // select the input pin for sensor
int sensorPin2 = 5; // select the input pin for other sensor
int sensorPin3 = 0; // select the input pin for other sensor
int ledPin = 13; // select the pin for the LED
int val1 = 0; // variable to store the value coming from the sensor
int val2 = 0; // variable to store the value coming from the sensor
int val3 = 0;

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(sensorPin1, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(sensorPin2, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(sensorPin3, OUTPUT); // declare the ledPin as an OUTPUT

Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {

digitalWrite(ledPin, HIGH); // sets the LED on

val1 = analogRead(sensorPin1); // read the value from the sensor
val2 = analogRead(sensorPin2); // read the value from the sensor
val3 = analogRead(sensorPin3); // read the value from the sensor

Serial.print("A"); //header variable, so we know which sensor value is which
Serial.print(val1, DEC); //send as a ascii encoded number - we'll turn it back into a number at the other end
Serial.print(10, BYTE); //terminating character

Serial.print("B"); //header variable, so we know which sensor value is which
Serial.print(val2, DEC); //send as a ascii encoded number - we'll turn it back into a number at the other end
Serial.print(10, BYTE); //terminating character

Serial.print("C"); //header variable, so we know which sensor value is which
Serial.print(val3, DEC); //send as a ascii encoded number - we'll turn it back into a number at the other end
Serial.print(10, BYTE); //terminating character

delay(10);
}



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


Processing Code

import processing.serial.*;

Serial myPort;
PFont myFont;
String buff = "";
int val = 0;
int NEWLINE = 10;
int i = 1;
int valueA, valueB, valueC;

int[] valuesA = new int[10];
int[] valuesB = new int[10];
int[] valuesC = new int[10];

float valNormA, valNormB, valNormC;
int valnormA, valnormB, valnormC;

String bufA="", bufB="", bufC="";
int buf;

int wrote = 0;
int legendary = 0;
int offset = 0;
int offsettext = 25;
int lf = 10;


void setup () {
size(800, 600);

myFont = loadFont("ArialMT-12.vlw");
textFont(myFont,14);
textAlign(LEFT);
smooth();
strokeCap(ROUND);

background(0);
println(Serial.list());
myPort = new Serial(this, Serial.list()[1], 9600);

line(0, 220, width, 220);
line(0, 440, width, 440);

}

void draw()
{
fill(0,5);
noStroke();
rect(0,0,width,height);

while (myPort.available() > 0) {
serialEvent(myPort.read());
}

valNormA = valueA/1023.0;
valNormB = valueB/800.0;
valNormC = valueC/1023.0;

valnormA = (int)valueA;
valnormB = (int)valueB;
valnormC = (int)valueC;

strokeWeight(5);
stroke(255,100);
fill(0,0,255);
ellipse(i, valNormA*220+100, 20, 20);

pushMatrix();
translate(0, 220);
stroke(255,100);
fill(0,255,0);
ellipse(i,valNormB*1000+100, 20,20);
popMatrix();

pushMatrix();
translate(0,440);
stroke(255,100);
fill(255,0,0);
ellipse(i,160/2 - valNormC*160, 20, 20);
popMatrix();

if (i > width) {
i = 0;
pushMatrix();
strokeWeight(2);
fill(0,1);
rect(0,0, width, height);

popMatrix();
}
else {
i++;
}

if (wrote > 30)
{

fill(255);
text(valnormA, i, ( valNormA*220)+80);
pushMatrix();
translate(0, 220);
fill(255);
text(valnormB, i, ( valNormB*1000)+80);
popMatrix();
pushMatrix();
translate(0, 440);
fill(255);
text(valnormC, i, (160/2 - valNormC*160)+60);
popMatrix();
wrote = 0;
}
wrote++;

}

void serialEvent(int serial){
if(serial!=10) {
if (serial=='A') buf = 1;
if (serial=='B') buf = 2;
if (serial=='C') buf = 3;

if (buf==1) {if (serial!='A') bufA += char(serial);}
else if (buf==2) { if (serial!='B') bufB+= char(serial);}
else if (buf==3) { if (serial!='C') bufC+= char(serial);}
} else {
if (buf==1) {valueA = int(bufA); bufA="";}
else if (buf==2) {valueB = int(bufB); bufB="";}
else if (buf==3) {valueC = int(bufC); bufC="";}
}
}

Sunday, February 10, 2008

Sensor walk

Sunghun Kim :: 8 February 2008

1. Ipod touch sensor
2. Elevator Door Sensor - IR
3. subway card reader
4. Grocery Store Doors - IR/Motion detect
5. Bar code reader
6. ATM card reader
7. Bathroom: automatic toilets - IR
8. NYU library entrance's card reader
9. Library book barcode reader
10. Heating system - Thermo-sensor
11. Lights on streets. - Light/timer sensor

Manufacturer Descriptions

precipart.com
- custom motion control products and devices, custom gear & gearbox

sensicast.com
- Ambient Temperature and Humidity, RTD (wireless temperature measuring devices) real-time temperature and humidity monitoring devices

kavlico.com
- Pressure Automotive Position Force Sensors

emxinc.com
- Color sensors : color, color mark, luminescent, brightness level

This blog is for Sensor Workshop at ITP S2008