“Pedrone” Part #4 – drive it using web browser and WiFi

This is the last step. “Pedrone” is now complete. Please, remember that this is just a toy, you can’t use it to discover any sort of life on Mars ! I wrote a small Android application that acts like a mini web-server receiving commands from a standard web browser. I realized a demo video, capturing the screen while driving Pedrone with my web browser (SeaMonkey). Here it is:

pedrone3 di robotop

The Android application is relatively simple. It receives commands as “get” requests and, depending on the parameters, outputs the sound sequence to communicate with the microcontroller. Acting this way, the Pedrone executes the requested movement. After moving, the application takes a picture of the new situation (position) and gives the answer to the browser, that is still waiting. The process is a little bit slow, ‘cause the full path for the command is: 1) you click a “button” on the navigation map on the browser 2) an internet request is sent to the mini webserver 3) the webserver executes the command and send a sound sequence to the microcontroller 4) the microcontroller decodes the command and runs the motors for half second (short move) or one second (long move) 5) the application takes a picture 6) the application sends back an answer to web browser, changing the name of the image to force the browser to reload (no-cache) 7) the browser sends a new “get” to download the updated image. A screenshot of the Android application is here:

Screenshot of the Android App Pedrone-Rx3 (click to enlarge)

Screenshot of the Android App Pedrone-Rx3 (click to enlarge)

If you want, you can freely download and install this App from the Google Play Store.

For the mechanical part, I used the Lego Technic (my “children” have given me when they left university) with addition of some small screws and strong glue to create the adapters from Servo-motors to wheels and from structure to Servo-motors. In the following picture you can see how it was realized.

Three different views of "Pedrone" (click to enlarge)

Three different views of “Pedrone” (click to enlarge)…

The microcontroller circuit is not changed, look at Part #2 for complete schematics. The firmware has some changes. You can download the C source and the compiled HEX packaged in a zip file from the link : pedrone3x.zip ; the password to unzip is : eficara. Remember to set the correct fuses configuration when burning the micro. You can read such configuration in the first lines of the C source file. Here is the full C source list.

Finally, note that you can drive the “Pedrone” on your local net using a PC / Tablet / Smartphone connected on the same WiFi subnet, but you can also control it from everywhere in the world if you set your modem / router with the following rules:
1) force the router to assign a fixed IP to the MAC address of the WiFi interface of the smartphone you use as “receiver”, es: assign local IP to MAC address 11:22:33:AA:BB:CC; this way the “Pedrone” smartphone will have every time the same IP on your local network.
2) modify the router’s firewall rules to accept incoming connections to port 8080, redirecting the requests to the IP assigned to the “receiver” ( in the example)
3) get a free account on some Dynamic Dns service, as no-ip or dyndns or others and set the relative username and password in the router’s Dynamic Dns settings.
After this, you can reach “Pedrone” from everywhere in the world (if there is an internet connection !) with a standard web browser, writing the address http://my-assigned-dynamic-ip.com:8080 in the navigation bar.

Historical notes:
The idea for this project was born in August 2009, when I was in France for a sabbatic time and my smartphone was equipped with WM6. I realized a circuit and a couple of applications to test the motor driving using DTMF tones. After that, I published a video on YouTube describing the general concept. After some months I removed the video ‘cause Google acquired YouTube. I think that too much power in the hands of a single subject is very dangerous, but now that all the world is fulfilled by Android devices, it’s impossible to stop the “Masters of Universe”… Anyway, the original video is now stored on “DailyMotion”. If you want, take a look here:

dtmf_remote di robotop

“Pedrone” Part #3 – 16 commands using sound protocol

This is the third step. The previous version of the firmware was able to recognize three tones and the demo used a single tone for a unique operation. Now, I used a “protocol” to send multiple tones and create 16 possible commands. I used Audacity, a fantastic sound editor, to create the sound sequences. Here is an example:

The sound file for command 1011

The sound file for command 1011

A “command” is composed by a “start” tone (1200Hz) and four bits starting from the most significative. The “ones” are 1600Hz, while the “zeroes” are 800Hz. In the picture is represented the code 1011. A full “transmission” is always 500mS. Every sound has 50mS duration, followed by 50mS pause. For sound file output, I used the format “ogg” because is compatible with Android and iOS smartphones.

To test the firmware, I wrote a small application on Android smartphone. This is a screenshot of the application running:

Screenshot of Pedrone-Rx2 application

Screenshot of Pedrone-Rx2 application

The three buttons in the middle are just for compatibility with the old version of the firmware, while the cursors at the right and at the left are the controls for the motors. There are five positions for each motor : Fast Forward, Slow Forward, Stop, Slow Backward, Fast Backward. So, at this moment, I used only 10 of the 16 commands available. The App was not published on Play Store because is just for testing purposes, but if you want, you can download it and install from this link: Pedrone-rx2.apk .

The schematic of electronic circuit has not been modified, while the firmware has been improved. If you want to load the C source and the HEX file to burn the micro, both of them are packaged in a zip file that can be downloaded from this link : Pedrone3.zip (use password eficara to unzip) . Here is the full list of the C source file ; the hex comes from compilation with IAR V5.50.0. To burn the micro, use the fuses configuration that is described in the first lines of the C source.

“Pedrone” Part #2 – connecting to smartphone

After the Part #1, with the Servo Motors control program, now I connected a smartphone to the circuit. The software on the phone (in the next future) will do all the Internet job, receiving commands and sending pictures. Anyway, a connection is needed to control the hardware (motors) for moving “Pedrone” via web commands. A very simple solution is to use the headphone jack and send some tones to activate the motors. As first option, I decided for one DTMF tone decoder, but after some considerations, like the absence of noise on direct connection, I decided to use single tones. The hardware is very simple (stereo version is shown, but you just need one channel) :

Particular of the schematic (click to enlarge)

Particular of the schematic (click to enlarge)

This circuit is a mixer of Left and Right audio channels coming from the headphones jack of the smartphone, followed by protection resistor and diodes to safely connect to the ICP1 pin of the micro ATmega48. The ICP1 is the input capture pin of Timer 1 (TMR1). I used such peripheral to measure the period of incoming frequency. There are three frequencies: the first is considered as “start” signal and the other two as “0” and “1”. The protocol isn’t still implemented (will follow soon). At this moment, the test program just recognizes the frequencies and does a programmed action for anyone of them. The frequencies are 800Hz, 1200Hz end 1600Hz. All the tones have 50 mS duration. The complete schematic (including the servo motors outputs) is in the following picture

The complete schematic (a PDF version is in the downloadable project's zip file) - click to enlarge

The complete schematic (a PDF version is in the downloadable project’s zip file) – click to enlarge

If you are interested in the C source list and in the hex file to burn into the micro, you can download both of them (plus the schematic PDF), from this link: Pedrone2.zip
(password for zipped file: eficara)

There is a small video to show the program running. The application for Android smartphone has not been published on Play Store, because it’s just for testing purposes, but if you want you can download the apk directly from this link: Pedrone-rx.apk.

Pedrone part 2 – connecting to smartphone di robotop

Here is the C source list for the test program (compiled with IAR V5.50.0).