Wednesday, November 7, 2012

Project November: Lego Automatic Coin Counter

Overview

This is a contraption that I built to automatically sort and count coins. I was inspired by the coin-counting machines that the banks have placed together with the ATMs, and thought of it as a marble-machine with a practical purpose, and hence decided to build one. Here it is, marvelously huge and freakin' time-consuming to build:




Coins are dumped into the hopper located at the left of the contraption and the machine will sort and count them without any human intervention, and at the end of the process the coins would fall into output bins at the bottom, which could be emptied by pushing down on a lever, allowing quick access to the collected coins.

Processing of data is done by the NXT mounted in the center of the machine. Input is provided by four light sensors, each corresponding to a specific type of coin. The NXT counts the number of each type of coin, displays the data gathered on its screen, and at the request of the user, calculates the total value of the coins fed into the machine.

From here on I would proceed to describe the working principles of this machine.

Mechanics 

The machine is made up of 4 main modules:

1) Hopper
2) Y-Stack Elimination
3) Conveyor
4) Sorting Module

Coins to be counted are dumped into the hopper at the top of the machine. The hopper is slanted towards the right, hence the coins would slide down the hopper due to gravity and approach the exit. Due to the funnel shape of the hopper the randomly-arranged coins would converge into a single row before exiting the hopper. Hence, piling up of coins in the z-axis is solved by utilizing gravity and the shape of the hopper.





Now we have to solve the piling of coins in the y-axis. This could be done easily if we create a barrier higher than the height of the tallest coin, which in this case is the 50 cents coin, but shorter than twice the height of the shortest coin, which in this case is the 10 cents coin, and mouting the barrier at the end of the funnel-shaped hopper such that piled-up coins would be blocked while the coins on the first layer below would be allowed through, effectively forcing the mess of coins into one single layer. However, the difference in the above mentioned heights is extremely small, on the order of fractions of millimeters, and as such, I am rather worried about the reliability of such a design. Lego is basically colored plastic molded into user-friendly shapes, hence their structural integrity and strength could represent a great problem. Vibrations due to collisions between the coins and the height barrier could potentially loosen connections and destroy the intricately-designed height barrier as the barrier deviates from the required height. Through experimentation I have proved my hypothesis correct and I concluded that the reliability of such a system is unacceptable.

I overcame this problem by making a lucky and important observation - the height of my ruler is a tiny bit smaller than the height of a 10 cents coin. Which means, if the ruler is placed in the path of the incoming stacked-up coins, then only the bottom layer would be blocked, while the coins on top would continue sliding down, unaffected at all. We're basically reversing the concept here; instead of blocking the coins on top, we're blocking the coins below. But then the treasure we're looking for is the guaranteed one-layer coins below, so instead of blocking them altogether, we slant the ruler, such that they're deflected, not blocked.

This is the mechanism you see in the pictures above. The slanted ruler ensures that the coins in the bottom layer gets deflected and proceeds onto the path leading to the sorting module, while the coins stack up on top goes straight and eventually fall into a chute leading to a conveyor belt, which would transport the coins back up into the hopper.




The conveyor is built with Lego tank tracks, with pins plugged into the track units at regular intervals to catch the coins prevent them from simply sliding down against the moving belt. To prevent the coins from bouncing and falling past these pins, and ending up on the floor, a barrier is built at the bottom end of the belt. This barrier can move up and down, hence when the pins pass underneath it it would move up and allow the coins to be caught by the pins, else, it would stay down and maintain contact with the moving belt, preventing the coins from sliding down past the bottom end of the belt.

At the top end of the belt, a slide is mounted such that coins would be directed into the hopper where the process begins again. The belt is driven by a PF XL-Motor, toggled on/off by an NXT motor.

In the meantime, coins that take the path leading to the sorting module falls into a chute where they are rotated along the y-axis and end up lying slanted rather than horizontally. Now the coins roll down rather than slide down.





The flip-like device, featured in the photo on the right, ensures that the originally horizontally-oriented coins gets pressed onto the platform behind so that the coins end up oriented correctly, slanted and parallel to the sorting mechanism.

