CODESYS is a leading manufacturer-independent IEC 61131-3 integrated automation software development environment for programming controller applications.
In this demo we will use Codesys Development System V3 software as IDE to config and program a project running on Elastel EG500 and EG410, to trigger a lamp on and off via DO port on device.
The conclusion is, the CODESYS is perfect compatible with Elastel Industrial Raspberry Pi products.
Powered by Raspberry Pi CM4, Designed as high-scalability and rugged industrial-grade hardware, rich I/O and connectivity options , and with the great Raspberry Pi software ecosystem compatibility, Elastel industrial Raspberry Pi series EG500 and EG410 are perfect as Edge Computer, IoT Gateway, Industrial Controller… for any kinds of your IIoT applications.
Featured Products
Please visit the CODESYS Development System V3 download page to download the CODESYS Development System V3 software according to your Windows PC Host computer, setup and follow the installation wizard to install the program.
Open the CODESYS Installer by click on “Tools> CODESYS Installer…”
Click “Browse” and search “CODESYS Edge Gateway for Linux”, then Install it after “accept the license agreements”
Note, you may need close CODESYS Development System V3 software as required during package installation, otherwise you will get warning as below:
Click “Browse” and search “CODESYS Control for Raspberry” and Install it after “accept the license agreements”
Click the “Install” button to install the “CODESYS Control for Raspberry Pi runtime” package into EG500.
Login credentials
Username: pi
Password: raspberry
Select Target:
IP Address: 10.0.0.10 ## (in this demo, the EG500 IP is 10.0.0.10, while EG410 is 10.0.0.16)
CODESYS Runtime Package:
Version: 4.7.0.0-b.truck.39 (raspberry, armhf)
Click “Start” at the “Runtime” section, and then check the “Messages” windows state that “Standard output: codesyscontrol already running”
Open the CODESYS Development System V3 software and select “File>New Project…” or click “New Project…” on Basic operations menu.
In this demo, we created a “Standard project” in templates, and named it “DO0-Test”, Click OK.
A typical user interface you should get after success setup a new project on Codesys IDE.
Double click the “PLC_PRG” tab at the left column menu, on PLC_PRG program page, create three variables that “Start”, “Stop” and “Lamp” as BOOL type.
And add Ladder Elements “Contact”, “Negated contact”, “Parllel contact”, and “Coil” items from right column ToolBox menu.
Click the “???” symbol upon element and “…” button, select the relevant variable in pop-up window. In this case,
Assign “Start” variable for “Contact” element,
Assign “Stop” variable for “Negated contact” element.
Assign “Lamp” variable for “Parallel contact” and “Coil” elements.
The completed settings would like below screenshot.
Select and right click “Device” tab at left column menu, -> “Add Device…”, on pop-up window, “Miscellaneous” -> “GPIO”, and click “Add Device” button.
The “GPIO (GPIO)” device will be added on the device tab list.
Right click GPIO to add 1 bit GPIO device. Following steps like “Add Device…” -> “Miscellaneous” -> “GPIOs 1 bit”, then click “Add Device” button.
Double click “GPIOs_1_bit (GPIOs 1 bit)” tab to open the GPIO setting page.
At first tab “GPIOSysfsModuleParameters”, config and assign the GPIO Direction, Pin Number and current PIN state.
In this case we will rely DO0 port on EG500 to toggle the Light on/off, which the DO0 port GPIO Pin number would be 22 according to EG500 admin guide.
While on EG410, we will use DO1 port to toggle the light, which the DO1 GPIO Pin number would be 24,
At tap “GPIOSysfsModule I/O Mapping”, assign the variable “Lamp” to GPIO out channel.
The operating steps like below screenshot.
After finished the GPIO configuration, CTRL+S save the settings.
Right click the Application tab in left column menu,
Following Application -> Add Object -> Visualization…, like below screenshot.
Active VisuSymbols (System) and “Add”,
Add two Buttons and a Lamp on Visualization configuration page to simulate and operate the Lamp light on and off.
Click “Visualization Toolbox” tab at the bottom of right column, drag and drop two “Button” from “Common Controls” section,
And drag and drop a “Lamp” from “Lamps/Switches/Bitmaps” section,
Config the Buttons name on Text value at “Property” -> “Texts” -> “Text”.
And assign its variable from “Property” -> “Input Configuration” -> “Tap” -> “Variable”.
In this case, the left button will be named “Start”, and assigned variable “Start”, operating steps like below screenshot,
The right button will be named as “Stop”, and assigned variable “Stop”, like below screenshot,
The Lamp symbol will be assigned variable “Lamp”, like below screenshot,
After finished the Visualization configuration, CTRL+S to save the project.
Double click the “Device” tab in left column menu, click “Scan Network” to search the device you are operating, in this case, select the found device “Elastel-EG500” to connecting.
You can also manually add the device with its IP address in case you knew it.
Following steps “Device >> Options >> Manage Favorite Devices… >> Add”, then input the device IP address (in this case the EG500 IP address is 10.0.0.10).
It will ask you input the login credentials username password when connecting to device.
The below screenshot shows the device (Elastel-EG500) was successfully connected.
Press F5 to run the project on device.
On EG500, we rely on the DO0 port to perform the light control, and the V-, V+ power output ports will be used as DC Power for Lamp. The wiring would like,
On EG410, we rely on the DO1 port to perform the light control, and bridge the power supply ports as DC power for Lamp. The wiring would like,
Test operation on EG500
When project status running, on Visualization page, click “Start” button, the Lamp on visualization will be turned on, meanwhile the light wiring on EG500 will be turned on as well. Like below test result recording,
When click “Stop” button, the Lamp will be light off at same time both in visualization and EG500 side, as below test result recording.
Test operation on EG410
When click “Start” button, the Lamp will be light on at same time both in visualization and EG410 side, as below test result recording.
When click “Stop” button, the Lamp will be light off at same time both in visualization and EG410 side, as below test result recording.
You can also operate the Visualization UI from web by accessing the IP address of EG500/EG410 device, with the 8080 port, like http://10.0.0.10:8080, as below test result recording.
Above demo conclude that CODESYS system is perfect compatibly running on Elastel industrial Raspberry Pi series products for your industrial applications.
Please contact with Elastel sales engineers [email protected] for more Raspberry Pi solutions on Elastel industrial Raspberry Pi products.