LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Traffic light control / demand request / night mode

Highlighted
Hello everybody,

i need your support.
I / We (prospective technicians) have to do a traffic light control with the following facts.

There is a main street and a side street as well as pedestrian lights.

Pedestrian crossing:
The pedestrian traffic light is always red.
When the traffic light switches to red, all (4) pedestrian lights automatically switch to green, taking into account a delay.
In addition, the pedestrian traffic lights of each of the four traffic lights can be switched to green by requesting a button (taking into account a delay).

Vehicle traffic:
The traffic lights on the main street are always green, those on the side street are red.
If, however, vehicles wait a certain time on the side street (request for demand (reed contact)), the switching process begins and the traffic lights on the side street switch to green:
After no more vehicles are driving on the side street, we restore the starting position taking into account a delay.
If this leads to waiting times on the main road, the starting position is established beforehand, taking into account a delay.

The system switches to night mode from a certain time. The pedestrian lights are off and the vehicle lights are flashing yellow.
When switching from night to normal operation and reversed, all traffic lights switch to red for 8s. Switching should also be possible by hand.

Now to our problem.
We only have about 20 hours of teaching material. And only scratched the top of the mountain.
Now we should write / make a program that I think is unthinkable for the short learning phase.
And we also have to build a model with all the traffic lights, buttons and reed contacts.

I have already done a lot (see attachment). But is still far from what is required.

We now want to integrate the night mode with a toggle switch and the requirement for the vehicles on the side street.
And that's our problem right now. We don't know how to go on. We are completely on the tube.

We would be very grateful for any help.

Best Regards
0 Kudos
Message 1 of 11
(514 Views)
Highlighted

Why do you have a phase where you have red and yellow on at the same time?  That doesn't make any sense.

 

Good news is that what you have now seems to otherwise work and is a pretty compact VI.

 

You have the beginnings of a "state machine" where you progress through states.  But it is rather simple in that it is just a series of states that you execute based on incrementing the enum.

 

Now you need to put some decisions in the state machine so that the next state is determined by conditions in the current state.  If you are in phase 1, but the side sensor is trip, maybe you decide to go to phase 3 instead of phase 2.  You may want to have a decision so that instead of waiting for 30 seconds before moving on, the cycle takes 1 second, but you keep track of an elapsed time and only move to phase 2 if 30 seconds have elapsed.  Or move to phase 3 if the side sensor is tripped and 15 seconds have passed.

 

For night mode that might be a decision where day mode the time for a phase is 20 seconds, and in night mode it is 30 seconds.  Thus the boolean will determine which elapsed time value you will use.

0 Kudos
Message 2 of 11
(473 Views)
Highlighted

I think "night mode" might mean flashing yellow on one street, flashing red on the cross street.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 11
(457 Views)
Highlighted

@billko wrote:

I think "night mode" might mean flashing yellow on one street, flashing red on the cross street.


That certainly makes sense, and certainly doable with a state machine.  If in the last state it detects night mode = true, then it will transfer to a state that blinks the lights on and off.  If the night mode state detects that the night mode =false, then it transfers to the first state of the regular light series.

0 Kudos
Message 4 of 11
(452 Views)

@RavensFan wrote:

Why do you have a phase where you have red and yellow on at the same time?  That doesn't make any sense.


