Tuesday 30 December 2014

High Speed Photography Project - Part 3


Software

The software script is listed below. At the moment it is very basic and requires ongoing work. The next stage is to add a menu option that will enable the user to select the 'sound' or 'light' option. At the moment if both elements of the code co-exist in the sketch it can cause some issues.

The sketch below has both elements contained within, however the you need to comment out either section. I would suggest saving two scripts, one for sound and one for light, it is easy to upload whichever you are using.

The display driver and button code is open source and provided by: www.Adafruit.com

#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

// constants won't change. Used here to
// set pin numbers:
int laserPin = 11;      //Laser input
const int ledPin =  12;      // Digital signal set pin
int val = 0;
const int thresholdvalue=200;//Mic Sensitivity
// Variables will change:
unsigned int Delay = 0; //Delay Time Variable
unsigned int Mute = 0; //Mute Time Variable

//---------------------------------------------------------------

void setup() {
  // Setup Digital & Analogue pin mode:
  pinMode(ledPin, OUTPUT);
  pinMode(laserPin, INPUT);
  Serial.begin(9600);
  // Setup welcome screen:
  // setup the LCD's number of columns and rows:
  lcd.begin(16, 2);
  lcd.print("FLASH CONTROLLER");
  lcd.setCursor(0,1);
  lcd.print("    ver: 1.8");
  lcd.setBacklight(WHITE);
  delay(5000);
  lcd.begin(16, 2);
  lcd.print("  SYSTEM ACTIVE");
  lcd.setCursor(0,1);
  lcd.print("  ENTER  TIMES");
  lcd.setBacklight(RED);
  delay(4000);
}

uint8_t i=0;

void loop() {

//-----------------Sound Trigger Delay Code -----------------------

  int sensorValue = analogRead(A0);//use A0 for Mic input
  if(sensorValue>thresholdvalue)
  {
  delay(Delay); // Delay from Trigger input to Flash
  digitalWrite(ledPin,HIGH);
  lcd.clear();
  lcd.print ("    INACTIVE    ");
  lcd.setCursor(0,1);
  lcd.print("  SYSTEM MUTED    ");
  delay(Mute); // Time sensor is inhibited:
  lcd.clear(); // Display Delay and Mute Time:
  lcd.print("Delay = "); lcd.print(Delay); lcd.print(" ms");
      lcd.setCursor(0,1);
      lcd.print("Mute = "); lcd.print(Mute); lcd.print(" ms");
      lcd.setBacklight(VIOLET);
  }
   else
  {
  digitalWrite(ledPin,LOW);
  // Serial.println(sensorValue); //Sensitivity Setup Aid - Serial Monitor
  }

 //-----------------Laser Trigger Delay Code -----------------------
 //int val = digitalRead(laserPin);
 //Serial.println(val);
 //if(val>0)
 //{
 // delay(Delay);
 //digitalWrite(ledPin,HIGH);
 // lcd.clear();
 // lcd.print ("    INACTIVE    ");
 // lcd.setCursor(0,1);
 // lcd.print("  SYSTEM MUTED    ");
 // delay(Mute);
 //lcd.clear(); // Display Delay and Mute Time:
 // lcd.print("Delay = "); lcd.print(Delay); lcd.print(" ms");
    //  lcd.setCursor(0,1);
     // lcd.print("Mute = "); lcd.print(Mute); lcd.print(" ms");
     // lcd.setBacklight(VIOLET);

// }
// else
//{
// digitalWrite(ledPin,LOW);
// }

//---------------------Button Control---------------------------

  uint8_t buttons = lcd.readButtons();
  if (buttons)
    lcd.clear();
    lcd.setCursor(0,0);
  if (buttons & BUTTON_UP) {
      delay(100); // wait for contact settle
      Delay = Delay + 10;
      lcd.print ("Delay = "); lcd.print(Delay); lcd.print(" ms");
      lcd.setBacklight(RED);
    }
    if (buttons & BUTTON_DOWN) {
      delay(100); // wait for contact settle
      Delay = Delay - 10;
      lcd.print ("Delay = "); lcd.print(Delay); lcd.print(" ms");
      lcd.setBacklight(YELLOW);
    }
    if (buttons & BUTTON_LEFT) {
      delay(100); // wait for contact settle
      Mute = Mute - 1000;
      lcd.print("Mute = "); lcd.print(Mute); lcd.print(" ms");
      lcd.setBacklight(GREEN);
    }
    if (buttons & BUTTON_RIGHT) {
      delay(100); // wait for contact settle
      Mute = Mute + 1000;
      lcd.print("Mute = "); lcd.print(Mute); lcd.print(" ms");
      lcd.setBacklight(TEAL);
    }
    if (buttons & BUTTON_SELECT) {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Delay = "); lcd.print(Delay); lcd.print(" ms");
      lcd.setCursor(0,1);
      lcd.print("Mute = "); lcd.print(Mute); lcd.print(" ms");
      lcd.setBacklight(VIOLET);
    }
 
   }

First Test Picture




High Speed Photography Project Part 2


Hardware Continued.




The 3 jack sockets provide input from the sound and light sensors whilst the third is the output for the flash unit.

Programming input is achieved via the push buttons. This provides input of delay time in milli- seconds. This is the duration between 'sensor stimulus' and the flash firing. Two buttons provide +/- increments.
The mute time is the duration the system is locked and will not respond the further stimulus. This is vital when operating in 'bulb mode' since it will inhibit the flash once the initial flash has occurred. It is user defined by two buttons again providing +/- increments.

I have designed a PCB to make construction easier and will upload the Eagle files later once I have refined it from the prototype.

High Speed Photography Project - Part 1

Overview

Over the past few months I have been developing ways to capture images from high speed events. There are many examples of ways to achieve this on the web and for those not wishing to undertake a home brew solution there are a number of commercial options. My objective was to set myself a challenge to develop a solution myself. My initial direction involved a fully hardware solution but I soon realised a software solution combined with limited hardware was the way forward. What follows is the documentation required to build this project.

I'm sure there are many talented individuals out there who could improve on this basic design, especially the software. All constructive inputs are welcome.

HardWare

The hardware utilises an Arduino Uno at its core and a limited number of external components to provide an interface for both Sound and Light Triggers.

The 'SOUND BOARD' can easily be constructed from an LM386 audio amp chip, as used in my original prototype. An easy option is to purchase a 'Linker Sound Sensor - A61NG' (available from Maplin) which I used in my final construction. It is easy to connect this via. a 3 core lead to the main Arduino board thereby providing flexibility for optimum microphone placement.

The 'LIGHT Trigger' can be configured in numerous ways. Using a laser pointer aimed at the photo cell providers a great 'beam breaking' option; the distance between sensor and laser pen can be many feet. Changing the laser pointer with an InfraRed LED Source and reducing the gap to a couple of centimetres provides a useful trigger for projectiles and water drops etc.

Output to the flash is via. Opto Isolator so all backend electronics should be safe. It is worth noting that some old flash guns have a high voltage across the input pins, it is possible to blow the Opto Isolator so I have used a high voltage option. To date I have used two very old flash guns with no issues.

The unit itself is very compact and runs for hours on a 9 volt battery. The construction comprises of three stacked boards: Arduino Uno - Homemade PCB - 16 x 2 LCD Shield from Adafruit.

Circuit Diagram