PDA

View Full Version : Traffic light sequence, cross roads


IMRAN
May 28th, 2002, 04:29 PM
Hello all. I am stuck and require help as soon as possible. I need to write a simple ladder diagram to control a traffic light sequence for a UK cross road. So we go green / amber / red / red and amber/ green.


This had to be done using one plc, and maximum four timers. If anyone has any ideas please e-mail me at imran@shaikhsport.fsnet.co.uk.
Thank you all!

Tom Jenkins
May 28th, 2002, 04:52 PM
I have several ideas.

First, do a search on this site. Traffic light problems abound, as they appear to be the most common application for PLCs, far exceeding slicing pickles, for example.

Second, you need to make a list of all of the inputs and outputs for the system - that is, a detailed list of everything that the PLC is turning on (outputs like Green North, Amber South, etc.) and signals it is receiving (penguin at south east crosswalk, for example.)

Then, you need to go to your text, and find out what makes a timer time, and an output turn on, and a contact close.

Then you need to write a detailed description of each step in the cycle.

Then you need to read the tutorial on this site.

Then you need to replace each event in your description with the corresponding ladder logic command (on = contact closed, for example).

Then you need to come back to the site and explain the educational value to you (and the monetary value to me) if I e-mail you the complete program.

I guess summer school is now in session, folks!

Allen Nelson
May 28th, 2002, 08:52 PM
ENOUGH !!!

I'm sick of you students demanding the "difficult" answer to the traffic light problem. So I'm going to break rank with my collegues, go against policy, and let you have it!

Here's what you do:

First, the East-West street is going to be the dominant direction of traffic. Therefore it's ON when nothing else is ON. Coded, that looks like this:

E-W E-W N-S N-S E-W
RED YELLOW GREEN YELLOW GREEN
----|/|------|/|------|/|------|/|---------+---( )
|
| N-S
| RED
+---( )


Next, When it's time to change the flow of traffic, the E-W GREEN light goes OFF. So you run the E-W YELLOW for 5 seconds (The timer resets itself after it is done so it will work the next time):

E-W +-- TMR --+
GREEN | | 10001
---|/|--------| V100 |-----( )
| |
10001 | 5 sec |
---| |--------| |
+---------+



Next, when that's done, the N-S traffic is set to go, so Set it to Green and make E-W Red.

E-W +---------- TON --+
YELLOW 10001 | Timer: T5:0 |
----|/|------| |-----+----| Time base: 1.0 |
| | Preset: 5 |
| | Accum: 0 |
| +-----------------+
|
| N-S
| T5:0 GREEN
+---|/|------+-----(SET}
DN |
| E-W
| RED
+-----(RST)

Don't worry about the different type of timer - no reset is needed here. Both timers are IEC 61131-3 complient.


Next, you would repeat the E-W YELLOW code for the N-S YELLOW, which goes ON only when N-S GREEN goes OFF.


