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.
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.
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.