Codesys and gateway integration

Topics about the Software of Revolution Pi
daniel.correa
Posts: 14
Joined: 27 Nov 2020, 15:19

Codesys and gateway integration

Post by daniel.correa »

Hello, hope you're doing fine.

I have two quick questions about RevPi's integration with Codesys.

Just a quick overview of what I've already achieved:
- The system is Profibus gateway <----> RevPi Connect as Profinet master. The system will be used to simply mirror input to output on both ends. I could establish connection on both ends and I was able to mirror a single byte on both networks. Everything worked fine.

The questions are:
1- The gateway module supports up to 488 inputs and/or outputs. Since the customer's application is scalable, he needs 244 inputs and 244 outputs, working with the gateway's entire memory region. In pictory I don't have access to all 488 bytes, only a few of them. How can I configure the gateway module in Pictory to allow access to all inputs and outputs? I currently have access from Input_1 to Input_16 and Output_1 to Output_16.
2- Is there an effective way to mirror the entire memory region in codesys? On the official Revolution Pi library, I could only find the block to read/write a single byte from the process image.

Thank you for your time. If you have further questions, please let me know.
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: Codesys and gateway integration

Post by dirk »

Hi daniel.correa, there is a feature in PiCtory which is called "variants".
switch variant
switch variant
2020-11-30 11_56_09-PiCtory - 1.4.7.jpg (20.13 KiB) Viewed 8804 times
Then you unfortunately seem to have 512 bytes for input and output.
changed variant
changed variant
2020-11-30 11_56_33-PiCtory - 1.4.7.jpg (18.24 KiB) Viewed 8804 times
And the output also also switched to "512".
244 bytes in PiCtory details
244 bytes in PiCtory details
2020-11-30 11_57_05-PiCtory - 1.4.7.jpg (33.54 KiB) Viewed 8804 times
You have now access to the Profibus Gateway IO data.
But as of Profibus specification definition you can just use up to 244 bytes of input and output.

We can enhace this in the future so that there are just 244 bytes for input and output instead of 512.

I'll have a chat with the team regarding the question about Codesys block of data read / write.
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: Codesys and gateway integration

Post by dirk »

Hi for your question on codesys
2- Is there an effective way to mirror the entire memory region in codesys? On the official Revolution Pi library, I could only find the block to read/write a single byte from the process image.
you need an updated version of the RevPi Library. It is not officially released but it includes this feature. I'll contact you via PM.
daniel.correa
Posts: 14
Joined: 27 Nov 2020, 15:19

Re: Codesys and gateway integration

Post by daniel.correa »

Hello Dirk,

Thank you very much for the information. I will try to implement this changes and will give you feedback ASAP.

Best regards
daniel.correa
Posts: 14
Joined: 27 Nov 2020, 15:19

Re: Codesys and gateway integration

Post by daniel.correa »

Hello Dirk,

[EDIT] Issue number 1 is not an issue anymore. The problem is that Pictory included and extra underscore character on all variables' names (e.g. Output__1 instead of Output_1). I can read/write variables as expected now using piTest

I could successfully install the package on Codesys, configurated the Profibus gateway on both pictory and Codesys. Kernel is updated according to the instructions given on the sent PM, Codesys' version is 3.5.16.30 and the Raspberry control for Codesys is version 3.5.16.20. I ran into two issues

Issue number 1 [SOLVED, according to EDIT]:
When i configure 512 Inputs / Outputs and reset the driver, I can't read (piTest -r Input_1) or write (piTest -w Output_1,1) values using piTest (the variables' names are according to the configured in Pictory). It says that the variable can't be found. The issue is totally solved after changing again to 20 Inputs/Outputs.

Issue number 2:
Codesys returns "No driver found" status for the Profibus Gateway, as shown on the image below, and it's independent from the number of inputs and outputs configured in Pictory. The Profinet slave (Icaro_A4) is not currently connected to the Revolution Pi. I can read and write the Input/Output variables without issues using piTest, and the Profibus works as expected.
nodrivefound.png
nodrivefound.png (42.29 KiB) Viewed 8752 times
Pictory configuration:
pictory.png
pictory.png (184.94 KiB) Viewed 8733 times
Any thoughts on these issues?

Thank you.
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: Codesys and gateway integration

Post by dirk »

Hi, here some ideas - the Gateway Icon shall be in Green state when the Gateway is in Op state.
Check the Module State parameter found under Revolution PI Extension Bus I/O Mapping

0x00 Physically Offline
0x01 Physically connected but no Communication
0x02 Standy/Ready(PreOp)
0x03 Cyclic Data exchange Active(Op)

Find if Gateway is Present with

