Contents:

Key chain camera (Hetai HD-818) hardware modification

Charger detection

How the switching to the USB mode works?

The USB mode switch

Hardware behavior

Possible modifications

Schematics

Assembly resources

The implementation

Convert dedicated emergency charger to a standard charger

Convert dedicated car charger to a standard charger

Related: Posts #4266, #5013, #5995, #5998, #6011, #6018 and #6026 in The REAL (#11) HD Key Cam Thread on RC Groups.com, USB Mini connectors

Key chain camera (Hetai HD-818) hardware modification

Charger detection

charger detector assemblyI was dissatisfied with a need of a dedicated car “charger” and especially with the fact, that it depletes battery during recording. Use of a standard charger switches the camera to the USB mode and makes recording control impossible. Well, it is basically a firmware problem, but as I don't have many changes to fix the firmware, I decided to poke into the hardware and create a circuit that fixes this problem.

How the switching to the USB mode works?

There must be a voltage detector that detects USB power voltage on the USB pin 1. The nearest parts there are:

Apparently one of the resistor is the right way to search. As one of these resistors is the 0R, we have a clean candidate.

The USB mode switch

It was easy to disable switching to mass storage or webcam mode at all. Just removed a single 0R resistor and the camera will never more switch to USB modes:

disable switching to USB modeRight side of the removed resistor is connected directly to USB pin 1 (Vcc).

Left side of the removed resistor is connected to the mass storage switch. If the voltage there is below 4.1V, the device remains in normal mode. If the voltage raises above 4.3V, the camera switches to mass storage or webcam mode and activates USB circuits (like the pull-up).

We need to detect status of the USB data lines and turn USB mode switch on only if they are wired to the real USB port.

So we need to detect that USB D+ or D- lines have proper wiring. (Chargers don't wire these lines, some high current chargers short D+ and D-.)

It is not as elegant as firmware modification to not switch to mass storage if handshake fails, but it works nearly exactly in the same way. Behavior after calling of “Safely remove the device” in the computer is the only difference between this solution and the standard software solution (simple detector cannot detect software USB suspend).

Hardware behavior

Discrimination between USB host and USB charger is not as simple as I initially thought. First of all, I needed to know the exact behavior of the hardware, which may work in several states.

The camera has three different USB modes:

Possible modifications

  1. Detect while camera is off: Turn the camera off, insert cable, turn on. Correct mode will be seleced. Easy, just connect the soft pull-up (1MΩ) to from 5V on pin 1 to data pin and detect voltage: If 5V power is there, then ~5V on data pin means charger, ~0V means USB host. Latch this value until 5V on pin 1 disappears.
  2. Detect while camera is on and camera mode is active: Just connect USB cable. Camera will turn into the correct mode. A bit more complicated. Connect the soft pull-up (1MΩ) to from 5V on pin 1 to data pin and detect voltage. ~0.09V means charger, ~0.05V means high power charger, <0.02V means USB host. Latch this value until 5V on pin 1 disappears. Note that the latch value must be “USB host” – USB connector design first connects power.
  3. Detect while camera is on and USB mode is active: Just connect USB cable. Camera will turn into the correct mode. Even more complicated. Turn USB mode on whenever USB power appears. Measure D+ and D- lines. If they conform USB standard, stay in USB mode, otherwise switch back to camera mode. This check would allow to use commercial USB detection ICs. On the other hand, it would require additional logic to wait before starting the check and then remember the detection result until USB power goes off.
  4. Don't detect USB master, switch according a different rule:
    1. Allow USB mode only if LED is on: Connect charger to the camera while recording is on. Camera will not switch to USB mode until you stop recording. To record again, disconnect, start recording, and reconnect.
    2. Change mode depending on On/Off state: Camera switches to USB mode only if cable is inserted while camera is:
      1. On
      2. Off
      Both solutions are easy but not intuitive.
    3. Use dedicated charger: If dedicated charger is used, camera will not switch to USB mode. Easy, but I want to avoid need of the dedicated charger.
    4. Add a mechanical or electronic switch: To change the camera behavior, user has to activate the switch. Easy from electronic side, but needs mechanical modification of the camera.

I implemented detection while the camera is on and the camera mode is active (see 2. above). It seems to be very intuitive, avoids need of dedicated charger, and not so complicated.

Schematics

Here is my solution (the design was created in gEDA using toporouter):

charger detector schematic charger detector PCB layout

USB Vcc means pin 1, USB D+ means USB data line, USB mode switch means left pin of removed 0R resistor, the main part is a cheap comparator with rail-to-rail support (MCP6541), diode (TS4148) is a plain cheap small SMD diode (0805), resistors and capacitors are standard SMD (0402) parts.

Using a 1MΩ pull-up to 5V should be safe according to the USB specification. It introduces effective error that is equivalent to about 2% change of the D+ pin pull-up resistor. USB v2 resistor ECN allows much higher tolerance.

Once the circuit is powered but the input voltage decreases below 0.06V, the output raises to 5V. Due to the positive feedback, it never fails back. Only turning or the power or raising input voltage above 4.2V (it never happens on USB data lines) may reset it back. It is exactly what we want: When our circuit turns on USB mode, voltage on D+ raises to 3.0V, but we want to ignore that – we already detected USB data lines and this should be true as long as power on pin 1 exists.

Assembly resources

The implementation

charger detector board charger detector assembly

The board was assembled on a small piece of a single sided 0.8mm thick copper clad (FR-4 type) using SMD parts. It is possible to get MCP6541 and diode even in yet smaller package, but my board is already small enough to fit inside the camera.

The finished board was connected to the main board with a thin wires (from an old Ultra ATA cable), covered by a Kapton tape (to prevent short circuits) and placed into a free space between the USB connector and the card holder. (You can also see the removed resistor 0R on the top of the USB connector on the photo above.)

As a last step, you can remove the Schottky diode near the pin 4 of the USB connector to disable dedicated “chargers”.

The complete assembly adds about 0.26g to the weight of the camera.

Convert dedicated emergency charger to a standard charger

After the modification of the camera, there is no need to have a dedicated AA charger that overcharges the camera battery.

Conversion to a standard charger is really simple: carefully open the connector and resolder red cable from pin 4 to pin 1. Hopefully, manufacturer did not cut pin 1, so I can recycle the connector.

convert AA charger to standard charger

Now I have a standard emergency charger that can be used with any device.

Convert dedicated car charger to a standard charger

After the modification of the camera, there is no need to have a dedicated car charger that never fully charges the camera battery.

To convert it back to 5V, you need to replace R3 on the board with a resistor (or combination of resistors) with value about 30.3kΩ.

The connector of a dedicated charger cannot be disassembled. You have to cut it and replace with another one with correct wiring.