Paja

Icon

Rapid prototyping for music, art and design work

Using Arduino and Memsic 2125 accelerator with C++ and Open Dynamics Engine

I made a simple prototype about using a Memsic 2125 dual-axis accelerator with C++ and an open-source physics engine called Open Dynamics Engine (ODE). The result was something that resembles the experience which you get while playing games on the motion sensing controller of the Wii console (although I haven’t tried that myself).

Throw some boxes with an accelerator sensor and ODE

It is a small game prototype where you drop some boxes to an empty space, and then you can select one of the boxes by hitting spacebar. Then you can use the accelerator board to throw the boxes to different directions and the boxes collide with each other and the flat ground, and get some g-forces and directions applied according to the direction and force used to move the accelerator board. The basis for the example was provided by a simple box-colliding example taken from the ODE (Open Dynamics Engine) examples. All I had to do was a couple of tweaks and adding the Arduino controlling code there. And then I needed a lot of testing to get the numbers I was getting from the accelerator to be interpreted sanely. In the end I wasn’t able to get that much control as I would have liked: It is really difficult to try to
throw the boxes accurately. But still you get some feeling of control, because the physics done by ODE is so convincing.

memsic 2125 and ODE

Here’s how it’s connected:

memsic 2125 connections to arduino

The final trick that made it working like it is now, was to set the baudrate higher. 9600 wasn’t enough. And the trickiest part was finding a correctly working source code for the Arduino. I think that one of the reasons why there wasn’t that much control, was that the memsic 2125 only has two axis. The third one would propably make the feel more realistic. Here’s the accelerator used in Wii.

In the .zip package of the source code I’ve included only the files that were changed from the ODE package that I downloaded. So you’ll have to download ODE from here and replace some of the files with my modified versions. Be sure to download a CVS snapshot, not a release version. My .zip package also includes the code for Arduino.

Throwing the boxes sourcecode
Joonas Kiviharju

Facebook Twitter Email

Category: Media Lab Helsinki, Student Projects

Tagged:

2 Responses

  1. jim says:

    hi, this is a very interesting application, and I am trying to do the similiar application too, but now, I still have no idea about the spec of MCU , may I know the model of your MCU (Adruino)? I can’t make sure what how uch RAM size is need ?? (of course, more is better, but I don’t have too much money)

    jim

  2. Greg says:

    Thank you for the great Arduino code. I thought there was something wrong with my accelerometer. I kept getting all sorts of wild readings. After trying your code, I’m convinced that the accelerometer works but I entirely understand your comment:

    “needed a lot of testing to get the numbers I was getting from the accelerator to be interpreted sanely.”

    Although I should comment that you must be using a custom serial library that isn’t included in the zip file. It looks like a nice library but all the “printByte”, “printInteger”, “printNewline” functions didn’t work for me.

    – Greg

Social links powered by Ecreative Internet Marketing