The sorting mechanism consists of two main rails, the difference in height between the two rails increasing gradually from left to right (direction is reversed in the two photos above due to perspective). Both rails are slanted along the y-axis. The L-shaped bottom rail supports the majority of the coins' weight, while at the same time the protruding portion acts as a wall, and together with the top rail, prevents the coins from falling. Contact must be maintained with both rails for a coin to continue rolling down the rails.

Due to the difference in height between the rails, the smallest coin (10 cents) would lose contact with the top rail earlier as they roll down, hence falling from the rails. The largest coin (50 cents) would maintain contact with the top rail for the longest, and would fall near the end of the mechanism. Hence coins are sorted according to diameter as they roll along the rails.

Friction is a problem here, because the coins rub against both rails on their journey down. Hence I used some baby powder for lubrication, which worked out quite well. I suppose the tiny granules of powder acted as small ball bearings. Oil cannot be used as the coins would get oily and it would be incredibly disgusting to use the machine. However, the powder is prone is getting blown or pushed around, hence frequent replacement is necessary.





The coins, now sorted by size, fall down chutes leading to light sensors, each of which detects the increased amount of reflected light as the coins pass above them. The flips you see hanging down on top of the sensors are there to ensure that the coins fall directly above the sensors such that accuracy is maintained.  The coins then fall into chutes that guide them into the collection bins below. With a press of a lever the bins could be tilted and the contents emptied.

Programming

At first glance the programming seems straight forward enough. Basically we have to accomplish 3 things:

1) Start-up sequence: Calibrate all sensors and define all variables.
2) Main sequence: Activate conveyor belt and keep track of the number of coins.
3) End sequence: Calculate total value, deactivate conveyor, clear all variables.

NXT-G automatically defines all variables and resets all variables at the start and end of each program, hence making live easier. On the other hand, NXT-G has some limitations, which would cause some problems as you'll see later.

At the start of the program, the conveyor belt is toggled on by an NXT motor. That's the first block in the program.





Then comes the calibration of sensors. This is done sensor-by-sensor in series. The ambient light value is first read, then 10 is added to the value and stored as a variable. This is the set point to which the NXT would compare light values with during the main sequence. This process is repeated for each sensor.


Next is the formatting for the screen. A bunch of display blocks, each corresponding to a line on the NXT screen.




Originally the idea was to continuously loop the main sequence such that each sensor repeatedly compares the light value to the set point and adds one to the number of the coins, which is defined as a variable, if the light value is above the set point. This would require a sensor-toggled switch; if light value ≥ set point then add one to variable, else do nothing. However switches in NXT-G does not accept value inputs, hence I am unable to link the set point variable into the switch. The solution to this is simple. Since switches only accept in the form of logic, I first compare the light value sensed to the set point. If it is greater, then I define it as true, else it is false. Now I could link the logic into the switch. If the logic is true, then the NXT would access the variable for the number of coins of each type, add one to the variable, store the new value for the variable in its memory, convert the value to text, and display the text on its screen in the appropriate line. Then I loop everything. This occurs for each sensor, for a total of 4 loops in parallel. The ending condition for all the loops is the center orange button being pressed.

Once the orange button is pressed the NXT would exit the loop and proceed. The belt would be toggled off and the NXT would then calculate the total value of the coins. It's just basic math, except that the NXT-G software can't do floating point operations, only integer calculations, hence the final value is displayed in cents.

Result

In HD, but my camera wasn't entirely in focus so kindly bear with the slight blur.


Limitations and Possible Improvements

One limitation is that I only have space to display 4 digits for the final value, so if the value exceeds $99.99 the user would have to carry out the operation in batches. But I doubt my machine is reliable enough to count that many coins without errors.

Firstly the powder I'm using tend to get pushed down the tract by coins, hence resulting in the lack of lubrication in certain areas and sometimes causing a jam. Perhaps an alternative lubricant would solve the issue, but so far I do not have any ideas.

Secondly the chute leading to the conveyor occasionally get clogged up by coins. This is due to one of the pieces that I used to build the chute having a corner sticking out slightly, presenting itself as an obstacle for the coins. I could have rebuilt the chute using other parts, but the fundamental problem here is that Lego, being plastic, could be deformed easily and hence is not ideal for projects that require precision. Unfortunately I do not have any other robotics set available for use.

