I spent the summer of 2013 interning at a robotics startup called Romotive. They make the robots in the above photo. One of the projects I worked on was what I dubbed the “DecaCharger.” Simply put, the DecaCharger is a charger capable of charging ten devices at once. This was built to easily and quickly charge the many iDevices and robots that Romotive owns.
The two selectable USB charging ports are on the left (labeled A and B). The switches above them allow the user to choose between iPad and iPhone charging mode. In iPad mode the USB port tells the device that it is allowed to draw up to 2.1 Amps of current. In iPhone mode the device is told that it is allowed to draw up to 1 Amp.
The three ports labeled “iPad” will tell a device plugged into them that they are allowed to draw up to 2.1 Amps.
The five ports labeled “iPhone” will tell a device plugged into them that they are allowed to draw up to 1 Amp.
There is a green LED for each bank of USB ports. There are three banks: the ports labeled “Selectable”, the ports labeled “iPad”, and the ports labeled “iPhone.” The LED for each bank lets the user know if that corresponding bank is powered on or not. The banks are powered off if they draw too much current.
There are little buttons above each green LED that will turn the corresponding bank of USB ports back on if they are powered off.
The DecaCharger operates basically like any other charger. All the user has to do is decide what type of device they are charging and plug it into the corresponding USB port.
There are more “advanced” uses than just basic charging. The real point of the selectable USB ports is to facilitate the debugging of charging modes. Coupled with the LCD that displays the current draw on each selectable USB port, switching between “iPad” and “iPhone” mode allows the user to see how the device reacts when allowed to draw more or less current.
Here is an example of the debugging of charging modes:
In this first picture USB port A is in “iPhone” mode and the robot is drawing 0.82 Amps (as seen on the LCD). In the second picture I switched USB port A to “iPad” mode and the robot responded by drawing 1.35 Amps. This is what was expected.
First up is the micro-controller. I used an ATMEGA328 mainly because it is Arduino compatible. Almost all the I/Os are used in this design. The ATMEGA328 runs at 16MHz with the external resonator (X1).
You can also see the LCD on the right in this picture. R66 is a potentiometer used to set the contrast of the LCD and R65 sets the current for the LED backlight.
The temperature sensor is an NTC thermistor, which is basically a resistor whose resistance changes based on temperature. The thermistor is in series with a 10K resistor - creating a voltage divider. The output of the voltage divider is read by one of the ATMEGA’s analog inputs. With a little math called the beta parameter equation, the program is able to calculate the temperature inside the charger.
Now onto what one of the selectable USB ports looks like. On the left there is a P-type MOSFET (Q5) used by the ATMEGA to turn power on or off. There is an LED (D3) connected after Q5 to indicate to the user whether or not the USB port is powered on by the ATMEGA.
J1 is the USB port itself. Between VCC of J1 and the drain of the Q5 MOSFET is a PTC (a PTC is a component whose resistance tremendously increases once a certain amount of current flows through it - causing a certain amount of heat). This PTC acts as a blown fuse once anything plugged into the USB port draws more than 5 Amps of current. Unlike a fuse, the PTC resets itself once it cools down.
The right side of the picture is what sets the actual charging mode. Depending on whether USB1+CTRL and USB1-CTRL are HIGH or LOW, R5 and R6 are either shorted or not. This changes the voltage at USB1+ and USB1-. The iDevice then reads those voltages and knows whether the charger is an iPhone or iPad charger. The values for some of the resistors are purposely missing.
Next is the bank of iPad ports. This is similar to the selectable ports, but instead the voltages on the USB- and USB+ signals are written in stone. There is still an LED, PTCs for each USB port, and a MOSFET that allows the ATMEGA to turn this bank on or off. There is one difference at the bottom of the image - the resistor R74, which is 0.005 Ohms. The small voltage drop across this resistor is how the ATMEGA measures current on the iPad bank. This is not meant to be a high resolution reading. Just enough to know whether or not the bank is drawing too much current. The current monitoring feature for the selectable USB ports is different and has a higher resolution.
The iPhone bank of USB ports is essentially the same, but with different valued PTCs and different voltages across USB1+ and USB1-.
The last thing I am going to mention is the current monitoring on the selectable USB ports. For a higher resolution current measurement than what was mentioned above, the INA3221 is used. This chip measures the small voltage drops across R49-51 and communicates with the ATMEGA through the I2C protocol.
There were some issues with the circuit design. Mainly the INA3221’s inputs needed to be connected in a different configuration. This was not really mentioned in the datasheet, but it was obvious that something about the internal connections of the INA3221 were creating issues. You can see some of the fixes on the bottom of the board.
The code was written in Arduino. I am just going to explain the main loop here. Download the code if you are interested in the actual functions that do these things.