This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Modbus Schneider PLCs
#1
Hello Im trying to optimize a modbus communication on order to read from a tcp slave (it will be a schneider PLC) with a single request.

First I'm triyng with floats, this is my test which is sending 3 separated requests:

{"name":"Teste1","bus_datatype":"float32","type":"register","address":0,"writable":"true" },
{"name":"Teste2","bus_datatype":"float32","type":"register","address":2,"writable":"true" },
{"name":"Teste3","bus_datatype":"float32","type":"register","address":4,"writable":"true" }

I have tryed to implement the following json, but without success :

{"name":"Teste1","bus_datatype":"float32","type":"register","address":0,"writable":"true","Read_count":3,"Read_offset":0 },
{"name":"Teste2","bus_datatype":"float32","type":"register","address":0,"writable":"true","Read_count":3,"Read_offset":2 },
{"name":"Teste3","bus_datatype":"float32","type":"register","address":0,"writable":"true","Read_count":3,"Read_offset":4 }

Any sugestions ?

Thank you Big Grin
Reply
#2
All JSON keys must be lowercase, but you have Read_count and Read_offset. read_count must be 6, it is counted in 16-bit registers so 2 x 3 in your case. Also, you are probably missing "datatype": "float32" for each profile entry.
Reply
#3
Thank you ! I will try it

But i have found another issue with float32.

I have to swap the 2x16bit registers themselves that create the correct float.

Reg0 = 3F80
Reg1 = 0000

to

Reg0 = 0000
Reg1 = 3F80

I have tried the read_swap="w" but I see no difference

Note: I'm using the json profiles

Any easy way to do this ?

Thank you
Reply
#4
Set swap to n, word swap (w) is set by default
Reply
#5
Hello,

The reading is working perfect now, but unfortunately when I try to write to one of the variables I'm only writing to the first one.
For example if I write for the third variable the value 22.0, this value will be written to the first one, in the slave !

I am using this simple profile:

{"name":"Teste1","bus_datatype":"14","datatype":"float32","type":"register","address":0,"writable":"true","read_count":6,"read_offset":0,"read_swap":"n" },
{"name":"Teste2","bus_datatype":"14","datatype":"float32","type":"register","address":0,"writable":"true","read_count":6,"read_offset":2,"read_swap":"n" },
{"name":"Teste3","bus_datatype":"14","datatype":"float32","type":"register","address":0,"writable":"true","read_count":6,"read_offset":4,"read_swap":"n" }

Am I doing anything wrong ?

Thank you
Reply
#6
For write to work you need to set address field correctly, but this will break single block read. We might add another field (write_address) for cases like you have in future releases.

For now you have two options:
1. Do not use block read at all
2. Create another set of registers with "write_only": true, disable writable for original registers and use their values as status objects in visualization. This will introduce a delay between status object update due to polling interval.
Reply


Forum Jump: