Você está na página 1de 12

Embedded Systems

Palettenhubtisch
Prof. Burkhard Stadlmann

Jinwook Baik
Li-Yuan Liu
Jesus Indalecio Garcia Ramirez

20 September 2016
Austria

Wels, Upper
PALETTENHUBTISCH

Introduction
Our
project
is
called

Palettenhubtisch, which its main purpose is to transport a pallet from one side of the system to
the other side, using a lift and some conveying belts. Below is the picture of the whole system.
Figure 1

As we can see in Figure 1, our system consists in one slide which has a magnetic sensor,
a lift with a conveying belt and a magnetic sensor, the lift has two mechanical sensors which are
pressed when the lift is completely down or up, and last another conveying belt with a magnetic
sensor.
The whole systems had to be programed by ADA language which in this kind of process
it makes everything easier. For been the first time working with this language, we were
impressed on how much we achieved in one semester working with it. The syntax and the
different documents types you can have in Ada makes things a little confusing at the beginning.
In order to start the project, we first needed some diagrams to understand in a better way
the process or the structure we should use at the moment of writing the code. In any project it
PALETTENHUBTISCH

does not matter which kind is, diagrams are always useful to understand and to organize the
ideas.

First we created an illustration to understand the movement of the system, mechanisms


and sensors. As we can see in Figure 2, we have 3 magnetic sensors one at the end of the slide
and two more in each motor. We have 1 lift and two conveying belts.

Figure 2

After understanding the main objective of this system we started to think about the
synchronizations of the systems and the interfaces we might need to accomplish the whole
movement. That is how we started to create a sequence diagram which can help us understand
the communications between this different tasks. To be able to create the optimal code we needed
to know how many interfaces were needed, but the less interfaces the better that way would be
simpler but optimal.

PALETTENHUBTISCH

During the system every task has to communicate with the other tasks to synchronize the
timing and active the next task at the precise moment. Every sensor and every motor has its
unique binary value at the moment of its activation, which help us to differentiate each task and
help us know where the pallet is at the moment.
A Sequence diagram is an interaction diagram that shows how objects operate with one
another and in what order. It is a construct of a Message Sequence Chart. A sequence diagram
shows object interactions arranged in time sequence. With this diagram we organized the timing
and the steps needed to operate the system, to synchronize the communication between tasks and
the order of them.

Figure 3

In this sequence diagram we included all mechanical and magnetic switches, motors and
belts. For us it was a great help this sequence because it gave us a better view of the whole
project. The communications between the task is the hard part, each switch, sensor and motor
needed to be connected to each other without being in the same task.

PALETTENHUBTISCH

Figure 4

With the help of a flow chart we organized the steps and the behavior of the system itself.
This was the last step before starting to program in Ada.

PALETTENHUBTISCH

Source Code
In our program we did two tasks, the motion of the belt and the detection of the sensors.
Firstly, in the program we have different cases, in the belt motion file we have the first case
which is the auto mode meaning the system does not have the box in any sensor.
elsif X = "auto" then
Input := Ets_IO.EtsInp(Port_Inp);
-must read the sensor; because there was an error like whole motor stop before final position
-- Case 1: without box
if integer(Input) = 12 or integer(Input) = 8 or integer(Input) = 4
then
--Initial position
while Integer(Input) /= 4 loop
if Integer(Input) = 6 then
exit;
end if;
if Integer(Input) = 5 then
exit;
end if;
Output := ets_IO.EtsOutp(Port_outp,VC.int(2)); -belt move down
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
New_Line;
Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
Put_Line("Ready");
delay(0.5);
--Step 1: After slope
Start_Time := Clock;
while Integer(Input) /= 6 loop
Output := ets_IO.EtsOutp(Port_outp,VC.int(4)); -operate motor 1
if Start_Time + Counter_Delay < Clock then
Put_Line("Take too long time");
exit;
-- excution time is too long
end if;
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
if Start_Time + Counter_Delay < Clock then
-- one more check on time error
Put_Line("Take too long time");
Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
Y.Element_1 := Output;
-- show the command line
PALETTENHUBTISCH

Message_Buffer.Put(Y);
delay(0.1);
exit;
-- excution time is too long
end if;
New_Line;
Put_Line("Stop motor 1");
Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
--Step 2: Lift up
while Integer(Input) /= 10 loop
Output := ets_IO.EtsOutp(Port_outp,VC.int(1));
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
New_Line;
Put_Line("Stop lifting");
--Step 3: Go to the final position
Output := ets_IO.EtsOutp(Port_outp,VC.int(20));
delay(2.0);
while Integer(Input) = 8 loop
Output := ets_IO.EtsOutp(Port_outp,VC.int(20)); -operate both motors
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
delay(1.0);
New_Line;
Put_Line("almost on motor 2");
while Integer(Input) /= 9 loop
Output := ets_IO.EtsOutp(Port_outp,VC.int(16)); -operate motor 2
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
New_Line;
Put_Line("the whole system ended");
Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
Y.Element_1 := Output;
-- show the command line
Message_Buffer.Put(Y);
delay(0.1);

PALETTENHUBTISCH

