Posts

Simulating cable disconnect on USB Host Shield 2.0

A MOSFET controlling VBUS

A MOSFET controlling VBUS


Today I want to show a simple USB Host Shield 2.0 modification which allows controlling power to USB peripheral. I learned this technique from Camille’s comment to one of digital camera USB control articles. In short, the idea was to cut VBUS connection between USB host and peripheral, simulating disconnect state. P-channel MOSFET, inserted into VBUS, worked as a switch. I designed this capability into USB Host Shield 2.0 but never needed the functionality therefore this useful feature was left undocumented. Recently I started working with very interesting Nikon P&S camera which can be turned on and off with VBUS power so I finally made this modification. It is very simple.

Take a look at the title picture (click on it to make it larger). The modification uses existing VBUS power select pads of the shield. Out of the box, the one labeled 5V is shorted with solder bridge. First step is to remove this bridge with a solder wick so both pads are clean.

It can be seen that a MOSFET in SOT-23 package fits nicely on those pads (I’m using FDN306P). Drain and source pins are soldered to VBUS and 5V, respectively, and gate, which hangs in the air, is routed to an unused digital pin via an 1M resistor. When digital pin is low the MOSFET conducts. When digital pin goes high the MOSFET switches off disconnecting VBUS from the peripheral.

If you are going to drive high-power peripherals, like digital cameras or phones, it is a good idea to add some capacitance to 5V. I’m using 220uF low-ESR organic polymer tantalum cap in 1210 package which fits nicely on 0.1″ spaced 5V and GND pins of the shield; an ordinary leaded 100-200uF aluminum capacitor will work as well.

Oleg.

Arduino USB Host 2.0 library progress report


[EDIT] r2.0-compatible PTP code has been released, see here [/EDIT]
A significant progress has recently been made in Arduino USB Host 2.0 library development. The estimated release date is still several months away; however, I just can’t wait that long to share my excitement. A hub support is now fully incorporated into the library, as well as all necessary multi-device support – connect/disconnect, initialization and event handling. The very first device class implemented for the new library is ever-popular PTP digital camera control. A short Youtube video shows Arduino controlling two different camera systems simultaneously.

Some interesting numbers: a sketch used to drive cameras in the video takes 19K and contains one instance of USB, one instance of hub, one instance of EOS and one instance of Powershot class. The same sketch with only one camera instance takes 17K, which means one camera instance occupies roughly 2K. Since ~30K of program memory is available on Atmega328P-based Arduino board, it should be possible to drive seven cameras with a single Arduino! Also, I’m using development version of code with lots of debug strings and other less-than-necessary stuff – release version will definitely be smaller.

Watch the video, stay tuned to the code development and please let me know what you think about all that! Multi-camera control opens new exciting possibilities – anyone interested in (relatively) cheap 3D video rig?

Generic PTP control of digital cameras

Development of Arduino_Camera_Control library (which runs on top of USB_Host_Shield library written to support USB Host Shield ) continues at steady pace. Nikon point-and-shooters has been on a test bench for the last couple of weeks and they are already talking. Even more exiting is the fact that they are talking the language we already know – the plain old PIMA 15740-2000.

Arduino-controlled Nikon P100

Arduino-controlled Nikon P100

It also looks like that PTP protocol implementation in all Nikons is very close to the standard with very few vendor extensions and it will be possible to use the same code base for both point-and-shoot cameras and DSLRs. In this article, I’m showing a lightweight implementation of Capture command for Nikon cameras. Unlike its’ sister sketches, EOSCapture and PSCapture, this one can’t really be called NikonCapture – keep reading to find out why.

The InitiateCapture command, which is part of standard PTP command set can be seen in PTPDevInfo output of several Canon PowerShot and all Nikon cameras – see, for example, Canon A640 section, line 82 or Nikon Coolpix S4000, line 47. Regrettably, PowerShots seem to require setting D045 vendor-defined property before this command will be accepted by the camera; therefore, PowerShot-specific class would have to be instantiated, adding significantly to program size. On the other hand, Nikons are happily executing InitiateCapture as-is.

The following sketch does what other “…Capture” sketches do – it takes a shot once a second second in an endless loop. What makes it different is that it doesn’t use any vendor-specific code, compiles in ~9K and can be loaded into Atmega168-based boards leaving plenty of room for another functions.


Continue reading Generic PTP control of digital cameras