Skip to main content
  1. Automation/

Connecting Codesys with FactoryIO via TCP/IP Protocol

3 mins· loading · loading · ·
Automation codesys FactoryIO
Hamouni Abderrezak
Author
Hamouni Abderrezak
HSE | Maintenace Engineer
Table of Contents

Codesys is widely used software in various PLC systems and has been adopted by many manufacturers. Its main advantage for learning purposes lies in its cost-free nature and lightweight hardware requirements.

1- What is TCP/IP:
#

TCP/IP: (Transmission Control Protocol/Internet Protocol) is a suite of communication protocols used to interconnect network devices on the Internet and other computer networks. It provides reliable, connection-oriented communication (TCP) and a routing mechanism (IP) to ensure efficient transmission of data packets between devices across diverse networks.

1-1- Why is it used in Automation?:
#

Reliability: TCP/IP ensures dependable data transmission, crucial for maintaining accuracy in automated processes.

Scalability: Adaptable to varying automation system sizes, from local setups to large distributed networks.

Compatibility: Works seamlessly with diverse devices and technologies, promoting interoperability.

Widespread Adoption: Widely used across industries, providing a standardized communication framework.

Efficiency: Facilitates efficient data exchange, optimizing automation workflows and enhancing productivity.

1-2- Safety Aspect of TCP/IP in Automation
#

Reliable Communication: Ensures accurate data transmission, critical for safety-critical systems.

Real-Time Monitoring: Enables swift response to hazardous conditions, preventing accidents.

In God we trust, all others must bring data.

W. Edwards Deming

Fault Tolerance: Includes error detection and correction mechanisms, enhancing system reliability.

Integration with Safety Standards: Complies with SIL, SIS, and other safety protocols, ensuring adherence to regulations.

Secure Communication: Supports encryption and authentication, safeguarding sensitive data from cyber threats.

Overall, TCP/IP protocols contribute to risk assessments in automation by providing valuable data for analyzing network performance, cybersecurity risks, interoperability, fault detection, and other factors that may impact the safety and reliability of the automation system.

2- Configuring Codesys:
#

  • First, let’s create a standard project named “Lights” using ladder logic programming.
Lights

Lights

  • Choose the coding language, for which I selected Ladder Logic.
Laddar Logic

Laddar Logic

2-1 Adding Ethernet device
#

Now, add a device to support Communications. First, add an Ethernet Device, and underneath, choose TCP/IP as a slave

Add Device

Add Device

choosing Ethernet

choosing Ethernet

slave TCP/IP

slave TCP/IP

2-1-1 TCP_IP_slave Mapping:
#

In the settings of TCP/IP module under device I/O mapping we will add our Input output one by one :

Mapping I/Os

Mapping I/Os

3- starting a project in FactoryIO:
#

Now, let’s begin a project in FactoryIO and add three push buttons:

  • Start Button with Green Light
  • Stop Button with Red Light (it is normally wired as NC)
  • Reset Button with a Yellow Light

After that, navigate to Driver and select TCP/IP client, mapping the inputs as coils and outputs as inputs in FactoryIO.

Push Puttons

Push Puttons

FactoryIO Configuration

FactoryIO Configuration

4- Start Programming
#

Return to Codesys and start programming the lights: we have 3 inputs :

  • Start
  • Stop
  • Reset

keep in mined that the “Stop Button” is mounted NO “Normally Open” so its state in programming will be the opposite to other buttons.

we will write a simple program to make each light turn on when its push button is pressed, the start light and the stop light will be indicators of the state of the machine so we will make them remain ON until a we change the state or the reset button is pressed.

network Lignes

network Lignes

Screenshots of “Codesys” by “Hamouni Abderrezak” in “windows 10”

These lines are used to activate the light when the button is pushed.

4-1- Execute Simple Program
#

Execute the simple program to check if the connection is working. The connection used is TCP/IP protocol between Codesys and FactoryIO; thus, we need to manually assign every input and output, unlike Tia Portal, which can be done automatically by importing the XML file exported from FactoryIO.