Sign in to follow this  
Followers 0
bryan372002

Traffic light project

27 posts in this topic

Hey Guys, Yepp Im here with yet another project, traffic lights, I'm working on part one right now which just ask for Red, Green , yellow with a 2 sec. delay on the reds. I did this project months ago using LogixPro, on my own and have it working, but i have seen where it is possible to do this wih just 1 timer. I have tried using one timer, with compare instructions(gretaer then and less then) but cant seem to get my numbers just right yet. also thought about using a sequencer(or drum with directlogic) but with logix Pro cant seem to figure that out either. Yet! however attached is my solution using a timer for each light. Have a looksy and see how badly I have done If you would. http://harnettfriends.com/images/traffic2.rsl Ps the site where this file resides is my domain so it is completely safe, scouts honor.

Share this post


Link to post
Share on other sites
Can you do the images of the ladder you did in the past?

Share this post


Link to post
Share on other sites
Sure, its a little more work for me. but Its worth it. I'll get it posted asap

Share this post


Link to post
Share on other sites
Ok Here is the Image, thanks in advance Mind you there is no documentation yet, I'll work on that and repost it if needed

Share this post


Link to post
Share on other sites
One thing you're going to have to learn is to document your code. I find it's best to document it as you write it, otherwise it will always be one of those things that you're going to do, but never get around to it. Six months from now if you open this project, you will not have a clue as to, what does what, you'll have to spend a lot of time trying to figure it out. At my current job, I inherited several large systems, with little or no documentation, I spent the last few years documenting it, it's not fun work. You will notice that most of the "regulars" post documented code, even if it's just a little snippet to explain one little detail. So........ As a general rule, I never review or comment on undocumented logic on any forum.

Share this post


Link to post
Share on other sites
Ken you are right, I apologize, I'll be out of town for the weekend but first of next week I will get it documented cleaned up and present it again. You Guys have a great weekend.

Share this post


Link to post
Share on other sites
Bryan first let me second Ken and say document as you go. Young and fresh we all felt invincible and could recall what bits did what days and weeks after having written the code. As the years pass that sharpness fades and if you haven't developed the habit of documenting from the start, you'll pay for it with many sleepless nights sorting out "Now what did I mean to do here?". One quick observation without deciphering your code. Are the OTL and OTU instructions really necessary. I prefer the bland old fashioned OTE and a branch of latching logic whereever possible. This is generally easier to follow and troubleshoot. Just my humble $0.02. Took a quick look and I am guessing here. IF O:2/0 is Red E/W then O:2/6 is Green N/S and O:2/5 is Yellow N/S. Also O:2/4 is then Red N/S and O:2/2 is Green E/W and O:2/1 is Yellow E/W. T4:1 may be a problem since it never resets and this will run the lights only once. After 20 seconds of running you'll end up wiht O:2/1 and O:2/4 always on. Looking forward to a documented post. Edited by BobLfoot

Share this post


Link to post
Share on other sites
Thanks again Bob, Sorry i havent post a documented version yet but the truth is yes there was major problems and I have rewritten some things. the big bite is....lol I have been writing my projests using LogixPro because I have it at home and can run sims and test it. but in class we are using DirectSoft32 and as allen bradley has timer timing bits Direct soft does not. which isnt a major problem, but a pain in the buttocks...lol I'll get this thing whipped into shape and posted real soon, so I can find out where my fubars are.

Share this post


Link to post
Share on other sites
Ok Guys Here is the documented version, and I have also added part 2 of this project, which states that between the Hours of 12:30am and 5:30 am that the e/w bound lanes will flow steady until a car approaches from the n/s bound lanes at which time, the lights will cycle one complete time, then return back to a steady e/w bound flow, any other times the lights cycle red, green yellow, in both directions with a 2 sec delay when both directions are red. The 12:300-5:30am time frame is just to controlled by a switch for this project. Hope i'm close, It works but maybe more complex than needed, yall tell me. and thanks in advance Crap Dont know where it went but up on rung 5 that unidentified XIO is suppose to be T4:6/TT Sorry

Share this post


Link to post
Share on other sites
Bryan - Looks like your program is headed in the correct direction. You will get T4:1, T4:2, T4:3 and T4:4 to time in succession time and again when you are not in the special time window. What I see is 6 seconds green North, 2 Seconds Yellow North, 2 Seconds Both Red, 6 Seconds green East, 2 seconds yellow east and 2 seconds both red. repeating at ifinitum. In the magic hours I see a couple of issues. 1. You might want a T4:6/tt branch around the I:1/1 because what happens when car pulls away? 2. Your Car Present North will cause an immediate switch from Green to Red with no yellow on the East lanes. This might not be okay? Any questions you have? Edited by BobLfoot

Share this post