Thirdly some of the coins tend to get stuck in the sorting mechanism if they travel too fast. This is due to an excess of lubricant on the rails. Again, problem with the powder.

Much remain to be improved.

Building Process

I spent quite a lot of time on this project, and have taken some pictures along the time.












Friday, January 13, 2012

Project Mike: Marble Launcher

Project Date: Jan 2012

This is my all-new Lego gun that shoots marbles. It is built machine-gun style, with a quad-pod and vertical handles.

It accelerates the marbles using two wheels that are spun by 6 PF M-motors. A geartrain increases the rotation speed of the wheels to around 3000 rpm. Two battery packs mounted at the back to counterbalance the weight of the motors powers them. Because of the increase in rotation speed, torque is severely reduced. This means that the wheels need some time to recover and speed up after every shot. The original concept of "feed in the marbles and let the gun do the work" is made complicated by this. I devised a mechanism to feed in the marbles one-by-one at a controlled rate. This way, the marbles do not go in one immediately after another and potentially jam the gun. It's possible to solve this problem by either using more powerful motors (which I don't have) or by sacrificing projectile power by decreasing the rotation speed (which I don't want to).



The mechanism I used consists of three simple parts: a simple, tilted, funnel-like magazine, a vertical S-bend and a flipping switch to control marble feed rate. You can see the large magazine in the pictures at the top. Marbles are poured into this magazine and are funneled into a single row by the two angles beams. They roll down  the track in the picture at the left, drop down into a hole, and continue rolling. The purpose of this vertical S-bend will be explained later. The first marble will roll into a switch, made up of two peg connectors, which can be seen in the top left picture, and get stuck. This stops the marbles from rolling further. Once the trigger is pressed, a motor periodically flips this switch (mechanism explained later) and allows one marble to go through at a time. This marble then rolls down a ramp and into the wheels.

The flipping action of the switch is violent and will force the marbles behind to roll backwards, up the ramp. The purpose of the vertical S-bend is to limit the distance the marbles can roll backwards and to reflect them back towards the switch. If there were no S-bend, the fire rate of this gun would be severely reduced since the marbles would roll back, stop, and return to the switch every time the switch is flipped. The switch can be more clearly seen in the left picture below.



The mechanism I used to flip the switch can be seen in the picture at the right. It requires a seventh motor. I used a PF XL-Motor for this purpose. It spins an axle connected perpendicular to the rotation axis, which at the 10 o'clock position, will strike a Lego piece, tilting it anticlockwise. This Lego piece is connected to the switch. Since the motor spins at about 200 rpm, the switch flips about 200 times a minute, which translates to a firing speed of around 200 rpm.

The trigger is extremely primitive in this gun. To fire, the handle at the right is tilted forwards, triggering an electronic switch and activating the motor that flips the switch, enabling marbles to proceed to the launching wheels.

Having said so much about the gun, it's time for some description for the quadpod.


The front legs are tilted sideways, but to save time, I constructed the back legs straight. To increase the strength, I used dental floss to chain the legs together (visible in the left picture). Otherwise the legs would spread out under stress and break.

This gun is supposed to fire at 200rpm, but the actual value is at 250 to 300 rpm. Likely reason for this is that some marbles managed to escape from my switch.

And lastly a picture of me and my gun:



And the video from my YouTube channel (didn't want to upload on blogger since the quality is so bad here):



Thursday, December 29, 2011

Project Lima: Assault Rifle

Project Date: Sep 2011

I haven't been making any Lego guns for a while now because I don't have enough of those studded beams. But a few months ago I found out that a shop called the Hidden Chamber in Thomson Plaza sells individual parts. That isn't very far from my home and I have been buying parts from there ever since.

Here's my assault rifle made primarily out of those beams found in RCX sets. Another source of those beams are Lego City sets and certain Technic sets, as well as Lego Star Wars sets.



Inspiration was from a few YouTube videos. I figured out the mechanism and incorporated it in this gun.

The mechanism is extremely simple. There is a rammer that is inserted into the magazine before loading. This rammer is connected to a spool at the top of the gun by dental floss. I chose dental floss because of its tensile strength. Once the rammer is inserted, we can begin loading the gun. Bullets (3-hole studless beams) are loaded into the magazine. Each  of the bullets have a rubber band tied to the middle hole. When loading, the rubber bands are stretched and hooked onto a beam at the front of the gun. The magazine can hold around 20 rounds, although I don't have 20 of those 3-hole beams.




The trigger is connected to a PF IR transmitter, tuned to the same channel as the IR Receiver behind the gun. Six PF M-motors serves to drive the spool. A lot of power is required to turn the spool and pull the rammer up due to the friction between the ammo and the magazine. When firing, the bullets are forced up the magazine and fired.

This is the strongest gun I've ever made. The bullets have awesome power and range. They can penetrate paper with ease as well as cause some nasty bruises. To be honest I'm scared of this gun. But also proud of my creation.

And just a note to anyone who want to try building this, you have to make the magazine really strong, or else it will bend and break under all the pressure exerted by the rubber bands. Also I would recommend using dental floss, because every other string that I tried had broke. Also I found out that 20 bullets is really all that Lego can handle, anything more and the Lego pieces can't take the stress, either that or the string will break. If you're thinking to use a rack-and-pinion method to pull the rammer, I would say that it's useless. I've tried and failed, the Lego components can't take the stress.

Here's the video of this gun firing. If you can't see the bullets because of quality issues, just listen to the noise (or watch the targets fall)


Project Kilo: Pen Centrifuge

Project Date: Aug 2011

The Pilot G-2 pen that I (and many others) use is extremely susceptible to ink flow problems if dropped. So I came up with this centrifuge to deal with low ink flow problems.

Depending on your luck, you either end up with a restored pen, or more often than not, a leaking pen. But it's worth a try.

A PF M-motor powers the centrifuge. Theoretically it should spin at 880 rpm, but I think the actual value is closer to 700. The damaged pen refill is placed in on of those small containers. In the other container is a counterweight. Then the centrifuge is turned on.

Centrifugal force pushes the ink out, but this is a gradual process so we'll have to estimate the time needed.

Other than functioning as a centrifuge, I have experimented by adding curved blades (taken from a Technic model) to make a fan. It works great but maybe I'll build a better Lego fan in the future. It doesn't move enough air.

Here's the short video:


Wednesday, December 28, 2011

Project Juliet: Clean-Up Bot

Project Date: July 2011

Very often I end up with a big pile of Lego on the floor after constructing something. Cleaning up takes a lot of effort so I made up this bot to clean up most of the mess for me. The entire project is made up of two modules.



The first module is the collector. I built it using my NXT set. Two NXT motors lift a scoop made out of paper pasted to a Lego frame, tipping its contents into a cardboard box behind. The NXT is placed in the cardboard box. I originally wanted it to be placed somewhere else, but the wires weren't long enough. The third NXT motor drives a telescopic linear actuator, which turns a PF battery module on or off. Once on, the battery module powers 2 PF M-Motors, which will push a bowling-style arm which pushes anything below the scoop away. This serves to clear the area before the scoop lands after tipping its contents out.

I programmed the NXT such that the scoop will tip its contents out every 9 seconds. At the same time, the arm will be activated. The timing is adjusted such that the arm will activate and retract when the scoop is raised to avoid collisions.



The second module is the tank, or rather, the bulldozer. The chassis I used was my old tank built in Project Delta. I added another battery pack and PF M-motor to power the blade. It is controlled using PF IR control unit, so I could sit on the sofa and let the bulldozer do all the work.

It would have been better if everything is automated, rather than remote controlled, but I didn't have a second NXT set. Nevertheless, this RC bulldozer coupled with the automated collector works quite well at clearing most of my Lego pieces.


Project India: Physics Project

This one is my physics project so there's not much I can talk about. It's not really a Lego Project, although I constructed it out of Lego, since I did not come up with the project.

More Carnage with my Flamethrower

Seeing that my Lego Flamethrower had worked so nicely I couldn't resist burning some more stuff up. Hence I commenced my second round of carnage and among my list of victims are a used G-2 Refill, a plastic case, and some ice. The ice took way too long to melt to be shown on video, thus I didn't include the footage. Here's the video, and enjoy the beautiful flames!


Project Hotel: Flamethrower

Project Date: June 2011

I had created several Lego guns, but they weren't real guns, because there wasn't any explosions to propel the bullets. To make up for the lack of explosions and flames, I made this flamethrower.



The fuel I used was a can of Linx deodorant. A candle at the front ignites the spray, which then completely combusts in front of the Lego frame. The flame has a reach of around 30-60 cm, which is not very far, but considering the simplicity of this contraption, you can hardly complain. Its hot enough to light candles and incinerate ants. Very fun indeed (as long as you're at the right end of the gun).

Watch the video to see the flamethrower in action.


Tips for Lego Gearing

Here are 2 tips that I have for building Lego gear-trains.

Tip 1: Reinforcing Gears

Gears often crack when the gear-train is under stress. Cracking will severely reduce and limit the amount of power transferred and will potentially damage the gears. To overcome this problem, I recommend adding a second mounting beam to the gears, such that the gears are sandwiched between the two beams.

Common Construction:                                                      My Construction:
This method works for almost all types of straight gear trains, even compound ones. It completely eliminates cracking. This is very useful in high-stress applications, for example, sumo bots, cranes, lifting devices, etc.


Tip 2: Dealing with 8-tooth Spur Gears

A problem I observed when building gear trains with 8-tooth gears was their tendency to slip slightly out of alignment.

Perfect Alignment:                                                             Slightly out of Alignment:


As you can see, the gear slips out of alignment slightly, the edge of the gear digging into the mounting hole. This would increase the friction in the gear train and would also limit the amount of stress it can handle. A method I came up with was to use half-bearings as washers, to separate the gear from the mounting beam.

Common Construction:                                                     My Construction:
You could apply the method in Tip 1 to eliminate gear cracking.

Project Golf: Automated Toilet

Project Date: Apr 2011

I've seen how automated toilets work and wanted to turn my home's ordinary toilet into an automated toilet too. So I created a few contraptions using my NXT set to carry out some of the functions of an automated toilet.



The first contraption is the automatic toilet tissue dispenser. A motor drives two pairs of wheels, which act as rollers to pull the tissue through. The wheel has enough grip such that you can tear a piece of the tissue off without pulling the entire reel of paper out. There's also a light sensor mounted between the tissue outlet and a piece of black paper. I'll explain the programming later.



The second contraption is the flusher. The actual mechanism is the tall, tower-like structure; the partially-dismantled cases are just there to add some weight. I used a rack-and-pinion mechanism to drive a beam downwards, which flushes the toilet.

Everything is connected to the NXT, placed beside the flusher. A ultrasonic sensor is mounted to the NXT. The picture at the right shows the entire project. The wire hanging down from the toilet tank is the programming wire, which leads to my laptop (not in the picture).

Here's the programming. The NXT will wait for the ultrasonic sensor to sense a person approaching, by comparing the distance between itself and the nearest object. Assuming that every person entering the toilet will use the toilet, the NXT will then patiently wait for you to do your business. If you're a male, and just taking a piss, then eventually you will walk off without needing any help from the tissue dispenser. So if the ultrasonic sensor senses that you've walked away, then it will return to its original state - waiting for people to enter. But if you've sat down, then the ultrasonic sensor will sense that the distance between itself and you have decreased below a certain threshold, then the NXT will wait for the touch sensor to be pressed. Once you've down your business, and if you need toilet paper, then you press the touch sensor to notify the NXT.

Once the touch sensor is bumped, the motor in the dispenser rotates a certain amount to pull a portion of the reel of tissue out of the outlet. You can then tear the tissue out and use it. Once the light sensor in the dispenser senses that you've torn out that portion, the motor then releases another portion. Once you're done, you will then walk off to wash your hands (assuming that you do, but the robot really doesn't care), then the ultrasonic sensor will sense that the distance has increased a lot. The motor in the dispenser will then retrieve the unused portion of the tissue. At the same time, the flusher will activate, flushing the toilet bowl. Then the NXT will return to its original state, waiting for people to approach, at which the cycle will repeat.

Like any other project, I've recorded a video of it functioning, but due to the complexity of the program, it's hard to show every aspect, so the video is rather unclear.