Wednesday December 12 2018

IR RTCS for robotic arm

This is a tutorial to build an Infrared Real-Time-Control-System for a simple robotic arm.

Here is the video for the arm demo:

********** Quick  Links ***********

ProcessingExtraLibs, ArduinoExtraLibs, ArmControl Arduino Code, ArmControl Processing Code

*********** LIST BLOCKS/PARTS ************

1) A basic robot arm kit (i.e. just DC motors, no fancy stepper based stuff).
    - I just used a $50 kit that I bought online, something like this:
2) Infrared LEDs (5 in total, but buy at least 10, you never know)
    - I used these ones, they work well:

3) Wii Remote
    - Now this could be the hard part to find if you don't already have such.  
      The newer Wii Remotes with that PLUS stuff, may not work.  
      I use the RVL-003 that came with my Wii (about 4yrs ago).  
      There's loads of solutions on ebay and related, but already having my own, 
      I have no recommendations there; sorry.
        - If someone happens to find a reliable source, just let me know and I will add it.

4) Arduino Uno + Motor Control Shield 
    - If you don't already have an Arduino, buy one.  It's a $30 development platform based 
      on a small microcontroller.  There is an entire community worth of free code and examples. 
      You can use it to make almost anything, from a 'knock-rythm-based door lock' 
      to an automatic keyboard (that could type all your long passwords for you).
    - Home Page:
    - Buy Uno:
    - Buy Sheild:

5) Laptop with Processing, Arduino, and WiiRemote software
    - You need the Arduino software to program the Uno.
    - The 'Brains' of this entire control system will be in java code written for Processing.
        - Processing is the best way I have seen to control and interface your PC's peripherals.  
          If you wanted to use microphone data to move your mouse, you would use Processing, 
          and it would take <1hr.
    - Drivers and Operating Systems, a quick word:
      This was developed on Linux, but all the code is portable and should work fine on Windows.
      In fact there is loads of help online with Processing+Windows and with WiiRemote+Windows; 
      Google is your friend.

******************** INSTALL  SOFTWARE *******************

Now first off: let’s get that software installed:

  • Arduino Software should be a breeze to install
  • Processing Software is also easy to install:
  • Wii Drivers/software/etc.
    • There is loads of stuff on Google to teach you how to do this, just search “connecting wii remote to XX” (where XX==Windows, Linux, or whatever you have)
    • For Linux/Ubuntu users:
      • You will need to get the libraries into your sketchbook folder, ProcessingExtraLibs is a zip with the ones you will need (to save you the search).
      • After unzipping into the sketchbook/libraries folder, you can get the bluetooth stack by:            sudo apt-get install bluez-utils libbluetooth-dev
    • For Windows users:
      • I think this is how I did it back when I tried this on Windows.
        • You can try one of the sites above for connecting.
        • You do not need GlovePIE for this project, but it is cool to play with:
        • You will also need the SAME Processing libraries.


**********************  HARDWARE  ************************

OOOK. So you should have all your software installed, and maybe you’re already using the Wii Remote as a mouse (it’s cool stuff eh?).

Now for the hardware (my favorite).

Robot Arm + LEDs:

After you have finished building the robot arm kit(or have placed an already built arm on your table) we need to mount the LEDs.

Now there’s probably a countably-infinite number of ways to do this, so let me just show you my answer.

Working with the limitation of the Wii Remote’s tracking (it can track a maximum of 4 dots), and with the design of the arm, I came up with these mounting points:

They made sense to me, but I have no proof that they are optimal in any way; meh.

I would also like to make a note on mounting: do not underestimate the gains of outlets.

Ok, so that’s too vague. Let me clarify by saying don’t solder the LEDs to wires and mount that. Instead, mount a thing into-which you can plug the LEDs. That way you can swap them in and out, flip them if plugged in backwards, change spectrum/colour, etc.

Here is a pic of my actual implementation (the arm doesn’t care that it’s ugly.. lol)

I used spare computer parts, but you can buy things like these online.

The fifth LED you will use to make an IR pen (basically a battery-powered IR LED at the end of some kind of pointer/stick/’pen’/wire/etc).

The most basic step in the whole project. I just made my own out of scrap parts, here is a pic:

And here is a basic schematic:

You can also buy these ‘pens’ (at your own risk, I don’t know if they will be 940nm or not).

************************** HAND *************************

Hand Sensors:

Since the computer has no idea what the hand feels (i.e. soft/squishy/hard or even size) we need to feedback such info, somehow. Otherwise the hand could get damaged (flimsy plastic parts etc).

The way I settled on was using an optocoupler to detect open, and a pressure sensor to detect close.

Here is a video to show you opperation:

And some more pics:

The Optocoupler was from an old VCR I had, so you’re on your own there; although I suspect that any Optocoupler will do. Just remember that light-blocked → 0V; that is the assumption that my Java code makes.

The force sensor is a special part, and this is the one you want:

Now the manufacture says that you have to use a socket for the pressure sensor, the reason is because they think that you are going to melt the plastic part of the sensor when you try to solder.

I soldered without any trouble by using this simple trick: can’t get hot if heat is taken away.

So I put tinfoil around the end before I solder (the tinfoil takes the heat out of leads before that same heat melts the surrounding plastic).

Now you can’t just hook up the sensors, you need a circuit, so here is a schematic of the sensors’ hook up.

There are many other ways to hook up those sensors, all that you should really be concerned with is determinism.

Who cares what the pattern is, as long as behaviour is predictable, you can write code to react.

*******************  Motor Control Shield *********************

Now with the LEDs mounted and sensors placed we need to interface the arm with the Arduino + Motor Control Shield.

Using the Motor Control Shield makes things very easy, in fact I will not even talk about code yet.

Since we have 5 motors (Base + 3 Joints + Hand), and the shield only supports up to 4, we need to drop one.

Thankfully the decision is easy, this system I made assumes the arm to be perpendicular to the field of view (of the WiiRemote).

Thus we drop the base motor, and use the 4 DC motor shield outputs to control the 3 Joints and Hand.

Here are some detailed pics of my wiring.

Note if you plan to ‘plug-and-chug’ this tutorial, you need to match it exactly or change the code:

******************** GUI and FINISH ********************

Now with the Arm interfaced with the Arduino+MCS, we can finish the project in Processing.

Using THIS Arduino Code for the Uno, we now have a serial interface to the arm. The protocol is as follows: “B_m0_m1_m2_m3_dur_E”, a string where the m# is the 1byte value for #’s speed, and dur is duration. It may seem unnecessarily long, but such is to be robust.

If you use my Processing code, you don’t have to care about the protocol.

You can download my Processing code from HERE.

The project is called ArmControl (*.ino for Uno, and *GUI.pde for processing).

Now we can run the entire system all at once:

Plug in the Arduino Uno (with motor shield) to the PC’s USB and program with ArmControl.ino, then start up the Processing GUI code and GO (the code is commented).