Go Down

Topic: Modbus TCP master library (Read 5950 times) previous topic - next topic

Watcher

#30
Jan 12, 2018, 07:00 pm Last Edit: Jan 12, 2018, 07:01 pm by Watcher
ok...

I must be doing something wrong...

I ve tried to read a few registers of  length 1 int and they all give back the value of 4 while the res variable returns  -10..

Not sure what it means...

Juraj

did you check if Modbus TCP is enabled on inverter?
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Watcher

#32
Jan 12, 2018, 07:13 pm Last Edit: Jan 12, 2018, 07:15 pm by Watcher
Yes I have enabled it.

Does the -10 result in the res variable mean anything to you ?

Also  is this

if (modbus.read() == -1)


universal for all modbus devices or specific to yours ?

Juraj

#33
Jan 12, 2018, 07:18 pm Last Edit: Jan 16, 2018, 09:43 am by Juraj
yes. it has a define on top of the snippet. connect didn't success.

Do you have Java skills? I have a java version you could try from a computer

EDIT: I put it here for future readers. The problem was resolved in other thread. It had nothing to do with the sketch or modbus protocol. Two devices in network had the IP address of the inverter.
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Watcher


Juraj

try on computer to connect with telnet client to ip of the inverter on port 502
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Watcher

#36
Jan 12, 2018, 07:29 pm Last Edit: Jan 12, 2018, 07:43 pm by Watcher
doesnt connect either...but maybe its nit designed to respond to telnet requests.

I can ping the inverter ok though

Juraj

telnet <IP> 502 should connect.

I found this. Do not know if it applies.

Procedure:
1. Start Sunny Explorer on the computer and create a Speedwire system (see Sunny Explorer user manual).
2. Log into the Speedwire system as Installer.
3. Select the SMA inverter to be configured in the system tree.
4. Select the tab Settings.
5. Select the parameter group External Communication.
6. Select [Edit].
☑ You will see the categories TCP Server and UDP Server under the parameter group Modbus.
7. To activate the TCP server, make the following settings in the group Modbus > TCP Server:
• In the Activated drop-down list, select the entry Yes.
• If necessary, change the port in the Port field (default setting: 502).
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Watcher

telnet <IP> 502 should connect.

I found this. Do not know if it applies.

Procedure:
1. Start Sunny Explorer on the computer and create a Speedwire system (see Sunny Explorer user manual).
2. Log into the Speedwire system as Installer.
3. Select the SMA inverter to be configured in the system tree.
4. Select the tab Settings.
5. Select the parameter group External Communication.
6. Select [Edit].
☑ You will see the categories TCP Server and UDP Server under the parameter group Modbus.
7. To activate the TCP server, make the following settings in the group Modbus > TCP Server:
• In the Activated drop-down list, select the entry Yes.
• If necessary, change the port in the Port field (default setting: 502).
Thats  correct. Thats exactly what i did to enable modbus on both tcp and udp.

Watcher

#39
Jan 12, 2018, 08:55 pm Last Edit: Jan 12, 2018, 09:22 pm by Watcher
Update:

Telnet connects on port 502!

Arduino still returns -10 !

Tried to use the same sketch and tried to connect to another Telnet server at port 23 and still doesnt connect. Must be something wrong with the connect function...
Will try again tomorrow..


Juraj

does the ethernet shield connect to nerwork? got IP address?
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Watcher

#41
Jan 13, 2018, 08:30 am Last Edit: Jan 13, 2018, 08:31 am by Watcher
Good morning!

yes.. I can also ping the Ethernet shield from the computer

Juraj

You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Watcher

ok...please see attached.

This compiles for a Mega board

Juraj

You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Go Up