Friday, September 26, 2008

Upgrades to the home-made GPS

I've been back in Ireland for just over a week and have had a chance to try out the GPS interface that I wrote about last time. Also, my dad gave me an amazing USB oscilloscope as a gift for starting my new job (and life!) in Paris. It is great for testing out the GPS interface circuit before it is ever connected to the camera, and I'll have some suggestions for using one to debug the datastream in the next post.

I used the GPS with my D300 at the weekend and I'm pretty happy with it. When I power up my camera with the GPS connected, it quickly starts to receive the NMEA datastream and the GPS light flashes. After about a minute the GPS locks on to its position and the GPS light turns solid. Photos then have the position and UTC time from the receiver embedded in their EXIF data. The photo sharing site Picasa recognises this information and put the photo onto a map automatically, which is nice.

I have a few reservations with the GPS engine and with the interface circuit:
  1. The combination of the D300 and GPS uses a lot of current, and runs down the battery very quickly. This happens because you really have to set the D300 so that it keeps the power on all the time when the GPS is connected, otherwise you will have to let the GPS power down between shots and it will take a long time to reacquire its position. When the power is on the D300's meter is also on, and between them they draw a lot of current. I measured the GPS at 80mA (at least during the period that it is acquiring the satellite lock). The D300 battery is 1500mAhr, which means that it should be able to power the GPS constantly for about 18 hours. It seems that you get more like 3-5 hours (I didn't measure it exactly), so I guess that having all of the camera electronics on must draw a lot of current also. You can obviously turn the camera off when you are not using it and save power, if you don't mind waiting for the GPS to reacquire its fix.
  2. The switch in the circuit doesn't allow the camera to power down as intended. Obviously it disconnects the +5V line from the interface board (by design) but somehow the circuit still keeps the camera awake even though there is no GPS data stream. Best that I can figure, the camera monitors the serial RX line for a transition from +5V to ground (i.e. it looks for the RS232 start bit).. and somehow it detects this when it is powering down and then comes back to life again. When you flip the switch on the GPS off you can see the meter turn off and immediately back on again over and over again.
  3. The GPS engine took a long time to lock on the first time it is turned on in a while... and occasionally won't lock on at all. Initially I though there was a problem with its backup battery.. but it turns out that it is not a battery at all but a 0.22F "supercap".
The first two problems can be solved by changing the way that the GPS is powered, either by powering from the VBATT (brown) line from the camera or from an external battery pack. With this change there is no need to leave the camera meter on permanently, i.e. you can enable "Auto Meter Off" mode again and the camera will shut down its internal electronics after a short time of inactivity. Since the GPS engine (BR-355) specs call for a maximum of 6.5V, and the Li-Ion battery in the camera is 7.4V, a +5V regulator should be used to reduce the supply voltage, as shown below. I used a TS7805 which is all that I could find in Maplin in Dublin over the weekend. This 1A regulator is really overkill, and also requires a 2V clearance, meaning it will only deliver +5V while the battery voltage is >7V. A smaller (100mA) regulator would be better, but they were out of stock.
This circuit fixes the first two problems perfectly. The switch on the GPS now controls the power to the GPS engine. When it is on the engine draws power from the camera battery directly, irrespective of whether the camera switch is on. You can leave it on when out shooting and the GPS will stay locked on. The two interface transistors are powered from the camera +5V regulated supply and are only powered when the camera is on. When the camera meter comes on the D300 recognises the GPS stream within about a second, so there is very little shooting delay.

It also seems that the cause of the third problem may have been that I had routed the wires to the switch right over the antenna of the GPS and these were then interfering with the reception of the very weak satellite signals. Moving the wires to the side of the box seems to allow it to lock on much more quickly. I haven't had time to test this rigorously yet though, or to measure how long the GPS will run when powered from the camera battery.

Friday, September 19, 2008

Home-made GPS for Nikon D300

Please read the next blog entry before building this circuit, as it details some important upgrades.

I'm in Ireland for a small vacation, having left Los Angeles (and indeed the US) permanently last week. I start my new job in Paris next week, so I'm enjoying the opportunity do do absolutely no work this week!

One small Nikon project I worked on before I left L.A., inspired by some other blogs, is a home-made GPS which connects to my D300. The GPS is based on a Globalsat BR-355 engine, which can be purchased cheaply on eBay ($25 - Sept. 2008), with a simple interface using two FET transistors and a couple of capacitors (bypass and reservoir) to ensure the signal is nice and clean.

The BR-355 outputs an RS232 serial datastream which carries NMEA-formatted position and time information at 4800 baud. Logic levels from the BR-355 are -5V for logic 1 and +5V for logic 0 (i.e. standard RS232 at 5V). The camera expects +5V CMOS signals, +5V for logic 1 and 0V for logic 0. The interface circuit therefore needs to be an inverter operating between +5V and 0V, which can deal with negative voltages at its input. Others have suggested a simple NPN-transistor with a diode clamp and a couple of resistors, which should work fine. I opted for an N-channel and P-channel MOSFET configured as a CMOS-like inverter. The basic circuit is show below:

