Docstoc

Brick Sorter Documentation

Document Sample
Brick Sorter Documentation Powered By Docstoc
					CIS 721: Real Time Systems

Programming Assignment # 2

BRICK SORTER PROBLEM




                             Team Members:
                             Nikhil Shah
                             Vinodkumar Mudaliar
                             Aditi Breed
Project Description

The project is a Brick Sorter using the ‘Lego MindStorms Kit’.
The brick sorter is capable of sorting brick of three different color: black, grey and red.

Brick Sorter Design:
The model consists of a rotating arm which sorts the bricks of 3 different colors. The
brick injector and brick chute together form the rotating arm.
The model consists of brick chute which holds bricks to be sorted. The bricks will slide
(due to gravity) down the chute which is inclined at an angle to the rotating arm. Each
brick is removed from the bottom of the stack and pushed into the bin by the brick
injector.
The rotating arm mounted on a fixed base, is driven by a motor. The rotating arm has 180
degrees of freedom. The rotating arm also has a color (light) sensor which identifies the
color of each brick. The light sensor is placed opposite to the chute. This ensures that
when the brick slides down chute, the light sensor identifies the color of the brick. The
direction of movement of the rotating arm is controlled by the RCX which in turn
depends on the value returned from the light sensor. The light sensor is connected to
input 1 of the RCX and the motors driving the injector and rotating arm are connected to
the RCX outputs A and C. The program uses the input from the light sensor to direct its
sequence of action. The brick is pushed into the bin by the brick injector (deflector).
A barrier is positioned behind the piston to make ensure that when the bricks get jammed,
the piston hits back on the touch sensor and the system comes to a halt.
The barrier only serves as a safeguard against the system being jammed by a brick.

Working of the Brick Sorter:
Initially the brick injector and rotating arm are idle. The bricks to be sorted are positioned
in the brick chute, close to the light sensor. The piston of the injector is moved backwards
and the brick is close the light sensor.
The light sensor will identify the color of the brick and send the appropriate signal to the
program. Accordingly the motor will drive the rotating arm to move in a direction
(predefined for each color in the program) such that the brick is ‘sorted’ or pushed into
the appropriate bin. The rotating arm returns back to the original position.
The next brick then slides the chute and the above process is repeated for each brick .

Brick Parter:
A count is maintained of the brick in the program. The program will move the rotating
arm in such a way, that one first brick if sorted or pushed to the output bin in a direction
while the next brick is sorted to the opposite side. In general, if the program starts
counting bricks with no 1, then the next brick, no 2, will be pushed in the opposite
direction.
Brick Sorter Design
Class Diagram :
State Diagrams for Brick Sorter Controls:

Motor 1 Control:




Motor 2 Control:
RCX Control:




Light Sensor Capsule:
//Source code for Brick sorting

#include <conio.h>
#include <dsensor.h>
#include <dmotor.h>
#include <config.h>
int j;
int k = 1;
int a[10];
int num[10];
int i = 0;
int ok;

void CheckJam()
{
      while(TOUCH_3 ==0)
      {
              lcd_int(TOUCH_3);
      }
      ok = 1;
}

int main()
{
  int first,prev;
  ds_passive(&SENSOR_3);
  ok = 0;
  execi(&CheckJam, 0, NULL, 10, DEFAULT_STACK_SIZE);
  ds_active(&SENSOR_1);
 a[0] = SENSOR_1;
 first =1;
         while(!ok)
         {
                motor_c_dir(2);
                motor_c_speed(100);
                delay(30);
                motor_c_dir(3);

              delay(70);
              j = LIGHT_1;
              if ( first )
              {
                       prev = j;
                       first = 0;
                }
                if ( j - prev <= 4 )
                {
                          motor_a_dir(2);
                          motor_a_speed(90);
                          delay(90);
                          motor_a_dir(3);
                          delay(20);
                }
                //Push the Piston
                motor_c_dir(1);
                motor_c_speed(120);
                delay(29);
                motor_c_dir(3);
                delay(30);
                if ( j - prev <=4 )
                {
                          delay(20);
                          motor_a_dir(1);
                          motor_a_speed(90);
                          delay(90);
                          motor_a_dir(3);
                          delay(20);
                }
          }

    return 0;

}

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:21
posted:4/28/2011
language:English
pages:7