Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,019 members, 7,818,019 topics. Date: Sunday, 05 May 2024 at 04:49 AM

Embedded Systems Tutorial For Beginners:experiment 4 (traffic Light System) - Science/Technology - Nairaland

Nairaland Forum / Science/Technology / Embedded Systems Tutorial For Beginners:experiment 4 (traffic Light System) (1977 Views)

Embedded Systems Tutorial For Beginners:experiment 5 Intro To 7 Segment Displays / Embedded Systems Tutorial For Beginners:experiment 3( Led Chaser And Rgb Led) / EMBEDDED SYSTEMS Tutorial:#include <module3.h>software And Hardware Tool Needed (2) (3) (4)

(1) (Reply)

Embedded Systems Tutorial For Beginners:experiment 4 (traffic Light System) by guassian: 7:55am On Apr 14, 2015
You can get previous tutorials from this link… https://www.nairaland.com/2244503/embedded-systems-tutorial-beginners-experiment
and if you are new to this series tutorial you can start from the beginning… https://www.nairaland.com/2175195/embedded-systems-future-electronics-computer



EXPERIMENT 4: TRAFFIC LIGHT SYSTEM
Tools needed:
Software: Proteus 8 to simulate the software on virtual hardware, CCS compiler version 4.0 and above to write and compile programs, pickit2 IDE to burn your compiled code into your MCU
Hardware: Bread board, Red Yellow and Green LED, jumper wire, pic12f683, 3 way switch, pickit2 programmer, USB cable and power bank or USB charger to create 5v supply. All the hardware components can be gotten from a reputable Electronics Component supplying company http://hub360.com.ng/shop-2/hub360-pic-starter-kit/

Overview: The fourth experiment for this series of tutorial is the Traffic light system. We are now moving from simple projects to an intermediate and more tasking one.
Traffic light system is a system used to control movements of vehicles and human on the road. It is always installed at strategic locations where vehicles coming from a particular lane or road intersect another. Traffic lights are also installed to location where pedestrians wants to cross the road, especially little school children. As we all know, traffic light has only three color signs; red which represents STOP, yellow which represents READY and green which represents GO. Modern traffic light now comes with countdown timer which tells the motorist the time left to GO or STOP. Modern traffic light systems are very complex system and sophisticated, some involves artificial intelligence which can make fast decision by itself on which lane to PASS and which to STOP at general and specific conditions, and respond to priority change and override.
There are two major categories of traffic light system. The open loop traffic system and the closed loop traffic system. Open loop is when the “go time” and “stop time” is fixed and the time allocated is not in any way determined by the weight of traffic. Closed loop traffic system is one that the time allocated is not fixed but is determined by the weight of traffic. Modern traffic light system is closed loop type; it is either controlled by an artificial intelligence robot or a traffic warden or from a control room in a remote location via wireless technology.
For the sake of this tutorial for beginners we are going to restrict ourselves to an open loop two ways traffic system without counter just for simplicity then later we can do a closed loop with countdown timer when we have reached intermediate or professional level. However even in this level we can modify our code to do a semi-closed loop; how do I mean… a semi-closed loop system in this context is a system where by different portion of code will be created to cater for heavy traffic, intermediate and light traffic, these code can be selected by using a switch. More explanation will be made later in this tutorial

[b]OPEN LOOP TRAFFIC LIGHT SYSTEM: [/b]In a two way traffic light system, when the light stops a lane, it passes the other lane and vice versa. So what we actually need is one circuit which will control the two traffic light system. The red light of a lane will be connected to the green light of the second and vice versa, both yellow lights are connected together. To achieve this all we need is to send 3-bit number which will represent the 3 light to the port of the microcontroller and to delay the output for some few seconds. We send “1” to the port which represents RED or STOP, we delay for the number of times we want then send “3” which will still activate the RED light and also switch on the YELLOW for READY and we delay it for the time we want. Then we send “4” which deactivates both red and yellow light and switch on the GREEN for a GO and we also delay the output, then the program moves to the top. The state table below explains more.

FULL TEXT OF THIS ARTICLE IS IN THE DOC FILE ATTACHED TO THIS POST

CLOSED-LOOP TRAFFIC LIGHT SYSTEM:
As we have discussed above, a closed-loop system is one that has a feed back to control the time allocated to a particular lane of the traffic. The feedback system can be a human e.g. a traffic warden or it can be automated i.e. sensors are installed at strategic locations to determine weight of traffic and allocate time as set by the designer of the system and specification given. In this tutorial, we will be doing what I personally called a semi closed-loop system. It will have 3 way switch for the user to switch between heavy, intermediate and light traffic conditions. The reason why it is not a full closed loop system is that it has only 3 conditions which in the real world, millions of condition exist.
Even with these 3 conditions a good project can still be done. Take for example at Abule-egba traffic light junction: early in the morning, the vehicles coming from Sango to Iyana-ipaja and Agege is much thereby making the traffic heavy but the vehicles coming from Iyanapa going to sango is few, in such case, we can assign 60 seconds “GO” and 20 seconds “STOP” to where there is heavy traffic which will amount to 20 seconds GO and 60 seconds STOP to the other side. In the afternoon the traffic is intermediate so we can assign 20 seconds to both sides. Then the evening is a reverse effect of the morning so we assign more traffic to vehicles going to sango. But remember that there are exceptional cases which is not included in these 3 sets of conditions, and that is what makes it a semi-closed-loop system.
In writing the program, we will be using a new syntax which is used to read the logic state on a switch, and along side, we will be suing “if” conditional statement. You can pick up a C programming ebook for more understanding of conditional statements.
There are so many approach we can use to write this code and get the same result, using functions, switch statements etc but the approach I will like to use for a beginner is the if-goto approach. Switch 1 will be for heavy “more traffic at lane 1”, switch 2 will be for “balance” switch 3 will be for “more heavy traffic at lane 2”. So the algorithm will be as follows:
1. Start
2. Initialize ports and internal registers and delays.
3. Read switch 1 if logic(1) is detected goto 6 else continue with 4.
4. Read switch 2 if logic(1) is detected goto 7 else continue with 4.
5. Read switch 3 if logic(1) is detected goto 8 else goto 3.
6. Do “heavy traffic” and goto 3.
7. Do “intermediate” and goto 3.
8. Do “light traffic” and goto 3.
9. end
CIRCUIT DIAGRAM...

FULL TEXT OF THIS ARTICLE IS IN THE DOC FILE ATTACHED TO THIS POST

THE SOURCE CODE, PROTEUS SIMULATION AND HEX FILE IS IN A RAR FILE ATTACHED TO THIS POST


WATCH OUT FOR THE NEXT TUTORIAL

Re: Embedded Systems Tutorial For Beginners:experiment 4 (traffic Light System) by yourstruely: 4:17pm On Feb 22, 2018
Fantastic work Sir. It's been close to three years and no new tutorials are forth coming. My interest in things embedded just woke up. Really looking forward to hearing from you.
Re: Embedded Systems Tutorial For Beginners:experiment 4 (traffic Light System) by Yemmyteespeed007(m): 8:11pm On Feb 23, 2018
welldone sir.

(1) (Reply)

Top 10 Best Selfie Apps For Android Phone / How To Recover Deleted Iphone Contacts From Icloud / Top 10 Android Games – 10 Best Android Multiplayer Games To Play With Your Frien

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 28
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.