Friday 21 February 2014

Netduino + Android controlled RC Car

When a friend of mine provided this use case, my eight year old son started developing interest doing this. This is the first time I'm working with these electronics prototyping platform. When I wanted to develop this rover, I ended up choosing between these options - Arduino Vs. Netduino Vs. Raspberry Pi. I picked Netduino due to the fact that I'm a .NET programmer and found that Netduino would be easier for me.

Use cases:
a. Control a toy car through my mobile (Android)
b. Send video from the car to the mobile device (later phase)

Being the first project I just wanted to take the first use case and build from there. There are many online materials available to control the car from your mobile using Arduino/Netduino. You will find more Arduino based experiments, if you are interested using Netduino look for Arduino based materials also.

Again, there are different approaches to control the car from Netduino. The sophisticated approach appear to be driving the servo motors directly which everyone recommends. Being a novice to this area, it appeared to be little complex and expensive for me. I was wondering with other easy approach and ended up controlling the RC Car Remote Controller instead of the car's motors directly. So my approach is to control the RC Car remote controller and don't break the car electronics. I just chose this approach as it was easier with my first attempt and was cheaper.

Requisites:
a. Toy Car
b. Netduino Plus which has ethernet connectivity
c. Edimax Nano router
d. USB Power banks to power router and Netduino
e. Soldering rod






Step - 1 : Wiring the RC Car Remote Controller
Thanks to the detailed instructions here, I just followed the steps there. The idea is to send signals to the remote controller from Netduino - we will be simulating the user pressing the remote controller buttons. In order to do that you need to remove the remote controller circuit board and wire it to the Netduino. The remote controller is powered by two 1.5V batteries, i.e., 3V. Netduino has a 3VDC output. So we are going to power the remote controller from Netduino itself. You need to break the remote controller connection to the battery bank and solder two wires and connect the (+) node to 3.3V and (-) node to GND in Netduino. At this stage you are just powering the remote controller from Netduino and you can test if it is working by pressing the buttons and see if the RC car is working as expected.

After powering up the remote control circuit board from Netduino, we need to solder 4 wires to the circuit board for front, back, right and left operations. You should be able to easily track down the buttons in the circuit board and see where they are connected in the transmitter IC. At this stage I am powering up the remote controller from Netduino and have four wires soldered into the remote controller circuit board which I'm going to send signal from Netduino in next steps.

Step - 2 : Controlling the RC Car Remote Controller through Netduino Plus
Now, it's time to write some .NET Micro framework/C# program and deploy to the Netduino and control the RC Car Remote Controller. Connect all those four wires from the remote controller into Digital I/O pins in the Netduino and remember each port's function like front, back, left and right.

All we are going to do is sending signal to the appropriate IO pin in Netduino. I just tested sending signal forward for 3 seconds and back for 3 seconds. When I deployed the solution to Netduino, the RC car was moving forward and backward repeatedly. The program works.

At this stage I figured out powering up the remote controller and sending appropriate signals from Netduino. Those are the core essentials.

Step - 3 : Controlling the Netduino over HTTP
I wanted to attach the Netduino to the rover itself so that it is portable and self-contained. To do that I need to send a HTTP Request to the Netduino and let Netduino send appropriate signal to the remote controller. To send a HTTP Request, I need to run a tiny web server in the Netduino. This is fairly straight forward, .NET Micro Framework has required classes readily available. You can follow this thread for building a simple web server.

I built the web server, my web server IP is 192.168.1.78 and can process these HTTP requests:
http://192.168.1.78/left
http://192.168.1.78/right
http://192.168.1.78/front
http://192.168.1.78/back
http://192.168.1.78/stop
Processing logic for those requests will just send appropriate signals to the Netduino digital pin and control the RC Car Controller. At this stage I was able to test the car working by typing these URLs in my browser.
To recap,

  1. Netduino is powered up by the computer's USB port
  2. Netduino is connected to my home LAN network
  3. RC Car remote controller is connected to the Netduino
  4. Netduino is powering the RC Car Remote Controller
  5. Netduino is running a web server and can process specific request
  6. My browser sends command over the LAN to Netduino
Everything works except that the Netduino is stationary. My next step is to control this with my Android device.

Step - 4 : Building the mobile application
I've a Samsung Galaxy Note and Android is much developer friendly. Write some code, wire up your device to the computer and deploy it. It's simple! Following is a simple Android application raising different HTTP requests.



My last step is to make the Netduino portable and fitted into the rover itself.

Step - 5 : Making everything portable
In order to fit the Netduino into the RC Car itself, I need these two things:
a. Battery to power Netduino (5V DC)
b. WiFi connectivity

I found this in Amazon and appear to meet the needs. Looked at Netduino forum, people appear to be using these power banks to power their Netduino without breaking.

Netduino doesn't seem to have a WiFi Shield, again looking at forums, I found this tiny router could be handy, mainly because of its size, it supports client mode and to the fact that it can be USB powered (5V). I ordered this tiny router and two power banks - one for powering up the Netduino and another one to power up the router.

I configured the router to work on client mode following the manufacturer instruction. Now I had to remove the car cover and put all the devices to the car. This is were I struggled a bit, it was a toy car and there was not much space to put the accessories. I had to use some rubber bands to drop them, it doesn't look great but works.

Here is the final version of the rover.



It basically works fine, my son kind of liked although he didn't get the same user experience with a physical remote. I should enhance the remote control Android application for better usability, I'm not going to do that now.

I will also need to find a hobby grade car for my next project. Hope this helps someone who is new to programming these electronics prototyping platform.

1 comment:

  1. Thanks for linking to my project.

    You should use the accelerometers/gyros in the phone so you can turn it left and right. It'll be a better user experience than a remote :)

    If you check out my latest article on "My First Time on Adafruit's Show and Tell" it show's my evolution of the project where I use Node.js to talk over serial to the Arduino and it can be controlled by any number of devices. Skip to 10:30 for the demo on the embedded video.

    Link: http://forefront.io/a/first-time-adafruit-show-and-tell

    Keep up the good work and keep sharing your knowledge!

    ReplyDelete