miércoles, 27 de febrero de 2013

Let's go physical ! (1)

Today, we will start building the platform! The first thing we need is to create an equilateral triangle, this means, a triangle with all their sides having the same length. You can create the platform using any material resistant enough to hold the elements we will mount on it. I suggest you to use wood board. It's cheap, easy to find and also easy to work with.

To cut your triangle, I suggest you to use this diagram. First mark point P0, then draw a line. Mark points P1 and P2 at 17,32 cm left / right of P0 (yes, I know, it's a funny number). Then draw a perpendicular line starting at P0.

Mark the Center Point 10cm away from P0, then P3 20 cm further.Now you can draw the lines joining the points P2 and P3, P1 and P3. Draw the lines P2 - Center and P1 - Center too. This two lines will help you to aling the motor axes later on.

I use a thin wood board, (some 4 mm thick). I cut the board using a medium size cutter and a metallic ruler. I just mark the line with the cutter using the ruler as a support,  using a light pressure on the cutter. I repeat it 3, 4 times using every time a little higher pressure. After this, the line is market and you don't need the ruler. I make the same cut over and over, each time with a higher pressure. After 10, 12 times the cut is done!

This is the result:

As you can see, I cut the corners of  the triangle. We must do it to mount the motor & wheel there. The distance of the cut depends on your motors. In my case, I need a 4 cm cut made in this way:

The final result once everything is mounted in place looks like this:

App Inventor

I created the "Omnidrive" App using App Inventor

App Inventor is a programming environment that allows you to create simple Android Apps in an (quite) easy way. Again, it is ligth, (mostly web based) and it is for free. (So far, I didn't use any commercial Software to design my platform. I hope to reach my final target in this way too!)

App Inventor offers you 2 Shells: The Viewer and the Block Editor. The viewer is where you create the Screen of your App. Here you create and organize all the visual (and non visual) elements of your App.
The Block Editor allows you to code your app in a funny way: There is a "white piece of paper" where you put together a kind of puzzle pieces into blocks, each covering a different function linked with the elements you previously created.

But we aware of it: you cannot use this tool to create complex apps. It allows you to use all the nice hardware elements of your Android device (Accelerometer, Photo/Video Camara, Bluetooth, compass, your locations, the music player, etc...). As soon as you want to do something more than just start/stop something, things can go pretty messy. You reach a nice level quite fast, but then you get "glue on your shoes". Each incremental improvement costs you more and more...

In my opinion, a "block" where you could program directly in Java would be a plus.

A feature of App Inventor, and a real nice one, is the ability to use your own device for testing your App nearly in real time via Wi-Fi. You modify something in your computer and, after a few seconds, you can see / test your modified app directly in your device.

All in all, I recommend to use it as an start point to start programming Android Apps. You can even deliver them via the Google Play, as I did with mine!

Remember I publish the source code of this App here!

domingo, 10 de febrero de 2013

The Remote Controller App

These are the steps you should go through to use my App "Omnicontrol" to control your own system.


- An Android device with the app loaded on it. You can download the compiled application from Google Play going here.
- A Bluetooth Modem. I use the RN-42.(  https://www.sparkfun.com/products/10269. )
- An Arduino Board. This example works only on the Mega or Leonardo Arduinos. I explain you later why.
- A USB cable.
- Some wiring materials.
- A computer with the Arduino Software.

This is what you must do:

1.- Wire the Modem in this way. 

The red cable is connected to the +5V, the black one to GND. Be informed that the Modem will be delivered to you without headers. So, a little bit of soldering will be needed.

2.- Connect the USB cable and load the test sketch. You can find it here: http://sourceforge.net/projects/omniplatform/files/Arduino%20Code/Bluetooth%20Test%20Sketch/?
It is a very short one!

3.- The modem will blink in red at this moment, because it is not linked to any other Bluetooth source. It's normal.

4.- Switch Bluetooth on in the Android device, search for new devices and pair it with the RN-42 modem.  This is the typical step you perform prior to use any Bluetooth device. Please refer to your Android documentation & the modem documentation if you need more information on this point. The modem shall appear as "Firefly ...........".

5.- Once you paired the devices in the Android device, start there the App "Omnicontrol". Press "Select device".  A list of all paired Bluetooth devices will be presented to you. Please press the name of the Bluetooth Modem you want to connect to (Again, "Firefly........."). You will go back then to the main screen.

6.- Press "Connect". If everything went Ok, after 1 or 2 seconds, the status bar will change from Red to Green and the text "Connected" will appear. The blinking red Led on the Modem switches off and the green one goes on (As in the picture above).

7.- If you press "Power On", the App starts sending telegrams. If you press it again, you stop the transmission. Have a look on this former entry of my blog to see a video with the whole process.

8.- While the communication is on, go to your computer and open the Serial Monitor in the Arduino IDE. (Tools -> Serial Monitor). You will see something like this:

The Structure is quite simple. There are letters, then associated values:
M -> Magnitude
A -> Angle
E -> Switch is On or Off. (E = Enable). When you switch off, you will receive a single time "E0", then communication stops.
T -> Turn

I programmed the Android App in such a way that when "Power On" is false, no communication takes place. If this is not OK for you, you can easily adapt the App to your own needs. F.ex. you may use this On/Off switch to control not the Move Enable but something else mounted on your robot.

The source Code is here: http://sourceforge.net/projects/omniplatform/files/Remote%20Controller/
This App is programmed with AppInventor. I will comment it in a next entry.

On the other side of the comm. channel, in you Arduino real sketch, you can read the values using a simple piece of code. Like this: (This works as it is on a Leonardo. The Serial1 must be changed to Serial2, 3 or 4 in the Arduino Mega)
r = Serial1.read();
    switch (r)
      case 'M' : vel = Serial1.parseInt();              // Magnitude
      case 'A' : ang = Serial1.parseInt();              // Angle
      case 'E' : moveEnable = Serial1.parseInt(); // Move Enable
      case 'T' : turning = Serial1.parseInt();         // Turning

I suggested you to use an Arduino Leonardo or Mega. Both boards have at least 2 Serial ports. This way you can upload & debug your Sketch through one port, while the Bluetooth communication is working on the other. This allows you to keep everything in place while modifying & debugging your sketchs.

The Arduino UNO has only 1 Serial port used for everything, included upload your sketchs.

This means: in an UNO, if you have the Bluetooth modem connected, you cannot connect your computer. Using this board is perfectly possible, but you will need to re-wire constantly from one configuration to the other each time you upload / test your sketch. Needles to say, the above mentioned test will not work on an UNO.

Bluetooth is tricky but the RN-42 do a nice job, making things much easier as I would expect. I ordered by mistake the HID version. It can be used too, but I recommend to use the normal one, the one I indicated before.

When using the Bluetooth modem, be sure to have adjusted the proper Baud Rate in your Arduino Serial Port (default value is 115200 Bauds) and that the Modem is working in SPP mode. If you are using the HID version, you must switch to this mode before using it. Again, refer to the modem documentation to see how to do it.

I didn't test this system with other Bluetooth modems, but if you are able to open a SPP channel with the correct Baud Rate on it, it must work too.


miércoles, 6 de febrero de 2013


I just created a project in SourceForge to publish all the files of my project.

This is the link:

I look forward to your comments!