Labview project --- traffic signal light simulator

tags: Labview  simulation  

Project Introduction

This article contains an introduction on how I designed and used this traffic signal simulator. The traffic light simulator simulates traffic lights and vehicle flow in four different directions at an intersection. There are three lights that simulate real traffic lights in each direction, and the order of the lights is green, yellow and red. The duration of the green light and red light can be controlled by two traffic light flow control devices. When the number of vehicles on one road is significantly higher than the number of vehicles on the other road, traffic managers can control the duration of the signal lights to avoid congestion at the intersection. The traffic flow on the road is simulated by optical flow. The program contains the speed control function to control the distance between vehicles. The higher the speed, the smaller the distance between vehicles. The program also contains an emergency button. When the emergency button switch is turned on, all the yellow lights at the intersection are on. When the yellow light is on, all cars should be waiting at the intersection.

Front Panel


The background image simulates a realistic intersection. A total of 12 round LED lights represent traffic lights, and 20 square LED lights represent traffic flow. The lower left corner is the control vehicle travel interval, high interval means low vehicle speed. On the right is the emergency switch button, we can use this button to switch to the emergency state. There are two STOP buttons in the lower right corner, which control the traffic lights in the east-west direction and the north-south direction respectively. On the left is W-E traffic flow control. This button can control the duration of the green light in the W-E direction and the duration of the red light in the other direction. The upper right corner is the N-S traffic flow control. This button can control the duration of the green light in the N-S direction and the duration of the red light in the other direction.

The three upper right LED lights are traffic lights in the W-E direction, the upper left three LED lights are traffic lights in the S-N direction, the lower left three LED lights are traffic lights in the E-W direction, and the lower right three LED lights are traffic lights in the N-S direction.

Block Diagram

Block diagram is mainly composed of five parts.

The first part is 12 round LED lights, 20 square LED lights and four controllers.

The color and size of each LED light should be set in the properties. I set the scale range of traffic flow to 5-30 and the moving interval of the car to 1-5. For the emergency button, set the default value to true to meet the following logic requirements.

The second part is the realization of the light function in the W-E direction.

From the figure, we can see that there is a while loop outside, a stacked sequence in the while loop, and a for loop in the first frame of the stacked sequence. The second part is the setting of two-way light control (W to E and E to W). There are a total of 6 frames (0-5) in this stacked sequence.
The above picture is frame 0, and the following pictures will show frames 1 to 5 in this stacked sequence:

1-2 frames:
3-4 frames:

Frame 5:

For the first frame (frame 0) of the stacked sequence, there are six local variables for lights, one local variable for traffic flow control, one local variable for emergency events, and one time delay in the For loop. When traffic flow control gives a number, such as 30, 30 is divided into 150 cycles, and then assigned to delay, which means that each cycle uses 0.2 seconds. Create an iterative terminal to the for loop, and when the urgent Boolean value is true, continue to the next loop. When the emergency button is switched to false, after this loop (0.2s), the entire for loop will stop and the stacked sequence will go to the next frame (frame 1).

In the first frame, the local variables of the emergency event control a case structure. When the emergency bool value is true (emergency status is off), true does nothing and jumps directly to the next frame (frame 2), but if the emergency bool value is false (emergency status is on), yellow The light starts to light up (the bool value of the yellow light is 0.5s true and 0.5s false), and a while loop is used to keep the yellow light on until the bool value of the emergency state becomes true (the emergency state is off).

The second frame is the duration of the yellow light for 1s, which is used for the for loop to check whether emergency switching has occurred (0.1s once, 10 times in total).

In the figure, we can see that the third frame has the same structure as the first frame. Use the emergency bool value to control the case structure. True does not perform any operation, and the False yellow light flashes. If the emergency bool value changes to True, it will stop to the next frame.


The fourth frame is the red LED light control. Different from the green control, we need to add 1s to the red light time input, because there is no yellow light after the red light. In order to achieve the balance of the entire 4 directions, we need to set the red light duration Add 1s. Therefore, the duration of the red light should be equal to the duration of the green light plus the duration of the yellow light. Using N-S traffic flow control means that the green light in the other direction is on at this time.


Frame 5 is the same as frame 3 and frame 1. After this frame, the next frame is frame 0 (because of the while loop).

The third part is the realization of the lighting function in the N-S direction

The third part has the same logic and format as the second part. The north-south light function controls 6 lights in the north-south direction. The 6-frame layout of the stacked sequence is: red light control -> (emergency) -> green light control -> (emergency) -> yellow light control -> (emergency).

The fourth part is the realization of the car light function in the W-E direction

From the figure, we can see that there is a stacked sequence in the while loop. The stacked sequence has 6 frames. The first frame (frame 0) has 6 local variables for car LED lights. The Boolean values ​​(ew1 and we) of the lights in the W-E direction are set to true, and the other lights are set to false. Take the local variable of the vehicle movement interval as input to control the delay time of the vehicle.

