Sorter Bin - Detect and Sort Your Trash

Have you ever seen someone who is not recycling or is doing it in a bad way?

Have you ever wished for a machine that would recycle for you?

Keep on reading our project, you will not regret it!

Sorter bin is a project with a clear motivation of helping recycling in the world. As it is well known, the lack of recycling is causing serious problems in our planet, like the disappearance of raw materials and sea contamination, among others.

For that reason, our team has decided to develop a project in a small scale: a sorter bin that is able to separate the rubbish into different recipients depending on if the material is metal or non-metal. In future versions, that sorter bin could be extrapolated to a big scale, allowing the division of the rubbish into all of different kinds of material (wood, plastic, metal, organic…).

Since the main purpose is to distinguish between metal or non-metal, the sorter bin will be equipped with inductive sensors, but also with ultrasonic sensors in order to detect if there is something in the bin. Moreover, the bin will need a linear movement to move the rubbish into the two boxes, hence ia stepper motor is chosen.

In the next sections, this project will be explained step by step.

Step 1: How It Works

The sorter bin has been designed to make the work relatively easy for the user: the rubbish has to be introduced through the hole that is placed in the upper plate, the yellow button has to pressed and the process starts, ending with the rubbish into one of the recipients.
But the question now is... how is that process working internally?

Once that the process has started the green LED is lighting. Then the ultrasonic sensors, attached into the top plate through a support, start their work to determine if there is an object inside the box or not.

If there is not any object inside the box, the red LED turns on on and the green one turns off. On the contrary, if there is an object, the inductive sensors will be activated in order to detect if the object is metal or non-metal. Once that the type of material has been determined, the red and the yellow LEDs will turn on and the box will move towards one direction or the opposite one depending on the type of material, propelled by the stepper motor.

When the box arrives to the end of the stroke and the object has been dropped into the correct recipient, the box will go back to the initial position. Finally, with the box in the initial position, the yellow LED will turn off. The sorter been will be ready to start again with the same procedure. This process described in the last paragraphs is also shown in the picture of the workflow chart attached in the Step 6:Programming.

Step 2: Bill of Materials (BOM)

Mechanical parts:

  • Bought parts for the bottom structure
  • 3D printer
    • PLA for all the printed parts (other materials can also be used, like ABS)
  • Laser cutting machine
    • MDF 3mm
    • Plexiglass 4mm
  • Linear Bearing Set [Link]
  • Linear Bearing [Link]
  • Shaft [Link]
  • Shaft holder (x2) [Link]

Electronic parts:

  • Motor
    • Linear Stepper Motor Nema 17 [Link]
  • Battery
  • Sensors
    • 2 Ultrasonic sensor HC-SR04 [Link]
    • 2 Inductive sensors LJ30A3-15 [Link]
  • Microcontroller
    • 1 arduino UNO board
  • Additional components
    • DRV8825 Driver
    • 3 LEDs: red, green and orange
    • 1 button
    • Some jumping wires, wires and soldering plates
    • Breadboard
    • USB cable (Arduino-PC connection)
    • Capacitor: 100uF

Step 3: Mechanical Design

In the previous pictures, all the parts of the assembly are shown.

For the mechanical design, SolidWorks has been used as CAD program. The different parts of the assembly have been designed taking into account the manufacturing method which one they are going to be manufactured.

Laser cut parts:

  • MDF 3mm
    • Pillars
    • Top plate
    • Ultrasonic sensors support
    • Inductive sensors support
    • Rubbish box
    • Battery support
    • Breadboard and Arduino support
  • Plexiglass 4mm
    • Platform

3D printed parts:

  • Pillars’ base
  • Linear movement transmission element from the stepper motor
  • Stepper motor and bearing supports
  • Walls fixation parts for the rubbish box

For the manufacturing of each one of these parts, the .STEP files should be imported into the correct format, depending on the machine that is going to be used for that purpose. In this case, .dxf files have been used for the laser cut machine and .gcode files for the 3D printer (Ultimaker 2).

The mechanical assembly of this project can be found in the .STEP file attached in this section.

Step 4: Electronics (Component Choices)

In this section, a short description of the electronic components used and an explanation of the component choices are going to be done.

Arduino UNO board (as the microcontroller):

Open-source hardware and software. Cheap, easily available, easy to code. This board is compatible with all the components we used and readily you find multiple tutorials and forums very helpful to learn and solve problems.

