Professional Documents
Culture Documents
RMIT Vietnam
OENG1207
Digital Fundamentals
Group Project Report
Tutor: Alexandru Fechete
Team Name: 2
"I declare that in submitting all work for this assessment I have read, understood and agree to the content
and expectations of the Assessment declaration
1
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
Table of Contents:
1. Introduction/background 3
Acknowledgments: 3
Design process: 4
Step-by-step process: 5
Program structure: 5
Design process 9
Step-by-step process 10
Program structure 10
Table 1. Code of each state - setting up the initial of constant value (0 is off - 1 is on) 11
Figure 2.2.5. State 2: when pressing a button - gradually change to yellow and still stay Pedestrian_red 12
Figure 2.2.6. State 3: after pressing a button - turn on red and Pedestrian_green 13
3. Conclusion: 14
References: 15
2
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
1. Introduction/background
In this final assessment, by using MATLAB and the tools Simulink and Stateflow, we are going to design the
Traffic Light System. Following the components of making up this project in Group Milestone 1, we are
developing the Automatic Traffic Controller by using Simulink, this is the important point of the project,
which involves gradual creation of a traffic light controller by utilizing the logical and relational operators, as
well as adjusting the counter’s parameters to ensure that the lights turn on in a particular sequence and the
system must be reset to the initial step and repeat automatically following the controlling of counter steps. The
second part of the Final Project is to design the Traffic Lights with Pedestrian Button by using Stateflow.
The Stateflow chart block is the core of this system, which is the central brain controlling light systems
following the conditions as well as input ports and output ports with the constant value that we set up.
Depending on certain conditions of state-machines being met when pedestrians press the button, the system
will automatically transfer each state, which guides pedestrians on when to go and stop. This Traffic Light
System aims for students to have a fundamental understanding of MATLAB's essential operations, enhance
logical reasoning and provide students with a stronger comprehension of programming issues and other
mathematical conundrums.
2. Design and methodology (12 marks): Explain the algorithm/state-machine structure of the
system. Present a flow-chart showing how your system should behave. Which Simulink blocks did
you need to use and why?
Acknowledgments:
Counter Limited : Blocks will count up until the certain upper limit is reached, and then warps back to
zero and restart counting up. The counter is always initialized to zero. [1]
Compare To Constant : Block parameter compares an input signal to a constant. In the Constant value
parameter, provide the constant. Use the Operator parameters to compare the input and the constant value. [2]
Lamp : To display the colors that indicate the value of the connection of signal outputs. [4]
3
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
- Includes three (3) traffic lights (red, yellow, and green), two (2) pedestrian lights, and (red and green).
- For seven (7) counts, the traffic should be allowed to continue (traffic green, pedestrians red).
- Following this, the warning signal should be activated for three (3) counts (traffic yellow, pedestrian
red).
- The pedestrians must be able to walk for six (6) counts in total (traffic red, pedestrians green).
- After that, the system must restart and return to the initial "traffic go" condition.
Design process:
The process of finishing the traffic light system program, including the notations and counts, is represented in
this diagram.
4
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
Step-by-step process:
1. At first, the vehicle traffic light starts at green and the pedestrian light starts at red.
2. Use the Step Forward button to simulate through each count (1 step = 1 count).
3. After reaching 7 counts, the vehicle's green light turns to yellow but the pedestrian light stays the
same.
4. Still using the Step Forward button to simulate and after 3 counts, the vehicle’s yellow light changes
to a red one and the pedestrian light turns green.
5. After the pedestrian green light counts to 6, then it will return to its original state and continue the
loop.
Program structure:
● Counter limited block: set up by assigning an upper limit to 15 and sample time is 1. This
means that the system will count from 0 to 15, and after completely counting, it will be
returned an initial count and repeated. (with each count equal 1 second).
5
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
Figure 2.1.3. Algorithm of this system by using logical and conditional operators
● Relational operator: used to compare with the value ‘count’ from the Counter Limited block
and will execute the order when the condition is met.
● Logical operator: used to combine 2 relational operators and will only run if a certain condition
6
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
is met. In this case, the AND operator will execute when count > 6 and count <=9 are both
true.
Figure 2.1.4. Scope shows value of count with respect to time (s)
● Scope: used to visualize the value of count with respect to time.
Figure 2.1.5. The initial counts (0 -> 6) turn on Traffic Go and Pedestrian Stop
Figure 2.1.6. The counts (7 -> 9) turn on Caution and still Pedestrian Stop
7
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
Figure 2.1.7. The counts (10 -> 15) turn on Traffic Stop and Pedestrian Go
● Light: Assign state 0 as off state and state 1 as on state. In this case, state 0 is when the traffic
light red is turned off and state 1 is when traffic light red is turned on.
8
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
Design process:
The procedure of completing the traffic lights with the Pedestrians Button software, including the notations
and counts, is shown in this diagram.
Step-by-step process:
1. The simulation must begin with the switch switched on; otherwise, it will remain in state 1 until the
operation is complete (traffic light green & pedestrian red).
9
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
2. It will change from state 1 to state 2 after the switch is turned "on" (traffic light yellow & pedestrian
red). After three counts, it will shift to state 3, staying in state 2 (traffic light yellow and pedestrian
red).
3. The process will change from state 2 to state 3 after three counts (traffic light red & pedestrian green).
It will remain in state 3 for 6 counts, enabling the pedestrian to cross while the traffic is stopped.
4. Finally, when the switch is still "on," the shift from state 3 to state 1 will occur after 6 counts,
repeating the process. To allow for traffic, the switch must be turned back "off."
Program structure:
● Firstly, a Push Button is used to act as the pedestrian button.
● The Push Button is then connected with the Constant block. Then set the constant value to ‘0’ which
means the switch is ‘off’. After that, set the ‘on value’ in Block Parameters (double-click the Push
Button) to ‘1’, which means when Push Button is clicked, the constant value changes to ‘1’ and the
switch is ‘on’.
● A connection exists between the Constant block and the Stateflow diagram. There are three states in
the traffic light system, and the Stateflow chart includes the information for it. The process will begin
in the first state, move on to the next, and so on until it reaches the last state, each of which has a
unique set of instructions. When the initial state is reached, the process will be repeated.
10
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
Table 1. Code of each state - setting up the initial of constant value (0 is off - 1 is on)
when pressing the button (1) the system will operate
● The Stateflow chart will be made, and after that, it will be connected to 5 separate outputs.
11
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
● Every Lamp will be connected to a particular output by a signal that will represent the color of the
traffic light and vary depending on the input number.
Figure 2.2.5. State 2: when pressing a button - gradually change to yellow and still stay Pedestrian_red
12
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
Figure 2.2.6. State 3: after pressing a button - turn on red and Pedestrian_green
Figure 2.2.7. Scope shows value of count with respect to time (s)
3. Conclusion (4 marks): Describe how your system has fulfilled the requirements of the task, any
weaknesses in the way the system works and what could be done in the future to make it work
better (i.e. Extra features that may be beyond the scope of this project/course/development
environment).
In conclusion, the objectives of this group project are to provide students to impart the fundamental
knowledge and foundational programming skills in MATLAB by using tools like Simulink and Stateflow to
design the Traffic Light System while also fostering students developing their grasp of and familiarity with
MATLAB as well as cooperation with teammates. By completing this task's criteria, which include a well-
designed and adequate performance of both the Automatic Traffic System in Simulink and Traffic Lights
with Pedestrian Button in Stateflow. Through the Final Group Project, the outcomes of this project are that
we are required to work together to complete the program and the report, so it is important to develop our
13
OENG1207 Digital Fundamentals - Group Project Report Semester 3, 2022 SSET – RMIT Vietnam
future that programmers have to cooperate with each other means that to learn teamwork skills and create a
successful program without bugs and handling-errors.
References:
[1] MathWorks. “Count up and wrap back to zero after outputting specified upper limit.” mathworks.com.
https://www.mathworks.com/help/simulink/slref/counterlimited.html (accessed Jan. 11, 2023).
[4] MathWorks. “Display color that reflects signal value on lamp.” mathworks.com.
https://www.mathworks.com/help/simulink/slref/lamp.html (accessed Jan. 11, 2023).
14