EXERCISE 5-PACKING LINE The packing line simulation is shown in FIGURE 5 Packing
ID: 3348901 • Letter: E
Question
EXERCISE 5-PACKING LINE The packing line simulation is shown in FIGURE 5 Packing Rictary Takle Postion 0P2 Cick on box to place orto conweyor P5 IP1 FIG. 5 Packing Line Simulation This exercise involves programming the simulator of FIGURE 5.The packing line carries boxes of different sizes that nced to be separated at the end of the first convevor. Which direction the boxes travel at the end of the first conveyor should be decided by using the input sensors IPI and IP2. If the box is a short one, the inputs will only be energised one at a time. If the box is a long one then, for a short period, both inputs will energise at the same time. When the box reaches the end of the first conveyor, which is driven by OPO, it will come to rest on the circular plate and will energise the sensor IP3 (the first conveyor will also stop) The plate will then turn cither to the left or the right depending on the length of the box. OP2 turns the plate to the right; OP1 turns the plate to the left. Once the plate has turned, the box will be pushed on to the next conveyor by either piston OP4 or OP3. Output OP6 drives the left-hand conveyor and output OPS drives the vertical conveyor. Inputs IP4 and IPS are sensors which detect the boxes on the conveyors as they are transported to the correct loading areas depending on their length.Once the boxes pass these sensors there should be a short delay and the respective conveyor should stop. Write a program to carry out the previously described operation and, as with the previous assignments, use the documentation facilities. When the program is complete, test its operation using the simulation package. To use the graphic simulation click on a box which, will place the selected box on to the first conveyor then operate the start switch IPO. The following is a list of the inputs and outputs, in addition to this list use any of the Flags, Timers, and Counters that you require in your program. IPO Start button IP12 Box length sensors OPO Loading conveyor OP Turns direction plate to the left IP3 Box on the direction plate scnsor Box on the vertical sensor OP2 Turns direction plate to the right IP4 OP3 Push the box on to the vertical conveyor IP5 Box on the left conveyor OP4 Push the box on to the left scnsor conveyor OPS Vertical conveyor OP6 Left hand conveyorExplanation / Answer
The programming language which is to be used is not specified. So I'll go with part of Arduino code which is mostly C++ and part of pseudo-code. Also, the same code can be used with MSP microcontrollers.
Even though I'm writing the code for Arduino, The logics are same for other software also and the only change would be the lines of code to read the input and write to the output.
code:
int box; //box is a flag. box=1 means long box and box=0 means short box
void start()
{
//write code here to initialize all flags and variables
ip0=digitalRead(ip0);//code to read ip0;
if (ip0 == high)
{
digitalWrite(op0,HIGH); //turning on the conveyer 1
check_box_size();
}
else
start(); // if ip0 is Low, then go to start function again and wait for the ip0 to be high
}
void check_box_size() //function which decides box size
{
ip2=digitalRead(ip2); //reading ip2 pin
if(ip2==HIGH) // if ip2 sensor is high
{
ip1=digitalRead(ip1); //reading ip1 sensor
if(ip1==HIGH) //if ip1 is also high when ip2 is high, then box is big one
{
box=1; //setting box flag=1 which means box is big
}
else // otherwise box is small
{
box=0;
}
wait(); // go to wait function;
}
else
check_box_size(); // if the box did not reach ip2 sensor, wait for it to reach ip2 sensor
}
void wait() //wait here until box reaches the end of conveyor 1
{
ip3=digitalRead(ip3); //reading ip3
if(ip3==HIGH)
{
// it means box reached circular plate so
digitalWrite(op1,LOW); //turning off converyer 1
seperate(); //go to check box function;
}
else // it means box did not reach circular plate
{
wait(); // wait again till box reaches circular plate
}
}
void seperate()
{
// This is the function to seperate box based on size
if(box==1) // if box is big
{
digitalWrite(op1,HIGH) //if box is big turn plate to right
digitalWrite(op3,HIGH) // push box to vertical conveyer
digitalWrite(op5,HIGH) // turning on vertical conveyer
final_stage(); // goto final stage function
}
else
{
digitalWrite(op2,HIGH) //if box is small turn plate to left
digitalWrite(op4,HIGH) // push box to left conveyer
digitalWrite(op6,HIGH) // turning on left conveyer
final_stage(); // goto final stage function
}
}
void final_stage()
{
// in this function we make sure the box reaches end of conveyer and
then we'll turn off conveyers and initialize all variables and return to start position
and wait for next box to be place
if{box==1)
{
ip4=digitalRead(ip4); // read input from ip4 sensor
if(ip4==HIGH)
{
delay(5000); // delay for 5000 ms
digitalWrite(op5,LOW);//turning off verticalconveyer
}
else
{
final_stage(); //wait for box to reach the end sensor
}
}
else if{box==0)
{
ip5=digitalRead(ip5); // read input from ip5 sensor
if(ip5==HIGH)
{
delay(5000); // delay for 5000 ms
digitalWrite(op6,LOW);//turning off left conveyer
}
else
{
final_stage(); //wait for box to reach the end sensor
}
}
/*
* write code for initializing all variable i.e.; box flag
* and all the inputs taken from sensors
*
*/
start(); // return to start function and wait for next box
}
please give a thumbs up if you like the answer.
Thank you.
?
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.