06.03.2023, 14:55
Yes this is modbus TCP
------------------------------
Ctrl+F5
Ctrl+F5
Universal Modbus TCP/RTU Slave
|
06.03.2023, 15:16
Try changing [1] in line 10 to [*] it will be any slave nr.
------------------------------
Ctrl+F5 (06.03.2023, 15:16)Daniel Wrote: Try changing [1] in line 10 to[*] Thanks, it works. but there's something strange if the value is over 20 on the logic machine 5 for example 21 the Modbus pool reader will read it as 30, if it's 22 will read it as 31.4, and so on... please see attached
07.03.2023, 11:55
I updated the original script and the library, now it will work correct.
------------------------------
Ctrl+F5
07.03.2023, 12:32
07.03.2023, 12:34
Do you mean RTU? No this is not implemented in this version.
------------------------------
Ctrl+F5
07.03.2023, 12:49
07.03.2023, 12:59
The original script still works
https://forum.logicmachine.net/showthread.php?tid=181 https://forum.logicmachine.net/showthrea...33#pid3233
------------------------------
Ctrl+F5
13.03.2023, 15:40
Hello Daniel,
I need to use the LM as modbus TCP slave and I'm trying to use the universal TCP script. The modbus master is the IP 192.168.2.108 and using the communication port 503, the LM is slave Id 3. I just need to write registers from 2002 to 2090 and read registers from 2102 to 2190. I've been trying just to read registers but I get a message error: "Modbus Universal 13.03.2023 16:37:00 Resident script:6: Address not available stack traceback: [C]: in function 'assert'" Code: local mb = require('user.mbtcp')
13.03.2023, 15:42
Keep the address variable unchanged. * will automatically use the Ethernet interface IP address.
13.03.2023, 15:58
(13.03.2023, 15:42)admin Wrote: Keep the address variable unchanged. * will automatically use the Ethernet interface IP address. Thank you for your quick response admin. I've done what you told me and the error message disappeared but there's no group address value update for the 4 registers I'm trying to read. Maybe I forgot something, is there any instructions manual for the script? Thank you.
13.03.2023, 16:00
Your master must send write command for value to be updated.
------------------------------
Ctrl+F5
13.03.2023, 16:07
(13.03.2023, 16:00)Daniel Wrote: Your master must send write command for value to be updated. The modbus master is a Siemens PLC and it is cyclically writing to these registers. I can communicate using the attached script but the CPU usage increases a lot and I have to communicate with multiple PLCs. Code: require('luamodbus')
13.03.2023, 16:15
mb:readregisters(2104) This is a read command, If you want to test reading you can simply use Read test under modbus tab.
Is yout PLC master or slave?
------------------------------
Ctrl+F5
13.03.2023, 16:32
(13.03.2023, 16:15)Daniel Wrote: mb:readregisters(2104) This is a read command, If you want to test reading you can simply use Read test under modbus tab. The PLC is configured as modbus master. Yes, this is a read command and both are working for me (read command and read test), but I want to use the universal Modbus TCP Slave script that you developed because if I use the read command and the write command for a large number of variables the CPU usage increases a lot. My question is why when I use read command or read test I receive a read result but when using the universal script there's no data update?
13.03.2023, 16:41
When mobus master will send write command to particular register then this script will update the object. So far you only doing a read so nothing is written to object.
------------------------------
Ctrl+F5
13.03.2023, 16:45
If 192.168.2.108 is the PLC address then you need to use master mode using profiles not a slave script.
13.03.2023, 19:31
14.03.2023, 05:22
(07.03.2023, 07:59)Fahd Wrote:[*](06.03.2023, 15:16)Daniel Wrote: Try changing [1] in line 10 to[*] I also encountered the same problem when using the "user. mbtcp" script. The value of the data address is 3300, but the value of the mapped 2-byte floating point KNX group address is 33.00. Another problem is that I added "holding registers" to map the address table, but it doesn't work. This is my address mapping list: Code: mb.setmapping({
14.03.2023, 06:18
holdingregisters = registers, you need to use inputregisters instead.
mb.setfloat16precision(2) sets how float16 is converted to integer. By default it's 2 decimals (0.01 precision). Change 2 to 0 to convert to integer without any decimals. |
« Next Oldest | Next Newest »
|