Go Down

Topic: Modbus TCP Master Communication Reading Register from Modbus slave (Read 14581 times) previous topic - next topic

rockwallaby

riken, with 5 months I am sure you will have success.
I thought you would get battery state of charge (SOC) either from data from the inverter or directly form the inverter ?
If not, then how will you get this by analogue I wonder ?

Remember Qt is an application framework as such, where you can add in your actual application functionality with C++ code.
So, doing this, you could have the RPi acting as Modbus TCP master, and communicating to both the Victron inverter as well as the M-Duino, which will both be Modbus TCP slaves.

To do this, you use the library I mentioned, the very good libmodbus library on the RPi.
The M-Duino can then just do the direct digital and analogue I/O and do what ever calculations.
But the idea with this is that you use the RPi (or other better GNU/Linux board) to do all the number crunching.

Then, you have a single Modbus TCP master which will get the all data from all devices.
There is no need to do other communication with 'strings' or other tricky stuff.

Use Qt for what it was designed for, for nice GUI's, and wrap it around the code to do the Modbus and other calculations you need.

Pylon, you are excused indeed, but it appears to me you did not read my comment correctly, where I say, and I quote, 'as it is not wise to have one Ethernet port communicating as Modbus TCP master as well as another TCP protocol at the same time', with the key word in there being 'wise'.

I did not say it was not possible, and simply mentioned this as many people do not understand the inner details of a protocol such as Modbus, where timing of responses might come into play.

Without the caution, a user might have a single Ethernet port on a board such as a RPi and have the Modbus polling very fast and then expect to be able to have another connection say by HTTP or streaming data via Web Sockets, and wonder why Modbus errors are suddenly appearing.

So, my caution is simply to highlight that it is not 'wise' to use a single Ethernet port while using Modbus TCP with another TCP/UDP protocol.

It has nothing to do with firewalls, and more to do with hardware that is not so good in this particular aspect, i.e. RPi mixed with multiple protocols used by an application that might not be coded in a way with full understanding to avoid tricky issues.

Pylon, I hope I have been able to clarify my point more for you.

Anyhow, riken, go for it and good luck, I think you shall succeed with determination.
____________
Paul - VK7KPA
Paul - VK7KPA

rojo20

The bigger problem is that the library is so bad, it doesn't check for a correct length but just accesses bytes outside the received message.
The library you used has some more drawbacks, it looks quite unfinished to me.
@pylon - do you have any desire to help finish the MgsModbus library and get it operational?  I only ask because I have spent about 10 hours (no exaggeration) looking for an operational Arduino-Modbus TCP/IP MASTER library and could not find one.

Since reading the slave device modbus data is one of the final steps of my project, and it appears that a modbus tcp/ip master library could benefit the Arduino community, I would rather not start over with a Rasp Pi.

I am willing to put in any leg work required and I have the time, but I am a very novice programmer at best.  Thanks in advance for any help that you can offer.  It would be much appreciated.
- Technology can help -

rockwallaby

rojo20, what is needed is a single unified Modbus library, one that can be configured as client or server for both RTU and TCP modes of operation. Much like the libmodbus library which has proved itself in many embedded applications.

From my research, existing Arduino Modbus libraries may be improved, I am hopeful.

I have been thinking about it over the past while, but it will need time to develop and prove.
Maybe at some time pylon or others and I could work on making some progress, if there is willingness.
Thoughts ?
____________
Paul - VK7KPA
Paul - VK7KPA

rojo20

rojo20, what is needed is a single unified Modbus library, one that can be configured as client or server for both RTU and TCP modes of operation. Much like the libmodbus library which has proved itself in many embedded applications.

From my research, existing Arduino Modbus libraries may be improved, I am hopeful.

I have been thinking about it over the past while, but it will need time to develop and prove.
Maybe at some time pylon or others and I could work on making some progress, if there is willingness.
Thoughts ?
____________
Paul - VK7KPA

rockwallaby, I am in total agreement with you.

I wish I could help more, but I suck at programming.  I am one of those guys that kinda understands, muddles through, edits any code he can find, bangs his head against the wall until something works.  I certainly offer my service in a testing capacity or anything else where I can be of use, but correcting libraries is outside of my proficiency unfortunately.  Any and all help is super appreciated though.  Seems like an Arduino would be perfect for this type of task.
- Technology can help -

riken

@rockwallaby,

I was thinking for a week and I think that Your opinion it's correct.
I will use a libmodbus library or QModbus library to implementing my program.

I have understanded these examples:

Libmodbus QT

Modbus Master Example

I want to read SOC data to inverter, I have an excell document whose it has ModBus TCP Addresses.

I will try to update with  new news.


pylon

Quote
@pylon - do you have any desire to help finish the MgsModbus library and get it operational?  I only ask because I have spent about 10 hours (no exaggeration) looking for an operational Arduino-Modbus TCP/IP MASTER library and could not find one.
To be honest: no. I had some looks at it and almost every time I inspected the code I found another unfinished work, in most cases without even mentioning the unfinished state. As I personally only have ModBus RTU in use I have very little interest in investing time into a ModBus TCP only library.

Quote
rojo20, what is needed is a single unified Modbus library, one that can be configured as client or server for both RTU and TCP modes of operation. Much like the libmodbus library which has proved itself in many embedded applications.
I agree that a unified library is probably the best for the Arduino community but I also knew that this will be a lot of work. It's much more work than on the Linux platform because we have to integrate with a lot of #ifdef parts to keep the code small to keep it running on a standard UNO.

Quote
From my research, existing Arduino Modbus libraries may be improved, I am hopeful.
Which library did you have in mind when writing the "hopeful"?

rojo20

To be honest: no. I had some looks at it and almost every time I inspected the code I found another unfinished work, in most cases without even mentioning the unfinished state. As I personally only have ModBus RTU in use I have very little interest in investing time into a ModBus TCP only library.
Pylon, I understand.  Thank you very much for taking a look at it again.  I appreciate it.  It is what it is, unfortunately.
- Technology can help -

rockwallaby

pylon, back in mid 2015 I had contact with another user who did a re-write on the SimpleModbusMaster code to improve a number of things, including providing a callback feature for response.

I found the posts made at the time, which might be of interest to you over on the long Modbus thread started by Juan. The discussion starts with Frank aka DDTechG at this post

But do agree with you in terms of the amount of work to create a single unified library, especially for the various boards with limited program memory.

The code for ModbusMaster by Doc Walker appears neat and very readable. Though I notice it appears that after a master to slave transaction, the code will sit in a while loop waiting for a reply from the slave, which is not the best method to handle this type of situation, hence why I like the callback feature implemented in the code by DDTechG.
____________
Paul _VK7KPA
Paul - VK7KPA

Moibbu

I tried your(kondradieee) program as modbus master in tcp i but I am not getting output. Please send me the correct program.

icg

@rockwallaby,

I was thinking for a week and I think that Your opinion it's correct.
I will use a libmodbus library or QModbus library to implementing my program.

I have understanded these examples:

Libmodbus QT

Modbus Master Example

I want to read SOC data to inverter, I have an excell document whose it has ModBus TCP Addresses.

I will try to update with  new news.


I need to develop a similar project, could you please tell me which library did you use? How did you manage the communication between inverter and Raspberry?

Go Up