The new control system for FTC (new as of 2015) uses Android phones to control the robot. One android phone hooks up to joysticks, reads those joystick values, and send them via a wifi-direct connection to a second phone. The second phone attaches to custom hardware from Modern Robotics which controls a variety of motors and servos, or reads sensor values. See Figure 1.
A protocol call On-The-Go (OTG) was developed to allow phones to act as HOSTS under certain circumstances. When a special cable is plugged into the phone, it acts as a HOST. When a normal USB cable is plugged into the phone, it acts as a client and can be charged and receive information from a computer (eg be programmed). See figures 2 and 3. These two modes of operation are currently mutually exclusive (although there is talk of a new OTG standard which will allow the phone to charge even when in OTG mode... this standard currently only works on certain Android phones).
|Figure 2: Configuration for CHARGING and|
|Figure 3: Configuration for Running and|
Controlling the Robot
In FTC, our students spend a lot of time toggling the phone between master and slave. Whenever they program the phone from Android Studio or need to charge the phone, they use a regular USB cable so the phone is the slave. Whenever they want to test the robot, the phone is the master and an OTG cable is required. Each toggle requires the cable to be swapped out. It became clear to me that this was an issue about halfway through the 2015-16 season as students started reporting that the micro USB connectors on the phones (ZTE speeds) were breaking. We moved to better phones (Moto G2 and G3), but even with those there have been failures. While the logical fix to the problem is to coach kids to be careful and gentle when swapping out cords, in practice this is a futile endeavor.
The difference between a standard USB cable for an Android phone and an OTG cable for an Android phone is that the fifth pin (called the "ID" pin) is left open for a standard cable, and grounded for an OTG cable (Figure 4). Hence a logical "fix" to the two cable problem seemed to me to make a cable with a switch that shorted the ID pin to ground in one position, and leaves it unconnected in the other (Figure 5).
I purchased USB DIY connector shells from Adafruit (figures 6, 7). This is the link for the standard size, and this is the link for the micro shell. I located pinouts for each of the shells (figure 8) and soldered solid core wire to each connector. Soldering to the micro USB connectors is tough... the size of the solder pad and the spacing between them are both small. It takes a steady hand and good hand-eye coordination, as well as a lighted magnifying glass.
I tested the concept by wiring the two USB connectors together on a breadboard. I could "toggle" the state of the ID pin by putting the wire for that pin into the breadboard line for GND, or leaving it out. The test proved successful, so I soldered all the wires together using a switch as shown in Figure 5. Figure 9 shows one of two finished cables that I made.
Testing showed that the cable worked. I needed a female to female connector and then a male to mini connector to test the connection to the Modern Robotics hardware. I used the female to female connector along with a male to male cord to connect to the computer, and to test charging the phones. All of the functions worked!
I attempted to replicate the procedure and make a second cable and had much more trouble. The soldering was messed up on the micro connector once and I had to start over. The breadboarding test showed erratic behavior. I purchased a micro USB female breakout (Figure 10) to make sure that my soldering was done well. When I couldn't find a problem there, I just soldered the wires directly to the standard USB connector and that seemed to fix the problem.
In all, this was a successful experiment to show a possible method to fix the problem of having to swap out cables. However, I was not convinced on the durability of the custom cables that I made, and they are not easy to remake. Hence, these cables are used on our school's soccer bots (Figures 11 and 12), but not on competition robots. The CAD files for Moto G3 phones for use with these custom cables are found here. I suspect that a new family of cables similar in principle to the one I made will be on the market soon, making my work obsolete. Still, it was a fun challenge.