Code: Select all

piTest -d
Send RevPi Codesys Log mentioned in Troubleshooting chapter of RevPi Codesys Help Documentation (chm file)
daniel.correa
Posts: 14
Joined: 27 Nov 2020, 15:19

Re: Codesys and gateway integration

Post by daniel.correa »

Hello Dirk,

piTest -d is currently returning:

Code: Select all

pi@RevPi1002748904:~ $ piTest -d
Found 2 devices:

Address: 0 module type: 105 (0x69) RevPi Connect V1.0
Module is present
     input offset: 1024 length: 6
    output offset: 1030 length: 5

Address: 31 module type: 77 (0x4d) Gateway Profibus V1.0
Module is present
     input offset: 0 length: 244
    output offset: 512 length: 244
Module state under Gateway_PROFIBUS > Module state = 0x00

I've noticed, when I login from Codesys with Download, the Profibus module vanishes from piTest -d (it was there before logging in from Codesys).

The logs requested:
log_picontrol.png
log_picontrol.png (83.67 KiB) Viewed 8646 times
log_iodrvrevpibridge.png
log_iodrvrevpibridge.png (35.91 KiB) Viewed 8646 times
Thank you for your time
User avatar
Amar
KUNBUS
Posts: 160
Joined: 15 Jul 2019, 12:58

Re: Codesys and gateway integration

Post by Amar »

Hi,
I've noticed, when I login from Codesys with Download, the Profibus module vanishes from piTest -d (it was there before logging in from Codesys).
This is because:
RevPi Codesys Project downloads a new config.rsc file (The one created by pictory) on application startup. Therefore one shall not use pictory to create a configuration when using Codesys.


You must already have been able to access process image area for Gateway through Codesys application. You can verify that using piTest -r to read certain bytes at a offset.
Eg: you can write certain values to Q_GW channel in codesys application and verify with piTest -r whether they are written to the concerned Process image offset using piTest -r
I_GW channel and Q_GW channel in codesys for input/output of the gateway are each 512 bytes.

Offset list
Input_0_1 0 //BYTE
Input_0_20 19 //BYTE
Output_0_1 512 //BYTE
Output_0_20 531 //BYTE
RevPiStatus 1024 //BYTE
RevPiIOCycle 1025 //BYTE

Module state under Gateway_PROFIBUS > Module state = 0x00
means the Gateway is offline and offline LED shall be blinking with RED color. Refer Gateway documentation inorder to get gateway in Online mode.

Regards,
Amar
KUNBUS
daniel.correa
Posts: 14
Joined: 27 Nov 2020, 15:19

Re: Codesys and gateway integration

Post by daniel.correa »

Hello Amar,

There are no red (or blinking) leds on the Profibus gateway. I can stablish communication with it with a Profibus master without any issues. The Power and Online leds are solid green.

When i reboot Revolution Pi, or download via Codesys, piTest -d doesn't show the Profibus gateway, only the Revolution Pi connect. Codesys returns a "No driver found" message on "Revolution Pi Extension Extension gateway". Looks like codesys is not downloading the correct _config.rsc file into RevPi.
codesys_nodriver.PNG
codesys_nodriver.PNG (6.94 KiB) Viewed 8598 times
Some more details:
codesys_pou.png
codesys_pou.png (34.09 KiB) Viewed 8598 times
codesys_profibus_memory.PNG
codesys_profibus_memory.PNG (17.68 KiB) Viewed 8598 times
I can read all parameters from RevPi connect, but no parameters from the gateway are updated.

When i configure the Profibus gateway on Pictory, i can read and write every single memory position using piTest. Codesys still doesn't recognize the module.
User avatar
Amar
KUNBUS
Posts: 160
Joined: 15 Jul 2019, 12:58

Re: Codesys and gateway integration

Post by Amar »

Hi,
Can you please carry out following steps.
1) Codesys Application download
Login with download
Update boot application checkbox should be selected

2) In codesys device tree select the root device Connect and right click for scan for devices
RevPi Connect -> Scan for devices
Check if Gateway PROFIBUS is found at Left
(That means the Gateway module is physically present)
At this state the Flags for bus should be as in figure below:
gateway.png
gateway.png (6.16 KiB) Viewed 8457 times
At this moment ,the Module not found flag can be ignored. Also R/W access to Gateway in process image is possible.

3) Use piTest -d
to see if Gateway PROFIBUS is present

4) If piTest -d also shows profibus module present, then try accessing memory of Gateway from codesys application and verify with piTest. (Ignore Module not found flag).

5) Read the ModuleState parameter value in Codesys.

Regards,
Amar
KUNBUS
Post Reply