DIY Camera Controller – The Program – Part 6

November 11th, 2009 by Louise

More Pages From This
Tutorial

Part 1 - Intro
Part 2 - Parts List
Part 3 - Schematic
Part 4 - Sensors
Part 5 - Bread Board
Part 6 - The Program


Are you getting excited, desperate to try out the new toy?

We are almost finished with the prototype controller but without the program its not going to do a lot, in fact it’s not going to do anything.

Before you upload the program you need to install a library to control the LCD display, this rather excellent piece of work has been created for you by Dale Wentz and you can find out more in the Arduino Playground

There is a tiny bug in the library code which has not as yet been updated, so to save explaining how to fix it I have included the fixed library along with my program.

First thing you need to do is grab the Camera Controller Program and save it to your desktop or other easy to find place.

Inside the zip file you will find 2 folders, CamConV2 is the actual program for the controller, which needs to be copied to your Arduino sketches folder – In windows the default directory is My Documents/arduino/ Unfortunately I have no idea about Macs and Linux because I have never used one, but wherever the default sketches folder is on your system that’s where to copy the CamConV2 folder and its contents ;)

The other folder is LCDi2cR and contains the LCD library code, this folder and its contents should be copied into the libraries folder in the default Arduino sketches folder. If the libraries folder is not there just create it first.

OK, the moment of truth is upon us, time to program the controller.

Start up the Arduino software and select File – Sketchbook – CamConV2. You should be presented with the program in a new window. I am assuming you have the Arduino plugged into the USB port on the computer and everything is ready to go, I did tell you previously that you should install the software and successfully upload the blink demo to the Arduino.

Now select File – Upload to IO Board, the lights on the Arduino should have a fit, and then you should get a message appear on the LCD, then the main menu. If you don’t get any error messages on your computer screen and don’t get a menu displayed on your LCD display it would be a good idea to pull the plug on the controller and check your connections again ;)

If you do end up with a menu appearing on your LCD then things are indeed looking good, if you have made a sensor or two things are looking even better. I guess an attempt at describing how this thing works is now in order.

First of all the controls, you either have a keypad or 5 buttons hooked up, either way there are only 5 ‘keys’ used.

  • Keys 1 – 4 select the various options displayed on the screen.
    • Key 2 is also the ‘UP’ key when entering numbers
    • Key 3 is also the ‘DOWN’ key when entering numbers
  • Key 5 is the enter key (on the keypad its key 5 get it?)
    • Also ‘EXIT or QUIT’  key when indicated on the LCD
    • Also ‘NEXT PAGE’  key when navigating menus
    • Also moves to next number entry field when entering multiple numbers (times)

When the unit first powers up you are presented with the main menu, this has 2 pages and includes the following items (menu pages will wrap round to the first page):

  • Page 1
    • 1 Sensor – Runs the 1 sensor mode
    • Cross Beam – Runs the cross beam mode
    • Directional – Runs the directional dual sensor mode
    • Interval Timer – Starts the interval timer
  • Page 2
    • Manual Shoot – Allows you to manually trigger the outputs via a key press
    • Shutter lag – Measures your cameras shutter lag
    • Settings – Enter the settings menu

Each of the different modes have different requirements for sensors etc, obviously 1 Sensor mode only needs sensor 1 configuring. Cross beam and Directional will need 2 sensors configuring. Interval timer and Manual Shoot don’t need any sensors and measure shutter lag needs sensor 1 configuring.

The Shutter lag option works by firing your camera and measuring the time to the flash firing, its probably not fantastically accurate but may help when determining delays etc. To use it you need an optical sensor such as laser trip wire in sensor 1 input, configure the sensor to trigger if higher, set the value as low as you can go (use option 4 to check the ambient) Then connect up the camera (or set it up for infra red control), manual focus, flash on (preferably manual lowest power), aim the flash directly at the sensor from about a meter away and hit 1 to measure.

