Saturday 22 March 2014

Project 22(Advance) Part 1: Wifi Controlled Tank with wifi webcam

It's been awhile since I last updated this blog. The main reason is because I was busy with university and work. Also, I've been working on a new project for quite some time now.








































I bought a new microcontroller: The Digix. It's 100% arduino due compatible with built in wifi, up to 99 input/output pins and a lot more features. My arduino uno didn't have enough output pins for this project but the digix is perfect.


GUI and Controls
I programmed the digix using the arduino IDE and used the g4p library to construct a basic GUI. There are a lot of functions on the GUI where the tank itself is not equipped with the hardware(ex. laser, bb gun). The GUI was originally designed to control a tank with bb gun. I can also use my keyboard to control the tank.



Wifi Control
I had no prior knowledge nor experience working with wifi. Establishing communication with my micro controller through wifi was very time consuming and frustrating. The digix was recently released and is not an official arduino board. Sample arduino wifi codes from the web won't work with the digix.A lot of tinkering was required but in the end, I decided to use the TCP protocol to communicate with the digix. TCP protocol is communicated on port 23 and its primary purpose is to be used to create chat servers.

The digix was setup as a server and my computer as a client. I used a wireless USB adapter to communicate with the digix.








Wifi Camera
I ordered a D'link 930L wifi webcam. To power this webcam, I need a regulated power source. The webcam came with a wall adapter (5v, 1.2A). I want to power this webcam with one of my lithium ion batteries. To safely do this, I need to step down the output voltage to 5 volts. Using a voltage regulator, I successfully powered the webcam with no issues at all.




In order to establish communication with my router and the webcam, I must press and hold the WPS button on the camera for about 5 seconds. Next, I had to press another WPS button on my Dlink router. This setup takes about a minute. Once communication is established, I can view the camera by entering the webcam's IP address in my web browser or through dlink's website. The camera can be viewed ANYWHERE from their website(of course, you must have access to my account).





















Ultrasonic Sensor
Objects in the camera are a lot closer than they seem. I added an ultrasonic sensor at the front of the tank to help me with navigation. To reduce power consumption, the ultrasonic sensor won't be constantly be polled, like in my previous projects. They will be activated when I send the correct command.



I'll be using 2 lithium ion batteries to power the tank: 11.1v with 4400 mah will power all the motors/camera and a 7.4v 5200 mah to power the micro controller. Due to a fairly low power consumption, the batteries can power the tank for a few days. I will admit that these batteries are overkill but they will be necessary for future upgrades. I plan on adding my airsoft gun on the tank and the electric airsoft gun is hungry for power.



Tamiya Tank Chasis and Mechanical Structure
The setup for the tamiya tank was custom built by me. I ordered 2 sets of tamiya track/wheels and 2 universal plates. I merged the plates together by screwing in an aluminum plate. The tank itself has 2 levels. The lower level will hold the two batteries and a gearbox to move the tank. The second level will hold all the electronics and the turret.






















Motor Drivers
I'll be using the SN754410 H bridge, the same motor drivers I've used in my previous projects. I wanted to install a heat sink on the ICs but it wont fit on the breadboard. The only option for this is to use a protoboard and solder the IC's together. Instead of soldering the ICs to the board, I soldered the IC sockets. 





















Tank Motors
The tamiya double gearbox contains 2 motors where each can be controlled independently. The gearbox can be set in 4 different gear modes, where each will provide a different speed and torque. I chose "option c (gear ratio 114.7:1)" where the rpm is 115 and the torque is 809 g/cm.

**turret tilting and panning motors** 
I salvaged old gearboxes from my robot, robosapein. These gearboxes will be used as a tilting mechanism have a very decent torque which can move my camera without any issues. I'll be using a stepper motor for panning motion.








Communication Range
There will always be latency issues with wifi. Whenever the tank is nearby other electronic devices that causes a significant amount of electrical interference(such as a fridge),  It is possible that I will lose communication with the tank. Also, the communication range will be reduced if there are walls in between my router and the tank. I was about to control my tank where is was located in the basement from my computer on the second floor. I was able to navigate for awhile but then lost control of the tank. However, the wifi webcam was still sending back the live feed.








Future plans: Hopefully, I can attach a bb gun on the turret. My main concern is the tilting motor's torque. I tried to control the turret with the bb gun attached but the movement is not very smooth. When moving the turret down, gravity comes into play and moves it a lot faster. If I try to tilt the turret up, the turret moves much more slowly. To solve this issue, strong servo motors will be required. Servo motors will also provide a significant increase in accuracy.






















Also, I'll be building an auto reloading mechanism for the airsoft gun at some point. I will need to construct a small container to hold the bb pellets. In the photo below, The container holds 2000 pellets and I don't want to use that container due to it's high profile. To minimize the size of the container, I must construct a cube. As of right now, I'm not sure if I want the container to hold 2000 pellets. The airsoft gun came with a Manuel reloading clip and I'll attach a motor to it at some point. This is probably going to be the most difficult mechanical challenges for this project.




Navigating in the day is perfect but what about in the dark? For now, I added a tiny flashlight on the webcam using tape. Obviously, I cannot remotely turn on/off the flashlight. I plan on adding a super bright LED and several IR led's for night vision. The digix cannot supply enough current to directly power the leds so I'll use a relay instead. A relay is an elector-mechanical switch which can be turned on/off through small electrical signals (in this case, my digix will be sending these signals).






Another thing I might consider making is a close range EMF detector. I built 1 of these in my previous projects and hopefully it will be sufficient enough for this application.




No comments:

Post a Comment