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.

Friday, 16 August 2013

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

This project is insane. Millions of my precious brain cells gave their lives in order to produce this scanner. /sarcasm

No really, this project is extremely difficult. Constructing and coding the servo motor's movement was simple overall but processing the data and creating a 3D image is not a walk in the park. The 3D image is created by Processing.

Processing

How does this work? There are 2 servo motors, where one of them is responsible for the panning motion and the other, tilting motion. Once the panning servo completed its 180 degree turn(incremented by 1 degree), the tilting servo will tilt 1 degree, and this process repeats itself. At all times, the sensor will be scanning for objects. The arduino will be sending 3 pieces of data: pan position, tilt position and the distance. These values will be picked up by Processing and for each set of data,(pan + tilt + distance), a dot will be mapped out.

This is where the fun comes in. We know 2 angles + distance, which could be interpreted as a vector. Using simple trigonometry, we can easily determine the x,y and z components 







Note: Ignore the purple dots
The image on the left is a good visualization of how the scanner works. The pink curve is the very first scan(tilt angle: 0 degrees and the panning angle ranges from 0-180). The green curve is exactly identical to the pink curve, but with a 10 degree tilt angle.









From this point, everything is generally simple. The hard part is to implement a "camera" movement algorithm in order to see the image at various perspectives. To get this to work, there is a massive problem. In order to change the point of view, the camera movement algorithm requires a complete deletion of the current image and redraw it. If I were to merge the camera algorithm with the mapping algorithm, I'll just get a blank screen with 1 dot that is constantly moving. This is because the data collected is not being stored and the image displayed is the current reading. Obviously, this has no use to me.

This is where arrays come in. In order to store these points, an array must be created. However, there is a TON of data. According to my calculation, there should be at least 32,400 points(x,y,z) that will be collected! Next, Each of these points will be written into a text file.

I then created a separate script, responsible for merging both the camera movement algorithm and plot all the points. Unfortunately, it crashes. Why? There is too much data. I wasted countless hours designing an algorithm which will plot the points and implementing a camera movement algorithm, which allows me to see the graph in different perspectives.

Now, I have no choice but to use another software. After some research, I decided to use matlab.All I have to do is copy and paste the coordinates into matlab and write a very simple code to graph these values. Once everything is completed, I decided to run a test trial. Both servos will be operating but the distance sensor will be turned off. Since this is a test trial, the micro controller will be sending "300cm" as the distance reading.

In this trial run, the tilting servo will be incremented by 10 degrees. As you can see, a portion of the image is missing. There is a bug in my code where the micro controller is not sending all the data for some reason.




For my second trial run, the tilting servo will be incremented by 1 degree. This scan took about 12 minutes and the results are beautiful. I can now conclude that my program is functional.







Hardware issues

