During the object classification and sorting process, if there is an unknown object after three pooling attempts by the deep learning algorithm, then it will be rejected. The rejection mechanism will have a single DC motor controlled by Arduino UNO and it will communicate with Matlab through Bluetooth. The rejection signal is coming from from the Matlab Deep learning algorithm similar to the classification and sorting process.
The rejection mechanism uses "Greartisan DC 12V 30 RPM Gear Motor" and it has a status indicator light mounted on the object positioning platform as shown in figure below. This device provides the following status indications.
The rejection mechanism uses Bluetooth module to communicate with the Deep learning algorithm.
/* EE 400D, Team OCS, rejection code
* Written by Andres Martinez and Fekadu Debebe
* Bluetooth "1" => rejection
* Bluetooth "2" => standby
* Bluetooth "3" => sorting green light
* This code uses a common cathode RGB LED
* The rejection mechanism uses "Greartisan DC 12V 30RPM Gear Motor"
* DC motor value varies from 0 – 255 and corresponds to 0 – 100% Duty cycle.
* Arduino UNO has 6 Pins that can be used to generate PWM Signals: 3, 5, 6, 9, 10 and 11.
*/
#include <SoftwareSerial.h>
int TxD;
int RxD;
int data;
int buzzer = 4;
//RGB LED diode
int red = 3; //multi-color LED red
int green = 5; //multi-color LED green
int blue = 6; //multi-color LED blue
//CW rotation
int IN_B = 12; // Direction motor CCW
int EN_PWM = 10; // PWM motor speed
//CCW rotation
int IN_A = 13; // Direction control CW
SoftwareSerial bluetooth(TxD, RxD);
void setup()
{
Serial.begin(15200); // serial monitor
bluetooth.begin(9600);// Bluetooth serial
pinMode(buzzer, OUTPUT); // D4 of the L298P Motor Shield
pinMode(IN_A, OUTPUT);
pinMode(IN_B, OUTPUT);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
// RGB dance
led_all_color_test ();// Lamp test
delay (200);
//turn RGB OFF
digitalWrite (green, LOW);
digitalWrite (blue, LOW);
digitalWrite (red, LOW);
}
void loop()
{
if (bluetooth.available() > 0)
{
data = bluetooth.read();
if (data == '1') // "1" for rejection
{
//rejection_inprogress (); // call buzzer function
analogWrite(red, 255); // red, rejection status LT
analogWrite(green, 0); //
analogWrite(blue, 0);
// motor CW
digitalWrite(IN_A, HIGH); // rotate CW
digitalWrite(IN_B, LOW); // disable CCW
analogWrite(EN_PWM, 255); // Set PWM to 225
delay(8000); // rotate for 8 seconds
analogWrite(EN_PWM, 0); // stop motor
analogWrite(red, 0); // red off
delay(1000); // wait for 1s
//returning_home ();
analogWrite(red, 255); // red on
// motor CCW
digitalWrite(IN_A, LOW); // disable CW
digitalWrite(IN_B, HIGH); // rotate CCW
analogWrite(EN_PWM, 255); // set speed
delay(8000);
//rejection_complete (); // call function
analogWrite(blue, 0); // blue rightness
Serial.flush(); // clear the serial port
}
if (data == '2') // "2" Standby
{
analogWrite(red, 0);
analogWrite(green, 0);
analogWrite(blue, 255);
}
if (data == '3') // "3" Green LT for sorting
{
analogWrite(red, 0);
analogWrite(green, 255);
analogWrite(blue, 0);
}
if (data == '9') // "9" Turn off status LT
{
analogWrite(red, 0);
analogWrite(green, 0);
analogWrite(blue, 0);
}
else {
analogWrite(EN_PWM, 0); // motor off
}
}
}
// Functions
void rejection_inprogress ()
{
tone(buzzer, 50); // Send 50Hz sound signal...
delay(50); // ...for 400 ms
noTone(buzzer); // Stop sound...
tone(buzzer, 50); // Send 50Hz sound signal...
delay(200); // ...for 400 ms
noTone(buzzer); // Stop sound...
}
void returning_home ()
{
tone(buzzer, 50); // Send 50Hz sound signal...
delay(50); // ...for 400 ms
noTone(buzzer); // Stop sound...
tone(buzzer, 50); // Send 50Hz sound signal...
delay(50); // ...for 400 ms
noTone(buzzer); // Stop sound...
}
void rejection_complete ()
{
tone(buzzer, 25); // Send 25Hz sound signal...
delay(100); // ...for 100 ms
noTone(buzzer); // Stop sound...
tone(buzzer, 25); // Send 25Hz sound signal...
delay(100); // ...for 100 ms
noTone(buzzer); // Stop sound...
}
void led_all_color_test () {
//Red, bright
analogWrite(red, 255);
analogWrite(green, 0);
analogWrite(blue, 0);
delay(1000);
// blue, bright
analogWrite(red, 0);
analogWrite(green, 0);
analogWrite(blue, 255);
delay(1000);
//Green, bright
analogWrite(red, 0);
analogWrite(green, 255);
analogWrite(blue, 0);
delay(1000);
// Cyan, bright
analogWrite(red, 0);
analogWrite(green, 255);
analogWrite(blue, 255);
delay(1000);
// magenta, bright
analogWrite(red, 255);
analogWrite(green, 0);
analogWrite(blue, 255);
delay(1000);
// Yellow, bright
analogWrite(red, 255);
analogWrite(green, 255);
analogWrite(blue, 0);
delay(200);
// white, bright
analogWrite(red, 255);
analogWrite(green, 255);
analogWrite(blue, 255);
delay(200);
}