Sunday, November 9, 2014

Canon IR Trigger

This article explains the development of an IR trigger to be used on Canon EOS digital SLR cameras. It should mimic the operation of the Canon RC-1 remote trigger and will be built around an MSP430G2553 microcontroller. The article showed up on the hackaday blog.

Canon RC-1 remote trigger
The Canon RC-1 device features two options to remote trigger a camera. Instant shot, just as it receives the signal and two seconds delayed shot after the signal is received. That way, if you are in the photo, you have time to hide the remote out of view when the photo is taken.

A clone of the RC-1 trigger can be bough at about 20€ in local photo stores so the point of this development is not for economic purposes but to exercise in miniaturization and power restrictions.
I will also use it to add some new features in the future as the system will be reprogrammable.

Let's start with the basics.

Precedents and signal specs

Developing a DIY RC-1 clone is not anything new. I have used as a reference the EOS IR REMOTE work at doc-diy.net. This work is quite interesting for anyone trying to develop a RC-1 clone as it includes a reverse engineering of the original RC-1 remote. I don't quite like the proposed direct connection of a IR LED to the output pins of a MCU but worse things I have seen.

From this reference I have obtained the needed signal specifications.
To send the trigger signal, the Canon RC-1 remote sends two 16 pulses bursts. The bursts are at about 32700 Hz and are obtained from a watch crystal (They should be probably 32768 Hz).
The two burst separation determines the operation of the trigger.
If the start of both bursts are separated about 8ms (7.82ms) the shot is taken just as the signal is received.
If the burst separation is about 6ms (5.86ms) the shot is delayed two seconds after the signal is received.

The signal protocol is quite easy to reproduce and that simplifies the developing of a RC-1 clone.

The reference also indicates that the RC-1 remote uses an infrared signal with a 950nm wavelength.

IR LED Selection

The main element in the remote trigger is the Infrared LED that should send the pulse bursts to the camera. To select an optimal component we would need the characteristics of the IR receiver on the Canon EOS cameras. Unfortunately I don't have that information but a reasonable guess can be made from other IR receivers we can find in the market. I have considered a TSOP11 as and example of a typical IR receiver (normally used in IR remote receivers).

TSOP11 IR Receiver

Silicon is sensitive to wavelengths from near infrared to the end of the visible spectrum. IR receivers usually incorporate an IR filter that reduces tha sensitivity to visible wavelengths. That way, the visible light that shines over the receiver don't interfere with the revived IR signal. In the following figure I show the typical silicon wavelength sensitivity (from a silicon photodiode BPW33) together with the sensitivity of a TSOP11 receiver and the visible wavelength range. As can be seen, the IR filter on the receiver removes all sensitivity to short wave light, including all the visible range.

TSOP11 IR Receiver Vavelength Range
We cannot be sure that the EOS Cameras have the same sensitivity as the TSOP11, but its a quite reasonable guess. The fact that the RC-1 uses a wavelength of 950nm, just at the center of the TSOP11 curve, gives us some additional confidence.

Knowing the receiver sensitivity is important to select the IR emitter LED for the project as not all IR LEDs are created equal.

For instance, we can check a TSUS5400 LED whose characteristics are shown below:


The peak wavelength is at 950nm, just at the center of the TSOP11 receiver. So it will be ideal for the project. But peak wavelength is not all that we need. We also need power. The TSUS LEDs feature powers between 14 and 20 mW/sr. That is, 20mW for each stereoradian of solid angle.

In every radiant emitter there is a compromise between angle and power density. The radiant angle of the TSUS diodes is +/- 22 degrees. As can be show in the following curve:

Angle spread of TSUS LEDs
Having a big spread angle is good because that way we don't need to point exactly in the Camera direction, but is also bad because the total energy is spread in a bigger angle so less power incides in the receptor. As always there is no win-win solution and we should compromise. We can have a good range and a need to a better aiming or a bad range and loose aim needs. In this project I considered that 20mW/sr was quite low so I checked for other IR emiter options.

I finally narrowed the selection to two LEDs: TSHF5210 and TSAL6100. Both LEDs have the same angle spread of +/-10 degrees. As you can see from the following figure, that means that we will need a good aiming to us those devices.