Motor (Linear Stepper Motor Nema 17):

Is a type of stepper motor that divides a full rotation in a certain number of steps. As a consequence, it is controlled by giving a certain number of steps. It is robust and precise and doesn't need any sensors to control its actual position. The mission of the motor is to control the movement of the box that contains the thrown object and drop it in the right bin.

To choose the model you made some calculations of the maximum torque required adding a safety factor. Regarding the results, we bought the model that largely cover the value calculated.

DRV8825 Driver:

This board is used to control a bipolar stepper motor. It has an adjustable current control that allows you to set the maximum current output with a potentiometer as well as six different step resolutions: full-step, half-step, 1/4-step, 1/8-step, 1/16-step, and 1/32-step (we finally used full- step as we didn't find any need to go to microstepping but it still can be used to improve the quality of the movement).

Ultrasonic sensors:

These are a type of acoustic sensors that convert an electric signal into ultrasound and vice-versa. They used the echo response of an acoustic signal firstly emitted to calculate the distance to an object. We used them to detect whether there is an object in the box or not. They are easy to use and provide an accurate measure.

Although the output of this sensor is a value (distance), by establishing a threshold to determine whether an object is present or not, we transform

Inductive sensors:

Based in Faraday's law, it belongs to the category of non-contact electronic proximity sensor. We placed them at the bottom of the moving box, under the plexiglass platform that supports the object. Their goal is to differentiate between metal and non-metal object giving a digital output (0/1).

LEDs (green, yellow, red):

Their mission is to communicate with the user:

-Green LED on: the robot is waiting for an object.

-Red LED on: machine working, you can't throw any object.

-Yellow LED on: an object is detected.

12V Battery or 12V power source + 5V USB power:

A voltage source is needed to power the sensors and the stepper motor. A 5V power source is needed to power the Arduino. This can be done through the 12V battery but it is best to have a separate 5V power source for the Arduino (such as with a USB cable and phone adapter connected to a power source or to a computer).

Issues that we found:

  • Inductive sensor detection, we didn't get the accuracy desired as sometimes a metallic object bad positioned is not perceived. This is due to 2 limitations:
    • The area covered by the sensors within the square platform represents less than 50% of it (so small object cannot be detected). To solve it we recommend using 3 or 4 inductive sensors to ensure more than 70% of the area is covered.
    • The detection distance of the sensors is limited to 15mm so we found ourselves forced to use a fine plexiglass platform. This also can be also another limitation detecting objects with a weird shape.
  • Ultrasonic detection: again, objects shaped in a complex way give problems as the signal emitted by the sensors is reflected badly and come back later than it should to the sensor.
  • Battery: we have some issues controlling the current delivered by the battery and to solve it we finally used a power source. However, others solutions like using a diode can be performed.

Step 5: Electronics (Connections)

This section shows the wiring of the different components put altogether. It also shows to which pin on the Arduino each component is connected to.

Step 6: Programming

This section will explain the programming logic behind the Bin Sorting machine.

The program is divided into 4 steps, which are as follows:

  1. Initialize system
  2. Check presence of objects
  3. Check type of object present
  4. Move Box

For a detailed description of each step, see below:

Step 1
Initialize system

LED panel (3) - set Calibrating LED (red) HIGH, Ready LED (green) LOW, Object present (yellow) LOW

Check stepper motor is at initial position

  • Run ultrasonic sensor test to measure distance from side to box wall
    • Initial position == 0 >> Update values of Ready LED HIGH and Calibrating LED LOW -> step 2
    • Initial position != 0 >> digital read value of ultrasonic sensors and based on values of sensor:
      • Update value of motor moving LED HIGH.
      • Run move box until value of both ultrasonic sensors is < threshold value.

Update value of initial position = 1 >> Update value of LED Ready HIGH and motor moving LOW and Calibrating LOW >> step 2

Step 2

Check presence of objects

Run Ultrasonic Object detection

  • Object present == 1 >> Update value of Object present LED HIGH >> Step 3
  • Object present == 0 >> Do nothing

Step 3

Check type of object present

Run Inductive sensor detection

  • inductiveState = 1 >> Step 4
  • inductiveState = 0 >> Step 4

Step 4

Move Box

Run Motor operation

  • inductiveState == 1
    • Update motor moving LED HIGH >> Make motor move left,(update initial position = 0) delay and move back right >> Step 1
  • inductiveState == 0
    • Update motor moving LED HIGH >> Make motor move right, (update initial position = 0), delay and move back left >> Step 1

Functions

As can be seen from the programming logic, the program works by executing functions with a specific goal. For instance, the first step is to initialize the system which contains the function "Check stepper motor is at initial position". The second step then checks the presence of object which in itself is another function (the "Ultrasonic Object detection" function). And so forth.

After step 4, the program has fully executed and will revert to step 1 before running again.

The functions used in the main body are defined below.

They are respectively:

  • inductiveTest()
  • moveBox(inductiveState)
  • ultrasonicObjectDetection()
// Check whether object is metallic or not
bool inductiveTest() {
  if(digitalRead(inductiveSwitchRight) == 1 || digitalRead(inductiveSwitchLeft == 0)) {
  return true;
  else{
    return false;
  }
}

void moveBox(bool inductiveState) {
  // Box goes to the left when metal is detected and inductiveState = true
        if ( inductiveState == 0 ){
        stepper.moveTo(steps); // random position to end for testing
        stepper.runToPosition();
        delay(1000);
        stepper.moveTo(0);
        stepper.runToPosition();
        delay(1000);
          }
        else if (inductiveState == 1) {
        stepper.moveTo(-steps); // random position to end for testing
        stepper.runToPosition();
        delay(1000);
        stepper.moveTo(0); // random position to end for testing
        stepper.runToPosition();
        delay(1000);
          }
}

boolean ultrasonicObjectDetection() {
    long duration1, distance1, durationTemp,distanceTemp,averageDistance1,averageDistanceTemp,averageDistanceOlympian1;
    // Define number of measurements to take
    long distanceMax = 0;
    long distanceMin = 4000;
    long distanceTotal = 0;

    for (int i=0; i<10;i++) {
      
      digitalWrite(right1TrigPin, LOW);  // Added this line
      delayMicroseconds(2); // Added this line
      digitalWrite(right1TrigPin, HIGH);
      delayMicroseconds(10); // Added this line
      digitalWrite(right1TrigPin, LOW);
      durationTemp = pulseIn(right1EchoPin, HIGH);
      distanceTemp = soundSpeed/100; // speed is in mm/s, duration in microseconds so 6 zeros must be removed in total
      distanceTemp = (durationTemp/2) * distanceTemp;
      distanceTemp = distanceTemp/10000; // remaining 4 zeros are removed to get a measurement in mm
      Serial.print ( "Sensor1  ");
      Serial.print ( distanceTemp);
      Serial.println("mm");
      if (distanceTemp > distanceMax) {
        distanceMax = distanceTemp;
      }
      if (distanceTemp < distanceMin) {
        distanceMin = distanceTemp;
      }
      distanceTotal+= distanceTemp;
    }
      
      Serial.print ( "Sensor1 maxDistance  ");
      Serial.print ( distanceMax);
      Serial.println("mm");
      Serial.print ( "Sensor1 minDistance  ");
      Serial.print ( distanceMin);
      Serial.println("mm");
     
    // Take average distance from readings
      averageDistance1 = distanceTotal/10;
      Serial.print ( "Sensor1 averageDistance1 ");
      Serial.print ( averageDistance1);
      Serial.println("mm");
      
    // Remove highest and lowest values of measurements to avoid erronous readings
      averageDistanceTemp = distanceTotal - (distanceMax+distanceMin);
      averageDistanceOlympian1 = averageDistanceTemp/8;
      Serial.print ( "Sensor1 averageDistanceOlympian1 ");
      Serial.print ( averageDistanceOlympian1);
      Serial.println("mm");</p><p>    // Reset temp values
    distanceTotal = 0;
    distanceMax = 0;
    distanceMin = 4000;

    long duration2, distance2,averageDistance2,averageDistanceOlympian2;
    // Define number of measurements to take

    for (int i=0; i<10;i++) {
      
      digitalWrite(left1TrigPin, LOW);  // Added this line
      delayMicroseconds(2); // Added this line
      digitalWrite(left1TrigPin, HIGH);
      delayMicroseconds(10); // Added this line
      digitalWrite(left1TrigPin, LOW);
      durationTemp = pulseIn(left1EchoPin, HIGH);
      distanceTemp = soundSpeed/100; // speed is in mm/s, duration in microseconds so 6 zeros must be removed in total
      distanceTemp = (durationTemp/2) * distanceTemp;
      distanceTemp = distanceTemp/10000; // remaining 4 zeros are removed to get a measurement in mm
      Serial.print ( "Sensor2  ");
      Serial.print ( distanceTemp);
      Serial.println("mm");
      if (distanceTemp > distanceMax) {
        distanceMax = distanceTemp;
      }
      if (distanceTemp < distanceMin) {
        distanceMin = distanceTemp;
      }
      distanceTotal+= distanceTemp;
    }
      
      Serial.print ( "Sensor2 maxDistance  ");
      Serial.print ( distanceMax);
      Serial.println("mm");
      Serial.print ( "Sensor2 minDistance  ");
      Serial.print ( distanceMin);
      Serial.println("mm");
      
    // Take average distance from readings
      averageDistance2 = distanceTotal/10;
      Serial.print ( "Sensor2 averageDistance2 ");
      Serial.print ( averageDistance2);
      Serial.println("mm");
    
    // Remove highest and lowest values of measurements to avoid erronous readings
      averageDistanceTemp = distanceTotal - (distanceMax+distanceMin);
      averageDistanceOlympian2 = averageDistanceTemp/8;
      Serial.print ( "Sensor2 averageDistanceOlympian2 ");
      Serial.print ( averageDistanceOlympian2);
      Serial.println("mm");

    // Reset temp values
    distanceTotal = 0;
    distanceMax = 0;
    distanceMin = 4000;
    
    if (averageDistanceOlympian1 + averageDistanceOlympian2 < emptyBoxDistance) {
       return true;
       }
     else {
       return false;
     }
}

Main Body

The main body contains the same logic explained at the top of this section, but written in code. The file is available for download below.

Warning

Many tests were performed to find the constants: emptyBoxDistance, steps and Maximumspeed and acceleration in the setup.

Step 7: Possible Improvements

- We need feedback about the position of the box to ensure that it is always in the right positions to pick the object at the beginning. Different options are available to solve the problem but an easy one could be to copy the system that we find in 3D printers using a switch at one end of the box's path.

-Due to the issues that we found with the ultrasonic detection, we can look for some alternatives for that function: KY-008 Laser and Laser Detector (image), capacitive sensors.

Step 8: Limiting Factors

This project works as described in the instructables but special care must be taken during the following steps:

Calibration of Ultrasonic Sensors

The angle at which the ultrasonic sensors are placed in relation to the object they have to detect is of crucial importance for the correct functioning of the prototype. For this project, an angle of 12.5° to the normal was chosen for orientation of the ultrasonic sensors but the best angle should be determined experimentally by recording the distance readings using various objects.

Power Source

The required power for the stepper motor driver DRV8825 is 12V and between 0.2 and 1 Amp. The arduino can also be powered by maximum 12V and 0.2 Amp by using the jack input on the Arduino. Special care must be taken however if using the same power source for both the Arduino and the stepper motor driver. If powered from an ordinary power socket using for instance a 12V/2A AC/DC adapter power supply, there should be a voltage regulator and diodes in the circuit before the power is fed into the arduino and stepper motor driver.

Homing the Box

Although this project uses a stepper motor which under normal conditions returns to its initial position with high accuracy, it is good practice to have a homing mechanism in case an error occurs. The project as it is does not have a homing mechanism but it is quite simple to implement one. For this, a mechanical switch at the box's initial position should be added such that when the box hits the switch, it knows it is at its home position.

Stepper driver DRV8825 Tuning

The stepper driver requires tuning to work with the stepper motor. This is done experimentally by turning the potentiometer (screw) on the DRV8825 chip so that the appropriate amount of current is supplied to the motor. So, turning the potentiometer screw slightly until the motor acts in a lean way.



Step 9: Credits

This project was done as part of a mechatronics course during the academic year 2018-2019 for the Bruface Master at the Université Libre de Bruxelles (ULB) - Vrije Universiteit Brussel (VUB).

The authors are:

Maxime Decleire

Lidia Gomez

Markus Poder

Adriana Puentes

Narjisse Snoussi

Special thanks to our supervisor Albert de Beir who helped us throughout the project as well.

Share

    Recommendations

    • Remix Contest

      Remix Contest
    • Epilog X Contest

      Epilog X Contest
    • Paper Contest

      Paper Contest

    Discussions