In this part of the code the auto mode is operating which the system is programmed to
detect the sensors in the whole system and knowing where the box is at the moment. Firstly, if
the box is not detected in any sensor the system goes to a home position, after that once the slope
sensor is activated the motor 1 starts to operate until the sensor of the motor 1 is activated. If the
time for the box to arrive to the second sensor is greater than 7 seconds a time error is triggered
causing the system to stop, and waiting for another command.
Once the second sensor is activated the belt stops the motion and the lift starts to operate,
once the mechanical switch is activated the lift stops the motion and the first and second belt
start the moment. Once the whole system ended a message in the command prompt is shown. In
every part of the system a message is shown to see where the box is and what the system is
doing.
The first option of the system is the auto option, but when asked for a command a manual
mode can be used. To use the manual mode instead of writing auto in the command line, you
can write the different task you want for example lift, which activates the lift, init which
activates the home position, mot1 that activates the motor 1 band, fina which activates the
final step of the system and finally stop that stops the whole system and it ends the simulation.
In order to insert this command a 4 length string was implemented in the code, so every
time a command line is placed, only 4 letters can be taken, if the word inserted is more than 4
characters or the command is not in the code, and error is triggered saying that a wrong
command was inserted, asking again for a new command.
Inside the auto mode the second case implemented is when the slope sensor is activated.
-- Case 2: slope sensor is activated
elsif integer(Input) = 20 then
--Step 1: After slope
Start_Time := Clock;
while Integer(Input) /= 6 loop
if Integer(Input) = 20 then
Output :=
ets_IO.EtsOutp(Port_outp,VC.int(4)); -- operate motor 1
end if;
if Start_Time + Counter_Delay < Clock then
Put_Line("Take too long time");
exit;
-- excution time is too
long
end if;
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
if Start_Time + Counter_Delay < Clock then
-- one more check on time error
Put_Line("Take too long time");
PALETTENHUBTISCH

Output :=
ets_IO.EtsOutp(Port_Outp,VC.int(0));
Y.Element_1 := Output;
-- show the command line
Message_Buffer.Put(Y);
delay(0.1);
exit;
-- excution time is too long
end if;
New_Line;
Put_Line("Stop motor 1");
Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
--Step 2: Lift up
while Integer(Input) /= 10 loop
Output :=
ets_IO.EtsOutp(Port_outp,VC.int(1));
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
New_Line;
Put_Line("Stop lifting");
--Step 3: Go to the final position
Output := ets_IO.EtsOutp(Port_outp,VC.int(20));
delay(2.0);
while Integer(Input) = 8 loop
Output :=
ets_IO.EtsOutp(Port_outp,VC.int(20)); -- operate both motors
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
delay(1.0);
New_Line;
Put_Line("almost on motor 2");
while Integer(Input) /= 9 loop
Output :=
ets_IO.EtsOutp(Port_outp,VC.int(16)); -- operate motor 2
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
New_Line;
Put_Line("the whole system ended");
Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
PALETTENHUBTISCH

Y.Element_1 := Output;
-- show the command line
Message_Buffer.Put(Y);
delay(0.1);
In this case if the sensor of the slope is activated and then the auto command is inserted the
system knows it has to continue from that point the whole operation. The third case is when the
box is in motor 1.
-- Case 3: box on motor 1
elsif integer(Input) = 6 or integer(Input) = 10 or integer(Input) = 14
then
--Step 2: Lift up
while Integer(Input) /= 10 loop
Output := ets_IO.EtsOutp(Port_outp,VC.int(1));
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
New_Line;
Put_Line("Stop lifting");
--Step 3: Go to the final position
Output := ets_IO.EtsOutp(Port_outp,VC.int(20));
delay(1.0);
Input := Ets_IO.EtsInp(Port_Inp);
-- must read the sensor; because there was an error like whole motor stop before final
position
while Integer(Input) = 8 loop
Output := ets_IO.EtsOutp(Port_outp,VC.int(20)); -operate both motors
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
New_Line;
Put_Line("almost on motor 2");
while Integer(Input) /= 9 loop
Output := ets_IO.EtsOutp(Port_outp,VC.int(16)); -operate motor 2
Input := Ets_IO.EtsInp(Port_Inp);
--Put(VC.Int'Image(Input));
end loop;
New_Line;
Put_Line("the whole system ended");
PALETTENHUBTISCH

1
0

Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
Y.Element_1 := Output;
-- show the command line
Message_Buffer.Put(Y);
delay(0.1);
-- to send the message
-- Case 5: wrong case
else
Put_Line("wrong order");
-- if the command does not make sense
Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
Y.Element_1 := Output;
-- show the command line
Message_Buffer.Put(Y);
delay(0.1);
end if;
When the box is in motor 1 and the auto command is inserted, the system continues from that
point, if the lift is down then it raises the lift and then continued to pass the box to the second
motor, but it does not activate the belt from the first motor. The fourth case is when the box is on
motor 2.
-- Case 4: box on motor 2
elsif Integer(Input) = 9 or Integer(Input) = 5 then
Put_Line("the whole system ended");
Output := ets_IO.EtsOutp(Port_Outp,VC.int(0));
Y.Element_1 := Output;
-- show the command line
Message_Buffer.Put(Y);
delay(0.1);
-- to send the message

In this case the system recognizes that the box is already in the final position giving only a
message back saying the whole system has ended.

PALETTENHUBTISCH

1
1

Conclusion
The project at the end was a huge satisfaction, being new to this
language presented more troubles than we could have imagined, but at the
end the result was satisfying. There were many complications during the
project starting with knowing the programming language and the syntax,
secondly with time and finally with error fixing.
One of the things we are glad to have learned is to work as a team with
different nationalities and culture differences. Being in a team where all the
members are from different countries is really helpful because each team
mate had a different knowledge in different areas. Combining this knowledge
was the result of this project.

PALETTENHUBTISCH

1
2

Você também pode gostar