RPI modbus TCP
Moderator: Benj
-
- Posts: 444
- Joined: Tue Apr 15, 2014 4:19 pm
- Location: Kajaani, Finland
- Has thanked: 345 times
- Been thanked: 227 times
- Contact:
RPI modbus TCP
Hi!
After couple of tries, i think theres something wrong with the RPI tcp/ip component or modbus tcp component.
Whenever i try to establish connection between modbus master and rpi, the rpi seems to not pick up...
Not near my pc at the moment, so cannot attach example program.. Just take modbus tcp slave example, target raspberry pi 3, add rpi tcp/ip stack, attach to modbus tcp slave-->rpi stack.
Run on rpi and try to connect to modbus server using master simulator.
Port setup to 502(generic modbus port).
After couple of tries, i think theres something wrong with the RPI tcp/ip component or modbus tcp component.
Whenever i try to establish connection between modbus master and rpi, the rpi seems to not pick up...
Not near my pc at the moment, so cannot attach example program.. Just take modbus tcp slave example, target raspberry pi 3, add rpi tcp/ip stack, attach to modbus tcp slave-->rpi stack.
Run on rpi and try to connect to modbus server using master simulator.
Port setup to 502(generic modbus port).
Ill just keep the good work up!
- 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
Hello,
There are problems with the Modbus TCP component at the moment, they work well in simulation but they have problems with embedded devices including the RPI. I have tried several workarounds but currently the solution eludes me. I'll keep trying.
There are problems with the Modbus TCP component at the moment, they work well in simulation but they have problems with embedded devices including the RPI. I have tried several workarounds but currently the solution eludes me. I'll keep trying.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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
I've been thinking on it and think I have a solution. Hopefully I can have this running for you early next week.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Hi,
I have also been trying to get this working, was the issue resolved?
Best Regards,
James
I have also been trying to get this working, was the issue resolved?
Best Regards,
James
- 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
Hi James,
Yes this issue has been resolved. Can you post your program and I'll have a look for you.
Yes this issue has been resolved. Can you post your program and I'll have a look for you.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Hi,
Thanks, please see attached.
Best regards,
James.
Thanks, please see attached.
Best regards,
James.
- Attachments
-
- remote.fcfx
- (10.45 KiB) Downloaded 224 times
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Good Morning Ben,
Did you get a chance to take a look at this? Am i doing something wong or is there a bug?
Best Regards
James
Did you get a chance to take a look at this? Am i doing something wong or is there a bug?
Best Regards
James
- 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
Hi James,
I've had a look at the program and coudn't see any major issues.
What are you using as the Master to generate the requests?
I've had a look at the program and coudn't see any major issues.
What are you using as the Master to generate the requests?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Hi Ben,
I use Abacom profilab, which connects fine but returns random numbers, not the values written to the registers.
https://www.electronic-software-shop.co ... anguage=en
The same software works fine using modbus serial. I have the same problem using arduino, see my other thread, hence now trying raspberry pi, who’s networking component is supported by yourselves.
I use the Abacom Profilab modbus tcp software extensively with commercial brain boxes ED series modules with no issues at all.
A good fee modbus test utility is qModMaster. http://domoticx.com/modbus-software-qmodmaster-windows/
In essence everything is proven. It’s just the modbus TCP component returns "random" values.
Best Regards
James
I use Abacom profilab, which connects fine but returns random numbers, not the values written to the registers.
https://www.electronic-software-shop.co ... anguage=en
The same software works fine using modbus serial. I have the same problem using arduino, see my other thread, hence now trying raspberry pi, who’s networking component is supported by yourselves.
I use the Abacom Profilab modbus tcp software extensively with commercial brain boxes ED series modules with no issues at all.
A good fee modbus test utility is qModMaster. http://domoticx.com/modbus-software-qmodmaster-windows/
In essence everything is proven. It’s just the modbus TCP component returns "random" values.
Best Regards
James
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Hi,
To give some more information on this issue, I get exactly the same results in simulation, which i have to admit i did not try before
As you can see, both values should be "1". I am not sure where 27887 comes from?
What software are you using to test this, maybe i can try that?
Best Regards
James
To give some more information on this issue, I get exactly the same results in simulation, which i have to admit i did not try before
As you can see, both values should be "1". I am not sure where 27887 comes from?
What software are you using to test this, maybe i can try that?
Best Regards
James
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Good Morning Ben,
Have you had a chance to look at this? Are you able to tell me what client you use for testing?
As it does not appear to work in simulation, and you cannot find an issue with my program, which essentially follows the example, can i assume this is a bug?
Sorry if this is not the correct way to get support on this issue!
Best Regards,
James.
Have you had a chance to look at this? Are you able to tell me what client you use for testing?
As it does not appear to work in simulation, and you cannot find an issue with my program, which essentially follows the example, can i assume this is a bug?
Sorry if this is not the correct way to get support on this issue!
Best Regards,
James.
- 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
Hi James,
I used Flowcode to test the Modbus TCP master and slave working together. It might be worth trying this to see if it's any better.
As for the example you posted, can you confirm Analog1 and Binary1 have been loaded with 1's?
I used Flowcode to test the Modbus TCP master and slave working together. It might be worth trying this to see if it's any better.
As for the example you posted, can you confirm Analog1 and Binary1 have been loaded with 1's?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Hi Ben,
I will give a flowcode to flowcode link a try and see what that gives.
I have tried loading both analog and binary with different values, and they never resemble what I read. The exception is binary, which has a 50% chance of being right!
I say this as if I make repeated coil read requests, I get 0 and 1 returned on alternate reads, regardless of how the register has been set.
The analog seems to return a random number, again regardless of what has been set in the program. I can also read registers that are not there, for example if I try to read 10 registers; I get 10 different values back, despite only one register being defined. It is almost like there is a disconnect between the registers that are being written, and the memory located the server is reading values from.
I would just like to reiterate that this all works fine using modbus serial, it is only in the move to TCP that this issue has arisen.
Best Regards,
James
I will give a flowcode to flowcode link a try and see what that gives.
I have tried loading both analog and binary with different values, and they never resemble what I read. The exception is binary, which has a 50% chance of being right!
I say this as if I make repeated coil read requests, I get 0 and 1 returned on alternate reads, regardless of how the register has been set.
The analog seems to return a random number, again regardless of what has been set in the program. I can also read registers that are not there, for example if I try to read 10 registers; I get 10 different values back, despite only one register being defined. It is almost like there is a disconnect between the registers that are being written, and the memory located the server is reading values from.
I would just like to reiterate that this all works fine using modbus serial, it is only in the move to TCP that this issue has arisen.
Best Regards,
James
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Hi,
I have just found the component debug console, and this is what it is showing me. I am not sure what this means?
I have just found the component debug console, and this is what it is showing me. I am not sure what this means?
- Attachments
-
- Debug Capture.PNG
- (43.86 KiB) Downloaded 3229 times
- 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
Hello,
Exception address means the address is out of range for the current Slave properties.
Try address 0 instead of address 1. Hopefully this will solve the problem.
Exception address means the address is out of range for the current Slave properties.
Try address 0 instead of address 1. Hopefully this will solve the problem.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
HI,
Sorry, i just realised. I did it the other way around and requested adress 1 instead of 0 and now the console reports the correct value, but the master still reports a random number (26060) instead of 255
Sorry, i just realised. I did it the other way around and requested adress 1 instead of 0 and now the console reports the correct value, but the master still reports a random number (26060) instead of 255
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Hi Ben,
I have taken some steps to try and pin this issue down further.
1. I have modified my program to accept an binary and analog value from the master, then set those to be read back again in order to test the ability to write values master>slave. Up until now I have only tried to read values. I am happy to report that using the consol output I can see that this works fine, I can write values without issue, and these are read correctly in the console view. The consol also shows the correct values being given in response to the masters requests, however, the actual values read do not match those the consol says it is giving, as seen in pervious tests.
2. As per your suggestion I have written a modbus master flowcode program to write values to the slave, then attempt to read them back. The values are successfully written according to the slave consol, however the master consol actually says “no reply” although the values have been received and set by the slave. When the master attempts to read the values back, the master console again says no reply, and the values are not received, although the slave consol reports it has replied with the values written.
I certainly seems there is something wrong with reading values from the modbus slave. I have tried different clients, and they ether read nonsense, or reply with no connection.
I have attached both flowcode programs, I would be most grateful if you could take a look and see where I, or the software, is going wrong.
Best Regards
James
I have taken some steps to try and pin this issue down further.
1. I have modified my program to accept an binary and analog value from the master, then set those to be read back again in order to test the ability to write values master>slave. Up until now I have only tried to read values. I am happy to report that using the consol output I can see that this works fine, I can write values without issue, and these are read correctly in the console view. The consol also shows the correct values being given in response to the masters requests, however, the actual values read do not match those the consol says it is giving, as seen in pervious tests.
2. As per your suggestion I have written a modbus master flowcode program to write values to the slave, then attempt to read them back. The values are successfully written according to the slave consol, however the master consol actually says “no reply” although the values have been received and set by the slave. When the master attempts to read the values back, the master console again says no reply, and the values are not received, although the slave consol reports it has replied with the values written.
I certainly seems there is something wrong with reading values from the modbus slave. I have tried different clients, and they ether read nonsense, or reply with no connection.
I have attached both flowcode programs, I would be most grateful if you could take a look and see where I, or the software, is going wrong.
Best Regards
James
- Attachments
-
- remote_test.fcfx
- (12.53 KiB) Downloaded 111 times
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
And the master program.
- Attachments
-
- remote_test_master.fcfx
- (11.22 KiB) Downloaded 113 times
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Hi!,
As suggested I have created a flowcode master/slave combo, which should work in simulation, please see above. I would be most grateful if somebody could take a look and confirm if this is a bug, or give me an idea where I am going wrong!
James.
As suggested I have created a flowcode master/slave combo, which should work in simulation, please see above. I would be most grateful if somebody could take a look and confirm if this is a bug, or give me an idea where I am going wrong!
James.
- 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
Hi James,
These are working well for me in simulation.
I'm pushing these to the Wiki now as the files there do seem to have a problem in that they were missing the network comms components!?
These are working well for me in simulation.
I'm pushing these to the Wiki now as the files there do seem to have a problem in that they were missing the network comms components!?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Hi Ben,
Thankyou, as you say, these examples work well together. I am trying to use them to see where i am going wrong, but am hindered by what really does seem to be a bug.
I load both examples and run them, everything is fine. if you stop the slave simulation, and restart it, it no longer works. i have to close the example, reload it, then it works again.
I can also get them to behave as my examples above, where the registers are actually written, but the master says no reply. Unfortunatly i have been unable to pin down the exact conditions when this happens, but reloading fixes it.
Hopefully you can recreate the "works once" issue above?
Best Regards
James
Thankyou, as you say, these examples work well together. I am trying to use them to see where i am going wrong, but am hindered by what really does seem to be a bug.
I load both examples and run them, everything is fine. if you stop the slave simulation, and restart it, it no longer works. i have to close the example, reload it, then it works again.
I can also get them to behave as my examples above, where the registers are actually written, but the master says no reply. Unfortunatly i have been unable to pin down the exact conditions when this happens, but reloading fixes it.
Hopefully you can recreate the "works once" issue above?
Best Regards
James
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
HI,
Further to the above, I note that while your example writes a binary value maste>salve, it does not read it back.
If i add this line to your example to read the binary value back.
I get the reponse.
Which i think clearly shows there is an issue reading values.
I have put a lot of time into trying to pin this down, do you agree from my eamples that the modbus tcp slave component is not issuesing correct responses to master requests?
Best Regards,
James
Further to the above, I note that while your example writes a binary value maste>salve, it does not read it back.
If i add this line to your example to read the binary value back.
I get the reponse.
Which i think clearly shows there is an issue reading values.
I have put a lot of time into trying to pin this down, do you agree from my eamples that the modbus tcp slave component is not issuesing correct responses to master requests?
Best Regards,
James
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Hi Ben,
Sorry to nag but you did ask me to! Have you had a chance to look at this?
Best Regards
James
Sorry to nag but you did ask me to! Have you had a chance to look at this?
Best Regards
James
- 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
Hi James,
Many thanks for keeping on with this and sorry for the delay. I've now managed to have a look and hopefully fixed the problem where we were getting incorrect reply. I've tested the readback of the various types of storage and all seem to be working fine now too. I've pushed the updated component to the v8 update system now.
As for stopping and restarting the sim I'm investigating this for you now to try and find where the problem could be. Edit this has now also been fixed
Many thanks for keeping on with this and sorry for the delay. I've now managed to have a look and hopefully fixed the problem where we were getting incorrect reply. I've tested the readback of the various types of storage and all seem to be working fine now too. I've pushed the updated component to the v8 update system now.
As for stopping and restarting the sim I'm investigating this for you now to try and find where the problem could be. Edit this has now also been fixed
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: RPI modbus TCP
Good Morning!
Thats great news, thankyou! I will take a look today!
Best Regards,
James.
Thats great news, thankyou! I will take a look today!
Best Regards,
James.