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.




Tuesday, 19 November 2013

Project 21 (Moderate): Sentry BB Turret

What happens when someone breaks into my room? My sentry BB turret will greet them in a very inhumane matter.


I bought a fully automatic bb gun, the MAG 9. It runs a 6x double AA batteries. I took it apart and salvaged the internal shooting mechanism. This includes cutting the wires which supplied the motors power and attached longer wires (by soldering) for increased flexibility.

wires for motor power





















An ultrasonic distance sensor will be watching the door. During the setup stage, the distance reading during the first few seconds will be used as a reference. If there is a significant change in the distance readings, the turret will start shooting. As of now, the turret does not have any motion tracking features implemented. The turret will blindly shoot at the entrance on my room.

There is a very tiny button which acts as a switch for the bb gun. I'll be using a servo motor to trigger this switch. 

This project is not yet completed. The loading mechanism has some serious issues. The magazine itself can carry over 100 bb pellets but can only load about 20 at a time. After depleting the clip, there is a gear which requires winding. Doing this will load the pellets in the "hold area" of the clip to the actual magazine.




















Features:
- bb turret shoots plastic pellets, at 200 fps (or 61m/s)
- an ultrasonic motion detector will be listening for intruders
- as of now, the turret can only shoot about 20 pellets before it requires manual reloading

Parts Used:
- 1x bipolar stepper motor (KP35FM2 ‐ 035 by japan servo)
- 1x SN754410 Quad Half H-Bridge (to control the stepper motor)
- 1x servo motor 
- 1x MAG 9 fully automatic bb gun









For the first video, a laser pointer will be mounted on the motor. The laser will show the general area where the turret will be shooting. The second video will demonstrate the capabilities of the bb turret itself. For demonstrative purposes, the bb turret is unloaded.




Future plans: The main priority is redesign the loading mechanism and significantly increase the magazine's capacity. Next, I'll try to implement some sort of tracking system.


Project 20 (Novice): Siren with Amplifier Circuit

I built an audio amplifier circuit using the lm386 and hooked it up to a 3 watt, 8 ohm speaker. I programmed the arduino to play 4 different sirens and it's incredibly loud. An external power source (9v power adapter) will be used to power the amplifier.


Schematic: http://www.hobby-hour.com/electronics/lm386-power-audio.php



Tuesday, 3 September 2013

Project 19 (Moderate): Pinpoint Laser Control

I decided to create a fairly simple project which can be expanded. As of now, I can control the laser pointer and make it point it any direction (within the servo motor's limit) by using a joystick.
















Increasing the delay factor will reduce the the motor's speed.

features:
- laser can be adjusted to point in any direction
- controlled by 2 servo motors, the laser can be moved horizontally or vertically
- controlled by 1 joystick
- the servo's speed can be adjusted via 2 buttons. one will reduce the delay time and the other will increase it.
- the current delay time will be displayed on the lcd.
- a locking button can be used to turn on/off the laser





Parts:
- 1x laser light module
- 1x joystick
- 2x servo motors
- 1x RGB lcd (16x2)
- 2x pushbuttons
- 2x 10k ohm resistor
- 1x locking button
- 1x potentiometer










This project will bring me one step closer to building a turret. All I need now is an airsoft gun.
**Getting one step closer to my dream security system **

Wednesday, 28 August 2013

Project 18 Part 2 (Advance): 3D Infrared Scanner

After multiple setbacks (and seizures), I finally hit a dead end. I almost gave up on this project. This is why I didn't update my blog for a couple of weeks. Eventually, I decided to try to turn that "dead end" into nothing more than a setback.

The biggest problem that I had was dealing with my stepper motor. I'll be using the KP35FM2 ‐ 035 stepper motor, made by Japan Servo. I had no idea what the specifications are for these motors. I couldn't find any datasheet on the internet. To make matters worst, the store owners don't know the specifications either.I found a similar model (KP35FM2 ‐ 044) and to power this motor, I need to apply up to 24V and a maximum current of 500ma. I found an old power adapter which outputs 9V, at 500ma. I have enough current to keep the motor going but applying a lower voltage would result in weaker torque.

I redesigned my scanner and it is a major improvement from my initial design. I replaced my panning servo motor with a stepper motor. A stepper motor is a type of motor which can turn at a specific degree. In my case, my stepper motor can turn at 1.8 degrees per step. This would mean it would take 200 steps to complete a full cycle.



The biggest issue with my previous design was that the sensor's position is constantly changing. I need to minimize this, since my program assumes that the distance readings are all relative to the same point. The image below shows that the IR sensor will always be at the pivot point. Also, the tilting servo will only rotate from 0° to 90°.

Tilt Angle: 45°
Tilt Angle: 0°





















There will be 2 main scanning modes which can be selected within the arduino code. The only difference between these modes is the stepper motor's maximum panning angle. For example, if I set the maximum number of steps equal to 100 (or 180 degrees), then the sensor's field of vision is within 180 degrees.

Partial Scan
This scanning technique is ideal for detecting a small area (example: a corner). I modified the code in such a way so that the stepper motor will only increment 100 steps (or 180 degrees). The images below are the scanning results of 2 laundry boxes, placed perpendicular to each other. To see the scanner in action, a video is posted at the end of this post.

Top View




Full 360 Degree Scan
This scanning technique is a little different than before. Since a stepper motor is capable of rotating a full cycle, I decided to take advantage of this. The scanner will make a full 360 degree turn and once it's cycle is completed, the tilting servo will be incremented by 1 degree. This process is repeated until the tilting servo reached 90 degrees.

I tried to scan my recycling box and the results are slightly disappointing. As you can see below, the scanner seems to behaving erratically on a certain area of the box.This is one of the biggest setbacks.

























It seems that the was a small error within my code. There are hundreds of lines of code(2 seperate scripts) and finding the bug was incredibly difficult. After a successful scan, the images produced by matlab is amazing.

Note: the scale of the graph changes in different perspectives










































Parts:
- 1x servo motor (dagu medium servo)
- 1x bipolar stepper motor (KP35FM2 ‐ 035 by japan servo)
- 1x SN754410 Quad Half H-Bridge (to control the stepper motor)
- 1x medium range IR sharp sensor (range of 10-80cm)
- an external power source for the motor

It took a lot of hard work and dedication to complete this ambitious project.