CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sat Oct 19, 2019 4:27 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 31 posts ]  Go to page 1 2 3 Next
Author Message
PostPosted: Thu Apr 10, 2014 8:23 am 
Offline
Frequent User
Frequent User

Joined: Fri Dec 23, 2005 7:36 pm
Posts: 179
What Modbus Functions does the Rpi support? I'm trying to use a package to write data to the Pi over modbus but I keep getting exceptions.
Thanks

_________________
nOrM
=====
nOrM = Norman Dziedzic Jr.


Top
   
PostPosted: Thu Apr 10, 2014 2:54 pm 
Offline
Frequent User
Frequent User

Joined: Fri Dec 23, 2005 7:36 pm
Posts: 179
I found out that they are using function 22 mask write register. I'm guessing that is not supported.

_________________
nOrM

=====

nOrM = Norman Dziedzic Jr.


Top
   
PostPosted: Fri Apr 11, 2014 8:16 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3494
Hi,

here the overview, if you are Master (ModBusMaster.jpg ) and you try to add slave functions codes you see them.

in case the plc is modbus slave (ModbusSlave_FC-Code.jpg):

Supported Function Codes
If not restricted by a special type of the controller, the slave generally supports the following function codes:

See the description in the online help:
FC03 Read Holding Registers
FC04 Read Input Registers
FC06 Write Single Register
FC16 Write Multiple Registers
FC23 Read/Write Multiple Registers


BR
Edwin


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Fri Apr 11, 2014 4:09 pm 
Offline
Frequent User
Frequent User

Joined: Fri Dec 23, 2005 7:36 pm
Posts: 179
Thanks Edwin.

Is there a way for my controller to be a slave and support Coil Data?

Thanks,

Norm

_________________
nOrM

=====

nOrM = Norman Dziedzic Jr.


Top
   
PostPosted: Sun Apr 20, 2014 7:30 am 
Offline

Joined: Fri Apr 18, 2014 5:36 pm
Posts: 70
Hi,

I am using Raspberry as as Modbus TCP slave device.

I like to write holding registers in Raspberry (%IW0) from Modbus master (PC).
When I write new value into the register, I can shortly see this new value in raspberry, but immediately after this, something override this with value 0.
Any idea?

I also like to use modbus coils and discrete inputs. Is this not supported?

Thank you.
BR
Zdenko.


Top
   
PostPosted: Sun Apr 20, 2014 8:02 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3494
Hi,

you need to remove the tag timeout in the modbus slave... see screenshot

From online help see supported function codes.

BR
Edwin


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Sun Apr 20, 2014 4:23 pm 
Offline

Joined: Fri Apr 18, 2014 5:36 pm
Posts: 70
Thank you Edwin :D . This works great!

I have another question. Rassberry is still configured as modbus slave.
I like to use holding registers for read and write variables value. The problem is that I can't write value to modbus holding registers variable within the program execution. For example: I like to read and write temperature setpoint from Modbus master (PC). This setpoint can also be set within the program execution on Raspberry. In this case, Modbus master have to read this changed value. How can I make this work?

Best regards,
Zdenko.


Last edited by switcher on Sun Apr 20, 2014 6:22 pm, edited 1 time in total.

Top
   
PostPosted: Sun Apr 20, 2014 4:43 pm 
Offline
Frequent User
Frequent User

Joined: Fri Dec 23, 2005 7:36 pm
Posts: 179
You need to use the Modbus Input Registers for that.

I was very confused by this as well.

_________________
nOrM

=====

nOrM = Norman Dziedzic Jr.


Top
   
PostPosted: Sun Apr 20, 2014 6:17 pm 
Offline

Joined: Fri Apr 18, 2014 5:36 pm
Posts: 70
Thank you Norman.
But I am not sure if I understand your suggestion.
Input register is only allowed to be read from Master. We can not write to it.

I think holding register have to be used. With function 03 we can read and with 06 we can write to it.
The main idea (and demand) is that we can read and write the same holding register from Modbus Master and in PLC (Raspberry in this case).

Any idea?

Best regards,
Zdenko.


Top
   
PostPosted: Sun Apr 20, 2014 8:45 pm 
Offline
Frequent User
Frequent User

Joined: Fri Dec 23, 2005 7:36 pm
Posts: 179
Sorry for the confusion. I have not been able to find a way to read and write to the same holding registers. I used a combination of holding registers and input registers for getting my sample application working.

I have seen this in other systems and I believe they are trying to avoid confusion over which is the proper data.

_________________
nOrM

=====

nOrM = Norman Dziedzic Jr.


Top
   
PostPosted: Sun Apr 20, 2014 11:56 pm 
Offline
User avatar

Joined: Tue Aug 30, 2011 1:21 am
Posts: 96
To have Holding registers read/write use CoDeSys ModbusTCP Slave library. See the screen shot for the example how to use it.


You do not have the required permissions to view the files attached to this post.

_________________
The Original SoMachine Ninja


Top
   
PostPosted: Mon Apr 21, 2014 8:29 am 
Offline

Joined: Fri Apr 18, 2014 5:36 pm
Posts: 70
Thank you very much. I added Modbus TCP slave library from Intern/ModbusTCP Slave.
It is strange that I don't have the same function block:

Image

Best regards,
Zdenko.


Top
   
PostPosted: Mon Apr 21, 2014 6:01 pm 
Offline

Joined: Fri Apr 18, 2014 5:36 pm
Posts: 70
Hi,

I created new project. In this project is Modbus server function block is shown as it should be. Why it was shown different in my first project I don't know... Maybe can someone help us and explain this situation.

Anyway, this version works perfect! I can read and write modbus holding registers with master and slave devices.

Best regards,
Zdenko.


Top
   
PostPosted: Mon Apr 21, 2014 6:47 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3494
Hi,

there are two ModbusServer fb's available one for Modbus TCP the other for Modbus RTU...
See screenshots:


BR
Edwin


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Mon Apr 21, 2014 7:30 pm 
Offline

Joined: Fri Apr 18, 2014 5:36 pm
Posts: 70
Thank you. Yes, RTU is different as TCP. But it is strange that I insert TCP FB and there is RTU.

This is added libraries. Here it TCP, which is correct:
Image

Here is Input Assistant to choose Modvus server TCP:
Image

And this is result, which is not correct:
Image

Best regards,
Zdenko.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 31 posts ]  Go to page 1 2 3 Next

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited