Objective: Run a simple traffic light circuit with CODESYS on a RevPi and visualize it with CODESYS WebVisu in a web browser.
The application simulates a traffic light system with two operating modes:
-
In normal mode, the red and the green light are each active for 10 seconds. The yellow light serves as a transition for 2 seconds.
-
In night mode, only the yellow light flashes.
The tutorial applies to the base modules of the RevPi Connect series and the RevPi Core series.
The preprogrammed example project with RevPi Connect S as base module is available in a GitLab Repository. It can be adapted to all RevPi base modules.
Prerequisites #
Devices
✓ Base module of the RevPi Connect series or the RevPi Core series
Hardware Installation
✓ RevPi is connected to the network.
✓ RevPi is connected to the power supply.
Software Installation
✓ CODESYS Development System (CODESYS) is installed on your PC.
✓ CODESYS runtime is installed in the CODESYS Development System.
✓ RevPi I/O driver is installed in the CODESYS Development System.
✓ CODESYS is connected to the RevPi.
✓ CODESYS runtime is installed on the RevPi.
See also Setting Up the CODESYS System with RevPi.
1. Opening the Example Project #
▷ Download the example project TrafficLight-WebVisu from the GitLab Repository.
▷ Open the example project in CODESYS.
❯ The example project opens with the preprogrammed traffic light control and the associated web visualization.
Setup in the CODESYS device tree:
▷ If necessary, adapt the project to your actual RevPi base module.
The example project contains a RevPi DIO in the CODESYS device tree. A physically connected RevPi DIO is not required for visualizing the traffic light circuit with WebVisu.
Optionally, you can use a RevPi DIO or RevPi DO to control an external traffic light via digital outputs in addition to the web visualization. The principle of controlling an output is described in the tutorial Blinking Light.
2. Downloading and Starting the Application #
▷ Select Generate Code (F11) in the menu bar to compile the program.
▷ Open the root device.
▷ Select Scan Network in the Communication Settings.
▷ Select the RevPi and establish the connection to the device using OK.
▷ Select Login (Alt+F8) in the menu bar to log in to the RevPi.
▷ When you log in for the first time, create a user by following the wizard and entering your login details.
▷ In the Device User Logon window, log in to the RevPi.
▷ The first time, confirm the download of the application to the RevPi by Yes.
❯ The application is transferred to the RevPi and is ready to run.
▷ Select ⯈ (F5) in the menu bar to start the application.
3. Accessing the Web Visualization #
▷ Open a web browser on a device that is in the same network as the RevPi.
▷ Identify the IP address of your RevPi.
▷ Access the web visualization:
http://<revpi-ip-address>:8080/webvisu.htm
❯ The web visualization of the traffic light circuit is displayed.
4. Testing the Traffic Light Circuit #
Normal Mode
▷ Activate normal mode.
❯ The red and the green light are each active for 10 seconds.
❯ The yellow light is active for 2 seconds during the transition.
Night Mode
▷ Activate night mode.
❯ In night mode, only the yellow light flashes.