wbj
Thiago, Hello 🙂
Why I cant write to the QW with the help of PSM?
I use psm.set_var("QW0", 10000) and psm.set_var("IW0", 10000), look at monitoring and see QW0 as 0 and IW0 as 10000 🙁
I have a module that cant use 10 and 16 functions for writing, I try use PSM to control him:
SerialConnect to the module
virtual slave with QW100 address, and I try to set value from QW100 to the Serial module.
QW100 is variable in the ST file. I cant READ and WRITE QW100 in the PSM => I cant set my Serial module from PSM 🙁((
 
Also, I cant change IW, for example, IW141... IW0 I can, but not 100+
In the psm.py I changed ModbusSequentialDataBlock(0, [0]*255). I dont see errors in the dashboard, psm is ran, but with register nothing is going on.
 
Also, When I change IW0 in the ST code, I get get_var(IW0) = 0, but there is not 0 in the ST code...
 
Hmmmmm, I set QW0 at 10000 and at the monitoring is %QW0 is 0, but when I print(get_var(QW0)) I see 10000 in the dashboard output, but not in the monitoring hmmm
Reply 0 0
wbj
I have one solution. Simple: open uart dev and connect to the tcp:502 via pymodbus... Reading of registers via tcp and write them to the uart... But I wanna know about psm possibilities 🙂
Reply 0 0
thiagoralves
You misunderstood the purpose of PSM. PSM is a driver, not a user program. In that sense, it should provide values for inputs (that's why you can write to %IW) and read outputs based on the user program (ladder logic, st, etc) processing. If you try to write to outputs using PSM, its value will immediately be replaced by whatever ladder logic says should be at that particular output.
 
If you have a device that you're attaching as slave, but won't accept FC 10 and 16, you will have to modify OpenPLC's modbus code (modbus_master.cpp). That's the only way. Bridging it with a custom pymodbus app also works, but creates an extra (unnecessary) step.
Reply 1 0
wbj
You misunderstood the purpose of PSM. PSM is a driver, not a user program. In that sense, it should provide values for inputs (that's why you can write to %IW) and read outputs based on the user program (ladder logic, st, etc) processing. If you try to write to outputs using PSM, its value will immediately be replaced by whatever ladder logic says should be at that particular output.
 
If you have a device that you're attaching as slave, but won't accept FC 10 and 16, you will have to modify OpenPLC's modbus code (modbus_master.cpp). That's the only way. Bridging it with a custom pymodbus app also works, but creates an extra (unnecessary) step.
Thanks Thiago! I thought about it but I needed to be sure 🙂
What about reading QW?
In my ST program I set, for example, %QW100 := 40, try to psm.get_value("QW100") and I get 0 🙁1.jpg2.jpg3.jpg 🙂
Reply 0 0
thiagoralves
Addresses after 100 are out of scope for the PSM since they are handled by the slave devices driver.
Reply 0 0
wbj
Thanks, Thiago ! 🙂
It's enough to write simple if-else for the some slave ID in the modbus_master.cpp, I did it 🙂
God Luck 🙂
Reply 0 0
Reply