Setting up Connect+ with Modbus on CODESYS

Topics about the Software of Revolution Pi
Nikolai
Posts: 8
Joined: 20 Mar 2020, 17:17

Setting up Connect+ with Modbus on CODESYS

Post by Nikolai »

Hello,

I'm trying to set up a Connect+ with Modbus and the AIO and DIO module. I haven't purchased the modules yet, as I want to test the feasibility of running CODESYS on the RevPI.

I followed this guide to flash the CODESYS runtime to the RevPi: https://revolution.kunbus.com/tutorials ... einbinden/

So far so good, and I'm able to connect and deploy and run code. I've attached a few screenshots to show the setup.

Now I am stuck. I feel there is a lack of guides online, and I'd like some help to move forward. My aim is to do this in four stages:

1) Prove that I can turn the LEDs and relay on the Connect+ on/off
2) Read Modbus TCP signals from my Teltonika GPS router
3) Purchase and set up the AIO and DIO modules and prove that I can receive and send signals
4) Develop the control system

My question for now is related to step 1:

Why am I not able to turn the LEDs on/off? What am I doing wrong?
Attachments
Screenshot 2020-07-02 at 11.01.16.png
Screenshot 2020-07-02 at 11.01.16.png (372.82 KiB) Viewed 8829 times
Screenshot 2020-07-02 at 11.00.35.png
Screenshot 2020-07-02 at 11.00.35.png (395.17 KiB) Viewed 8829 times
User avatar
Amar
KUNBUS
Posts: 160
Joined: 15 Jul 2019, 12:58

Re: Setting up Connect+ with Modbus on CODESYS

Post by Amar »

Hi Nikolai,
Here is a sample project which would be of use in your Application concept.

You need to export appropriate offsets in GVL list of codesys.

Rev Pi LED's info:
https://revolution.kunbus.com/tutorials ... rect=en_US

Attachment:
RevPiConnectImageTest.zip
(412.89 KiB) Downloaded 678 times
Regards,
Amar
KUNBUS
Nikolai
Posts: 8
Joined: 20 Mar 2020, 17:17

Re: Setting up Connect+ with Modbus on CODESYS

Post by Nikolai »

Hi Amar,

That's great I'll try it out .

In the meantime, are you able to explain what the "offset" means? Is it an offset in time? I don't understand the purpose?

Thanks,
Nikolai
Nikolai
Posts: 8
Joined: 20 Mar 2020, 17:17

Re: Setting up Connect+ with Modbus on CODESYS

Post by Nikolai »

Hi Amar,

So I think I have understood that the "offset" is specifying the location of the individual modules - am I right?

I managed to set up your image test, but I still cannot turn the LEDs on and off.

What am I doing wrong?

Thanks,
Nikolai
Attachments
Screenshot 2020-07-05 at 16.42.21.png
Screenshot 2020-07-05 at 16.42.21.png (169.1 KiB) Viewed 8456 times
Screenshot 2020-07-05 at 15.59.38.png
Screenshot 2020-07-05 at 15.59.38.png (554.04 KiB) Viewed 8456 times
User avatar
Amar
KUNBUS
Posts: 160
Joined: 15 Jul 2019, 12:58

Re: Setting up Connect+ with Modbus on CODESYS

Post by Amar »

Hi Nicolai,
The example which i send was with following configuration.

pi@RevPi17643:~ $ piTest -d
Found 5 devices:

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

Address: 31 module type: 103 (0x67) RevPi AIO V1.3
Module is present
input offset: 1137 length: 20
output offset: 1157 length: 4

Address: 30 module type: 96 (0x60) RevPi DIO V1.4
Module is present
input offset: 1024 length: 70
output offset: 1094 length: 18

Address: 29 module type: 93 (0x5d) Gateway ModbusTCP V1.3
Module is present
input offset: 0 length: 512
output offset: 512 length: 512

Address: 32 module type: 109 (0x6d) RevPi CON CAN V0.0
Module is present
input offset: 0 length: 0
output offset: 0 length: 0


In your configuration you have a connect device and Modbus TCP virtual module.Your exported pictory offsets for codesys will look like this.

//SYS_PROJECT_TS:20200706102009
VAR_GLOBAL

aby_CPI: ARRAY[0..4095] OF BYTE;

