Go Down

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

pylon

Quote
Where can I see how much RAM uses Arduino Uno?
Current IDE versions tell you how much RAM you use for constant strings. What version do you use?

Quote
So i did not do this with the print-Command i.e. Serial.print("lalalalala"). And not with the line " Serial.println(Mb.remSlaveIP);" because it doesn´t work.
"Serial.println(Mb.remSlaveIP);" is not a constant string but a constructed one, so leave it as it is. But

Code: [Select]
Serial.print("lalalalala");

can be changed to

Code: [Select]
Serial.print(F("lalalalala"));

without generating errors.

riken

Hello together,

I´ve been trying for several days to establish a Modbus connection to get values from my wood heating system. https://www.eta.co.at/produkte/produktuebersicht/stueckholz/eta-sh-20-bis-60-kw/

My Hardware:

Arduino Uno R3
Arduino Ethernet Shield

My Software:

Arduino 1.0.5

My Library:

http://myarduinoprojects.com/modbus.html     /example.zip     /MgsModbus_test_Master

I try to get information (temperature exhaust, temperatur outdoor, percentage heating puffer) with Function Code 0x03 (Read Holding Register) from Start Adress 1000, 6 Registers, so I need the value from Register 1000,1001,1002,1003,1004,1005,1006.
But it doesn´t work. I can´t get the data form holding registers  :'(  :'(  :'(  :'(

Ethernet/TCP Connection from Arduino 192.168.178.12 / 255.255.255.0 to Modbus slave wood heating system 192.168.178.54 / 255.255.255.0 works.

What´s my mistake?
Which software do you use for Modbus master simulator? I ask for software that I see in Modbus_Daten.png.

I am trying a comunication Modbus with my PLC arduino based on arduino mega, and I want to read a holding registers of Victron Energy inverter, and I am using a MgsModbus library. I would be very grateful if you can help me with your response about software that you are using.

If I found your code mistake, I will tell you :)

pylon

Quote
Which software do you use for Modbus master simulator? I ask for software that I see in Modbus_Daten.png.
We are using QModBus, it supports ModBus TCP as well as ModBus RTU.

Quote
I am using a MgsModbus library.
Did you read the thread? You might have noticed that this library is unfinished and not usable the way it currently is. So be prepared to invest quite a bit of work if you want to get your project running using that library.

riken

We are using QModBus, it supports ModBus TCP as well as ModBus RTU.

Did you read the thread? You might have noticed that this library is unfinished and not usable the way it currently is. So be prepared to invest quite a bit of work if you want to get your project running using that library.
Thanks, I will use QModbus!

I read the thread but I think If I did little changes, I would get running.

Now, I am searching other libraries to implement my project.

riken

We are using QModBus, it supports ModBus TCP as well as ModBus RTU.

Did you read the thread? You might have noticed that this library is unfinished and not usable the way it currently is. So be prepared to invest quite a bit of work if you want to get your project running using that library.
I have found otre library, it's this.
Modbus library

rockwallaby

riken wrote:
Quote
I am trying a comunication Modbus with my PLC arduino based on arduino mega, and I want to read a holding registers of Victron Energy inverter
Which implies you will be wanting to use a library for your Arduino that offers Modbus master mode. Beware the library you pointed to above at reply #19 appears to only offer slave mode.
_____________
Paul - VK7KPA
Paul - VK7KPA

konradieee

Hello pylon,

I´m very busy at the moment. Sorry.
I use Arduino IDE version 1.0.5.
I think, I have to update because ARDUINO 1.8.1 is the latest version. :-o
I will do it. So i hope it is possible to do the Serial.print(F("lalalalala")); change. In 1.0.5 it is not possible.


Hello riken,

yes I use qModMaster.exe. Did you get it?
It´s important that your Arduino mega act as a master. The master can get the holding register data from your slave (Victron Energy) with the function 03 (reading holding register).
Thanks in advance for your help.
We will fix it :-D





riken

riken wrote:Which implies you will be wanting to use a library for your Arduino that offers Modbus master mode. Beware the library you pointed to above at reply #19 appears to only offer slave mode.
_____________
Paul - VK7KPA
Hello pylon,

I´m very busy at the moment. Sorry.
I use Arduino IDE version 1.0.5.
I think, I have to update because ARDUINO 1.8.1 is the latest version. :-o
I will do it. So i hope it is possible to do the Serial.print(F("lalalalala")); change. In 1.0.5 it is not possible.


Hello riken,

yes I use qModMaster.exe. Did you get it?
It´s important that your Arduino mega act as a master. The master can get the holding register data from your slave (Victron Energy) with the function 03 (reading holding register).
Thanks in advance for your help.
We will fix it :-D





I don't know that I need to implement my arduino as a master. I think that I can choose the mode.
Thanks a lot. If I don't find a library with Modbus TCP master, I will do my project with modbus RTU master.

rockwallaby

riken wrote:
Quote
I don't know that I need to implement my arduino as a master. I think that I can choose the mode.
I do know you will need to use Arduino as Modbus master if you wish to succeed in communicating to any slave device such as a Victron inverter. I don't know of any inverter or solar charge controller that will act as Modbus master, they all act as Modbus slaves.
___________
Paul VK7KPA
Paul - VK7KPA

pylon

Quote
If I don't find a library with Modbus TCP master, I will do my project with modbus RTU master.
As far as I found information on the Internet Victron doesn't support ModBus RTU (physical interface is an RS-485) but only ModBus TCP.

rockwallaby

I have no idea what model inverter is being talked about, just that it is a Victron brand, so we have no idea what communication interfaces are available, either inbuilt or via any purchased accessories.

I believe Victron inverters use their own VE.Bus and VE.Direct propriety protocol communications system.
Depending on the model of inverter, it may have a CAN bus interface that you could use.
Some inverters even use a simple HTTP protocol.

You could look to use the VE.Direct protocol as I believe it could be a fairly simple protocol to implement and connect to it using standard async communications, say from an Arduino, though I would suggest using a galvanic isolator.
___________
Paul VK7KPA
Paul - VK7KPA

riken

riken wrote: I do know you will need to use Arduino as Modbus master if you wish to succeed in communicating to any slave device such as a Victron inverter. I don't know of any inverter or solar charge controller that will act as Modbus master, they all act as Modbus slaves.
___________
Paul VK7KPA
As far as I found information on the Internet Victron doesn't support ModBus RTU (physical interface is an RS-485) but only ModBus TCP.
I have no idea what model inverter is being talked about, just that it is a Victron brand, so we have no idea what communication interfaces are available, either inbuilt or via any purchased accessories.

I believe Victron inverters use their own VE.Bus and VE.Direct propriety protocol communications system.
Depending on the model of inverter, it may have a CAN bus interface that you could use.
Some inverters even use a simple HTTP protocol.

You could look to use the VE.Direct protocol as I believe it could be a fairly simple protocol to implement and connect to it using standard async communications, say from an Arduino, though I would suggest using a galvanic isolator.
___________
Paul VK7KPA
Thanks a lot, I read datasheet three months ago and I forgot that I can use modbus TCP only.

Well, I think that I have to explain my project. I am doing my final project degree. This project consists in management photovoltaic energy using open source.
I use:
-Raspberry pi 3 + QtCreator
-M-Duino, It's a PLC based on Arduino.
PLC

I want to do control of charges in PLC arduino and having GUI in Raspberry Pi.

I connect PLC and Raspberry using USB connection. I will send data string althouhg, I don't know as I send diferents strings because I need to send four strings.
The only way of getting SOC(state of charge battery) variable, it's reading a inverter photovoltaic register. The model is inverter/charging multiplus 800 VA-5KVA and it's necessary use a color control GTX.
I think that If I read SOC, I will need to use Modbus TCP.

I have two options:

-I connect PLC with inverter and use MgsModbus library.(I need to change much code).
-I connect Raspberry pi with inverter and using QModbus master.
I think the second option is more difficult than first option because I will use QThread surely and I don't know using this library.

I will spend a lot of time on both options.



rockwallaby

There are many options on how to do this, using the M-Duino and RPi or just M-Duino or dare I say it, just RPi.

It comes down to how you will implement the GUI.
Will it be via some form of web based application or will it be by a directly connected LCD ?

If you do not have any requirement for any direct control of I/O, then is there any real need for using an M-Duino ?
You can do the whole thing quite well with just using a single small board, such as a GNU/Linux board.
If you use a small ARM based GNU/Linux board, say like RPi, then you can have it communicate Modbus TCP using the very good libmodbus library.

The problem will be if you will implement a GUI that will need an Ethernet connection, say using HTTP or Web Sockets for example. Then you need two Ethernet ports on the board, 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.

You could add an extra Ethernet port by using one of those USB adapters that has Ethernet.
The problem is that it is a RPi, which is not highly rated in my books, not at all.
Look at Olimex boards, say like a Olimex LIME 2.

So, you need to design your system and understand all aspects of what is needed, not just the communications part.

Other factors you need to think about are, your level of programming skill and your available time to complete the project.
I will be honest and say, it would appear your level of skill to design and implement the project will likely be very challenging for you, especially if you have not had a lot of previous experience to use to help pull you through.

So, you have a few options, and here are a few thoughts to consider
Use M-Duino as Modbus TCP master using MsgModbus library. This will allow the M-Duino to get data from Victron inverter and do some other I/O control if necessary. Then, as M-Duino is Modbus TCP master, it can also write data to RPi (phutt, yuck) which is operating also as Modbus TCP slave. The RPi is coded up with a bit of code using libmodbus library and some other code and libraries for GUI.

Throw the M-Duino in the rubbish and just use a small GNU/Linux board as mentioned above, if your choice is RPi, then use that.
All you need is a single board, using libmodbus library. If you have no need for any direct I/O. I would suggest other boards other than RPi, even microPython board would be worth considering, using PyModbus.

Throw the RPi in the rubbish and just use the M-Duino. It can act as Modbus TCP master and also do GUI, either with a LCD connected to the I/O. Even better GUI can be made using the USB port connected to a computer acting as a terminal and code the M-Duino output as VT220. Using VT100/220 allows you to do quite nice GUI using colour (not color) with cursor position control. It is how we all did stuff years ago and I use it with many of the Arduino projects. Look here as an example of a solar project I did to help someone using a MidNite solar charge controller. You will see in this post the png image of the output the Arduino was outputting directly to the computer using a simple terminal application. VT100/220 example image. You might find some useful information and ideas in that thread as well, including code.

Anyhow, it probably would have been better to start a new thread rather that latch on to this thread by another user.
___________
Paul VK7KPA

Paul - VK7KPA

riken

Thanks rockwallaby,

I need to use RPI and M-Duino because I use M-Duino to sense physics variables as current, soc, irradiance and I also control outputs for manegement energy. RPI is used for GUI and user can programe control.
I want to connect with Internet in the future therefore I want to use Modbus TCP on M-Duino.

Yes, I haven't any experience with Raspberry and Modbus but I will achieve experience with this project.

I have 5 moths to complete this project. Maybe It's possible.

My main problems are Modbus TCP and USB comunications because I need to send a lot of datas for seria USB.
I think that I can do timer interrupts in Qt and sending  data strings or bytearray.

I will start new thread.

pylon

Quote
Then you need two Ethernet ports on the board, 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.
Excuse me but this is rubbish. ModBus TCP is communicating on a specified port and will not be disturbed in any way by other traffic on the same segment. It makes sense to use two separate Ethernet segments (aka two Ethernet ports on the RPi) if you want to connect the RPi to the Internet, so that the ModBus segment is clearly separated. But even in that case it's better to put the firewall before the RPi.

I strongly suggest to use the libmodbus on the RPi for the ModBus TCP protocol. That software is tested to work and not a piece of unfinished work that seems to never got out of a pre-alpha state like ModbusMsg.

Do whatever you already do with the M-Duino and implement the ModBus on the RPi.

Go Up