Wi-Fi Controlled Remote Control Car Without Microcontroller

by smching in Circuits > Wireless

17730 Views, 180 Favorites, 0 Comments

Wi-Fi Controlled Remote Control Car Without Microcontroller

Front Page.jpg

This is a Wi-Fi controlled remote control car with camera that can be driven over the internet. The RC car is very unique since it's using a wireless router and eliminate the need of a microcontroller.

Car Structure

Car_Structure.jpg
  1. This is a two wheels drive RC car
  2. An universal wheel in the front.
  3. Two wheels and the car motors on the back.

Materials

Materials.jpg
  1. OpenWrt compatible router such as GL.iNet 6416.
  2. USB Video Class (UVC) compatible webcams, I'm using Microsft LifeCam HD-5000 with auto focus
  3. 4 x 3.7V Rechargeable Lithium-ion batteries (Built-in Protected Circuit)
  4. Arduino Compatible DIY Motor Smart Robot Car Chassis Kit 2 WD
  5. L298N Motor Driver Controller Board
  6. Multifunctional DIY DC to DC Converter
  7. Female to Female Dupont Jumper wire cable
  8. Male to Female Dupont Wire Jumper wire cable (20cm), with additional $0.07, you can get a solderless breadboad
  9. 47ohms and white color LED
  10. Nuts and Bolts

Block Diagram

Wi-Fi_car_block_diagram.jpg

As shown in block diagram, everything is controlled by a wireless router, the webcam is connected to the wireless router via USB port that allows live streaming video, the motor controller board is connected directly to the router via GPIO in order to control the motors without the use of a microcontroller.

Wireless Router

GL.iNet_6416.jpg
GL.iNet_GPIOs.jpg

I chose the GL.iNet 6416A for this project because it is an extremely small wireless router (dimension: 58*58*22mm), the 5 GPIOs & serial port are all easily accessible via though holes or headers.

All other wireless routers supporting OpenWrt should work fine provided there is enough space in flash, you can find a list of supported router models on OpenWrt's website.

Most of the wireless router may not have enough GPIO to control the motors, however, you can use other pin on the router such as the LED pin, this require to unload the leds_gpio module or this way to control LED manually.

Webcam

Microsoft_LifeCam_HD-5000.jpg

I do already have a Microsoft HD-5000 webcam, it’s capable of capturing video up to 1280x720 pixels. The auto-focus was really getting annoying and I do not want autofocus in a car, so why not disable this feature (please refer article below).

Those USB webcams that are UVC compliant should work for this project.

Motor Controller Board

L298N_Motor_Driver_Controller_Board.jpg

A motor may require significantly more current than the wireless router can provide, it may damage your router if you control the motor without a H-bridge. Hence the L298N Motor Driver Controller Board Module is used in this project in order to control the direction & speed (see PWM) of two DC motors.

I found out that there is about 1.5V voltage drop between the input voltage and the L298’s motor outputs.

Multifunctional DIY DC to DC Converter Auto Step - Up Step - Down Boost Buck Solar Power Supply Module

dc-dc_converter.jpg

This is a buck–boost converter that has an output voltage magnitude that is either greater than or less than the input voltage magnitude.

Comparing with linear regulator, dc-dc converters primarily strive for efficiency, it can deliver efficiencies greater than 95% while boosting and hence reducing power consumption. Here is a simple test for the module. I set the module output to 5V and feeding 2V-24V to its input, no matter the input voltage is higher or lower than 5V, I always get a very stable 5V except the input is lower than 2.6V.

Car Chassis Kit

Car_Chassis_Kit.jpg

Chassis is made from acrylic material, size(L x W x H) 19.8 x 14.0 x 6.5 cm which is smaller than expected, I ended up spending hours and scratch my head on how to fixed all the gadgets/modules/devices onto the chassics.

The kit included two deceleration motors, two plastic wheel, a battery holder for 4xAA batteries, and there are also two speed encoder which I'm not using.

The input voltage of the motors is 3V-12V according to the product description given by Gearbest.com, following is the additional specifications getting from internet.

  • Recommended operating voltage of about 6 to 8V
  • Maximum torque: 800gf cm min @3V
  • No-load speed: 1:48 @3V
  • Load current: 70mA (250mA MAX) @3V

Something very interesting, the two deceleration motors is small but it is very strong that can push and move a placstic chair (see video).

Batteries and Voltage Supply

Li-on_battery.jpg
Double_USB_Voltage_Step_Down_Regulator_Module.jpg

