Grupal Assignment.

Design a machine that includes mechanism+actuation+automation+application
Build the mechanical parts and operate it manually
Document the group project and your individual contribution

In poor countries where the Government doesn't help financialy the sick people,
people have to find their own way of paying the bill for their treatment.
In Bolivia the Unifranz Foundation is working
with kids with cancer, and so they created a lot of campaigns to help them.

One of them is the plastic bottle cap recycling.

The bottle caps are sent to a local company Empacar that recycles them
and gives in exchange money for treatments at the Oncological Hospitals in four cities
(Santa Cruz, El Alto, La Paz, Cochabamba).

But there is also families that crafts with those bottle caps some artefacts that they sell later.


In Peru there is also the same campaign.

That's when the idea came to us, we could make a machine that helps the sorting
by color of those bottle caps to help the handcraft.

We looked at what was already made but only found machines that sorts candies (Skittles, M&Ms...)

Grace came with this model and we decided to follow it.

The caps will go from above into the charger, then one by one the caps will go to the sensor
it will be detected as a color and then sent through the slider onto the box for that color.

Then it was 3D created on TinkerCad.

The machine will be made with 3D Printed parts with PLA and the body will be on MDF.
3D Parts: Charger SensorGuide SensorSlider Slider SliderSupport
MDF: Body

Some fails on the way...

We started with the cardboard models to check the funcions.

We detected some weight issues because all the heavy parts are in the front, so we had
to reinforce the supports. The Cardboard where the servo motor was screwed went down,
so we made a 3D printed plate.


We changed the columns for walls.




Machine Design

Grupal Assignment.

Actuate and automate your machine
Document the group project and your individual contribution

For the automation, we used an Arduino UNO Board with two servo motors and a color sensor TCS34725.

We had to install the Adafruit TCS34725 library on Arduino IDE.

Here is the connection schematic.

To see if the sensor is working, we made a simple test of color using the colorview example from Arduino IDE.

The we started to calibrate the values of each color. We have to pick 4 colors for the machine.
All the others colors will be sent to a same slot for now.

But we faced our first problem, caps have two diferent faces that candies doesn't
so the reading of the sensor will not always be the same. So we had to chose for the lower values.

Then we had to calibrate the Servo Motors. We set the angle to 0 with the following code:

 
      #include "Servo.h"

      Servo topServo;
      void setup() {
      topServo.attach(8);
      Serial.begin(9600);

      }
  
      void loop() {

      topServo.write(0);
    
      }
      

Once the 0 is set, we can can adjust the plastic arrow and see that it's not realy on 0. Trying with anothers angles
we detected variations that we had to fix for the proper use.

Here is the code

 
      #include "Wire.h"
      #include "Adafruit_TCS34725.h"
      #include "Servo.h"

      Servo bottomServo;
      Servo topServo;

      int color=0;

      byte gammatable[256];

      Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
      
      void setup() {
      
        bottomServo.attach(7);
        topServo.attach(8);
        Serial.begin(9600);
      
        for (int i=0; i<256; i++) {
                             float x=i;
                             x / =255;
                             x=pow(x, 2.5);
                             x *=255;
                             gammatable[i]=x;
                             }
                             }
                             void loop() {
                             topServo.write(110);
                             delay(800);
                             for (int i=110;i>50;i--){
         topServo.write(i);
         delay(2);
       }  
       delay(800);
  
       color=readColor();
       delay(100);
   
       switch (color) {
    
         case 1:
         bottomServo.write(30);
         break;

         case 2:
         bottomServo.write(65);
         break;

         case 3:
         bottomServo.write(100);
         break;

         case 4:
         bottomServo.write(135);
         break;

         case 5:
         bottomServo.write(170);
         break;
    
         case 0:
         break;
    
       }
       delay(300);

       for(int i=50;i>0;i--){
         topServo.write(i);
         delay(2); 
       }
       delay(300);

       for(int i=0;i<110;i++){ topServo.write(i);
                               delay(2);
                               }
                               color=0;
                               }
                               int readColor(){
                               float red, green, blue;
                               tcs.setInterrupt(false); // turn on LED
                               delay(1000); // takes 50ms to read
                               tcs.getRGB(&red, &green, &blue);
                               tcs.setInterrupt(true); // turn off LED
                               Serial.print("R:\t"); Serial.print(int(red));
                               Serial.print("\tG:\t"); Serial.print(int(green));
                               Serial.print("\tB:\t"); Serial.print(int(blue));
                               Serial.print("\n");
                               Serial.print("Color:\t"); Serial.print(color) ;
                               Serial.print("\n");
                               if(red>160 & green<60){ color=1; // Red
                                                       }
                                                       else if(blue>110){
       color = 2; // Blue
       }
       else if(green>105){
       color = 3; // Green
       }
       else if(red>140 & green>60){
       color = 4; // Orange
       }
       else{
       color = 5; // Others
       }
  
       return color; 
     }

     

Improvements

Electronics

We could miniature the electronics by changing the Arduino Uno R3 by a Xiao RP2040 and make a custom PCB
within a case to hide it.

Body

The body could be made of acrylic for a better transparency so we can see the process.
The machine could be made like a vending machine so it could be on every Super Market
all over the World helping even the kids for some handcrafts.


Slide and Video