To configure the sensors (and other settings) you enter the settings menu which has the following items:

  • Page 1
    • Sensor 1
      • Trig if higher / Lower
        • Determines whether the sensor value has to be higher or lower than the trigger value. The current setting is enclosed in [ ] brackets
      • Value
        • This is the trigger value, should be set close(ish) to the non triggering value
      • View realtime
        • Displays the lowest, current and highest sensor values detected, use this to determine what value needs to be set above, or to ensure sensor/ reflector are lined up correctly etc
    • Sensor 2
      • Same as sensor 1
    • Output 1
      • Delay
        • This is the delay between the sensor detecting something and the output firing. For example when photographing water splashes you would enter a delay here that gives the drop time to hit the water and splash back up before taking the photo.
      • Time
        • This is the duration of the output in hours, minutes, seconds and milliseconds with a maximum time of 12 hours. You can use this to take long exposure shots with camera in bulb mode, or you could set your camera to continuous shooting mode and take several rapid shots.
    • Output 2
      • Same as output 1
  • Page 2
    • Number of frames
      • The number of frames to be shot, you can exit before by using ENTER/ EXIT key
    • Direction time
      • The maximum time allowed between sensor 1 detecting and sensor 2 detecting. The direction mode works by waiting for a trigger on sensor 1 and then checking sensor 2 for a trigger, if sensor 2 is triggered within the set time then the outputs are fired otherwise it goes back to waiting on sensor 1. This allows you to set up 2 laser trip wires parallel to each other some distance apart, the camera will take a picture when sensor 2 triggers but only if sensor 1 was tripped first and therefore the object is moving in the direction of sensor 2 from sensor 1.
    • Interval time
      • The time between frames and is active in all the modes except manual, so if you set this to 1 minute even sensor modes will not take more than a maximum of 1 frame per minute. The interval time is in hh:mm:ss:ms format up to 12 hours all but 1 ms.
    • Offset Delay
      • This delay (0-1000ms) is added to the output delay for each frame. It will allow you to create animations of things like water splashes by taking successive frames at a slightly later time each frame.
  • Page 3
    • Output 1 mode
      • Sets the way output 1 works with the current option enclosed in [ ] brackets
        • Wired – using a wired lead to fire camera (or flash)
        • Infra red – Using Nikon IR remote emulation
    • Backlight
      • Lets you set the backlight mode with current option enclosed in [ ] brackets.
        • Off – No backlight used
        • On – Backlight is permanently on
        • Timed (5-60s) comes on for the set time when any key is pressed then goes out.
    • Main Menu
      • Returns to the main menu.

There are a couple of things to be aware of:

When using Infra Red control mode you cannot use bulb mode on the camera, you should set the camera to a manual or auto exposure otherwise the camera will open the shutter and not close it again. So at the moment at least you cannot do long exposures with IR

Both outputs are fired every trigger event, although not necessarily at the same time nor for the same duration. You can use a camera or flash on either or both outputs so you could for instance use 2 cameras take stereo photos or 2 flashes to create double exposures with very small time differences etc

If your flash has a strobe effect (Nikon SB800/ SB900 etc) you can set the output to a longer duration to take strobe effect photos.

If an output with a flash has too short an Output Time the flash may not fire, use trial and error to find the minimum duration needed for your flash.

Cameras should preferably be set to manual focus, the controller has no means of detecting if auto focus has finished so for autofocus use you will need to increase the Output Time to allow the camera enough time to focus. Given that the controller is geared toward detecting an object at a specific place I don’t think autofocus is really an issue.

Some flash guns can have very high voltages on their PC sync/ hot shoe connectors and if so could fry the 4N35 opto coupler, if this is an issue contact me and I will try to sort out a more robust output isolator for you.

Next version of the software will hopefully save all the settings to Flash memory to cut down the workload setting it up each time ;)

More Pages From This
Tutorial

Part 1 - Intro
Part 2 - Parts List
Part 3 - Schematic
Part 4 - Sensors
Part 5 - Bread Board
Part 6 - The Program


Finally, I am by no means a expert programmer as you will probably be able to tell from the spaghetti code, if you are (or at least better than me) and have any suggestions for improving the code PLEASE do let me know.

Well that’s about it for now, next part I will cover connecting cameras and flash guns to the outputs so you can really start to use the thing in anger.

Part Seven – Outputs is coming soon, watch this space..

Tags: , , ,