I don't know where the OP lives, but in the UK traffic lights do have a Red+Amber phase when changing - this indicates if you're about to go to green, or about to go to red. If I recall correctly (it's been a while since I drove in the UK...) you get just Amber when transitioning from Green to Red, and Red+Amber when transitioning from Red to Green. This looks like what I saw running the VI too...

0 Kudos
Message 5 of 11
(420 Views)
Highlighted

Hi NowhereMan/iKnowNow,

 

please indicate this is a crosspost from German www.LabVIEWForum.de, to avoid unneccessary work done twice.

 

You already got the suggestion to setup a proper statemachine!

Best regards,
GerdW
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 6 of 11
(406 Views)
Highlighted
@RavensFan

These are the traffic light phases in Germany.

In night mode in Germany it is so that the traffic lights for the cars flash yellow and the pedestrian traffic lights
are switched off.

It would be good for us if we had an example for our VI where we can understand how it is constructed.

Because our basic knowledge in LabView is very small.

We would be very grateful for further examples.

Best Regards
0 Kudos
Message 7 of 11
(375 Views)
Highlighted

@cbutcher wrote:

@RavensFan wrote:

Why do you have a phase where you have red and yellow on at the same time?  That doesn't make any sense.


I don't know where the OP lives, but in the UK traffic lights do have a Red+Amber phase when changing - this indicates if you're about to go to green, or about to go to red. If I recall correctly (it's been a while since I drove in the UK...) you get just Amber when transitioning from Green to Red, and Red+Amber when transitioning from Red to Green. This looks like what I saw running the VI too...


Ouch.  Why would they do that?  That is one of the dumbest things I've ever heard.  Does that provide some advantage?  I've been to England a couple times, but I don't recall seeing that.

 

That seems to be a dangerous situation.  It would be more likely for a driver to jump ahead on the green light in anticipation of it turning green and risk being in the intersection early when someone runs a red light!  When driving safely, just because you light turns green, you should still take a second before hitting the gas pedal to look to see you don't have someone about to run the light that just turned red for them.  Giving an advance warning of green to you means you are going be biased to starting out a second or so earlier than would be safe.

0 Kudos
Message 8 of 11
(354 Views)
Highlighted

@iKnowNow wrote:

@RavensFan
These are the traffic light phases in Germany. In night mode in Germany it is so that the traffic lights for the cars flash yellow and the pedestrian traffic lights are switched off. It would be good for us if we had an example for our VI where we can understand how it is constructed. Because our basic knowledge in LabView is very small. We would be very grateful for further examples.


We have that night mode too in the US on many lights.  I've never really though of it as "night mode" even though that is exactly what it is.  I know of some lights on the road to where my work used to be that they actually doing flashing on Saturday and Sunday during the day as well.  Just when I read your problem, the flashing situation didn't occur to me.  I was thinking of a case where you the timing of the light cycles change based on the time of day.

 

As for the red/yellow thing.  That is the dumbest thing I've ever heard of because that would make the intersection less safe.  Read my message of above for why.

 

As for examples of state machines, from the LabVIEW Getting Started window, you can start a new project based on a template, and a state machine is one of them.  Plus state machines are a common design pattern and people are always asking about them on the forums.  Search for "state machine" in the LabVIEW forum and begin reading.  JKI also provides a state machine template that is based on strings, (I prefer enums myself), that you can get if you install the VI package manager from JKI.

0 Kudos
Message 9 of 11
(351 Views)
Highlighted

@RavensFan wrote:


Ouch.  Why would they do that?  That is one of the dumbest things I've ever heard.  Does that provide some advantage?  I've been to England a couple times, but I don't recall seeing that.

 

That seems to be a dangerous situation.  It would be more likely for a driver to jump ahead on the green light in anticipation of it turning green and risk being in the intersection early when someone runs a red light!  When driving safely, just because you light turns green, you should still take a second before hitting the gas pedal to look to see you don't have someone about to run the light that just turned red for them.  Giving an advance warning of green to you means you are going be biased to starting out a second or so earlier than would be safe.


You had me thinking I was crazy, so I had to check, but here it is from Wikipedia:

 

In Britain, and much of Europe, normal traffic lights follow this sequence:

  • Red – stop
  • Red and amber – stop, but prepare to proceed
  • Green – proceed with caution, but only if the way is clear
  • Amber – stop unless it is unsafe to do so

I would hazard that perhaps being ready to go saves time, gets more cars through the light, etc.

 

In Japan, it's often a slow-moving affair when a light turns green (despite the fact that I think it's common to watch the other (90 degree sideways) light to see their Amber and then know it will soon be red, and you can go on green. However, sometimes people start to push forward, despite it still being red... so I suppose it's a mixed bag regardless of the signalling.

It's also common to see people accelerate into amber lights and run lights that really turned red before they entered the junction too... Perhaps that encourages starting slowly on green lights.

 

Edit: to put at least something helpful and related to LabVIEW in this post, here's a link to the NI description/tutorial for a State Machine.

0 Kudos
Message 10 of 11
(350 Views)