Triediaca stanica: Rozdiel medzi revíziami
Zo stránky SensorWiki
Riadok 87: | Riadok 87: | ||
* [https://www.arduino.cc Arduino IDE] | * [https://www.arduino.cc Arduino IDE] | ||
== | == Program == | ||
Program triediacej stanice: | |||
<source lang="c"> | |||
#include "Servo.h" | #include "Servo.h" | ||
#include "Wire.h" | #include "Wire.h" | ||
Riadok 118: | Riadok 98: | ||
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_1X); | Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_1X); | ||
// | //variables | ||
Servo feed; // feed wheel | |||
Servo sort; // deflection mechanism | |||
int | int IR_pin = 0; //IR sensor | ||
int | int IR_value=0; //value from IR sensor | ||
int | int Led_pin=11; // RBG sensor lighting | ||
// | |||
int blue = 10; //RGB led blue pin | |||
int green = 9; //RGB led green pin | |||
int red = 6; //RGB led red pin | |||
//*Color conditions of candies | |||
int sOrange[6]={140,175,45,65,22,32}; | int sOrange[6]={140,175,45,65,22,32}; | ||
int sGreen[6]={80,100,95,115,30,40}; | int sGreen[6]={80,100,95,115,30,40}; | ||
Riadok 139: | Riadok 117: | ||
int sPurple[6]={110,137,73,84,40,50}; | int sPurple[6]={110,137,73,84,40,50}; | ||
int sYellow[6]={117,137,70,83,20,32}; | int sYellow[6]={117,137,70,83,20,32}; | ||
void setup() { | void setup() { | ||
Serial.begin(9600); | Serial.begin(9600); | ||
Serial.println("Arduino sotring machine"); | Serial.println("Arduino sotring machine"); | ||
feed.attach(5); | |||
feed.attach(5); | |||
feed.write(0); | feed.write(0); | ||
sort.attach(3); | sort.attach(3); | ||
sort.write(90); | sort.write(90); | ||
Riadok 174: | Riadok 147: | ||
void loop() { | void loop() { | ||
IR_value=analogRead(IR_pin); | IR_value=analogRead(IR_pin); | ||
if(IR_value>450) | |||
if(IR_value>450) //feed wheel interupt | |||
{ | { | ||
feed.write(90); | feed.write(90); | ||
Riadok 180: | Riadok 154: | ||
digitalWrite(Led_pin,HIGH); | digitalWrite(Led_pin,HIGH); | ||
//color detection | |||
int colordec=detection(); | |||
// | |||
//candy classification | |||
divert(colordec); | divert(colordec); | ||
delay(300); | delay(300); | ||
Riadok 193: | Riadok 167: | ||
//function of color detection | |||
int detection(){ | int detection(){ | ||
float red, green, blue, clean; | float red, green, blue, clean; | ||
Riadok 201: | Riadok 175: | ||
tcs.getRGB(&red, &green, &blue); | tcs.getRGB(&red, &green, &blue); | ||
// | //write a color spectrum | ||
Serial.print("R:\t"); Serial.print(int(red)); | Serial.print("R:\t"); Serial.print(int(red)); | ||
Serial.print("\tG:\t"); Serial.print(int(green)); | Serial.print("\tG:\t"); Serial.print(int(green)); | ||
Riadok 211: | Riadok 181: | ||
Serial.print("\t"); | Serial.print("\t"); | ||
//conditions of colors | |||
if((sOrange[0]<red && red<sOrange[1]) && (sOrange[2]<green && green<sOrange[3]) && (sOrange[4]<blue && blue<sOrange[5])) | if((sOrange[0]<red && red<sOrange[1]) && (sOrange[2]<green && green<sOrange[3]) && (sOrange[4]<blue && blue<sOrange[5])) | ||
{ | { | ||
Riadok 241: | Riadok 211: | ||
color_num=0; | color_num=0; | ||
} | } | ||
Serial.print("Color:\t"); | Serial.print("Color:\t"); | ||
Riadok 249: | Riadok 217: | ||
} | } | ||
// function of servo 2 positioning | |||
void divert(int color) | void divert(int color) | ||
{ | { | ||
switch (color) { | switch (color) { | ||
case 1: //orange | case 1: //orange | ||
Riadok 289: | Riadok 257: | ||
break; | break; | ||
} | } | ||
} | } | ||
</source> | </source> | ||
Zdrojový kód: [[Médiá:Serial.h|serial.h]] a [[Médiá:Pip.c|main.c]] | Zdrojový kód: [[Médiá:Serial.h|serial.h]] a [[Médiá:Pip.c|main.c]] | ||
[[Médiá:MojProgram.c|program.c]] | [[Médiá:MojProgram.c|program.c]] | ||
[[Category:DTV2019]] | [[Category:DTV2019]] |
Verzia z 17:35, 27. máj 2019
Autor: | Patrik Herčút | |
Študijný odbor: | Robotika a kybernetika | 3. Bc. (2019) |
Opis projektu
![](/sensorwiki/images/thumb/a/aa/GifVideo.gif/300px-GifVideo.gif)
Cieľom projektu je vytvorenie triediacej stanice farebných cukríkov SKITTLES.
Prečo?
Balíček SKITTLES obsahuje viacero farieb cukríkov s rôznymi príchuťami. Po roztriedení môže konzument začať ktoroukoľvek farbou alebo príchuťou bez nutnosti prehľadávania obsahu balíčka.
Ako ?
Triediaca stanica pozostáva z týchto častí:
- Násypník
- RGB snímač
- IR snímač
- Podávač
- Servomotor podávača
- Triediaci mechanizmus
- Servomotor triediaceho mechanizmu
3D Model
Model mechanizmu pre podávanie a triedenie cukríkov.
![](/sensorwiki/images/thumb/e/ef/3D_model.jpg/300px-3D_model.jpg.png)
Servomotory
Pre chod podávacieho zariadenia je použitý servomotor s kontinuálnym chodom. Triedenie zabezpečuje klasické modelárske servo.
![](/sensorwiki/images/thumb/a/a3/ServoObr1.jpg/300px-ServoObr1.jpg)
Snímače
![](/sensorwiki/images/thumb/3/37/ServoObr2.jpg/200px-ServoObr2.jpg)
Snímanie farby cukríkov zabezbečuje RGB snímač, správnu pozíciu podávacieho bubna určuje IR snímač.
![](/sensorwiki/images/thumb/7/7c/RGB_Snimac.jpg/300px-RGB_Snimac.jpg)
![](/sensorwiki/images/thumb/8/83/IRsnimac.jpg/200px-IRsnimac.jpg)
Konštrukcia
Pre vytvorenie konštrukcie je využitá buková preglejka hrúbky 4mm. Laserom boli narezané jednotlivé diely z ktorých je zostavená celá konštrukcia triediacej stanice. Rozmer preglejky 1200*600 bol upravený kvôli rozmeru rezacieho stola lasera, rozmer 800*600 (žltý obrys na obrázku).
Rezanie konštrukcie.
Kvôli pohldnému rozoberaniu boli na spájanie použití puzdrové matice s rôznou dĺžkou skrutiek (20,30mm).
Vyhotovená konštrukcia.
Schéma zapojenia
Schéma zapojenia servomotorov a ostatných periférií.
Výsledný proces triedenia
![](/sensorwiki/images/a/aa/GifVideo.gif)
Použité zdroje
Užitočné odkazy:
Program
Program triediacej stanice:
#include "Servo.h"
#include "Wire.h"
#include "Adafruit_TCS34725.h"
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_1X);
//variables
Servo feed; // feed wheel
Servo sort; // deflection mechanism
int IR_pin = 0; //IR sensor
int IR_value=0; //value from IR sensor
int Led_pin=11; // RBG sensor lighting
int blue = 10; //RGB led blue pin
int green = 9; //RGB led green pin
int red = 6; //RGB led red pin
//*Color conditions of candies
int sOrange[6]={140,175,45,65,22,32};
int sGreen[6]={80,100,95,115,30,40};
int sRed[6]={132,175,55,70,32,40};
int sPurple[6]={110,137,73,84,40,50};
int sYellow[6]={117,137,70,83,20,32};
void setup() {
Serial.begin(9600);
Serial.println("Arduino sotring machine");
feed.attach(5);
feed.write(0);
sort.attach(3);
sort.write(90);
pinMode(Led_pin,OUTPUT);
digitalWrite(Led_pin,LOW);
pinMode(green,OUTPUT);
pinMode(red,OUTPUT);
pinMode(blue,OUTPUT);
//Control conection to RGB sensor
if (tcs.begin()) {
Serial.println("Sensor ready");
} else {
Serial.println("Sensor filed");
while (1);
}
}
void loop() {
IR_value=analogRead(IR_pin);
if(IR_value>450) //feed wheel interupt
{
feed.write(90);
delay(350);
digitalWrite(Led_pin,HIGH);
//color detection
int colordec=detection();
//candy classification
divert(colordec);
delay(300);
feed.write(0);
delay(350);
}
}
//function of color detection
int detection(){
float red, green, blue, clean;
int color_num;
String detected="";
tcs.getRGB(&red, &green, &blue);
//write a color spectrum
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("\t");
//conditions of colors
if((sOrange[0]<red && red<sOrange[1]) && (sOrange[2]<green && green<sOrange[3]) && (sOrange[4]<blue && blue<sOrange[5]))
{
detected="orange";
color_num=1;
}
else if((sGreen[0]<red && red<sGreen[1]) && (sGreen[2]<green && green<sGreen[3]) && (sGreen[4]<blue && blue<sGreen[5]))
{
detected="green";
color_num=2;
}
else if((sRed[0]<red && red<sRed[1]) && (sRed[2]<green && green<sRed[3]) && (sRed[4]<blue && blue<sRed[5]))
{
detected="red";
color_num=3;
}
else if((sPurple[0]<red && red<sPurple[1]) && (sPurple[2]<green && green<sPurple[3]) && (sPurple[4]<blue && blue<sPurple[5]))
{
detected="purple";
color_num=4;
}
else if((sYellow[0]<red && red<sYellow[1]) && (sYellow[2]<green && green<sYellow[3]) && (sYellow[4]<blue && blue<sYellow[5]))
{
detected="yellow";
color_num=5;
}
else{
detected="blank";
color_num=0;
}
Serial.print("Color:\t");
Serial.println(detected);
return color_num;
}
// function of servo 2 positioning
void divert(int color)
{
switch (color) {
case 1: //orange
sort.write(10);
analogWrite(red,255);
analogWrite(green,127);
analogWrite(blue,80);
break;
case 2: //green
sort.write(45);
analogWrite(red,0);
analogWrite(green,255);
analogWrite(blue,0);
break;
case 3://red
sort.write(90);
analogWrite(red,255);
analogWrite(green,0);
analogWrite(blue,0);
break;
case 4: //purple
sort.write(135);
analogWrite(red,0);
analogWrite(green,0);
analogWrite(blue,255);
break;
case 5: //yellow
sort.write(170);
analogWrite(red,255);
analogWrite(green,255);
analogWrite(blue,0);
break;
default: //empty
analogWrite(red,0);
analogWrite(green,0);
analogWrite(blue,0);
break;
}
}