RPI modbus TCP

Moderator: Benj

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

Re: RPI modbus TCP

Post by jhill »

Hi Ben,

The good news is as you say, the flowcode master>slave example does seem to work now. Unfortunatly when using external modbus masters, i ether got no response, or an incorrect reponse. Did you test a 3rd party master or just a flowcode master?

I think my next step is to use wireshark to look at the tcp packets and try and see where its going wrong, but wanted to let you know it doent look good in the mean time.

Ill keep you posted.

Best Regards

James

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

Re: RPI modbus TCP

Post by jhill »

Hi Ben
Having looked into this some more, this does seem to work in simulation. However when using an external master to query the program, I ether get a incorrect response (analogue or binary) , or a failed transaction, depending on the modbus master program I try.
To try an pin this down, I used wire shark to capture the TCP packets between master and slave.
First I tried a read holding register transaction between a master and a known working slave device (not flowcode). You can see the request go out, and the response from the device.
Working.PNG
(152.34 KiB) Downloaded 2007 times
I then tried exactly the same transaction with the flowcode modbus slave example. You can see again the request get sent, but no response packet is ever sent from the slave.
not working.PNG
(133.26 KiB) Downloaded 2007 times
I believe this explains why writing values works, as no response is required, however most masters require one to flag a successful write. Consequently the values are written, but some master devices will show a failed transaction.

When trying to read a register or coil however the slave needs to send a response, as shown in the successful transaction above. The flowcode program is clearly not doing this. I am however at a loss to explain how the flowcode>flowcode simulation example is working!
If we are to use modbus tcp for reading values from a flowcode based device, it needs to send the proper responses to read or write quires via TCP. At the moment, it certainly does not seem to be doing this?
Would it be possible for you to take a look and see why this might be?
Best Regards,
James

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: RPI modbus TCP

Post by Benj »

Hi James,

Many thanks for your time and effort here. The Modbus TCP components have only been tested together and not with other third party equipment. The None TCP Modbus components have been tested with third party equipment though and is known to work. The code bases for the modbus part should be identical.

So it's probably something to do with the opening and closing of the TCP port. I'll have a look for you and see if I can get any further to solve the issue for you. In the mean time if you find anything further then please let me know as it may be of great help.

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

Re: RPI modbus TCP

Post by jhill »

HI Ben,

I agree, the non TCP Modbus components work very well in my experience, so I don’t think the problem is there. It certainly seems to be that the tcp port is being opened and closed without issue. I have tried to capture an entire tcp exchange of a good Modbus transaction with a known good device, and also with the flowcode component. As you can see below, it’s not that the component doesn’t respond. The only difference I can see is that the component doesn’t send the modbus "response" packet in reply to the query, otherwise everything else looks good. Maybe there is something in the tcp comms component that is stopping the packet being sent?

Best Regards

James
Attachments
Good Capture.PNG
(124.15 KiB) Downloaded 1983 times
Bad Capture.PNG
(76.24 KiB) Downloaded 1984 times

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

Re: RPI modbus TCP

Post by jhill »

Hi Ben,

Sorry to be a pest but have you had a chance to look into this?

Best Regards

James

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

Re: RPI modbus TCP

Post by jhill »

Hi Ben,

I am keen to get this component working properly. If there is anything I can do to further a fix please let me know!

Best regards

James

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: RPI modbus TCP

Post by Benj »

Hi James,

Having another look for you now using the QModMaster Modbus Master software.

It connects but I can't currently get it to transfer any data to the Flowcode simulated Modbus TCP Slave.

I'll see if I can work out what's not working.

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

Re: RPI modbus TCP

Post by jhill »

HI Ben,

Thats great, thankyou. Yes the QmodMAster needs to see the reponse packet even when writing, so it shows fail when writing as well as reading. That replicates exactly what i see. Please let me know if i can help in any way.

Best Regards

James.

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

Re: RPI modbus TCP

Post by jhill »

Good Morning Ben,

Did you manage to ake any headway with this issue?

Best Regards

James

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

Re: RPI modbus TCP

Post by jhill »

Hi Ben,

Have you been able to get to the bottom of this issue? I need this component for a project and would realy apreciate an update!

Best regards

James

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: RPI modbus TCP

Post by Benj »

Hi James,

I've been working on this and have got it at least partially working now. I'll spend a bit more time and do a push later today so you can try my improvements.

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

Re: RPI modbus TCP

Post by jhill »

Hi Ben,

Thats great, thank you. I just checked and there doenst seem to be any update to the modbus slave component but let me know when ts ready and I Iwill give it a try. :D

Best Regards,

James.

Post Reply