Showing posts with label sensor. Show all posts
Showing posts with label sensor. Show all posts

Friday, August 9, 2013

PIR Sensor IO

Datalogging the output from a PIR sensor. The output of the PIR is connected to an Arduino digital input. The PIR output is digital with no PWM for distance. On or Off is as good as it gets.
A separate +12V supply is connected to the PIR as the +5V from the Arduino is not enough for the PIR output to be stable.
PIR hooked into an Arduino via a Protoshield
Data saved to microSD card and charted in Excel

The Arduino code to monitor the PIR and fade in an LED if motion is detected.

int LED = 11;
int sensor = 7;
int n = 0;
int light = 0;

void setup()
{
  pinMode(LED, OUTPUT);
  pinMode(sensor, INPUT);
  digitalWrite(LED, LOW);
  delay(1000);
}

void loop()
{
  int sens = digitalRead(sensor);
  if(sens == LOW)
  {
    for(n=0; n<255; n++)
    {
      analogWrite(LED, n);
      delay(10);
    }
    light = 1;
  }
  if (light == 1)
  {
    if (sens == HIGH)
    {
      for(n=255; n>-1; n--)
      {
        analogWrite(LED, n);
        delay(10);
      }
      light = 0;
    }
  }
}

Tuesday, August 6, 2013

From Midday till Dusk

Light readings taken with the stormTrigger circuit from mid-day until dusk in Songkhla - Thailand.


The graph shows interval (x-axis) and A/D output (y-axis). Readings were taken at 400mS intervals.



Next step is to correlate the readings with actual light level measurements.

Saturday, August 3, 2013

Friday, August 2, 2013

soundTrigger first shots

With soundTrigger set to activate the camera at 50 A/D counts above ambient, I got some shots of my lighter striking. They came out not too bad.


From breadboard to protoshield

Tests on both the light and sound circuits on breadboard were promising. They tests did show a great deal of false triggering and I believe this was due to the bad connection nature of breadboards.

I took both circuits and layed them out on protoboard. This allows direct connection to the Arduino.

Tests so far are very promising.
soundTrigger circuit with microphone in the background
stormTrigger V3 layed out and working well

Wednesday, July 31, 2013

Ultrasonic distance measurement

Playing with the LV-MaxSonar-EZ1 together with Arduino. Wonderful self-contained module only requiring +5V and GND connections.
LV-MaxSonar-EZ1, PWM output connected
PWM output, 9.8ms @ 2 meters
Data captured varying distance between 2 meters and 10cm

Tuesday, July 30, 2013

soundTrigger rising

Playing with an electret microphone and a simple circuit.
A Mega328 samples the noise generated by the circuit and triggers a camera on the output via an opto-isolator.
Schematic in Eagle
Bread boarded Prototype
Measuring I/O performance
Performance looks promising. Measuring a triggering delay of 35uS (microseconds).
Arduino sketch to follow...


Monday, July 29, 2013

New light detector circuit

Prototyping the new light circuit on breadboard. Everything is working well so far.
Circuit detail (Transistor is wrong type but the correct footprint for the PCB)

Output in dim light is about 0.13V going up to just over 1V with an inspection lamp close to the transistor.

Photo Transistor
Low Power Op-Amp
This circuit will form the second PCB in a two stack design. Interconnects will be via pin headers (0.1") and power will be from a CR2032 3V coin cell battery.

The prototype PCB will be mostly SMD tech with the photo transistor and pin headers being through-hole.

Bit of code that just works...

/*
StormTrigger V3 30-07-2013
 */
#define FASTADC 1
// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

#define LIGHT 0
#define OUT_FOCUS 2
#define OUT_SHUTTER 3
#define LED 13
int trigVal = 0;

void setup() {

#if FASTADC
  // set prescale to 16
  sbi(ADCSRA,ADPS2) ;
  cbi(ADCSRA,ADPS1) ;
  sbi(ADCSRA,ADPS0) ;
#endif
  pinMode(OUT_FOCUS, OUTPUT);
  pinMode(OUT_SHUTTER, OUTPUT);
  pinMode(LED, OUTPUT);
  PORTD = B01010000;
  // calibrate sensor to just above ambient reading
  int ambVal = analogRead(LIGHT);
  trigVal = ambVal + 40;
}
void loop() {
  //read light level
  int lightVal = analogRead(LIGHT);
  //compare light reading to trigger value
  if (lightVal >= trigVal)
  {
    //trigger camera
    PORTD = B00101100;
    delay(15);
    PORTD = B01010000;
    digitalWrite(LED, HIGH);
    delay(30);
    digitalWrite(LED, LOW);
  }

}

Sunday, July 14, 2013

Version 3 - New Design

Hotshoe mounted
Built-in sensor
Coincell battery operation
Single LED feedback
Automatic setting & operation

35mm x 25mm x 15mm volume to work within.

Shown is the enclosure mounted on 7D.


Stacked PCBs. One uC PCB and one I/O PCB with a board interconnect.

Saturday, May 5, 2012

Input & Output

Still in September 2011...

Input specifications:

The A/D input range of the Arduino Uno (Atmega328P) A/D is 0-5V with a range of 0-1023 representing fully dark (0) to fully bright (1023).

Light measurement to allow for ambient light from fully dark up to full sunlight, plus sufficient sensitivity to detect lightning pulses.

Types of light sensor played with were LDR (Light Dependent Resistor) and Photo Transistor. 

Output specifications:

While triggering a camera (Canon DSLR to be specific) I do not want any circuit voltages or power of any kind to be passed to the camera external trigger port. In order to prevent this an optically isolated Solid State Relay was reviewed. Two devices were looked at (ASSR1219 and ASSR1228) as they are dual channel devices with low power requirements and with the control current set properly, they are very fast acting.

Circuit testing to be done.

Full information of the awesome Arduno microcontrollers can be found by following the link below:

http://arduino.cc/en/

The stormTrigger

Back to September 2011.

A quality camera triggering device is expensive.

The need for a lightning trigger was highlighted to me while staying in Hat Yai for a few days. Setting up a tripod on a balcony then setting the camera to long exposure mode, and continuously pressing the shutter, hoping to capture a lightning strike proved to be very hit & miss.

I have been playing with Atmega microcontrollers for a few months now, developing my understanding of programming and interfacing with sensors.

I set about deciding upon the specifications.