Link to post
Share on other sites
Thanks Bob, Im going to have to work on that problem You pointed out about going straight from red to green, that is a problem....lol. I did add the seal in for I:1/1, thanks for the help Do You feel that My basic layout is all wrong? I mean should I make changes to what i have started or would you ditch it and start over? Thanks again Bob For your time and patience.

Share this post


Link to post
Share on other sites
Your Welcome. The day I forget what it's like to be that novice programmer is the day they can hang up my keyboards. Just a teaser Brian - I did your basic project {before "Special Hours"}with One Timer, One Integer and less than 12 rungs of logic. I added One Timer and Two Internal Bits on 4 more rungs for "Special Hours". And yes mine does Yellow after the North car arrives before turning it green. But that is after thirty years of "borrowing the wheel" from other talented programmers. In a couple of weeks once I'm sure your class is past that point PM me and I'll send it to you if yu're interested.

Share this post


Link to post
Share on other sites
Bob Once again Thanks For Your help. im going to work on this again this weekend and I'll let you know where it goes. I would love to see Your program and I'll let you know soon as I get past this project so you can send it to me. I wish all the veteran Programmers Had that attitude. it really gives Me incentive to drive forward when someone is encouraging and Humble yet a Professional.

Share this post


Link to post
Share on other sites
Let's Just say I had an excellent example: Phil 2:5-8

Share this post


Link to post
Share on other sites
Hey Bob, and anyone else that may wish too, Have a look at this, i decided to go about this a different way and although it may be a bit disarrayed.....lol It does seem to do all that is required, except i havent added My fire truck sequence yet. Also in rung 0 I do not have any type of bit turning on the master timer and I have read somewhere that this is illegal, however i couldnt figured a good contact or bit to place before it that didnt have an Ill effect on the rest of my logic, any suggestions, comments etc would be greatly appreciated.

Share this post


Link to post
Share on other sites
First Quick Blush it looks good. Might want to use Integer registers like N7:0, N7:1, N7:2 etc rather than discrete exact times in your compares. This will allow you more flexability later on.

Share this post


Link to post
Share on other sites
Not sure about it being illegal. Allen Bradley allows you to have a condition with no contacts on the rung, as you have. Directsoft does not, it will tie the condition to the rung above, but they do provide an Always on Bit. I looked in A&B and could not find an equivalent.

Share this post


Link to post
Share on other sites
Thanks guys, Yeah I found out today that direct logic doesnt allow a condition with no inputs, but I have read about the always on bit. Problem now may be, I think i over heard the instructor scolding someone for trying to do this with compare instructions, I think he wants it done with timers and done bits, but anyway. Hey Bob Im not sure I understand how to use the integers instead of the discrete exact times. thanks again guys

Share this post


Link to post
Share on other sites
I'll give an example using your rung #2, Your Rung is as follows in mnemonics SOR BST BST GRT T4:0.ACC -1 LES T4:0.ACC 20 NXB GRT T4:0.ACC 220 LES T4:0.ACC 240 BND NXB XIC I:1/0 XIC T4:0/DN XIO B3:3/0 BND XIO OTE EOR With Integers It becomes: SOR BST BST GRT T4:0.ACC N7:0 LES T4:0.ACC N7:1 NXB GRT T4:0.ACC N7:2 LES T4:0.ACC N7:3 BND NXB XIC I:1/0 XIC T4:0/DN XIO B3:3/0 BND XIO OTE EOR And N7:0 = -1 ; N7:1 = 20 ; N7:2 = 220 and N7:3 = 240. To change the red overlap from 2 to 3 seconds you need only change N7:1 from 20 to 30. No need to edit the rung if you use integers.

Share this post


Link to post
Share on other sites
Thanks Bob, I cant express enough how much i really appreciate your, time and help here. You have really been a Blessing.

Share this post


Link to post
Share on other sites
I my have figured it out, I went to the data table and enetered the values for N7:0 etc and that seemed to have worked, is this correct?

Share this post


Link to post
Share on other sites
Yes that is one way you can also craft a load values rung like follows: SOR XIC S:1/15 BST MOV -1 N7:0 NXB MOV 20 N7:1 NXB MOV 220 N7:2 NXB MOV 240 N7:3 BND EOR This will load your integers on first scan and still let you change them with the Data Table Editor Function.

Share this post


Link to post
Share on other sites
Bob, could You please try and explain how using integers will make this more flexible later on or what the advantage is of using integers here. Thanks a million

Share this post


Link to post
Share on other sites
Imagine this. Your system is running and you are asked to change to to a four second red overlap or make the east green shorter. You can edit the rungs in your system and change the performance. With Integers you just change the integer values. Hope this is clear.

Share this post


Link to post
Share on other sites
Bryan you're on to Truth Table from the last post I saw so here is the traffic light master set. TRAFFIC_LIGHT.zip

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0