I'm using 4 pcs 3.7V 18650 Li-on Rechargeable Batteries, 2 pcs connecting in series and the other 2 pcs connecting in parallel yielding 7.4V (full charge = 8.4V). Charging or using the batteries incorrectly may cause explosion or fire, therefore I suggested to use the batteries with built-in protection circuits.

The RC car may require two different voltage supplies depend on the input voltage of motors, the 5V goes to the wireless router and the other voltage supply goes to the motors.

Before building the RC car, I order a Double USB Voltage Step Down Regulator Module as shown in figure and a DC to DC Converter (Auto Step-Up & Auto Step-Down) (Auto Step-Up & Auto Step-Down). The Double USB Voltage Step Down Regulator Module provide a constant 5V to the wireless router and webcam via a USB cable, while the DC to DC Converter required to adjust its output voltage before power the motors.

During testing, I found out that the input voltage of the motor must not exceed 5V, otherwise the RC car is running too fast or in worse case the power is shut down automatically (battery protection circuit triggered).

Based on the results of the experiment, I only need a DC to DC Converter that the output voltage is adjusted to 4.5V, while the Double USB Voltage Step Down Regulator Module is not using in this project. Therefore the wireless router & webcam is running on 4.5V, and the two motors is running on 3V (4.5V-1.5V voltage drop).

OpenWrt - a Linux Distribution for Your Router

GL.iNet_main_menu.jpg
Luci_Web_Interface.jpg

The GL.iNet wireless router comes with OpenWrt Barrier Braker pre-installed, it includes their newly designed easy to use web interface for configuring the router. Navigate to http://192.168.8.1 & login to the router, the GL.iNet web interface should appear on the screen.

