CONTENTS

Home
Updates
Software
Electronics
Music
Resume
Contact


YouTube
Twitter
GitHub
LinkedIn


WiFi R/C Car With IP Cam

Posted: January 4, 2013

Introduction

Since the entire office at work is covered with WiFi, I figured it would be fun to build an R/C car that I could control from my netbook using a standard PC game pad with an FLTK app and a camera mounted on to the top. Since POV R/C car cameras tend to be pretty expensive and have probably a fairly limited range in a building I went searching for a cheapo IP camera that could also use the WiFi of the building. I found this TRENDnet TV-IP551W 802.11g camera for under $50 which I was able to make run on the car's battery.

For the car, I ended up getting a Tamiya Rising Fighter (not sure if they sell this one anymore) which came in pieces and required a bit of assembly. It's also probably a bit over-powered for this project which made it a little hard to control, especially with the delay in the camera's video feed.

Related Projects @mikekohn.net

RC Cars: IR Toy Car, IR Toy Car dsPIC, Bluetooth RC Car, RC Drag Race, WiFi RC Car, Xbee RC Car, RC Food

Explanation

The R/C car came with a speed controller, so I decided to keep that part, but remove the radio part. This simplifies my circuitry quite a bit since I don't have to make an H-bridge as I did with my previous R/C car. The signalling and code that controls the steering is also now identical to the motor. The code is pretty simple, using the MSP430G2553's timer module I send a pulses out P2.0 and P2.1 between 1ms and 2ms every 20ms. If the signal is at 1.5ms on P2.0, the steering is centered while 1ms and 2ms (and the numbers in between) move the wheels left or right. If the signal on P2.1 is 1.5ms the car is stopped while 1ms and 2ms is full speed forward or reverse. The length of these pulses is changed when it receives commands over the UART. If the UART receives no command for something like 400ms, the car centers the steering and stops the car. For the heck of it I threw a buzzer on P2.2 for a car horn.

The commands over the UART as follows:
0x00: NOP (heartbeat to let the car know it still has a connection to the netbook)
0x01: Car horn on
0x02: Car horn off
0x80: Command to channel 1. 0x80 + (0 to 63) where 0 is 1ms and 63 is 2ms
0xc0: Command to channel 2. 0x80 + (0 to 63) where 0 is 1ms and 63 is 2ms

For a radio unit I found this Roving Networks WiFi module from SparkFun. This little module is pretty easy to configure. I just connected it to the computer with one of these XBee to R232 converters and used minicom to set the SSID and password. Also, I put the device in UDP mode and set up a port to listen on. At this point any UDP packet I send to the WiFi module's IP/port will be sent over the UART to my MSP430. In other words, if I send a UDP packet with 'A' in it to the module, just the letter 'A' will be sent over the UART to my chip. My firmware doesn't even have to think about the fact that the data being sent to it came from a UDP packet over the network.

For video I found this cheap TRENDnet TV-IP551W IP camera. The camera is a little quirky, for example when requesting a single JPEG from the camera the webserver won't honor the keep alive header so I can't do a "client pull" to get the video without extreme lag. Unfortunately, I couldn't find any TRENDnet documentation on programming the camera, but they did have some GPL compliant download with a binary version of their webserver in the tarball. Running the Unix command "strings" on their web server I found a bunch of hidden URL's for the camera including one that will allow me to pull data MJPEG "server push" style. I wrote some simple code that connects to the camera's web server over a TCP socket, makes a request for the MJPEG stream, and displays the video in the FLTK app. I was actually kind of surprised for being such a cheap camera it does have a pretty decent picture, even in low light. Unfortunately, the videos below make the camera look pretty awful. This is just the way the Nikon camera I used to make video adjusted for the bright screen I guess.

For anyone looking to play around this camera, the URL's I found are:

http://cameraip/image.JPG for a client-pull JPEG and
http://cameraip/mjpeg.cgi for a server-push MJPEG stream

To be clear (since I'm being asked this question by people already) the camera runs on one IP address and has a TCP connection to the computer which connects to the camera's web server and the Roving Networks WiFi module has a second IP address which I send commands to via UDP. I haven't posted the FLTK app that communicates with these two devices because, well, the code was thrown together really fast and I'm kind of embarrassed at the way it was written :(. The MSP430G2553 firmware is however posted below and can be assembled using my own naken_asm assembler.

Video

The first video here shows the first test of the car from a front view. Unfortunately, the motor is just too powerful and it flips over the back of itself when I pushed forward. I think this is because the car was designed to run on an NiMH battery, but that battery was sagging and resetting my camera and circuit when the car was starting out on the ground, so I replaced it with a LiPO. The LiPO weighs less and probably supplies more current to the motor (considering the NiMH battery was in pretty bad shape). https://youtu.be/0dpS_eVPm74

I adjusted the throttle control (halved it) and was able to move the car across the office. The car is still pretty hard to control. The WiFi in the office seems a bit saturated so my commands to the car and the video sometimes lag a bit. On top of that the steering is quite sensitive. https://youtu.be/G5ctIrHmqE8

This is a top view of the car recorded at the same time as the first video. https://youtu.be/4OOowfdTbUE

And I believe this video is an outside view of the second video. https://youtu.be/H58xGySylSY

Pictures

WiFi R/C car

A view of the car with the cover removed.

WiFi R/C car circuit

A closer view of the circuit board. The red module on the front is the WiFi module.

WiFi R/C car with camera

Front view of the car with the mounted camera. Yeah, the masking tape is ugly, but it holds pretty well and comes off easily.

WiFi R/C car with camera

Side view of the car with the mounted camera.

WiFi R/C car schematic

And here's the schematic...

Source code
wifi_car.asm

Assemble with naken_asm.

Copyright 1997-2024 - Michael Kohn