MECHATRONICS PROJECT

OVERVIEW
The project was to design and implement a system that would sort 48 pieces into four bins (black, white, steel and aluminium) in under a minute with minimal errors. The system also had to have pause functionality which paused the system and displayed the current system sorting status until the system was unpaused and a ramp down functionality which would wait until the last pieces on the belt were sorted and then stop the DC motor and display the system status.
-
Components are individually working.
-
Sensors values are properly read.
-
Stepper motor can be calibrated.
-
DC motor can be controlled.
-
-
System can sort one object at a time (no Linked List).
-
System can sort one object at a time with Linked List and keep count.
-
System can sort multiple objects at a time with Linked List. The number of objects was increased incrementally until it reached 8 at time.
-
System works at improved efficiency (better system flow and stepper acceleration).
-
Implement pause functionality.
-
Implement ramp down functionality.
DESIGN OBJECTIVES
The design consisted of the following hardware:
• Atmel AT90USB1287 Microcontroller Unit
• DC Motor
• Stepper Motor
• Sensors:
o 3x optical sensors
o 1x ferromagnetic sensor
o 1x analog reflective sensor
o 1x hall effect sensor
• Additional Circuitry:
o 2x push buttons
o 3x low pass filters
o 8x LEDs
The DC motor was used to drive the conveyor belt that pushes the objects through the sensors. The stepper motor was used to rotated the compartment tray to change which bin the object is dropped into. The sensors were used for determining object position on the belt and object sorting; the optical sensors were for position, the ferromagnetic sensor determined whether the object was magnetic, the reflectance sensor returned the reflectance value of the material, and the hall effect sensor was used to calibrate the stepper motor.

HARDWARE
FIRMWARE
The full system flow chart can be found below. It is divided into two parts; the main program and the ISRs. The ISRs updates flags and performs time crucial tasks. The main program controls program initialization and calibration, protocol at the exit area, pausing and the ramp down sequence. Dividing the code between ISRs and main was important to ensure that interrupts were not missed and for correct timing.


The pieces were sorted using the reflectance sensor values. From the data collected from the sensor, 3 decision boundaries were set, one between black and white, another between white and steel, and lastly one between steel and aluminum. The decision boundaries were weighted with the standard deviation of each data set to increase the statistical accuracy of the system. Below is the pseudo code of the sorting algorithm used:
object =black;
if(RL_value<black_boundary) object=white;
if(RL_value<white_boundary)object=steel;
if(RL_value<steel_boundary)object=aluminum;
The algorithm always assumes that the object is black first, as black has the highest reflectance value (RL_value). It then goes through checks if it is smaller than the other boundaries. From highest to lowest reflectance, the types are black, white, steel and aluminum. The black and white demonstration pieces were very close to each other and were the most difficult to differentiate. Steel and aluminum had a much greater standard deviation but had means that were much further apart, making differentiation much easier.
RESULT
The design successfully met all five requirements however it did not perform as well as expected on demonstration day due to an unexpected error. If a piece stopped in front of the reflectance sensor, the program would contiunally sample the reflectance value of the piece which would make the stepper motor stutter and slow down. This was a very easy problem to fix, all that was need was to time out the reflectance sensors after it made X number of samples.
To the right is a video of a test run of the project.