You can click on the Advance Settings (or navigate to http://192.168.8.1/cgi-bin/luci) in order to open the traditional Luci Web Interface.

I'm faced with a problem that the video streaming is not working without login to the router, for this reason I have to download the image file from OpenWrt website and flash it to the router.

If you do not already have a OpenWrt firmware on your router, please refer to this tutorial for instructions on how to upgrade the firmware.

Network and Internet Connection

Wireless_Bridge.jpg

The router need to have internet connection in order to perform the package installation. Check this tutorial out, it gives you a detailed guide to setting up network and internet connection for your router. Furthermore it shows you how to create a new virtual interface (SSID) that allows your computer/notebook/smartphone connect to the router

Installing Packages - Install Additional Software on Router

PuTTY.jpg

By default, OpenWrt includes standard software that lets the router create wireless network or join existing ones, it would require to install additional software on the router which is currently not included. Steps below show you how to install all the software needed by webcam, you can skip this section if you don't have a webcam or you don't need video streaming

  • SSH to router and execute the command line by line, preferred PuTTY.
  • You must download the current list of packages available from local package repositories before you can install packages onto your router.
opkg update #update list of available packages
opkg install kmod-video-uvc #UVC camera driver
opkg install mjpg-streamer #stream JPEG files over an IP-based network
  • Edit the file /etc/config/mjpg-streamer in order to enable video. I'm using WinSCP to edit file.
config mjpg-streamer core
option enabled "1"   
option device "/dev/video0"    
option resolution "640x480"    
option fps "15"    
option www "/www/webcam"    
option port "8080"
  • Require to install uvcdynctrl if you want to disable/enable auto-focus.
opkg install uvcdynctrl
  • Require to install lsof if you want to get the webcam status.
opkg install lsof
  • Start video on router reboot.
/etc/init.d/mjpg-streamer enable
  • Reboot the router and you are ready to stream.
  • Command below will temporary disable auto-focus. You should disable auto-focus on startup (see below).
uvcdynctrl --set='Focus, Auto' 0
  • Getting webcam state via lsof command
lsof /dev/video0

Disable Auto-focus on Startup

Save the following code to /etc/init.d/disableAutoFocus. Please click here for more information about Init Scripts.

#!/bin/sh /etc/rc.common
START=99
STOP=15
start() { 
uvcdynctrl --set='Focus, Auto' 0
} 
stop() { 
uvcdynctrl --set='Focus, Auto'
}
  • Set file permission to 0755, you can also use WinSCP to changing permission.
chmod 0755 /etc/init.d/disableAutoFocus
/etc/init.d/disableAutoFocus start
  • Enable service autostart
/etc/init.d/disableAutoFocus enable

Schematic

wifi_car_schematic.jpg

Source Code

The core code for this project is written in Lua scripting languages, while the web interface is written in html and javascript. All the files are packed into a single zip file which is available here.

Lua is an interpreted language, a change in a script will not necessarily require a rebuild of the entire project, its code is executes immediately after you have saved it, and therefore it is easier to update and maintain. Please read the following Lua files for those interested in seeing how it works.

  • /usr/lib/lua/gpio.lua

GPIO's read/write function for router, more information is available here.

  • /usr/lib/lua/2w_motor.lua

Work with gpio.lua in order to control 2 DC motors, more information is available here.

  • /www/cgi-bin/control

A program that acts as an interface between browser (web page) and router.

As mentioned above, the web interface is written in html and javascript. Please study the following files for those who wants to develop their own interface (GUI).

  • /www/car/index.html

The main program, load the external js & css files and implement image onClick events.

  • /www/car/pantilt.html

The main program, bigger video size.

  • /www/car/car.css

Layout options such as image postion, colors, and fonts.

  • /www/car/car.js

Consists of javascript function.

  • /www/images

A folder consists of the images which shows on the web page.

  • /www/codebase

Consists of javascript components to create slider (dhtmlxSlider), more information is available here.

Software Installation 1/3

WinSCP login to router.jpg

The software do not need installation, make sure you have transfer them to the correct folders on router. I'm using WinSCP to manage files and folders.

WinSCP is a SFTP/FTP/WebDAV/SCP client for Microsoft Windows that allow you to transfer files and manage folders between computer and router.

Software Installation 2/3

Files and folders tree view.jpg

Assumes you already have WinSCP running on your computer and are connected to the router. Now extract the downloaded file (2W_WiFi_car.zip) to your computer and transfer them to the respective folders on router as shown in figure above.

Software Installation 3/3

Change_file_permissions.jpg

The /www/cgi-bin/control file require execute permission, please change its permission to 0755 (rwxr-xr-x) as shown in figure above. Please refer to WinSCP on how to changing permission.

PWM - Speed Control

GL.iNet wireless router use Atheros AR9331 CPU and it doesn't have hardware PWM, the only way to implement PWM is through adopt software PWM.

Kernel after 3.14 , OpenWrt such as Barrier Breaker and Chaos Calmer has dropping support for PWM over gpio, therefore you must compile your own OpenWrt firmware in order to enable the software PWM feature.

I'm trying to follow this tutorial and compile the OpenWrt firmware successful, when I upload the compiled image to the GL.iNet router, it bricked my router (the network interface is not working). Lucky it is recovered easily.

I've been playing around with the gpio-pwm-ar9331, I downloaded the precompiled ipk file and uploaded to my router, but it failed to install with the following errors:

Installing kmod-gpio-pwm-ar9331 (3.10.49-1) to root...Collected errors:
* satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-gpio-pwm-ar9331:* kernel (= 3.10.49-1-69f3c9d824d79ff97e8c05f8219a41f3) *
* opkg_install_cmd: Cannot install package kmod-gpio-pwm-ar9331.

Moreover, i recompiled the gpio-pwm-ar9331 from source, this time it can install onto my router, unfortunately it is not working.

I found out a tutorial related to software PWM that is not fully tested yet. It is now compiled succesful for my router. Hopefully it can run without any problem.

At the moment, the PWM is not working for my router, hopefully this will get fixed on the next few week. If anyone has any idea how we can fix this, please let me know.

Controlling the Car

Web_interface.jpg

You can control the car from a web browser (do not use Internet Explorer, recommended Google Chrome) or Android application.

  • Open up a browser and navigate to http://routerIP/car/ (eg. http://192.168.8.1/car/) or http://routerIP/car/pantilt.html (eg. http://192.168.8.1/car/pantilt.html)
  • Click on the images or use a keyboard to control the car
  • Keep pressing a key on the keyboard will keep the car running, release the key will stop the car.

Keyboard Shortcut

Keyboard shortcut.jpg

I'm Wi-Fi RC Car

1Front1.jpg
2Front Left.jpg
3Left.jpg
4Back.jpg
5Right.jpg
6Back Right.jpg
GL.iNet Wireless Router and L298N Motor Driver Controller Board.jpg
GL.iNet Wireless Route.jpg
L298N Motor Driver Controller Board.jpg

My name is Wi-Fi RC Car, I was born in Malaysia on Oct 2015. I can run, I can see, I'm handsome, I'm strong, please try to knowing me, I'm sure you love me.