19 Responses to “DIY Camera Controller – The Program – Part 6”

  1. Jesus says:

    Great work, congratulations and thanks for sharing it with us.

  2. Louise says:

    Jesus: You are welcome, it’s not over yet though. I will be covering putting this together on veroboard with Arduino pro mini so you can put it all in a project case next, also a sound sensor circuit for balloon bursting type photos.

    Watch this space ;)

  3. Barry says:

    This is great , I have already built one project with the ardunio using a photogate , and also built the Hi-viz light and sound unit before that , and I was looking for a decent laser system , looks like I have found it. Have you thought about making a PDF file , black backgrounds play havoc with my eyes lol

    thanks for your hard work

  4. Louise says:

    Thanks, the laser detector works very well. I originally used an LDR to detect the reflected light which worked quite well also but the photo transistor response is obviously way faster.

    As for the colours, I haven’t any plans to produce a PDF but there is a solution to 99% of dark backgrounds if you don’t like them.. Get firefox browser; go to Tools menu, options; select the content tab; click colours; select your preferred text and background colours and remove the tick from ‘Allow pages to choose their own colours’ and voilà, no more dark background ;)

    You could also just highlight the text and copy & paste it into a notepad/ wordpad file ;)

  5. Alan says:

    Hi
    I stumbled into your Website a few weeks ago,whilst researching a controller for my son.
    After reading your instructions I decided to give it a go

    Ordered everything as per your instructions, then when everything arrived set about building the unit
    3 days later and wooohoo it works
    He is now the envy of all his pall’s at college
    Crackin project, with clear instructions
    Big thanks
    Alan H

  6. Louise says:

    Fantastic :)

    You are the first person to let me know you have re-created the controller and I am really pleased you found it worthwhile.

    The project is not complete yet and I am hoping to get the next stage, the portable version, done early in the new year. Building the portable version using the Arduino pro mini will involve a bit more electronics as the on board regulator is not quite up to the job of powering everything, I now have all the components needed but I have just changed address so they are temporarily lost in the piles of yet to be unpacked boxes and with Christmas approaching fast I don’t have time at the moment.

    Ask your son to pass on the website URL to his pals ;)

  7. Louise says:

    Thanks to Barry for pointing out a bug in the program.

    When changing backlight mode the program hung. To fix it re-download the program which is now fixed or if you want to change it manually, find the following line (near line 440):

    if (page>=21 && page< =29) page=int((page-21)/4)+10;

    and change it to:

    if (page>=21 && page<=30) page=int((page-21)/4)+10;

    Then upload to the Arduino.

  8. Casey says:

    Amazing! Was really wanting to dabble with droplet photography and other perfectly-timed subjects. Anxious to dust off my soldering/electronics skills and build this puppy! Thanks so much for sharing your project, and your test photos are wicked!!

  9. Peter says:

    Just to say thanks for publishing such a great project. I have just finished the main box and 1st sensor and need to get my head round the cross beam sensors. I have adapted your sketch to make use of a 4×3 keyboard and made it more menu based.
    Photos of my work so far at http://www.flickr.com/photos/15498653@N08/sets/72157623843176383/

  10. Louise says:

    You are welcome.

    Actually my design used the 3X4 keypad, but I wanted to fit it all into as small a box as possible so decided to use push buttons instead.

  11. mark says:

    Well done! Did something similar myself using microchip PIC and found your page while I was thinking of revisiting the project. I used opto isolators on my version too and found that I had to add diodes to stop them blowing due to the voltage spikes when turning them off. Have you had this problem?

    Anyway I never did get round to writing a progressive delay program to add to my chip so I better get back to it

  12. Jeff says:

    Did you ever write section 7 and did you make up the kit of parts? I think the project looks great, just what I want but a bit beyond my skills!

  13. Louise says:

    No I didn’t write up section 7, I have moved house 3 times since then and have had too many things going on to spare time on it.

    I have not really had that much interest shown in it, in fact you are the first person to ask about part 7, so it is not exactly a high priority for me and there is little chance of me making a kit of parts without there being a fair bit of interest – I would have to buy in bulk and split the lots, I don’t want to end up with loads of components I will never use ;)

    Sorry :(

  14. Shane says:

    Hi Louise

    Interesting project!!

    I couple of questions if I may:

    - The setup of the LCD includes LCDi2cR lcd = LCDi2cR(4,40,0×63,0); but it looks like you have the same LCD as me i.e. 4 x 20 characters. Any reason for the reference to 40?
    - I am using the same LCD library as you. This library includes a command to obtain a value from the keypad – lcd.keypad() – but I see that you have included your own code in the sketch. Was there a reason for this?

    I ask because I am having problems with false characters being read when no key is pushed – I might try your code if that is OK.

    Cheers

  15. Louise says:

    Hi Shane,

    I have not worked on this project for quite a while so it is not fresh in my mind but I would say the setup is just a typo – although it does not appear to make any difference.

    As for the key reading, I used my own code in order to incorporate a debounce and custom repeat. If the key is held down it goes into repeat mode for increasing/ decreasing the values quickly.

    The code is rather untidy, it was the first project I have done with the Arduino so I was learning the syntax & language as I wrote it, if you wish to make use of any of the code and/ or modify it then please feel free to do so.

  16. Shane says:

    Thanks Louise, I am also learning the programming language for the first time, although I have done some Pascal programming many years ago.

    I can learn a lot by looking at existing sketches and using bits that fit my needs – yours has been very helpful. I also like the ‘get_value’ routine for increasing/decreasing numbers!!

    Cheers

  17. Louise says:

    My programming days were a long time ago, I used to program 68000 assembly language back in the days of the Amiga 500, not exactly much in the way of any similarities to programming the Arduino LOL

  18. Daniel says:

    I see that you have had a lot of other things to do since you posted the last post, and that you have had very few requests about the following chapters, but I am wondering if you are at least thinking about publishing the final parts of this excellent build?

  19. Louise says:

    I may do so, but at the moment I do not know when.

Leave a Comment