Selected LEDs angle spread

The range is much better because those LEDs feature a quite bigger radiant power:



Both feature radiant powers over 100mW/sr (much better than the TSUS LEDs) but they are different in peak wavelengths and response time.

There are IR LEDs in the market with better radiant power. The SFH4550, for instance, features 400mW/sr at 100mA. But its radiant spread angle is only +/3 degrees so you will need a very good aim to use it.

Respect to the response time we would like to send 32768Hz signal bursts. That means a period of about 30us. A response time of about 1us in the TSAL6100 seems to be ok, but the TSHF5210 is better.

Respect to the wavelength, the TSAL6100 at 940nm is very near to the 950nm peak value of the RC-1 and the expected sweet point of the IR receiver. The project were I got the RC-1 specs used a SFH484 LED that has a peak wavelength of 880nm so I think that the 890nm of the TSHF5210 could not be too bad.

To further analyze the wavelength question we can put the LED responses, obtained from their datasheets, in the expected receiver sensitivity curve.

LED Wavelength comparison
As can be seen, the TSAL6100 diode is better positioned in the center of the receiver range. But the TSHF5210 has a bigger output (180mW/sr versus 130mW/sr). The bigger radiant power somewhat compensates for the wavelength offset. As the TSHF5210 also is faster I selected in the end this diode. In fact I can change it in the future so its not a big deal.


Circuit Design

The circuit to drive the IR LED is constructed around a MSP430G2553 microcontroller in a DIP20 package. This MCU, as the following figure shows, features 16KB Flash, 512B RAM, Two 8 bit ports (The third one is not available in a DIP package) and several peripherals. It can be overkill for this project but, for the added cost respect to less complex MCUs in the MSP430G family I don't need to optimize program size and several features can be added in the future without needing to change the MCU.

MSP430G2553 Features

Around the MCU there are several components, as we can see from the schematic below.

Canon IR Trigger Schematic
The IR LED is driven by a BC547 bipolar transistor in emitter follower configuration (common collector). This configuration don't require a base resistor as the common emitter configuration and is faster because the transistor never gets into the saturation region. This comes at a price, though, as the output voltage is reduced about 0,5V respect of the common emitter configuration. In this application this is no problem because we only need a maximum of 1.6V to drive the LED at 100mA as we can see from its datasheet:



TSHF5210 data
We can see that the maximum continuous forward current is 100mA. In our application we send a 16 pulse burst at 32768Hz. That gives a total duration of 488us that is more that the allowed peak forward current time of 100us in the datasheet. So we will keep the current at about 100mA.

The emitter follower configuration needs series resistor with the LED that can be calculated:

Rseries = ( Vport - Vled - Vbe ) / Iled

Where:
  Vport: Is the output voltage in a microcontroller port (3V)
  Vled: Is the maximum LED forward voltage Vf (1,6V)
  Vbe: Is the base emitter voltage of the transistor (0,7V)
  Iled: Is the desired LED current

That gives a  7 Ohm value. We will select a 6,8 Ohm value as it is a similar normalized resistor value.
In practice the battery output resistance, specially when it ages, can also limit the current so its easy that the current falls below 100mA in practical operation.

In the circuit, the transistor can be controlled with two port outputs: P1.4 and P2.1. We have selected both outputs because that way we can select three different ways to drive the LED:
  • Using normal GPIO operation with P1.4 or P2.1
  • Using the SMCLK output with P1.4
  • Using the line TA1.0 of the Timer 1
In the first test firmware of the system I have used normal GPIO operations, but in the future I plan to test the other options and connecting the base to both P1.4 and P2.1 leaves the options only on the software side.

MSP430G2553 20 pin package
The circuit includes a normal 3mm red LED diode connected to P1.0. That LED will light when the trigger signal is sent and will also be used to any other user interaction.

There are two push buttons connected to P1.3 and P1.5. One button will give an instant trigger of the camera and the other will give the two second delayed operation.

Two capacitors of 10uF and 100nF provide the needed supply filtering.

