buergeb
Hi,
 
I tried to read/write to Holding Registers (Memory (16-bits)) with addresses "%MW0 – %MW1023" (Modbus: 1024 – 2048).
This worked with python from a connected PC, but inside the OpenPLC Runtime (Blank Linux) I was not able to read the values. In "Monitoring" all variables were 0. After changing addresses to "%QW0 - %QW1023" (Modbus: 0 - 1023) in plc program and python, everything works. Why is this?
 
In addition, it would by cool, to map arrays directly to Modbus addresses. Is there a workaround available?
 
Thanks
    Bodo
Reply 0 0
thiagoralves
Monitoring only displays the values of located variables. If you don’t have any located variable in your program, you won’t see anything in there
Reply 0 0
buergeb
Turns out, that my problem is more specific than generally:
I wrote a test program to show the effects with holding registers and memory holding registers.
 
import pymodbus.client as ModbusClient
from pymodbus import (
    FramerType,
    ModbusException,
    pymodbus_apply_logging_config,
)

# Modbus-Konfiguration
MODBUS_HOST = '192.168.2.148'  # IP-Adresse des Modbus-Servers
MODBUS_PORT = 502              # Standardport für Modbus/TCP

# Modbus-Client initialisieren
client = ModbusClient.ModbusTcpClient(
    MODBUS_HOST,
    port=MODBUS_PORT,
    framer=FramerType.SOCKET,
)

value = 2

client.connect()
# MW0 := QW0;
client.write_registers(0, [value])
# QW1:= MW1 ;
client.write_registers(1025, [value])
# QW3 := QW2 + 7;
client.write_registers(2, [value])
# MW3 := MW2 + 9;
client.write_registers(1026, [value])
client.close()




MW0 := QW0;
QW1:= MW1 ;
QW3 := QW2 + 7;
MW3 := MW2 +9;
 
[203128%2F9152849%2Fmceclip0]
 
In the end - holding register %MW0 (1024) is not working. The operation "MW0 := QW0 ;" is not working properly. Registers >= 1025 seem to be ok.
 
Any idea?
 
buergeb@grenache:~/wks/OpenPLC_v3$ git show
commit c490ebf82c715c028bea3ad0a44db4a78033f35d (HEAD -> master, origin/master, origin/HEAD)
Author: Thiago Alves <thiagoralves@gmail.com>
Date:   Tue Dec 31 09:28:22 2024 -0500

Reply 0 0
thiagoralves
There seems to be a bug with %MW0. I'll have to look
Reply 0 0
Reply