32leaves.net

Controlling a robot arm using an ez430 Chronos

A few days ago the ez430 Chronos I ordered from Farnell was delivered. This particular piece of hardware is an evaluation platform for the MSP430 (or the MSP430 as a CC430F6137 SoC to be more precise) which comes as a sports watch. It’s got some pretty neat features such as a temperature sensor, accelerometers on all three axis (which is why I’m using it here) and an RF transceiver built in. The first thing I did to it was to enable the watch to display the current time binary encoded.
After getting this to work (which was not that hard at all) I moved on to trying to get some data using the RF link. In the ez430 Chronos Wiki someone posted a Python program which polls the RF hub for accelerometer data. Having a Mac and not wanting to spend hours on getting pyserial to work, I wrote my own version in Ruby.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'rubygems'

# on my machine a simple require does not work for this library
Kernel.require 'serialport'


SERIAL = SerialPort.new ARGV[0], 115200
SERIAL.read_timeout = 1000
def serial(data); data.each {|c| SERIAL.putc(c) }; SERIAL.flush end

# start access point
serial([0xFF, 0x07, 0x03])

while(true)
  # request the data
  serial([0xFF, 0x08, 0x07, 0x00, 0x00, 0x00, 0x00])

  accel = SERIAL.read(7)
  unless accel.nil?
    accel = accel.scan(/./).map {|c| c[0] }

    if accel[3] == 1
      puts accel[4..6].join(" ")
      STDOUT.flush
    end
  end
end

SERIAL.close

That’s pretty nice, but I wanted some real time graphs of the data, so a half an hour later I got a short Processing sketch running which does exactly that.

Next semester I’ll participate in a project in which we’ll built a new hardware interface to some pretty old robot arm hardware (it states “Made in West Germany”, that’s quite some time ago). In order to do that we need some sort of protocol to communicate with the new hardware interface. In preparation for that project I wrote a simulator for the robot (actually that’s supposed to be a part of the project, but I simply couldn’t resist) which uses an early draft of that particular protocol. Just to have that mentioned, the protocol itself is described as a state machine in a DSL which can be compiled to virtually any programming language. I’ll probably write a post about that nice piece of Scala code at some later time.
So with a working robot arm simulator, a watch which has accelerometers built in and is capable of wireless communication what else could I’ve done than to combine those two. That said I got to work and enhanced the script above to communicate with the simulator. About an hour later I got the first movements controlled by the accelerometer data of the watch. You might have seen the video already, if not go and watch it :-)
Update: We had some spare time to spent and did some really basic proof of concept with the real hardware. Here we go:

6 Responses to “Controlling a robot arm using an ez430 Chronos”

  1. Srikanth says:

    Hello Christian,

    I am having similar watch and our university is carrying out few projects on this. We are planning to start a new course on this watch next semester. Can you help me write a code to control the lights of a room with either a click on the watch or by hand movement (acceleration data)? Please help me through this…

    Thanks,
    Srikanth Sistla.

  2. Christian says:

    Hi Srikanath,

    an easy thing you could do is grab the accelerometer data the same way I did, smooth it (e.g. using a Kalman filter, a sliding average or alike) and try to recognize certain gestures using some sort of classifier or neural network (probably support vector machines).
    Another thing that could be done is to modify the firmware and add some menu to it. But that involves quite some in-depth knowledge of the ez430′s hardware and MSP430 programming. Something I’ve never had time to dive into.

    hope that helps,
    Christian

  3. Jason W says:

    Hey, nice project! Looks like you ended up having some pretty decent control of that robot arm, I’m curious how you were able to do that with raw accelerometer data.

    Did you derive velocity / position data from the accelerometer data or just use the accelerometer data by itself? I’d really like to know more about how you were able to get such good positional control over your robot arm using raw accelerometer data :)

  4. Jason says:

    Great work! I am working on a much more basic project and have had some problems getting good accelerometer data from my ez430. I’m using an ez430, here’s what my graphs look like: http://imgur.com/lh9nl

    As you can see the data jumps around like crazy for me (this is with me moving my hand in slow, smooth motions). Would you be so kind as to e-mail me a copy of your Processing sketch that plots the accelerometer data?

    I used some code posted on Chemical Oliver’s blog to get the serial data, but my research mentor is wondering if maybe my code isn’t reading the packets correctly. If you open the Chronos Control Center software you can get the X,Y,Z values to exceed 2000, whereas it looks like the maximum I can get is 255!

  5. Alex says:

    Hello, would you be kind enough to put code for Processing online?
    Thank you

  6. Jeff says:

    hi Christian:

    I’m from the Philippines. I just bought my own chronos. I’m based in an exercise science facility (zero background on coding :(. I was hoping if it’s possible to view speed and acceleration data using Ruby. I think your project is the closest to what I have in mind. Thank you.

Leave a Reply

Fork me on GitHub