Gateways and Energy Servers
Schneider Electric support forum to share knowledge about product selection, installation and troubleshooting for EcoStruxure Panel Server, PowerTag, Com'X, Link150…
User | Count |
---|---|
81 | |
46 | |
28 | |
28 |
Link copied. Please paste this link to share this article on your social media post.
Since MPM has limited build-in IOs, and the TE2 is also limited in terms of I/Os, we will explore the possibilities of using Advantys OTB (Optimized Terminal Block) as the extension IO Module for Can2go/SSL controllers.
The Advantys supports several communication protocols (Modbus RTU, Modbus TCP and CANOpen ) with different Network Modules, however in this article, we will focus on Modbus TCP integration and we'll look at others later.
* for fix IP assignment, please refer to <<Advantys OTB User Manual.pdf>> for more details
create a AV1 and AV2 object
AV1 --- use to store the DIs value
AV2 --- use to control the DOs.
Lua script
---------------------------------------------------------------------------------------------------
if init == nil then
var("DI_status", "ME.AV1")
var("DO_control", "ME.AV2")
ipAddr = "192.168.1.100"
port = 502
--Advantys OTB DI use holding resiger with address 0
DI_modbus_reg_addr = 0
--Advantys OTB DO control use holding register with address 100
DO_modbus_reg_addr = 100
init = true
end
--Read DIs
--output:
-- bit 1: DI1
-- bit 2: DI2
-- bit 3: DI3
-- bit N: DIN (n = 1 .. 12)
function read_ios()
code, value_table = modbus_tcp.hr_read(1, DI_modbus_reg_addr, 1)
if code == 0 then
--please note that the holder register in UN are using big-end
--so we need to adapt it here
raw_data= value_table[1]
value = bit.rshift(raw_data,8) + bit.lshift(bit.band(raw_data,0xff),8)
DI_status = value
print( "DIs Status", DI_status);
else
print("read status failed, error code :" ,code)
return 0
end
end
--Write DOs
function write_ios()
if DO_control == -1 then
return
end
if DO_control < 0 or DO_control > 256 then
print("illegal control value")
end
if DO_control ~= -1 then
--please note that the holder register in UN are using big-end
--so we need to adapt it here
raw_value = bit.lshift(DO_control,8)
print(raw_value)
code, value_table = modbus_tcp.hr_write(1, 100, raw_value)
if code == 0 then
DO_control = -1
else
print("write control command failed, error code: " , code)
end
end
end
----main logic
modbus_tcp.close()
modbus_tcp.open(1, ipAddr , port)
read_ios()
write_ios()
modbus_tcp.close()
-----------------------------------------------------------------------------------
Give a first DI a 24V input, the AV1 value shall be 1 (could also monitor the stats in the Status indicator in OTB module)
Set the AV2 to 1, the first DO will be activated. (could also monitor the stats in the Status indicator in OTB module)
Link copied. Please paste this link to share this article on your social media post.
Another script from the SBS team on how to use this I/O extender:
https://documentation.smartstruxurelite.com/pages/viewpage.action?pageId=13828358
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.