Is modbus TCP possible in next time?

Give it a try, it costs you nothing !
Helmut_number_one
Posts: 97
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 41 times
Been thanked: 9 times

Re: Is modbus TCP possible in next time?

Post by Helmut_number_one »

Whatever is here in Annex Basic is super well thought out, I think it will be good.
And, I'm also sure that Modbus TCP and/or RTU will be well received by users.
Best regards, Helmut
User avatar
cicciocb
Site Admin
Posts: 2056
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1354 times
Contact:

Re: Is modbus TCP possible in next time?

Post by cicciocb »

I'm experimenting with modbus TCP in client mode ... seems to work ....
User avatar
cicciocb
Site Admin
Posts: 2056
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1354 times
Contact:

Re: Is modbus TCP possible in next time?

Post by cicciocb »

Ive just published the version 1.52.6 for the ESP32 and the ESP32-S3 that contains a first initial experimental support for the MODBUS, in TCP slave only.
For info, I've tested using a Modbus simulator (Modbus Slave).
You'll find below a preliminary documentation .

Please test it and let me know
SteanX
Posts: 39
Joined: Sat Jun 19, 2021 10:33 pm
Has thanked: 17 times
Been thanked: 6 times

Re: Is modbus TCP possible in next time?

Post by SteanX »

Wow, the last time I saw Modbus it was still a serial protocol. Interesting to see Modbus TCP support in Annex!
Helmut_number_one
Posts: 97
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 41 times
Been thanked: 9 times

Re: Is modbus TCP possible in next time?

Post by Helmut_number_one »

I thought I was dreaming, that was the burner. I'll just get around to testing it this evening.
Thanks alot
Helmut_number_one
Posts: 97
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 41 times
Been thanked: 9 times

Re: Is modbus TCP possible in next time?

Post by Helmut_number_one »

Please help me out:
I want to access IP address 192.168.0.200
Port 4196
Device ID 1
Address 4273 dec.
with read holding register
Read out
What must i write into the modbus.request line ?

Code: [Local Link Removed for Guests]

READ_HOLD_REGISTER = 3
'WRITE_HOLD_REGISTER = 6
SERVER_ID = 1
modbus.connect "192.168.0.200", 4196 'address of the remote server
modbus.request 4567, SERVER_ID , READ_HOLD_REGISTER, 4131, 41320

Edit 19:45
The code i test is ok:

Code: [Local Link Removed for Guests]

'MODBUS example - write and read in the HOLD_REGISTER 0
READ_HOLD_REGISTER = 3
WRITE_HOLD_REGISTER = 6
SERVER_ID = 1
' MODBUS.CONNECT IP$, [port] [,timeout] [,idleTimeout]
onWgetAsync modbus_received 'set the event handler function
modbus.connect "192.168.0.44", 504 'address of the remote server
for z = 0 to 1000
'write to the address 0
'modbus.request 1234, SERVER_ID, WRITE_HOLD_REGISTER, 0, z
'read from the address 0
modbus.request 4567, SERVER_ID , READ_HOLD_REGISTER, 10, 11
pause 1000
next z
end
modbus_received:
r$ = WGETRESULT$
wlog r$
print r$
token$ = word$(r$, 1) 'extract the token (first word)
if (token$ ="4567") then ' if the token correspond to the read request
if (word$(r$, 2) <> "Error") then 'if is not an error
'assemble the 2 bytes in one 16 bits word
value$ = "&h"+ word$(r$, 5) + word$(r$, 6)
wlog val(value$) 'converts from hex to integer
end if
endif
return
If i test it with a Ethernet to RS485 i have problem (with adress in top her)
I test it longer, thankyou for this tool !!!
Last edited by Helmut_number_one on Fri Apr 12, 2024 5:45 pm, edited 1 time in total.
User avatar
cicciocb
Site Admin
Posts: 2056
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1354 times
Contact:

Re: Is modbus TCP possible in next time?

Post by cicciocb »

Following your information :
I want to access IP address 192.168.0.200
Port 4196
Device ID 1
Address 4273 dec.
with read holding register
Read out
What must i write into the modbus.request line ?
You must use :

Code: [Local Link Removed for Guests]

READ_HOLD_REGISTER = 3
'WRITE_HOLD_REGISTER = 6
SERVER_ID = 1
modbus.connect "192.168.0.200", 4196 'address of the remote server
modbus.request 4567, SERVER_ID , READ_HOLD_REGISTER, 4273, 1 ' adress 4273, 1 register
Helmut_number_one
Posts: 97
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 41 times
Been thanked: 9 times

Re: Is modbus TCP possible in next time?

Post by Helmut_number_one »

Hm....
With the Ethernet to RS485 Connect, the first value returned is incorrect, all the next ones are correct.
I don't have that with devices without a converter.
it is not a mistake from Annex Basic.
Is there a way to delete the first error message?
EthernetKonnverter.png
Image

But, Franzessco, I'm thrilled
The token concept is also great

Without Ethernet Convert:
Image
withoutKonnverter.png
You do not have the required permissions to view the files attached to this post.
Helmut_number_one
Posts: 97
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 41 times
Been thanked: 9 times

Re: Is modbus TCP possible in next time?

Post by Helmut_number_one »

or can I do something different here?
Edit 21:26
i chanche destination port to my Annex Basic ESP32, but doesn't help....
Konvert_Parameter.png
You do not have the required permissions to view the files attached to this post.
Last edited by Helmut_number_one on Fri Apr 12, 2024 7:32 pm, edited 1 time in total.
User avatar
cicciocb
Site Admin
Posts: 2056
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1354 times
Contact:

Re: Is modbus TCP possible in next time?

Post by cicciocb »

It looks a little bit complicate this interface. :roll:
Post Reply