The circuit includes also a 32768 Hz 12pF watch crystal and two 22k resistors connected to P1.6 and P1.7. Both elements are optional as the system can work without them. In fact, the first developed firmware makes no use of them. The watch crystal is included to provide a better frequency stability than the internal DCO oscillator if it is needed and the two resistors are included to use the MCU ADC to measure the supply voltage and give indication of a low battery situation. 

Finally there is a 6 pin ISP connector. This connect, together with the 47k resistor and 1nF capacitor enables the system to be programmed using a custom cable using the TDIO and TCK signals. Pin 1 is eliminated from the connector to indicate its proper orientation. Pin 6 is connected to the CR2032 battery that supplies the system. That way we can power the system shorting pins 5 and 6 using a jumper. The circuit don't include a power switch because it can be powered off removing a jumper and because I plan to use the very low power modes of the MCU in the final firmware to make powering off the system unnecessary.


Breadboard Prototype

To test the system the main circuit elements were put on a solderless breadboard. To program the MCU a MSP430 Launchpad was used. I could use my previously constructed Launchpad FET but it was in use in another more important project. An Analog Discovery was used to test the timings.


Breadboard Setup

The first firmware for the project was developed on Energia, an Arduino like development environment for the MSP430 family. The timings for the IR signal were manually fine tuned using the Analog Discovery oscilloscope. You can find the code at this google drive reference. Energia provides a quick and dirty way to develop the firmware. The future firmware of the system will be developed under MSP GCC, but in order to check the operation of the system, Energia is ok.

UPDATE: There is a new firmware developed with GCC. See more information at the end of this article.



Circuit implementation

The final circuit is implemented in a solder 100 mil pitch breadboard. First step was to lay down all the components to check for needed space.

Project components (1nF cap is missing)
The following figure shows the layout of the components over the board that way the needed space is checked so that I can cut the board to the needed size.


Layout of the components
After the board was cut to size, the components were soldered and all the connections were done one by one. The routing was made on the fly with no previous planning, so I wrote down all connections as they were made on the board to check what was missing to route.

Board Routing Drawing



The following figure shows the upper side of the final soldered circuit. The 100uF capacitor, the IR LED and the watch crystal were locked in place with soldered metal wires.


Board. Upper side
To minimize the used space, the battery holder was soldered on the lower side of the board  after all the other component were routed

Board. Lower side



The IR LED needed some foam to guarantee that it was properly aligned to the board. As the radiant angle is only +/- 10 degrees it is important to get it right.


IR LED alignment
As was explained before, the ISP connector doubles as the power switch. As the first firmware, developed in Energia, was not efficient enough, the board needs to be put in off position when its not in use. Next firmware, to be developed with MSP GCC will use the low power modes of the MCU son the jumper won't need to be put in OFF position after each use.


ISP-Power connector
For now, the system works OK for distances up to 5m. Enough for my needs for a camera IR trigger.


Next Steps

The system, as it is now if fully functional. However I plan to do some improvements in the future:
  • Develop the firmware using my Eclipse MSP GCC toolchain
  • Implement the MSP430 low power mode so that the jumper can always be in ON mode
  • Use the 32768Hz crystal to provide a more robust timing
  • Implement the low battery indication using the resistors connected to P1.6 and P1.7

New Firware released (Update at 26/11/2014)

I have written a new firmware for the IR Trigger. You can find it in the following link:


It is developed using a portable MSP430GCC environment I describe in this other reference:


The new firmware uses the 32768 Hz crystal so it gives a more stable timing on the generated signal. It also greatly improves the idle current that goes from 3.2mA to 0.1uA.


Code is now embedded (30/11/2014)


Thanks to Gist, now the code is embedded inside the blog entry.


3 comments:

  1. Nice write up. Is the source code for this available?

    ReplyDelete
  2. Yep, the link is in a link included in the text:

    https://docs.google.com/document/d/1rqWkRUU4eEmcjEnAVqccBHkRR-vANMMnUwILBC5ER6o/edit?usp=sharing

    ReplyDelete
    Replies
    1. Thanks I was looking at this on a tablet and the light green link color wasn't noticeable. Thanks!

      Delete