Introduction: Screw Sorting Machine
One day in the lab (FabLab Moscow), I saw my colleague busy sorting a full box of screws, nuts, rings and other hardware. Stopping next to him, I watched for a second and said: "It would be a perfect job for a machine." After a quick look on google I saw that different ingenious mechanical systems already existed but they couldn't solve our problem because in our box is a broad variety of parts. Doing something purely mechanical would be quite complicate. The other good reason to go to a more "robotic" system was because this would require all the technical fields I love: machine vision, robotic arms and electromechanical actuators!
This machine picks the screws and place them in different boxes. It consists in a robotic arm which handles an electromagnet, a translucent worktable above lights and a camera on the top. After spreading some screws and nuts on the worktable, the lights are turned on and a picture is taken. An algorithm detects the part shapes and returns their positions. Finally the arm with the electromagnet places the parts one by one in the desired boxes.
This project is still in development but now I obtain decent results that I want to share with you.
Step 1: Tools and Material
Tools
- Laser cutter
- Angle grinder
- Hacksaw
- Screwdriver
- Clamps (the more the better)
- Hot glue gun
Material
- Plywood 3mm (1 m2)
- Plywood 6mm (300 x 200 mm)
- White translucent plastic 4mm (500 x 250 mm)
- Computer (I am trying to move to raspberry pi)
- Webcam (Logitech HD T20p, anyone should work)
- Arduino with 4 PWM output / analogWrite (three servos and the electromagnet coil) (I use the ProTrinket 5V)
- Prototyping board
- Electronic wire (2m)
- Switching transistor (any transistor that can drive a 2W coil) (I have S8050)
- Diode (Schottky is better)
- 2 resistors (100Ω, 330Ω)
- Power supply 5V, 2A
- Servo micro (width 13 length 29 mm)
- 2 servos standard (width 20 length 38 mm)
- Wood glue
- 4 metallic corner with screws (optional)
- Wooden rod (30 x 20 x 2400)
- Hot glue
- Enamelled copper wire (0.2, 0.3 mm diameter, 5m)(old transformer?)
- Soft iron (16 x 25 x4 mm)
- 3 light bulbs with socket
- Connector strip (230V, 6 elements)
- Electric wire with socket (230V) (2 m)
- Bearing 625ZZ (inside diameter 5mm, outside diameter 16 mm, height 5mm)
- Bearing 608ZZ (inside diameter 8mm, outside diameter 22 mm, height 7mm)
- Bearing rb-lyn-317 (inside diameter 3mm, outside diameter 8 mm, height 4mm)
- Timing belt GT2 (2mm pitch, 6mm wide, 650 mm)
- Screw M5 x 35
- Screw M8 x 40
- 8 screws M3 x 15
- 4 screws M4 x 60
- 6 wood screws 2 x 8 mm
- Screw M3 x 10
- Relay board module (directly controllable by controller)
Step 2: Make the Light Box
The light box has four main parts and some braces. Download these parts and glue them together except the translucent plastic. I started with the wooden half disc and the curved wall. You need to keep the wall tighten around the disc during the drying. I used clamps to secure the half disc and the curved wall basis. Then some tape maintains the wall around the half disc. Second, I glued a rim to withstand the translucent worktable. Finally the flat wall is added with wooden (inside) and metallic (outside) right edges.
Once the box completed, you just have to add the lightbulbs and connect the wire and socket with the connector strip. Cut the 230V wire where it is convenient for you and insert the relay module. I enclosed the relay (230V!) in a wooden box for security reasons.
Attachments
Step 3: Make the Robot Arm
Download the parts and cut them. To secure the belt on the servomotor I used pieces of paperclips. I nailed the two part belts on the servomotor and added some glue to be sure that nothing moves.
For the linear vertical guidance, the plunger has to be sanded to avoid any blockage. It has to slide smoothly. Once assembled, the height can be adjusted by cutting the guidance at the desired length. However, keep it as long as possible to prevent over-center lock. The plunger is simply glued to the arm box.
The bearings are enclosed inside the pulleys. One pulley is made of two layers of plywood. These two layers are not necessarily touching each other so instead of gluing them together, glue them to their respective arm plate. The top and down arm plates are maintained by four M3 x 15 screw and nuts. The first axis (big one) is simply the M8 x 40 screw and the second (small one) the M5 x 35 screw. Use nuts as spacers and lockers for the arm parts.
Step 4: Make the Electromagnet
An electromagnet is simply a soft iron core with enameled wire coper around it. The soft iron core guides the magnetic field at the desired place. The current in the enameled wire coper creates this magnetic field (it is proportional). Also the more turns you make the more magnetic field you have. I designed a U-shaped iron to concentrate the magnetic field near the the caught screws and increase the prehension force.
Cut a U-shape into a piece of soft iron (height: 25mm, width: 15mm, iron cross-section: 5 x 4mm). It is very important to remove the sharp edges before winding the wire around the U-shaped iron. Be careful to keep the same winding direction (particularly when you jump to the other side, you need to change the direction of rotation from your point of view but you keep the same direction from the U-shaped iron point of view)(https://en.wikipedia.org/wiki/Right-hand_rule) Before branching the coil to the circuit, check the coil resistance with a multimeter and calculate the current with the Ohm's law (U=RI). I have more than 200 turns on my coil. I suggest you to wind until you have only 2 mm of space inside the U-shape.
A wooden holder has been made and the U-shaped iron has been secured with hot glue. Two slits allow to secure the wire on both ends. Finally two pins are nailed on the wooden holder. They make the junction between the enameled cooper wire and the electronic wire. To prevent any damage of the coil, I added a layer of hot glue all around the coil. On the last picture you can observe a wooden part who closes the U-shaped iron. Its function is to prevent any screws to get stuck inside the U-shaped iron.
The enameled wire coper has been taken from a broken transformer. If you do so, check that the wire is not broken or has no short circuits in the used portion. Remove the tape on the ferromagnetic core. With a cutter, detach one by one all the iron slices. Then remove the tape on the coil and finally unwind the enameled wire cooper. The secondary winding (the big diameter coil) has been used (transformer input 230V, output 5V-1A).
Step 5: Make the Circuit
On a prototyping board, I built the schematic above. A bipolar transistor (S8050) has been used for switching the electromagnet coil. Check that your transistor can handle the current calculated in the previous step. A MOSFET is probably more suitable in this situation but I took what I had on hand (and I wanted a low on-resistance). Adjust the two resistors to your transistor.
In the schematic above, VCC and GND icon are connected to the + and - of my power supply. The servomotors have three wires: Signal, VCC and GND. Only the signal wire is connected to the controller, the others are connected on the power supply. The controller is powered by the programmer cable.
Step 6: The Code
Last but not least: The code. You will find it here: https://github.com/adrienrosselet/optical-screw-s...
There is one program for the controller (arduino type) and another who runs on the computer (hopefully soon on raspberry). The code on the controller is responsible for trajectory planning and the one on the computer makes the image processing and sends the resulted position to the controller. The image processing is based on OpenCV.
The computer's program
The program takes an image with the webcam and the lights, detects the translucent worktable center and radius and corrects the eventual image rotation. From these values, the program calculates the robot position (We know the robot position according to the plate). The program uses the blob detector function of OpenCV to detect the screws and bolts. The different types of blobs are filtered with the available parameters (area, color, circularity, convexity, inertia) in order to select the desired component. The result of blob detector is the position (in pixels) of the selected blobs. Then a function transforms these pixel positions into millimeter positions in the arm coordinate system (orthogonal). Another function calculate the required position of each arm join in order to have the electromagnet at the desired position. The result consist in three angles which are finally send to the controller.
The controller's program
This program receives the join angles and moves the arm parts to reach these angles. It first calculates the top speed of each join in order to perform the move during the same time interval. Then it checks if these top speeds are ever reached, in this case the move will follow three phases: acceleration, constant speed and deceleration. If the top speed is not reached, the move will follow only two phases: acceleration and deceleration. The moments at which it has to pass from one phase to another are also calculated. Finally the move is executed: At regular intervals, the new actual angles are calculated and sent. If it is time to pass to the nest phase, the execution continues to the next phase.
Step 7: The Final Touches
The frame
A frame was added to hold the camera. I chose to make it with wood because it is cheap, easy to work with, easy to find, environmentally friendly, pleasant to shape and it stays in the style I began with. Make an image test with the camera to decide what height is needed. Also be sure to make it rigid and fixed because I noticed that the resulted position is very sensitive to any camera moves (at least before I added the worktable auto-detection function). The camera has to be situated at the worktable center and, in my case, 520 mm from the translucent white surface.
The boxes
As you can see in the picture, the movable storage boxes are on the flat part of the worktable. You can make as many boxes as needed but with my actual setup the space is quite limited. Nevertheless I have ideas to improve this point (cf. future improvements).
Future Improvements
- For the moment the timing belt is closed with a wooden part but this solution limits the area that the arm can reach. I need to add more space between the big servo and the arm axis or make a smaller closing system.
- The boxes are along the flat worktable edge, if I put it along the half circle edge, I would have much more space to add boxes and sort many component types.
- Now the blob detection filter is enough for sorting the parts but as I want to increase the number of boxes, I will need the increase the selectivity. For this reason, I will try different recognition methods.
- Now the servomotors I use do not have enough range to reach all the half disc worktable. I need to change the servos or change the reduction factor between the different pulleys.
- Some issues occurs quite often so improving the reliability is the priority. For that I need to classify the type of issues and concentrate on the more likely. This is already what I did with the small piece of wood which closes the U-shaped iron and the auto detection center algorithm but now the issues become more complicate to solve.
- Make a PCB for the controller and the electronic circuit.
- Migrate the code to Raspberry pi to have a stand alone station

Second Prize in the
Organization Contest
45 Comments
3 years ago
Очень круто!!!!
Question 3 years ago
Is that bread board larger than a normal bread board? It
looks like it accepts thicker gauge wire then a standard bread board. If it
does and you remember where you got it, please let me know where I can purchase
one. A bread board that can handle more current would be really nice to have.
Question 4 years ago on Step 7
Does it differeniate between flat head , round head , hex head , carriage bolts . This is great but it will not work on stainless steel . I on occasion get 5 Gallon bucket of mixed brand new hardware that I sort , this machine would do the first sort by category for me . Thank you
Answer 3 years ago
Hey Gregg, how can I get a 5-gallon bucket of hardware?
Reply 3 years ago
I too would like to know how I can get a 5 gallon bucket of hardware.
Answer 4 years ago
It actually does not differentiate each type but I hope it will soon. Effectively it doesn't work with stainless steel. If you need it, use a vacuum gripper instead of electromagnet. You are welcome.
3 years ago
This sort of thing might put my six-year-old out of business as my shop helper. He is great at sorting through boxes of mixed screws and putting them in their own tubs. One problem he has is determining brass from yellow metal, but he’s learning how to use his little magnet to separate them.
Great machine building idea. I am envious of your skills.
3 years ago
I never thought someone could do it... I'm very impressed. Good job
3 years ago
This is a very innovative idea that can only come from a real thinker.
I wanna kind of reproduce this project for my next robotic summer camp. I understand everything except for the vertical motion system. I know there are one servo (Z) and a arm that handle the vertical motion, but I cannot figure out how all the pieces are connected in this part of the assembly. Where is servo Z located? How is the arm attached to the plunger? There are not enough pictures provided for that particular area that can help me clearly understand the mechanism. Great job. I really like it.
Reply 3 years ago
The servo is in the circular cut in the center. It is placed on its side and lift up the whole arm with a small bearing who pushes the frame. The vertical box contains another box that fits inside: this is the Z axis guide.
4 years ago
I know this is not the best place for a request, but here goes.
you seem confortable with OpenCv, i have been intermitently trying to learn it with little success.
A open source tool software that made vectors of backlit tools to cut shadowboars from foam to store the tools is a must have for any hackerspace or fablab
is easy to make for anyone confortable with OpenCv.
you would calibrate the camera, place the tools on a backlit light box that could be made from a old monitor backlight take 2 photos and feed it to the app.
the app would spit vectors at the right scale that could be uses as mostly ready paths to cut on a cnc or laser
i can help with the ui if you want :P
4 years ago
https://youtu.be/kki6MiY94Wo
Reply 4 years ago
Thanks for the video. I also like the 100% mechanical systems. I found a lot of them on youtube. As I said in the intro. I wanted to make a robot :) and if you want to make boxes with 10 bolt M3 and 5 screws M3*15 and 5 M3*20, with my system you can.
Reply 4 years ago
that is actually a better use for it :)
packing kits
Reply 4 years ago
How did you keep the electromagnet from picking up more than one item… I think it was the last one... a bolt and nut were touching but it only picked up the bolt.
Reply 4 years ago
It happens sometimes. But I can control the current in the coil so I control the force. When I begin with small components and small force and finish with the bigger ones, I avoid too many mistakes.
4 years ago on Step 7
Really cool project! I am going to look at making something like this. I love robots - and I hate sorting hardware. :)
4 years ago
Cool i love this idea & am interested to see how the project develops. I already have a robotic arm so maybe i could make it into this idea. Keep up the good work - love it!
Reply 4 years ago
Thank you. If you make your own, let me know.
4 years ago
WOW! The only thing that would make it better, was if it would give you the fasteners that you needed, when you requested them. Sort of like a "reverse" of what it does. Great job.