Codesys#Using PI4 as a Profinet Device

In this Tutorial I will explain how to configure a Profinet Device in the Raspberry pi4 where Codesys runtime is installed .

Export the GSDML

If we need to configure the Profinet network, a GSD file is necessary. You can image it as a XML Files.

Go to Tools>Devices Repository.

image.png


If we need to configure the Profinet network, a GSD file is necessary. You can image it as a XML Files.Go to Profinet IO>Profinet IO Devices>Codesys Profinet Device and click the Export button to output your GSD Files.

image.png

zip files are exported.

image.png

After unzipping, we can see 2 xml files.

image.png

Configuration

This time Siemens TIA Engineering tools  is using it to configurare the profinet.

GSD Install

Go to Options>Manage general station description (GDS).

image.png

Choose the XML file that we unzipped, and check the GSD files inside, press install.

image.png


Network Configuration

On the right side, choose Field devices>PROFINET IO>I/O>SS-Smart Softwarexxxx>CODESYS>CODESYS Profinetxxx and Drop it into the network view.

image.png

Right Click the device that we inserted , and choose Assign to new IO controller.

image.png


Profinet is configured in the TIA Project.

image.png

Device setting

Although we inserted the device inside our profinet network, some configuration setting is necessary.

Insert Submodules

In the TIA Project Click the Profinet device that we inserted before , and switch to device view.

image.png


IP and Device Name setup

Device name and IP are necessary for Profinet.While the Controller is changed from Stop to Run, the Profinet Controller will assign the IP address for all Profinet devices, base on their device name.

image.png


ModulesUpdate Cycle

The Engineering Tools of Siemens will auto calculate the update cycle time and we do not need to care too much.image.png

Codesys Project Setup

Now it is the time to set up the Codesys Side.

Profinet Devices setup

Go to Ethernet(Ethernet)>Add Device..

image.png


Select Profinet IO>Profinet IO Devices>CODESYS Profinet Device.

image.png

A Profinet device is inserted in our project.

image.png


Now we need to set up the Data Exchange Area.
Go to CODESYS_Profinet_Device>Add Device.

image.png

Let’s choose Input/Output> In/Out 64 Bytes and press Add Devices to insert it.We need to use the same setting on both Controller and Device side.

image.png


64 Bytes In/Out is inserted.

image.png


Device Setting

In Profinet , Device name is necessary.Please make sure to set it and assign it from the Engineering tools.

image.png

Symbol

Finally I would like to configure the Symbol of these 64 bytes in/out.It is not a must step but variables with good names are better for everyone.

GVL

Let’s define a 64 bytes size array.

image.png


Assgin

configure the Symbol of these 64 bytes in/out.It is not a must step but variables with good names are Let’s assign these variables from the Symbol to your profinet IO.fGo to the InOut_64_bytes>Profinet Device Module I/O Mapping> and click the … button to assign it.
Please be careful, Q is the output area and I is the input area.All these input/output are in the Controller view – it means that the “input” are the inputs to Controller and “Output” are the output from Controller to your PI Devices.

image.png


Program

are the inputs to Controller and “Output” are the output from Controller to your PI DeviceNo just in Codesys but also Beckhoff, all the variables if you do not use inside your program,the values will not update.Please make some simple program.

image.png

PI4 Setup

You can get more information from this link: https://help.codesys.com/webapp/_pnio_runtime_configuration_device;product=core_ProfinetIO_Configuration_Editor;version=3.5.16.0

/etc/CODESYSControl_User.cfg

insert the following code.

[SysEthernet]

QDISC_BYPASS=1

Linux.ProtocolFilter=3

[SysSocket]

Adapter.0.Name=”eth0″

Adapter.0.EnableSetIpAndMask=1

/etc/dhcpcd.conf

interface eth0 static ip_address=0.0.0.0

Install the Vlan

sudo apt-get install vlan  # Install VLAN package

sudo modprobe 8021q        # Load 8021q kernel module


Start UP

Open the TIA  and press the ? button.

image.png

Choose the network interface that you are connecting to and start serah..image.png


you can see which devices are visible in your network.

image.png

Right Click the Devices and press Assign device name.

image.png

Choose the interface that you are connected into network, press update list.

image.png

 Choose your raspberry devices and press the assign name.

image.png

The profinet connection is established.

image.png


Notes

If you login to the Codesys runtime, a green icon is shown while the device is connected to the controller.An also the statues are shown Online and IP active as TRUE.

image.png

And also in the Ethernet Tab, you can view the alarm message and current status.

image.pngResult

image.png

Send

setAllFromMaster.gif

Receive

getFromMaster.gif

Footer_Basic

Please Support some devices for my blog

Amazon Gift List

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする