January 5th, 2014

# Hacking Robotic Arm with Android

• Categories
• We bought a robotic arm because it looked cool on the box.  It took us about 3 hours to assemble it. The robot came with a control box that was hardwired to it.  The control box wasn’t designed for kids – the buttons were difficult the press and hold. So after a while the kids didn’t want to control the robot and I became the control engineer. After a few minutes, I got tired of the control box too (it was fun to control the arm, but we wanted more) so I decided to make it more fun. The first thing that we thought of was to add remote control.So in fit of  pretend DIY rage I cut the control box wire and set the robot free.

After a little while I was able to convince the kids that the robot was ok and would soon function again.  I had a quick look at the inside of the control box. I also found a simple circuit diagram inside the manual. Armed with this knowledge, we went scavenging for components.

I have a few IOIO boards that can be connected to an Android device via USB or Bluetooth.

https://github.com/ytai/ioio/wiki/Getting-To-Know-The-Board

So we decided to use the IOIO boards as the control mechanism for the remote control system.  We quickly create a simple power supply for the board. The IOIO has two on board voltage regulators, one a switching regulator that can take 5V-15V and the other one linear regulator that feeds off 5V line.  Based on the components at hand I’ve decide to bypass the voltage regulators use a 9V batter with a 7805 linear voltage regulated that outputs 5V.  Here is a circuit diagram of the power supply for the IOIO.

The IOIO board has 48 I/O pins. I’ve decided to use 10 of the pins to control 5 of the DC motors that are used by the robot arm. 2 pins are assigned to each motor for forward and reverse direction.  Here is the circuit diagram from the manual that show the DC motors on the robot arm.

The pins on the IOIO can be used in 2 modes, normal and open drain.  The open drain mode the logic low will force the connected circuit to the ground or 0. The logic high in open drain mode will act like it was disconnect the pin from the circuit.  Therefore, we chose the open drain so that we could pull up the the voltage to any thing wanted for the logic high or 1.The DC motors draw a lot of current, relatively what can the pin supply. We can’t drive the motors from the IOIO board.  I decided based on the available components to use automative 12V 5A single pole double throw relay.  The relays separate the IOIO board circuit from the motor circuit and are easily activated with the with low voltage. They are rated for 12V, but can be activate with voltage as low as 6V.  Since the IOIO output pins only output 5V using the open drain mode allows us to provide higher voltage to activate the relays.  I used another 9V battery and a pull up resistor to activate the relays in the open drain mode-logic high.  For debugging, I also added an LED in series with the pull up resistor.  This gave me a quick visual way of determining if the circuit was working correctly.   Here is a circuit that represents the open drain mode-logic high and shows the relay and the DC motor.

Once we had the circuit wired we quickly created an Android app that connects to the IOIO via bluetooth.  I created a simple layout that mimicked the control box:

Once you’ve set up your Android project with all the dependencies you are ready to link the UI to the output pin.  The app runs in a loop checking the registered pins and updating the state. To use a pin you first need to requester the pin and then write a value to it. For the digital I/O pins you either write a true or a false to it. Here is the code that defines the pins and writes to them.

```    class Looper extends BaseIOIOLooper {
private DigitalOutput led_;
private DigitalOutput pinM1up;
private DigitalOutput pinM1down;
private DigitalOutput pinM2up;
private DigitalOutput pinM2down;
private DigitalOutput pinM3up;
private DigitalOutput pinM3down;
private DigitalOutput pinM4up;
private DigitalOutput pinM4down;
private DigitalOutput pinM5left;
private DigitalOutput pinM5right;

@Override
protected void setup() throws ConnectionLostException {
led_ = ioio_.openDigitalOutput(0, true);
pinM1up = ioio_.openDigitalOutput(18, DigitalOutput.Spec.Mode.OPEN_DRAIN, true);
pinM1down = ioio_.openDigitalOutput(19, DigitalOutput.Spec.Mode.OPEN_DRAIN, true);
pinM2up = ioio_.openDigitalOutput(20, DigitalOutput.Spec.Mode.OPEN_DRAIN, true);
pinM2down = ioio_.openDigitalOutput(21, DigitalOutput.Spec.Mode.OPEN_DRAIN, true);
pinM3up = ioio_.openDigitalOutput(22, DigitalOutput.Spec.Mode.OPEN_DRAIN, true);
pinM3down = ioio_.openDigitalOutput(23, DigitalOutput.Spec.Mode.OPEN_DRAIN, true);
pinM4up = ioio_.openDigitalOutput(24, DigitalOutput.Spec.Mode.OPEN_DRAIN, true);
pinM4down = ioio_.openDigitalOutput(25, DigitalOutput.Spec.Mode.OPEN_DRAIN, true);
pinM5left = ioio_.openDigitalOutput(26, DigitalOutput.Spec.Mode.OPEN_DRAIN, true);
pinM5right = ioio_.openDigitalOutput(14, DigitalOutput.Spec.Mode.OPEN_DRAIN, true);
}

/**
* Called repetitively while the IOIO is connected.
*/
@Override
public void loop() throws ConnectionLostException {
led_.write(!led.isChecked());
pinM1up.write(!m1up);
pinM2up.write(!m2up);
pinM3up.write(!m3up);
pinM4up.write(!m4up);
pinM5left.write(!m5left);
pinM1down.write(!m1down);
pinM2down.write(!m2down);
pinM3down.write(!m3down);
pinM4down.write(!m4down);
pinM5right.write(!m5right);

try {
} catch (InterruptedException ignore) {
}
}
}```

There you go – a quick DIY project to add remotely control a robot arm.

Here is how it looks :

Video

Article Rating

January 5th, 2014

⟵ Back

Subscribe
Notify of