Saturday, October 6, 2018

Using Arduino Nano as a External Shutter Release (External Trigger) with DigiCamControl Software


External triggers can be used to extend camera(s) capture capabilities like bulb mode for cameras which don't support it or to trigger multiple cameras in same time without lag. In this project we using Arduino Nano and opto Isolator to interface Shutter release PC serial Port Cable.

Nikon DSLR Camera require the metering circuit (Auto Focus) signal to be present when the shutter release signal fires. If the shutter release button on the camera half pressed, its will focusing the metering circuit to focus the camera lens. To handle with these two signal controls without interfere each others, we need an opto isolator for each signal control.

Nikon camera has an interface terminal called "Nikon 10-pin remote terminal", which has connected to ground pin, release trigger pin, and wake up/ focus pin. We use those pins to interfacing with Arduino Nano with PC serial that will be able to triggering Nikon Camera externally.


From the Arduino Nano digital output pins to these Nikon shutter pin and focus pin, we need to add opto isolator circuit to separate the camera power and the arduino power. The opto isolator also use to separate the focus signal and the shutter signal to avoid interfere each others when internal shutter button pressed manually.

To work with DigiCamControl Software External device Trigger, we need to define its interface controller first. This can be done in Setting->Device->Add. The image below shows the setting for Arduino Shutter Release, more combinations shows in Setting->Devices.


After a device is defined, the Arduino Nano shutter release can be used in multiple places like in multiple camera control. If the camera has an attached device, all capture action will executed by the device, not by the normal PTP script utility. In this way if the arduino Nano connected to 2 cameras and if we click on capture, both cameras will capture.


The DigiCamControl Software using RS232 serial protocol with default baudrate 9600bps. The Command control is using ASCII text ended with "Carriage Return" and "Line New" codes. The first line coding is to setting the baudrate and define the shutter pin on Arduino:



int RLY_CAMERA = 12;
            int BAUDRATE = 9600;

void setup()
{               
  // initialize the digital pin as an output.
  pinMode(RLY_CAMERA, OUTPUT);
 
  Serial.begin(BAUDRATE);
  while(!Serial)
  {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  // reserve 200 bytes for the inputString:
  inputString.reserve(100);
  digitalWrite(RLY_CAMERA, LOW); // Ccamera off
}



And for the next step, we need to matching the command to "Shutter ON" and "Shutter OFF" as declared before in DigiCamControl Software.


·                            Shutter ON  : “A”
·                            Shutter OFF : “O”


Below are the coding to check the command sent from DigiCamControl Software to the Arduino Nano and trigger the Camera if a command found.



// the loop routine runs over and over again forever:
void loop()
{
            digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
            digitalWrite(PULSE, HIGH);   // turn the LED on (HIGH is the voltage level)
            delay(1);               // wait for a microsecond
            digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
            digitalWrite(PULSE, LOW);   // turn the LED on (HIGH is the voltage level)
            delay(1);               // wait for a microsecond

            if (stringComplete)
            {
                        if (inputString.startsWith("A"))
                        {          
      Serial.println(inputString);
      Serial.println("Trigger ON");
      inputString = "";
      stringComplete = false;
      digitalWrite(RLY_CAMERA, HIGH);  
                        }
                        else if (inputString.startsWith("O"))
                        {
      Serial.println(inputString);
      Serial.println("Trigger OFF");
      inputString = "";
      stringComplete = false;
      digitalWrite(RLY_CAMERA, LOW);  
                        }
            }
}


void serialEvent()
{
  while (Serial.available())
  {
    // get the new byte:
    char inChar = (char)Serial.read();
    //delay(10);
    // add it to the inputString:
    if (inChar != '\n')
    {
            inputString += inChar;
    }
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n')
    {
            stringComplete = true;
    }
  }
}