Finally, All that's left is to return the system back to N-S Red, and E-W Green. I'll leave it to you to work out the Karnaugh map (it's in your text book), but that logic should be this:


E-W E-W N-S N-S E-W
RED YELLOW GREEN YELLOW GREEN
-----|/|-----+-----|/|-----+-----| |-----+-----| |-----+-----+-----( )
| | | | |
E-W | N-S | | E-W | | N-S
RED | YELLOW | | GREEN | | RED
-----| |-----+-----|/|-----+- +-----| |-----+ +-----( )
| | | |
E-W | N-S | N-S | E-W |
YELLOW | YELLOW | RED | GREEN |
-----| |-----+-----| |-----+-----| |-----+-----| |-----+




Now all you have to do is shove it up your PLC, and watch it go.

Now, a couple of warnings: I don't want to have to do this EVER again. Don't tell anyone about this site!!!. I don't know the PLC you are using, so I made this rather generic. You may have to adjust a few thing depending on your PLC. This is off the top of my head. You may need to debug it (probably not - I get paid for my ability to bang out code). Everything here is a lie and won't work

That's the "big problem"!!! 5 lines of code!!! I can't figure out why students make such a big deal about it!
Good Luck You'll need it!!


Eric Nelson
May 28th, 2002, 09:00 PM
I'm amazed! :eek: Since Phil opened the new forum, it took over a month before we got the first traffic light question! I figured it would only take a few days...:rolleyes:

-Eric

Peter Nachtwey
May 28th, 2002, 10:09 PM
I would use tables to do this. I would have the light sequence divided into states with a table of bits representing the 6 lights that must be turn on and off and a table of timer values to before going to the next state. The index register would represent the state number.

The advantage tables have:
1. The light patterns and time delays can easily be changed from a HMI.
2. One can insert, move, or delete states easily.
3. They are very efficient. Less code but more data.

One may have to add a left turn lane later. The above technique makes this easy and easier to understand later.

Gerry
May 28th, 2002, 11:35 PM
Allen:

Can you also post the dynamic Karnaugh map?

iant
May 29th, 2002, 04:26 AM
Its a nice new forum. But what about the elevator on the 40th floor where is the Zebra crossing.

Can we get degree's in breakfast cerial packs:D

iant
May 29th, 2002, 04:34 AM
Originally posted by Gerry
Allen:

Can you also post the dynamic Karnaugh map?



DO THE WORK ....LEARN THE JOB..... MAKE YOUR OWN FUTURE

YOU CAN NOT RELY ON OTHERS FOR YOUR ANSWERS:(

Steve Bailey
May 29th, 2002, 06:33 AM
Allen,

I can't decide whether you should be stripped of your credentials or awarded an honorary doctorate in compassionate PLC programming. While I understand (and share) your frustration with the students who seem unwilling to attempt their own solution to the traffic light problem, posting such an elegant solution on a public forum such as this could lead to hordes of new graduates descending upon the intersections of the world, and reprogramming the light sequences. Consider the potentially catastrophic ramifications of a simple typo such as inserting a XIC instead of the XIO for the timer done bit in the third rung.

I think as penance, you should be required to write a 1500-word essay on the difference between unitary, modular, and rack-mounted PLCs.

IMRAN
May 29th, 2002, 06:39 AM
Just want to thank every one who has tried to help, thank you all.

Thanks for the Program, (i liked the 'hidden' comments in the diferent colour text-amusing) Ill be stydying it carefully.

Thanks for the 'tables' idea, but
This program had to be in Ladder diagram form.

Also this program will never see a PLC, it simply has to be seen running by the lecturer on a PC based simulator, that lights up the outputs as the program runs, etc.

I have found an Aus. traffic light sequence, which was helpfull, but as they miss out the sequence: RED / RED AND AMBER / GREEN, and go from RED - GREEN directly, (and it used an extra timer) i couldnt see how to modify it to work on the UK based light sequence.

Any more ideas from anyone are most welcom.


Imran.

Pierre
May 29th, 2002, 07:16 AM
Steve B.-
I think as penance, you should be required to write a 1500-word essay on the difference between unitary, modular, and rack-mounted PLCs.

Hey, what about embeded smoke?

Tom Jenkins
May 29th, 2002, 08:42 AM
"Any more ideas from anyone are most welcom."

Imran, ole pardner, you is clueless! You will never be a good engineer until ya recognize sarcasm! Allen wuz jist tryin' to stop the flow of questions from students whut wants us to do their homework fer them, instead of askin' fer help on doin' it themselves!

"i couldnt see how to modify it to work on the UK based light sequence."

Thet is 'zactly my point. The objective of the instructor wasn't to git a program - it wuz to teach you how to analyze a problem and learn and apply problem solvin' skills to findin' a solution. After all, I is in great doubt thet the instructor is buildin' traffic lights in his basement!

Engineers is not guys thet know the answers to specific problems. REAL engineers is guys whut know how to analyze problems and apply the principles of science and logic to developin' the solution to ANY problem.

Lessons learned hardest is learned best!

PhilRey
May 29th, 2002, 10:26 AM
Eric-

The reason it took so long to get a traffic light question on the new forum is because the geniuses are still posting those questions on the old forum - you know ... the one that says
Please post ALL NEW questions in the NEW forum
in big red letters on the top of the page.

Does that tell you anything?bonkhead

Allen Nelson
May 29th, 2002, 04:27 PM
Steve -
I am unrepentant.
I will pay no such penance.
My reply was a Darwinian thing - a matter of survival....

Gerry-
I left the creation of the Karnaugh map (which, in dealing with traffic lights, must, by nature, be dynamic. I mean - who ever heard of STATIC traffic lights?)

IMRAN -
You private messaged me, which is fine, but all discussions pertaining to posted material should be kept public, so that other lurkers may benefit. (As you can gather, the Traffic Light Problem has come up before, and not just from your school. But you also have classmates who may also wish to use my code.God help them. So please, feel free to post again with any lingering questions.

PhilRey -
Yes, they've been posting at the old site - but the conversation in Vietnamese(?) is fascinating.

IMRAN
May 30th, 2002, 03:12 AM
Ok friends, ive had enough of this. Ive tried to be respectfull and humble to you all in my questions and all i get is this 'student asking questions' bull.

Ive just come home from a 12 hour night shift, so excuse my typing. But i feel some points have to be made here......

I understand that good engineers are about problem solving. I understand this and respect this. I have a job which involves these principles.

But it would be nice for people to take note that i am no PLC engineer (as i sure some of you have guessed), nither do i wish to be. As nice as they are, i have no intention of programing PLCs for a living, so all those of you worried that i may be causing motor way (or freeway) 'pile ups' may calm down.

Also, and i hope ur still reading this, i have already solved all other assingment, from a central heating system, to a metal/plastic sorting machine, and i have just done my exam, which at my level was bloody easy.

But this darn trafficlight sequence has got me bloody well fussed and rather ****ed off- mainly cos i cant find the solution to this relativly simple task.

All I wanted, well......not even wanted. All i asked was for some help in this assingment of mine. So i could put PLCs behind me and continue in my HNC and make my prospects in finding a job within the railway (not PLCs or signaling) a better one.

Insted all i have (with the exception of a few) is snubby nosed 'engineers' talking down to a 'student'. Now i dont want to sound rude, but i am quite sure those snubby nosed 'engineers' couldnt do my 'engineering' job to save ur wage cheque.

Now, if someone from a computer based or PLC based engineering background had a question for me, on locomotive traction or mechanical engineering, I WOULD GLADLY HELP THEM.

Now ill leave you 'engineers' with this thought. You all have fine PLC jobs, or so it seems. But remember how you got there.
BY ASKING THE RIGHT PEOPLE THE RIGHT QUESTIONS AND LEARNING FROM THEM.


Have a nice day :)

Eric Nelson
May 30th, 2002, 03:25 AM
Utoh... Here we go again!...http://www.peyups.com/images/phpbb/icons/twak.gif

Rick Densing
May 30th, 2002, 07:37 AM
Originally posted by IMRAN
.
BY ASKING THE RIGHT PEOPLE THE RIGHT QUESTIONS AND LEARNING FROM THEM.


You asked the right people, I think.
You did not ask the right questions.
As you may have guessed, the traffic light question pops up every few months or so. Each time it sounds the same. You may not have realized it, but your question was interpreted as "I don't know how to do my assignment, please do it for me." This is not snobbery on our part. As stated in the introduction, how you ask is much more important that what you ask. If you had simply explained your efforts in more detail, you would have likely recieved a different response. Granted, the traffic light question is such a sore subject that you were handicapped from the start.

Allen Nelson
May 30th, 2002, 08:52 AM
IMRAN:

You say you are having a problem with the traffic light code. What problem EXACTLY is the problem you are having.

Do you know what all your I/O are (6 lights minimum, but what about turn signals and crosswalks (aka zebra crossings)? Car detection pressure pads (how many?)?

Do you know the sequence? What are the transistions from each step to the next?

Or is there just some line of code tha you've writen, that .looks to your eyes like it should work, but for reasons you don't understand, it doesn;t.

Post what you don't understand, and we [b]WILL{/b] give help. But we have no way of knowing where you are stuck, until you tell us. Don't chew us out for your shortcomings.

Tom Jenkins
May 30th, 2002, 10:59 AM
OK, Imran, maybe we misjudged you. However, we can only go by our past experiences here (lots of lazy, sloppy students asking the IDENTICAL question) and by what you write in your post. Your original question was poorly defined and open ended.

Clearly defining the problem is the most critical step in obtaining a good solution.

IMRAN
May 31st, 2002, 05:40 PM
Hello all.

I must appoligise with my last post. It was a little 'over done' by any standards. Sorry all :) I must sound like a real miserable wanker.

Also, Im sorry if the details were not made clear, I thought I had explained that it was simply a cross road, N-S and E-W, and that there was no plc to program just a computer simulator that works on ladder logic.

There was no way i would ask anyone to do my work for me. I just asked for assistance:
Rick, mate, read the question, dont assume what is being asked. Cheers!

But, with all that aside, i think i have cracked it now, just last night while on a tea break at work. I just need to test and debug now. So with that said, ill leave you all in peace!

Hopefully, (cos who knows where a job can take ya), i can come back here and call upon ur knowledge and experience in the future.
In a few years or so.

Take care.

rsdoran
May 31st, 2002, 09:10 PM
Personally I dont think any apologies are needed by anyone, yes the traffic light thing comes up regularly...so what. Not all can see what needs to be done even when they may have done other things before. NO, noone should do anyone else's work but it doesnt hurt to give an idea/clue on a path to take...even if it is a student.

YES in most cases the students are lazy and looking for a freebie..so? In the real world they will act the same way so will NOT get the job/money etc they desire. WHY? Because they will not have learned HOW.

There was a time when YOU ALL didnt know the RIGHT question(s) to ask.

Not all students are kids looking for the easy route, some may just need a nudge in the right direction.

Yes I know this site gets deluged with that question every year..so what? WHERE else would they go for this kind of assistance? WHO else has this kind of knowledge? Ability?

You think most of them have an Instructor that is that capable?

You should be proud of the fact that you are the source of info for future minds.

To alleviate this deluge I have (besides Allen's post) 3 other traffic light ladder diagrams...from this day forward I plan to post them at the first sign of derision, not in response to the question.

Tom Jenkins
June 1st, 2002, 02:18 PM
Thanks for posting back Imran. I'm glad you cracked it.

Hope to see you here some more.

Matthias Von Zorn
June 4th, 2002, 11:39 AM
Then u need to ask the right questions. Do have any idea how many times we have seen "give me the answer to the traffic light! Need now!"?? If you want to avoid these rather generous peoples jabs, your should have posted differently. Why not tell us what you have done already, and where you are stuck? Obviously you care more than most (they almost never reply to our little games here). So if we mistook you, it was soley to the way you asked the question.

June 4th, 2002, 01:36 PM
IMRAN, LIKE YOURSELF IAM TRYING TO HOLD DOWN 5&6 12 HOUR SHIFTS AS WELL AS STUDY A LIST OF SUBJECTS WHICH ARE COMPLETLY NEW TO ME IN THE HOPE THAT I MAY INPROVE ON MY FUTURE PROSPECTS.H.N.C ANY HELP YOU CAN OFFER ON THE LADDER DIAGRAM FOR THE LIGHTING SEQUENCE WOULD BE GREATLY APPREACHATY ................................IS THIS SITE NOT FOR THE SHARING OF KNOWLEDGE???????????????

Allen Nelson
June 4th, 2002, 01:47 PM
Look at Post #2 - I put the soluton there. What more do you want?

Here, we don't just hand out code. We teach. Teaching involves effort on behalf of the student and the teacher.

This is our effort, where's yours?

Rick Densing
June 4th, 2002, 02:22 PM
Originally posted by
IAM TRYING TO HOLD DOWN 5&6 12 HOUR SHIFTS AS WELL AS STUDY A LIST OF SUBJECTS

And this somehow justifies having someone else do your work for you?
The logic escapes me.

iant
June 10th, 2002, 10:19 AM
Well done Imran
However I have a question for you
I beleive the answer will benefit the 'students' who need to be given the answers.

Did you feel relieved and satisfied that you could crack the problem?

And what about the Logic skills you now have learnt doing this excercise..?

Please Post the Answer seperate to this thread.

As you know and others will learn 'we were not told by some one'
We learnt by teaching ourselves. and asking refined questions.
[how does .... operate] or [ how to input timer variables in a ... type PLC] etc.

Regards Ian T :p

red alert cavy
September 19th, 2003, 04:18 PM
I still say stop signs would have saved the world A LOT of trouble. :D *sigh* I'm a beginning student and even I knew how to program those lights. Now I gotta figure out how to put a walk light in there.

panic mode
September 20th, 2003, 01:34 AM
you can do one timer and bunch of LIM instructions (or GRT and LES)
to do this:


T4:0/DN
----|/|-------------------------------[T4:0]

GREEN
---[LIM N7:0 T4:0.ACC N7:1]-----------( )

RED
---[LIM N7:2 T4:0.ACC N7:3]-----------( )
etc.

rms
November 13th, 2003, 05:20 AM
Just wanted to thank you all for a most interesting thread, albeit more from the sociology rather than a PLC angle. It was interesting to note that there was no discussion of what the UK traffic light sequence was and how the differences might affect the logic employed (I googled here while looking for other traffic light sequences than the UK and US models).

Obligatory traffic light humour/humor.

Traffic light sequence in UK.

Legal:
Red - Stop. Wait behind the stop line on the carriageway.
Red + Amber - Stop. Do not pass through until green shows.
Green - You may go on if the way is clear. Take care if you mean to go left or right and give way to pedestrians who are crossing.
Amber - Stop at the stop line. You may only go on if the amber appears after you have crossed the stop line or are so close to it that to pull up might cause an accident.

De facto:
Red - Curse the lights, your bad luck, other road users, pedestrians, and life in general.
Red + Amber - Slip into first, start crawling forward, and aim to cross the stop line and floor it the instant the light turns green.
Green - Go.
Amber - Go faster to get over the stop line before the light turns red.

Thanks again,

Robert

Rube
November 14th, 2003, 09:14 AM
I have read all the posts to this thread, as well as "lurked" as Allen put it, through this site for several weeks and as someone who learned PLC programming without benefit of a teacher, I agree with Allen's frustration. I was dropped into a position of being "the only guy here that could do it", when the guy who was supposed to teach me quit. I did a tremendous amount of reading, trying, and quite honestly, screwing up, because I didn't know sites like this existed.

However...

This site should not be considered the homework convenience store, where you just drop in when you need something quick. Some people use the site for that reason. There are, as you are all aware, many different things that can go south when you give someone the answer, not the least of which is you rob them of the need to think something ALL the way through. (Tell me your name if you've never thought up logic, written it, and scrapped it because it didn't test well.)

Allen, (as well as Eric N., Tom J., Rick D., and others) seems to be an intelligent programmer and a generous man as well. I'd like to spend a week studying with someone with his talent. Students would do well to heed his advice--as long as you write the logic yourself.

If you are in school, learn. You start a bad routine if you let others who have done their time do yours also.

Allen. I'm amazed at you for posting your logic. I know why you did it, I just wish you hadn't. You are too nice a guy.

Imran, don't take it too personally, when people say the things that were said in this thread. These things were said to all of Allen's lurker students as well.

vinyong
March 28th, 2004, 09:44 AM
Help.... I need help in PLC for Traffic Light... can someone help me? E-mail me at vinyong2003@yahoo.com pls

cnrservices
March 28th, 2004, 10:20 AM
Here is a simple traffic light control, that can probably be modified for UK needs, but was designed for US apllications.

As my comment says: You may need to make a few changes for your exact application...

Greg

I figure it's really worth about 2 cents.

cnrservices
March 29th, 2004, 09:25 PM
Just in case any students need to add Walk / Don't Walk lights to my above program, I spent some free time and came up with the following add-on. Enjoy.

Greg

cnrservices
March 29th, 2004, 10:29 PM
This time a Fully Functional (Australian style) pedestrian Push For Walk set of buttons. No modification required to meet Sydney's standard operation.

Greg