Like real CMOS output stages, one of the transistors is fully on and the other fully off when the input is held at a fixed logic level. When the GPS voltage is -5V (logic 1), Q1 is on and Q2 off, so the output is held at the +5V rail. When the GPS is at +5V (logic 0) then Q1 is off and Q2 on, and the output is held at ground. No clamping diode is needed as the N-channel FET (Q2) can handle negative voltages on its gate. Current only flows through this circuit when it is switching from one logic level to another. At some cross-over voltage (between 0V and +5V) both transistors conduct equally and current flows between the rails. This happens only very briefly as the GPS voltage slews between its two states, but can give rise to spikes on the output line. The bypass and reservoir capacitors in the circuit eliminate these spikes (actually, in a circuit this simple only one of the capacitors is really needed, but it's good practice to put them both in). The voltage at which this cross-over occurs is dependent on the characteristics of the MOSFETs used - in a real CMOS gate the two transistors are built so that the switch over is half the rail voltage (+2.5V). With the two transistors shown the switch over is +1.8V, and the circuit uses approximately 1 microamps when fed from the NMEA datastream (compared with the 40-80 milliamps that the GPS itself consumes!).

The circuit and GPS board all fit nicely into a small project box.

The final thing that needs to be discussed is the connections to the GPS engine and to the camera. The BR-355 consists of a GPS engine in a nice molded enclosure with a magnet to attach it to a metal surface. To use the engine in this project I suggest that you extract it from its enclosure - you have to do some cutting to get the cable free. The GPS engine has a small 5-pin connector and comes with cable that you can cut to any length you desire. You can see in the photo above that I left about 2 inches. The wires on the GPS cable have the following functions:
  • RED - +5V supply to GPS,
  • BLACK - Supply ground,
  • GREEN - Serial data (NMEA stream) out of GPS,
  • WHITE - Serial data in to GPS - can be used to send commands to GPS board to change its configuration,
  • SILVER braid - Cable ground.
The BLACK, GREEN and RED should be wired to the connector labelled GPS in the circuit diagram (as pins 1,2,3). I also connected the SILVER braid to the ground point. I left the white wire unconnected as I suspect it is pulled-up internally to the correct voltage.

On the camera side, the D300 has a 10-pin multi-function connector which is used by various Nikon products, such as the MC-30 shutter release and the MC-35 serial converter (Nikon's device for use with GPSs etc.) You can also get this connector on various non-Nikon products, such as the cheap shutter releases that you can get on eBay, but it does not seem to be available through the major electronics outlets, such as Digikey.

Initially, in my desire to be thrifty, I got a couple of these cheap shutter-releases from China with the hopes of using one of them, as described in epicblog. The two I bought both had 10-pin connectors but to save money they use 4 full size, active pins in the connector, to which wires can be soldered and 6 small stud pins, which do not penetrate the plastic molding at the back and so cannot have wires attached. This necessitates dismantling the cable and moving the active pins to different positions and re-soldering the cable. In the process of removing some of the stud pins by pushing them through the plastic molding they broke off. It seems that (at least) the stud-pins are quite brittle - I tested this on some of them that I successfully removed. I decided that, rather than risking having a pin break in the connector on the camera (which would be a disaster!), I would not use the cheap connector at all.

The next cheapest way to get one is to bid on any of the Nikon MC-?? accessories that has one, as it seems that all these Nikon products have connectors with 10 active pins and a high quality 10-wire cable. I got a Nikon MC-22 on eBay for about $35 and chopped off the banana clips that were on the end, leaving just the beautiful 10-wire cable and 10-pin connector.

A diagram of the pins on the connector and table of the function of each pin, and the colour of the wire that corresponds to it on the MC-22 I purchased is shown below.

  1. RED - RX - serial data in to camera
  2. BROWN - Battery voltage (~6V) - on all the time
  3. GRAY - Regulated voltage (5V) - this voltage is powered when the camera meter is also on. The D300 can be configured to keep this powered on whenever a GPS datastream is detected, so that the GPS stays on.
  4. PURPLE - Release shutter - the Nikon shutter release (MC-30) shorts this to ground when the button is pushed all the way in.
  5. ORANGE - unknown
  6. YELLOW - Signal ground (to regulated supply)
  7. GREEN - Battery ground
  8. BLUE - TX - serial data out from camera.. does the D300 use this line?
  9. WHITE - Enable meter - MC-30 shorts this to ground when the button is pushed half way.
  10. BLACK - unknown
I connected the YELLOW, RED and GRAY wires to the three pins on the CAM connector (again as pins 1,2 and 3 respectively) in the circuit above. I strongly advise you to verify the function of each of the wires on any cable you want to use, as I cannot accept responsibility for any damage you do to to your camera by using the information in this post, I am simply reporting on what I did.

With everything connected, turn on the camera and set the "Auto meter off" option to OFF (in the GPS menu), so that the power to the GPS remains on all the time that the camera itself is switched on. You should see the GPS indicator flash and eventually stay lit, showing that the camera is receiving the datastream and the GPS has locked on.

That's enough for now. Next time some thoughts on how well the circuit works in real life, further refinements and some options for debugging the data stream with a DSO (if you have one!).

Saturday, September 13, 2008

Summary of strobe project

I'll be moving from LA to Paris (via a 2 week holiday in Ireland), and I likely won't be doing anything more on my strobe measurements until all my electronics gear arrives in Paris, assuming it doesn't sink into the Atlantic. Here's a summary of where the project is:
  1. Understand the Nikon CLS protocol - not started yet.. I need to get a digital oscilloscope to work on this. I have my eye on a USB scope from the UK company Picoscope.
  2. Understand the response of the Nikon strobes to TTL control signals - some measurements made. Seems like it should be possible to calibrate a controller to generate fixed power settings (1/2, 1/4 etc..) to emulate a Nikon CLS wireless flash in manual mode. This calibration would need to be changable so that it could work with any Nikon strobe.
  3. Design and build a controller that can be connected to a Nikon strobe to make it compatible with the Nikon optical "wireless" protocol - not started.
  4. Design and build a radio frequency controller to do CLS over radio - a long way off!
Obviously there is still a lot to do. Hopefully I will get back to it in the new year.. or sooner if I can get a DSO before then, as point 1 may not really need all of my electronics gear.

Before I leave I hope to post something about interfacing a Nikon D300 with a serial GPS module.

Friday, September 5, 2008

Flash pulse vs. quench delay

Likely the best way to measure the amount of light emitted in the flash pulse is to use a flash meter. These are calibrated devices which measure the absolute amount of light in a flash pulse. They also cost a lot! Home-made solutions, based on a cheap photo-diode, are also possible. A photo-diode is a device that produces a current that depends on the intensity of light falling on it. Assuming that the flash pulses all have the same spectral profile, i.e. that all pulses have an equal mix of colours, but differ only by the overall amount of light produced, the photo-diode will produce an electrical pulse with a charge proportional to the amount of light in the flash pulse.

A nice method too read out the photo-diode would be to digitize the flash pulse intensity vs. time profile using a digital storage oscilloscope (DSO) and integrate the amount of light in software, but again, you need an expensive DSO to do this. A cheap solution is to integrate the amount of light in the flash pulse using an electronic integrator and then read out the result with a volt meter. An integrator is a small circuit using an operational amplifier chip, which stores charge in a capacitor, producing a voltage that is proportional to the total amount of charge that flows into it, ideal for this application. Pretty much any op-amp will work, but those with FET input transistors work best, since they draw almost no input current and have very low bias and offset currents, to which integrators are particularly sensitive. A typical integrator circuit is shown below.


I used the Texas Instruments TLC27M2A1 opamp in this circuit and was very happy with the results. The charge in the pulse is integrated while switch SW2 is held closed. The pulse size is read as a voltage at OUT. Switch SW1 clears the charge on the capacitor, zeroing the integrator for the next flash pulse. Ideally D1 is a photo-diode, but any regular LED will also work. To cover a large range of flash pulse sizes it is convenient to be able to change the value of C1 - an IC socket into which the capacitor is plugged makes this easy.



The plot shows the integrated charge from the photo-diode for a Nikon SB-25 and SB-600 strobe set in manual mode. The strobes were set to full, 1/2, 1/4, 1/8, 1/16, 1/32 and 1/64 power and the photo-charge measured at each setting. The charge is plotted in stops -- a change of one stop corresponds to a factor of two change in the detected charge. With the exception of the full power setting on each strobe the amount of charge is linearly related to the manual power setting to within a fifth of a stop. For each strobe the full power setting is almost a half a stop above the expected value. I have no explanation of why this is.. my guess is that it is difficult for the manufacturer to control the discharge of the capacitor at the full power setting, and this is the best the could do.



The results of using the a time delayed TTL quench with the SB-25 and SB-600 is shown in the second graph. The plots shows the amount of photo-charge measured as a function of the delay between the trigger and quench signals in milliseconds. The flash pulse size is again shown as a fraction of the full-power pulse in stops. A few things are immediately obvious:
  • The SB-600 can produce flash pulses over an amazing range of almost 14 stops. Fourteen stops is equivalent to ~1/16000! The lowest few points were hard to measures and there is considerable measurable error in the data.
  • The SB-25 seems to flatten out at small quench delays. Presumably the electronics in the -25 are not able to stop the current flow from the capacitor quickly enough to produce very dim flash pulses.
Well, that's enough for now. Next time a summary of where the project stands, and possibly also a small diversion into interfacing Nikon cameras with a GPS.