ModbusTCPSlave

Moderator: Benj

Post Reply
jhill
Posts: 65
Joined: Thu Jan 31, 2019 3:46 pm
Has thanked: 11 times
Been thanked: 12 times
Contact:

ModbusTCPSlave

Post by jhill »

Hi,

I am in the progress of adapting a program from Modbus RTU to Modbus TCP and have come across what seems to be a bug in the ModbusTCP slave Macro.

In your examples, and in my previous modbus RTU program, the initialise macro is called once, then the check for incoming macro on a loop.

When used for ModbusTCP the system will answer the first modbus query, then all future requests will fail. I re-initialise tcp slave upon successful receipt of data, future quires are successful and everything works ok.

It is like a successful response from the “checkforincoming” macro prevents future quires being successful.

Is this behaviour intentional?

Please see the attached basic program. As it stands, data is returned successfully to repeated modbus queries. If you remove the (re) initialise on successful query brnach, only the first modbus query is answered and all further quires get no response.

Hardware is arduino uno with Ethernet shield (WizNet W5100)

Best Regards,

Jim
Attachments
Uno_Modbus_TCP_Test-2.fcfx
(18.4 KiB) Downloaded 262 times

jhill
Posts: 65
Joined: Thu Jan 31, 2019 3:46 pm
Has thanked: 11 times
Been thanked: 12 times
Contact:

Re: ModbusTCPSlave

Post by jhill »

Hi,

Playing with this some more, it seems that that this macro is broken?
Looking at other forum posts, its appears necessary to have the “network Coms” component between the TCP/IP component and the Modbus TCP component. Can anybody confirm this is the case? This program will not compile without it.
Whilst the program compiles ok and I can write to binary and analogue modbus registers over the network using an external modbus master, these do not make it back to the variable assigned in the programme.
I can also read form binary and analogue registers using modbus, but it seems that random, and in the case of binary, changing values are returned to the master. This is the case even if no coils or analogue values are set in the programme, in which case the documentation says the modbus tcp/ip initialise makro should set all values to zero?
I have everything working fine using modbus RTU over serial, but the Modbus TCP macros do not seem to work.
I have tried many things and can only assume this is a bug, can anybody at Matrix confirm?
Best regards,

Jim

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ModbusTCPSlave

Post by Benj »

Hi Jim,

Sorry for the delay. Yes the network comms component is required. It translates the TCP calls to the specific TCP module your using. Out of interest which TCP module are you using?

The network comms component currently supports some TCP modules but not all yet so let us know and maybe we can add support for any module that is currently unsupported.

Did you look at the examples on the Wiki to get you started?

jhill
Posts: 65
Joined: Thu Jan 31, 2019 3:46 pm
Has thanked: 11 times
Been thanked: 12 times
Contact:

Re: ModbusTCPSlave

Post by jhill »

Hi Benj
Thank you very much for getting back to me. I am using an arduino Ethernet shield (WizNet W5100). I appreciate that this isn’t the right module for the macro, but other people on the forums seem to using it successfully. The communication seems ok as the IP address etc is being set ok, I can ping the module, and the module will answer modbus tcp queries, all be it with odd values.
The issue seems to be between the modbus TCP makro and the network coms makro.
I am using the tcp/ip modbus makro exactly as in your example, as in the previous modbus RTU systems which work perfectly, and as in others work posted on the forums.
The only exception to this is the need to re-initialise the modbus-tcp component after each query, otherwise only the first modbus request is answered, and all subsequent requests fail
In summery, the issue seems to be between the modbus TCP makro and the network comms makro.
Kind Regards,
Jim

jhill
Posts: 65
Joined: Thu Jan 31, 2019 3:46 pm
Has thanked: 11 times
Been thanked: 12 times
Contact:

Re: ModbusTCPSlave-UPDATE

Post by jhill »

Hi,

I have ported this project over to the raspberry pi, as this has supported tcp/ip coms and should remove this "unknown" from the problem.

I now longer have to re initialise the modbus coms every loop, which is good!

However i still have a problem that the values written to the modbus registers in the program do not resemble those read by the modbus master.

Hopefully as this is generic hardware is it repeatable by flowcode support? I would very much appreciate some help here, as this does look like a bug!

Best Regards

James
Attachments
remote.fcfx
(10.44 KiB) Downloaded 203 times

jhill
Posts: 65
Joined: Thu Jan 31, 2019 3:46 pm
Has thanked: 11 times
Been thanked: 12 times
Contact:

Re: ModbusTCPSlave

Post by jhill »

In case anybody else is interested in this, it still apears to be an issue and continues here:-

viewtopic.php?f=78&t=20201

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ModbusTCPSlave

Post by Benj »

Hi James,

Please keep reminding me. I'm pretty flat out with other projects at the minute but I do need to look into this and try to replicate.

jhill
Posts: 65
Joined: Thu Jan 31, 2019 3:46 pm
Has thanked: 11 times
Been thanked: 12 times
Contact:

Re: ModbusTCPSlave

Post by jhill »

Thats great, thanks Ben. It will be good to get this working! :D

Post Reply