g_uiIn0Offset: UINT := 0;
g_uiOut0Offset: UINT := 6;
g_aui_RevPiStatusOffs: ARRAY[1..2] OF UINT := [0,0]; //
g_aui_RevPiIOCycleOffs: ARRAY[1..2] OF UINT := [1,0]; //
g_auiRevPiLEDOffs: ARRAY[1..2] OF UINT := [6,0]; //
g_uiIn64Offset: UINT := 11;
g_uiOut64Offset: UINT := 112;


END_VAR

You have to update these above variable offsets in your codesys Program in GVL variables.At moment you are writing at different offsets due to different device configuration from pictory.
KUNBUS
Nikolai
Posts: 8
Joined: 20 Mar 2020, 17:17

Re: Setting up Connect+ with Modbus on CODESYS

Post by Nikolai »

Excellent! - thanks, that's working now. I can turn the lights on/off. I understand the basics of the offset now.

Moving on to Modbus I have now added a Modbus TCP module to communicate with a Teltonika 955 router and a Modbus RTU module to communicate with a Carel EVD Evolution driver. piTest prompts:

Code: Select all

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

Address: 64 module type: 24579 (0x6003) ModbusTCP Master Adapter V0.0
Module is present
     input offset: 11 length: 101
    output offset: 112 length: 73

Address: 65 module type: 24580 (0x6004) ModbusRTU Master Adapter V0.0
Module is present
     input offset: 203 length: 101
    output offset: 304 length: 75
I have set up an input in piCtory prompting a temperature of 25.6 degrees

Code: Select all

pi@revpi:~ $ piTest -r EVD_S2
2 Byte-Value of EVD_S2: 256 dez (=0100 hex)
However, how do I get this value into CODESYS? - please note I'm using the g_uiOut65Offset variable
Attachments
Screenshot 2020-07-07 at 18.11.37.png
Screenshot 2020-07-07 at 18.11.37.png (399.24 KiB) Viewed 8185 times
Screenshot 2020-07-07 at 18.11.18.png
Screenshot 2020-07-07 at 18.11.18.png (31.58 KiB) Viewed 8185 times
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: Setting up Connect+ with Modbus on CODESYS

Post by dirk »

Hi Nicolai, thank you for your positive response.
Nikolai
Posts: 8
Joined: 20 Mar 2020, 17:17

Re: Setting up Connect+ with Modbus on CODESYS

Post by Nikolai »

Thanks Dirk.

Are you able to help me please?
User avatar
Amar
KUNBUS
Posts: 160
Joined: 15 Jul 2019, 12:58

Re: Setting up Connect+ with Modbus on CODESYS

Post by Amar »

Hi Nicolai,
The example you received uses MODBUS TCP Master and MODBUS RTU Master available from CODESYS.You therefore should not configure the available MODBUS TCP and RTU master from pictory.
Only Connect module should be configured in Pictory.

For Configuring MODBUS TCP and RTU master you can look help available on Codesys forum.

One Important Hint when you use MODBUS RTU from CODESYS for RevPi,the serial port needs to be added in CODESYSControl.cfg.
so you need to add in /etc/CODESYSControl.cfg
(Attention you need to remove the 0 from USB0)

[SysCom]
Linux.Devicefile=/dev/ttyUSB

You can check out some relevant help resources:
https://www.fleaplc.it/index.php/tutori ... ys-control
KUNBUS
Nikolai
Posts: 8
Joined: 20 Mar 2020, 17:17

Re: Setting up Connect+ with Modbus on CODESYS

Post by Nikolai »

Hi Amar,

Thanks, that helped with the Modbus TCP setup which now works. The last step is to get Modbus RTU up and running. I have a temperature sensor on my slave device, and I know it can be read from pictory.

I've updated the CODESYSControl.cfg with

Code: Select all

[SysCom]
Linux.Devicefile=/dev/ttyUSB
I have NOT added

Code: Select all

portnum := COM.SysCom.SYS_COMPORT1;
although I tried it and it doesn't seem to make a difference

And it appears that the module is identified by CODESYS - am I right? However, it doesn't appear to communicate with the slave like Pictory does.

I have the same slave address, offset and length.

Do you know what could be wrong?
Attachments
Screenshot 2020-07-08 at 17.47.33.png
Screenshot 2020-07-08 at 17.47.33.png (139.67 KiB) Viewed 8147 times
Post Reply