Sign in to follow this  
Followers 0
Hưng Smart

Programing for traffic light system

8 posts in this topic

Hi bro, I'm programing a traffic light example and then maybe develope to a project using the real time function. But i got some problems and i just need you help me with the easy part first. This traffic system has two crossroads. I intended to set the green,yellow ,red lighs of the first crossroad in the X-direction (horizontal) to 20s,10s,30s, and in the Y-direction (Vertical) to 20s,10s, 30s, respectively. Similarly, for the second crossroad in the horizontal direction i set green,yellow,red lights to 35s, 5s, 20s. In the vertical direction i set them to 15s, 5s, 40s, respectively. when i push start button i saw the all yellow and red lights lit immediately and i tried to wait if the green lights would turn on but it didn't. The system just stop after that in this situation. All yellow,red lights were lit permanently .Even i push stop button, there were only some lights turned off, the rest still light. Can you fix that problem for me and give me some dirrection to understand Compare instruction and timer instruction clearly. I just learned about OMRON PLC for a short time so i'm not good enough. http://www.mediafire...sx75pv0aq1b084s . This link is the instruction way using Compare instruction and timer http://www.mediafire...23230w9p1s61i3i . This link is the instruction way using timer and set,reset.... I want to program with compare instruction, it looks shorter than using the 2nd way Edited by Hưng Smart

Share this post


Link to post
Share on other sites
We had this in my first year of programming. Think of the logic statements that will create each light individually and use the corresponding functions in the ladder. Remember that OR statements imply branched logic, AND statements imply series logic and the two can be used together in a rung to achieve your goals. The following can be simplified, but it is a basic approach. Rung 0 if the light is green start green light timer duration x. Rung 1 if green light timer is done start yellow light timer duration y Rung 2 if green light timer is done and yellow light timer is done start red light timer Rung 3 if red light timer is done reset all timers Rung 4 if yellow light timer is done turn on red light Rung 5 if green light timer is done and yellow light timer is not done on turn on yellow light Rung 6 if green light timer is not done then light green light I do not have omron software yet, but have several of the other brands out there. Try to learn the concept behind programming logic, and transitioning between software will become easy. If you only learn how one manufacturer does things, you will have a harder time with this. When I program whether it is AB, Siemens, Eaton, Mitsubishi, or Automation Direct for starters, I think to myself, this is what I want this rung to say, now how does this software say that. It has been very helpful, since the approach of saying for example 'this is how AB does it, now how does Siemens do what AB does' can sometimes be your biggest obstacle. Software X may not have the exact function that Software Y has, but each system has the tools you need to do most anything.
1 person likes this

Share this post


Link to post
Share on other sites
"When I program whether it is AB, Siemens, Eaton, Mitsubishi, or Automation Direct for starters, I think to myself, this is what I want this rung to say, now how does this software say that. " Awesome statement! I wish others could internalize that. Here's a link to a discussion of compare. Using Compare Functions on the Omron PLC

Share this post


Link to post
Share on other sites
Yeah, i got your point but i never learn something inflexibly. I tried to figure out the meaning of each instruction, never thought that "Software X doesn't have the exact function that Software Y has, i can't do this...."Now i'll attach a Doc file, someone can point out the mistake in my work, please!!! Traffic light.doc

Share this post


Link to post
Share on other sites
The timer appears to be appropriate, counting to 600 by 100ms should give you 60 seconds elapsed, but the doc I downloaded has only two rungs of program. I see nothing for the red light control.

Share this post


Link to post
Share on other sites
I fixed that problem and now i want to program for traffic light system using real-time function. Can anyone give me some direction to do. I'm using PLC omron CJ1M. I don't know exactly what instruction or memory area, special bits i must use. Do i have to use Clock instruction or something else? Let's discuss this topic and guide me Edited by Hưng Smart

Share this post


Link to post
Share on other sites
I would ignore the clock in the PLC and count time in 1second or 0.1 second pulses's and then use this alongside TIMX and TIMHX timers. (i prefer binary timers to the BCD ones)

Share this post


Link to post
Share on other sites
another way to look at your traffic light dilemma... we know traffic lights should have a "State" where the red lights ought to be on in both directions... lets say 3 seconds & call this state "10" next, one of those directions will have a state where it stays green, while the other is red... eg. 30 seconds & lets call this state "20" next, that direction that was green should go to yellow... eg 5sec & state "30" next, back to all reds for 3sec. state "40" next the opposite direction green for 30sec. state 50 next to yellow for 5sec. state 60 back to the beginning... state 10 and repeat.... using a register (or bits if you want) to manipulate your "states" you can have... you can then time appropriately and when the timer is complete... change states... using the bits or register values could tie to coils for your outputs (lights)... just don't use the same coil twice in the code. hope this helps

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