As for hardware issues, My arduino board couldn't supply enough power to run 2 servo motors simultaneously. An external power source will be required to power 1 of the servo motors. I'll be using 1 micro servo and 1 medium servo(this servo requires more power). I tried using 4AA batteries(measured it with a multimeter and got 5.3v) but it simply wasn't enough to power the servo motor. I guess the batteries wasn't supplying enough current.I have 9 volt batteries but those things die way too quickly(mine is rated at 200 mah and I might be able to power the motor for 1 hour, if I'm lucky).

I decided to get a little creative. The most reliable power source available is my computer. I'll be using the USB port to power both my arduino and my medium servo. I found an old cell phone usb charger, cut off 1 end of the wire and soldered it onto a 2 wires. Next, I measured the voltage using a multimeter and its exactly 5volts! Finally, I tested my circuit and everything is running smoothly.



Future Plans

This project is not yet completed. As of now, the only thing I successfully accomplished is creating a program that can split the readings into 3D points and graph it using a plotting software(matlab). The scanner itself needs some serious improvements. From the images You can see that the sensor's position is changing. (For example, starting position is about 5cm below the tilt servo and the end position is 5cm above the tilt servo).  Unfortunately my program assumes that the sensor will always be in the same position. I tried to take this into consideration (software wise) but it's not very effective.
Tilt Angle: 0°
Tilt Angle: 180°






































Top View



















 I need to replace my micro servo. Physically, it can only turn up to 160-170 degrees, which could
explain why the scanned image is not perfect. The image above shows that the 2 objects are not at a 90 degree angle. On the bright side, the corner readings are pretty accurate. The top right image of my laundry boxes shows that one box is slightly curved in. Thankfully, the infrared sensor noticed this!

This is a very challenging project and I still need to improve my physical scanner. Hopefully by then, I'll get more accurate readings.

Monday, 12 August 2013

Project 17 (Advance): Ultrasonic Alarm System (Version 2), with Sonar Display

After creating my ultrasonic alarm system, I wanted to map nearby objects onto a screen, similar to radars. To do this, I need another software called Processing. Processing is a programming language which is used to create images, animations and a bunch of other stuff. In my case, I wanted to create a radar screen. Luckily, the programming language and syntax is exactly identical to the arduino IDE. All I had to do is figure out how to draw basic shapes and the rest is just math and coding.

The features in this project is exactly the same as my previous alarm system(version 1). I replaced my LCD screen with a sonar display produced from Processing. The arduino board will be sending data onto my computer serially, which is then picked up by Processing. The arduino will be sending the servo's angle position and the ultrasonic sensor's reading. The sonar screen is produced by using basic trigonometry.

On the sonar screen, the top right hand corner will display the status of the system. On the bottom right hand corner, the distance between the sensor and the object in front of it is displayed and is being constantly updated in real time. The little red dots are the detected objects.

"Normal" indicates that everything is running normally and nothing is within the danger limits.
Also, a green light indicates that the sensor/servo motor is operating as expected.




 "Caution" indicates that either the servo motor or the ultrasonic sensor is not working properly. If someone manages to trespass into the safety limits and attempted to disable the sensor, the caution light will be turned on. In addition, the speaker will produce a loud buzz every second, until the ultrasonic sensor is enabled.

"Danger" indicates that an object is detected within safety limits. The alarm will then be triggered and the sonar screen will no longer update itself. A hard reset will be required to restart the sonar display.





This is my most proudest invention yet and over time, I will add more features. The speaker is not very punishing so I want to add something else that will PUNISH anyone where dares to enter the safety limits. What I have in mind is a sentry bb gun, which will shoot the intruder. The next step is to add motion tracking. Unfortunately, none of this will be accomplished(yet). I'm missing lots of materials and if you were to check my current balance (project 15: Digital Piggy Bank), my wallet is practically empty.

Thursday, 8 August 2013

Project 16 (Moderate): Ultrasonic Alarm System (Version 1)

This is my favorite project yet. I've created a motion detector that scans the room and if it detects any object within 25cm, the speaker will go nuts.


As for the alarm, a piezo buzzer is not very loud. so I went to a local electronics store and bought new speakers + an audio amplifier. An audio amplifier pretty much converts small inputs and outputs something much bigger. The arduino digital pin can only output 5 volts and any more would damage the board. In order to make the speaker louder, I need more voltage. That's where the audio amplifier comes in.












At first, the arduino board was suppling all the power but I noticed that the LCD display was flickering.
Due to the high power requirements, I need an external power source. A 9 volt battery will be powering the audio amplifier, which means the speaker will be even louder than before. 4 AA batteries(about 5 volts) will power the servo motor. The arduino will only be powering the LCD display and the ultrasonic sensor. With this setup, the LCD display is no longer flickering!

Features:
- an ultrasonic sensor, mounted onto a servo motor will scan for nearby objects(can detect objects up to 3 meters away!)
- the distance will be displayed on a LCD display
- once the alarm is triggered, "INTRUDER ALERT!!" will be displayed on the LCD

Parts:
- 1x ultrasonic sensor
- 1x servo motor
- 1x RGB LCD display (16 X 2)
- 1x 8 ohm speaker (0.25 watt)
- 1x 10k potentiometer
- 1x lm386
- 1x 220uf capacitor
- 1x 9v battery and a battery holder (to power the audio amplifier)



Scanner Limits

The ultrasonic sensor has a range from 2cm to 3 meters. Also, I noticed that the sensor has issues detecting corners. This is because the sound waves emitted from the sensor will bounce off the surface at an angle. Instead of going directly back to the sensor, it will then bounce off another surface, and then back. Thus it will take a lot longer for the sensor to read the sound. The longer it takes to read the sounds, the farther the distance is. Also, any object that can absorb sound(ex. sponges) will disrupt the readings.

Tuesday, 6 August 2013

Project 15 (Moderate): Digital Piggy Bank

Detecting a coin and its weight can be complicated and expensive. I came up with several solutions to this problem. One of which, I tried to create a switch out of aluminum foil. Whenever a coin is inserted, it will cause the aluminum foil to come in contact, and therefore completing the circuit. However, this switch is too big for my tiny piggy bank.












I decided to use a photoresistor as a "coin detector". When the arduino is powered up, it will go through a calibration state. During this phase, the arduino will be recording the light intensity for about 5 seconds and after that, it will calculate the average light intensity. Finally, the arduino will now accept coins. Once coin is inserted, the light intensity will change. This is a very basic way of detecting a coin. 









As of right now, I don't know how to create a simple and efficient way to detect what kind of coin is inserted. So instead, I'll create a user interface to record the deposit. This will consist of 5 buttons. Each button will represent a state (see picture on the left). The LED will indicate which state you are in. From left to right, the states are $0.05, $0.10, $0.25, $1.00 and $2.00.

Once the state has been determined, simply insert the coin and your deposit will be incremented by the amount specified.




features:
- 5 buttons (5 cent, 10 cent, 25 cent, 1 dollar, 2 dollar)
- 5 LED's will represent each button to identify the current state  
- current balance will be displayed on LCD
- savings will be recorded and saved (unless the power is turned off)
- a photoresistor will be used as a coin detector



Parts:
- 5x red LEDs
- 5x 330 ohm resistor
- 5x pushbuttons
- 6x 10k ohm resistor
- 1x photoresistor
- 1x RGB LCD (16 x 2)
- 1x 10k potentiometer


Using a photoreisstor as a coin detector can cause some problems. For example, suppose the arduino is running its calibration in a very bright room. When the calibration period is over, turning off the lights will confuse the arduino and it will think that a coin is constantly being inserted. This is because the arduino is comparing the average light intensity during the calibration period with the current light intensity. When there is a significant difference between these light intensities, the balance will be incremented.