Screw Sorting Machine

53,425

189

20

About: After a degree in micro-engineering in Switzerland, I moved to Russia to discover new landscapes

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.

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
Organization Contest

This is an entry in the
Organization Contest

Share

    Recommendations

    • Build a Tool Contest

      Build a Tool Contest
    • Pocket Sized Contest

      Pocket Sized Contest
    • Tape Contest

      Tape Contest

    20 Discussions

    0
    None
    Ardutronico

    12 days ago

    Oh, cool! Except I don't have that many screws... If I can find a way of sorting electronic components instead, it'll be awesome! Though that would be more difficult as it'd need to recognize not only the type of component (easy) but also read the colours/numbers/letters in the component for sorting (resistors and capacitors would be sorted by value, transistors and ICs by type)

    1
    None
    JETDRIVER1955

    13 days ago

    Nice work, however it will only work on ferrous objects.
    Get it to work on NON-FERROUS and you will have an enormous winner!!!!
    The majority of screws or nuts used in manufacturing these days are SS and subsequently non-ferrous!!

    And for those that winge about everything in life the Capitals are not yelling it’s just to get the item noticed!!!

    0
    None
    DanielatbramblewoodX3msnake

    Reply 16 days 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.

    0
    None
    yrralguthrie

    16 days ago

    Great work. Just reading and looking at the pictures, I'd say that cost $200-$300 USD. Plus 40 hours of build time. In the US maybe $20.00 an hour. So $1000 to build it. I hope not on company time! Might be more cost effective to just build the boxes and not make the mess in the first place though.

    0
    None
    GreggV1

    Question 16 days 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

    0
    None
    Sylvaind9

    16 days ago

    Would me interesting to make sorting a new function on a multi purpose 3D machine with swapable function head (i.e. 3D printer, lathe, water jet cutter, laser cutter and screw sorter! )

    0
    None
    pgs070947

    16 days ago

    Interesting.
    The sort of job I used to do on a sunny afternoon armed with a strip of aluminum with holes drilled in and scale down the side, plus plenty of empty coleslaw tubs.
    First sort by type e.g. machine or wood-screw etc, then sort by diameter, then sort by material, then sort by head, pan, cheese-head, Philips, Pozidrive, Torx, socket, slotted and so on.
    Then remember not to get in the mess in the first place - no chance. Food ingredient sorting machines are some of the smartest. They seem to rely on camera recognition and compressed air to sort.

    0
    None
    Georgejb75

    16 days ago

    This is an amazing project, Well done. I must also say that I'm quite envious of your humongous workshop/lab. I have to work from a small workbench/desk in the corner of my living room.

    0
    None
    mlduffy

    4 weeks ago

    Great job!- I've been wondering when someone was going to make something like this. One of my favorite stories about Cal Ripken (one of our American Baseball legends) is that when he was a mis-behaving child, his dad emptied a big jar of mixed screws, etc. onto a table and gave Cal instructions of how he wanted them sorted. When Cal was finished his dad swept them all back into the jar, mixed them up again, then dumped them back onto the table, giving him different instructions on how he wanted them sorted. The idea was that it was half punishment, half a test to make sure his child knew how to follow directions.

    I always wondered if there would be an efficient way to sort miscellaneous hardware much like a Coinstar machine...

    1
    None
    CHARLESCRANFORD

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

    0
    None
    ChiefInstructor

    5 weeks ago

    Excellent project. How do you recognize the different shapes? What algorithm is used? How much do the parts need to be spread (so that the electromagnet does not pick up two objects at once)?

    2 replies
    0
    None
    AdrienRChiefInstructor

    Reply 5 weeks ago

    I use the blob detector of OpenCV. There are parameters like area, circularity, inertia. You are right, if the parts are all together, it is more difficult to pick up but also to detect. I can chose how much current I send to the coil so I start with the small marts and put little current. Then the bigger parts with more current. I need to tune this parameter and it happens quite often that several parts are picked together.

    0
    None
    ChiefInstructorAdrienR

    Reply 5 weeks ago

    OpenCV. Yes, that's like magic. Love that package. Will keep that in mind. We did a Raspberry Pi program last year using OpenCV and it tracked faces very accurately. We used that to control motors.

    0
    None
    mimax

    5 weeks ago

    Good project, what are the requirements for the camera? Cou'l'd I use other models?

    1 reply
    0
    None
    AdrienRmimax

    Reply 5 weeks ago

    There are no requirements. You just have to know that the more pixels you have the more precise is the detected position. You can also detect smaller parts with more resolution. During my tests, I reduced the resolution (nbr of pixels) by four and the detection was still very good. Having less pixels reduces the computation time.

    0
    None
    reddragonzz

    5 weeks 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!