The picture above is the second frame (frame 1) of the stacked sequence. I set the lights we2 and ew2 to be true, and the other lights are false.

The first two lights are before the intersection (ew1, ew2, we1, we2). After the second light, I set up a case structure to choose whether to let the car continue or wait before the intersection. From the figure, we can see that there is a for loop in the case structure. When the bool value'green light' and emergency in the WE direction are both true (emergency status is false), we switch to the true case structure and do nothing, and then Skip to the next frame and let the third light turn on (ew3, we3). But when one of the bool values ​​is false, we will go to the false situation and keep the second light on (ew2, we2 keep true simulates the car waiting for the green light to turn on). Although I think it is sufficient to only check the green light, because when the emergency is true, the green light must not be on, but I still do this for double insurance.

In the case of an error, I set up a for loop, I set the maximum waiting time to 300s (the emergency state may be very long), and then divide it by 1500 cycles (0.2s per check). When the green light and emergency in the W-E direction are both true, the for loop is terminated and we enter the next frame.

The next 3 frames control the third (ew3, we3), fourth (ew4, we4) and fifth (ew5, we5) lights respectively, the format is shown in the figure.

The last part is the realization of the car lighting function in the N-S direction

The layout of the N-S direction lamp function is almost the same as the W-E direction lamp function, the only difference is that the N-S direction lamp function controls 10 lights in the N-S direction.

design description

Front Panel design:

According to the requirements of each step, create 12 lights to simulate traffic lights, create 20 lights to simulate traffic flow, and add 3 controls to control traffic flow, vehicle interval time, and emergency status. Use real intersection graphics as the background to adjust the size to make it more user-friendly.

Block Diagram design:

The hardest part in the Block Diagram is to stop the stacked sequence or flat sequence immediately. I tried many ways to abort the sequence outside, but they all failed. The sequence must complete that round. Therefore, the only way to achieve "immediate" is to stop inside the sequence, so for loops and case structures have become my effective tools. Use a for loop to divide the time into very many parts, such as 0.2 seconds or 0.3 seconds, to achieve the "immediate" operation. When designing a traffic flow simulation, the key is the inspection before the intersection, because when the vehicle passes through the intersection, it will not be affected by the traffic lights. It is a good way to use the status of the relevant green light to make logical judgments. Only when the bool value of the green light is true can the vehicle pass through the intersection. Using the for loop can help jump out of the for loop.

Instructions

According to the above figure, first, select the appropriate traffic flow control for each direction, and secondly, select the vehicle travel interval, and then start the simulation. When an emergency occurs, pull down the emergency control lever, all yellow lights start to light up, and all cars are waiting at the intersection. When we want to stop in a specific direction of a traffic light, press the corresponding stop button on the right.

Intelligent Recommendation

Proteus vsm Studio compilation +traffic signal light simulation

Proteus vsm Studio compilation +traffic signal light simulation Proteus vsm demonstration and simulation process Based on Proteus vsm Studio compilation code (.sm) Simulation resources and program sou...

Traffic Signal Light Automatic Control Analog Indication System

1. Purpose of the experiment 1. Master the connection method between the CPU and each chip pin, and improve the connection ability of the interface expansion hardware circuit. 2. Deepen the understand...

Easy Language-Traffic Light Project Tutorial Show

 Source link Program link  ...

Labview ECG signal processing

Using LabVIEW as a development platform, a set of virtual ECG data analysis system is designed, which has the functions of ECG signal processing and analysis, waveform display, heart rate display and ...

traffic light

Send monkeys to the reinforcement   What is a ghost One day rushed to the crossroads, but just become a red light, wait 20 seconds. Then a dozen intersections, wanted the red light waiting for 20...

More Recommendation

Signal light

#include <stdio.h> #include <unistd.h> #include <limits.h> #include <errno.h> #include <string.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/w...

Single-chip small project --- traffic light remote control system

table of Contents   1. Course design goals and tasks: 2. Design requirements: 3. Resource content: 4. General design drawing 1. Course design goals and tasks: Through the course design, the follo...

Microcontroller (ISIS 7 Professional): Simple traffic light code project

This article mainly introduces a simple traffic light to flash in red, yellow, and green order with C language. The software used is:ISIS 7 Professional、Keil uVision2 The basic circuit diagram is as f...

Arduino Basic Project 3: Making traffic signal lights

1. Project description When the button is pressed, Arduino will automatically react to change the state of the traffic light, let the car stop, and allow pedestrians to pass. 2. The required component...

Labview sound signal collection and separation

1 Procedure requirements Collect the sound of a certain musical instrument (guitar, flute, erhu, violin, harmonica, etc.) in a quiet environment, or the pronunciation of a certain character (or differ...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top