How can I create a traffic light logic?

How can I create a traffic light logic?

edgar_a
Not applicable
17 Views
8 Replies
Message 1 of 9

How can I create a traffic light logic?

edgar_a
Not applicable

[ FlexSim 16.1.2 ]

I'm trying to make a simple traffic intersection control by traffic litght. But I dont know how to control the times. I think it will be necessary use Time Table, im trying but not successful.

0 Likes
Accepted solutions (1)
18 Views
8 Replies
Replies (8)
Message 2 of 9

jeff_nordgren
Not applicable
@Edgar A

I notice that your FlexSim license expired over 2 years ago. The first thing you should do is contact your local distributor in Brazil and get the latest version of FlexSim. Although we try and support all versions of FlexSim, it is not practical to try and do something in an older version that may be easier in the latest version of FlexSim. But if you have created a model that we can look at, that would make it easier for us.

Have you tried closing and opening node edges to stop traffic? You could use a User Event, that is timed, to send a message to an object and open/close the appropriate node edges.

0 Likes
Message 3 of 9

edgar_a
Not applicable

Thanks a lot for answer. I've try every mode close and open nodes. I'm working now with a extra processor than utilize global variables to use with time process.

I'm using 3 variables: 1º time, 2º time and Flag (to sinalizate wich open). It's work, but too complicate to see that.

7152-sem-titulo.png

Thanks..

0 Likes
Message 4 of 9

jeff_nordgren
Not applicable
@Edgar A

Not sure what you mean by it being "too complicated to see that"?

0 Likes
Message 5 of 9

philboboADSK
Autodesk
Autodesk
Accepted solution

You can customize the Traffic Control object's logic by writing code in its OnEntryRequest trigger and using the trafficcontrolinfo() command:

7166-traffic-control-info.png

Thus, you could write custom logic that keeps track of which lanes are open on labels and change those values based on time like a traffic light.



Phil BoBo
Sr. Manager, Software Development
Message 6 of 9

edgar_a
Not applicable

It was complicated to found a result. Sorry for my english.

0 Likes
Message 7 of 9

edgar_a
Not applicable

It works.. I'll learn more about traffic controll. Thanks!!

0 Likes
Message 8 of 9

andrew_j3
Not applicable

@phil.bobo would it be possible for you to provide an example or example code related to the above commands. For example, a 3 lane roadway whose light would turn red every 10 minutes and stay red for 40 seconds. Thanks in advance, Drew.

13513-rumlx.png

0 Likes
Message 9 of 9

philboboADSK
Autodesk
Autodesk

custom-traffic-control.fsm

The attached model shows you how to do this. You can set the labels timeRed and timeGreen on the traffic control to control how long it is red vs green.

The On Reset and On Message triggers control whether the state label is 1 or 0 (red or green).

The On Entry Request trigger checks the state label and returns TC_ON_ENTRY_REQUEST_QUEUE if the light is red and TC_ON_ENTRY_REQUEST_ALLOW if the light is green.

In the On Message, when the light turns green, it calls the following code to release any requests that are currently pending:

int numWaiting = trafficcontrolinfo(current, TCI_NR_ENTRY_REQUESTS);
for (int i = numWaiting; i >= 1; i--) {
	trafficcontrolinfo(current, TCI_ALLOW_ENTRY, i);
}


Phil BoBo
Sr. Manager, Software Development
0 Likes