12.11.2024, 12:11
hi all,
I have a project that uses LM and Wago PLC. I am communicating with Modbus.
i think so that if mb is global variable, the problem will be solved
LM send a value to PLC by using event-based script this like : event for (32/1/2)
LM get values from PLC by using resident-script :
I have 2 questions.
First;
I don't want to write connect and ip in every event script. Because when the PLC IP address changes, it will be troublesome to change all of them. And this type of usage is not a correct usage.
Second;
If the value of LM or PLC changes, that value will be equal in both.
I have a project that uses LM and Wago PLC. I am communicating with Modbus.
i think so that if mb is global variable, the problem will be solved
LM send a value to PLC by using event-based script this like : event for (32/1/2)
Code:
value = event.getvalue()
mb:writeregisters(0, value)
LM get values from PLC by using resident-script :
Code:
require('luamodbus')
mb = luamodbus.tcp()
mb:open('192.168.1.102', 502)
mb:connect()
value = mb:readregisters(0)
grp.update('32/1/2', value)
mb:close()
I have 2 questions.
First;
I don't want to write connect and ip in every event script. Because when the PLC IP address changes, it will be troublesome to change all of them. And this type of usage is not a correct usage.
Second;
If the value of LM or PLC changes, that value will be equal in both.