setup modbus tcp slave - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10) +--- Thread: setup modbus tcp slave (/showthread.php?tid=1232) Pages:
1
2
|
setup modbus tcp slave - Patrik1985 - 12.02.2018 Can i setup HL as aslave by using a json file under the modbus menu? or most i go true the lua script way? i want to read out 4 tempatures from my knx, to the ventilation system via modbus. if it possible iwant to trigger a forced vetliation command in the knx to the modbus to. RE: setup modbus tcp slave - Daniel - 12.02.2018 Hi Slave is only available as a script. Modbus tab works only as master. https://forum.logicmachine.net/showthread.php?tid=181 BR RE: setup modbus tcp slave - Patrik1985 - 12.02.2018 it is enough just to add this script to "resident script", or do i have to add something in "common functions" ? when i have this setup, i just add a event script like this ? and link it to my 0/1/0 (outdoortemp) : value = event.getvalue() mb = mbproxy.new() mbetregisters(3, value) RE: setup modbus tcp slave - Daniel - 12.02.2018 It is resident script with 0s interval, no need for event script. Yes just copy, setup all coils/registry/regdt/ RE: setup modbus tcp slave - admin - 12.02.2018 Modbus proxy works only in master mode. It is meant to share serial port between mapper and scripts. You don't need any additional scripts for that slave example, mapping between objects is done via configuration table. RE: setup modbus tcp slave - Patrik1985 - 12.02.2018 thanks for all answers! So if want to read out the outdoortemp ga 0/1/0 (2 byte float value), to the modbus, should i type in to the coil mapping or register mapping? Is there anything more i have to change except the ip-adress port, slavenumber ? -- list of coil mapping, starting from 0 coils = { '1/1/1', '1/1/2' } -- list of register mapping, starting from 0 registers = { '2/2/2', '3/3/3' } -- list of register data types, element count must match registers table regdt = { dt.int8, dt.uint16 } RE: setup modbus tcp slave - admin - 12.02.2018 You don't need to change IP on LM side, script will automatically use whichever IP LM has. Port is set to 502 and no slave id is used by default, this can be adjusted as needed. Coils are boolean values, so for temperature you need to use registers. You need to adjust regdt table, but keep in mind that float16 is KNX-specific data type and your Modbus master might not support it. Instead, you can use int16 value with a certain precision, either x10 or x100. For this, you need a simple script which multiplies float16 value and writes to int16 object. RE: setup modbus tcp slave - Patrik1985 - 12.02.2018 Ok, so i add int16 to the regdt. How this little script look like? i have found some examples in the forum but its just for json profile. sorry for all the questions. RE: setup modbus tcp slave - admin - 12.02.2018 Attach event script to your float16 objects, change 1/2/3 to your int16 object Code: value = event.getvalue() RE: setup modbus tcp slave - Patrik1985 - 12.02.2018 in the resident script? or make a new event script add the 0/1/0 and put the script there? i tried that and the temp value went crazy in the object view. RE: setup modbus tcp slave - Daniel - 12.02.2018 (12.02.2018, 13:16)Patrik1985 Wrote: in the resident script? or make a new event script add the 0/1/0 and put the script there? i tried that and the temp value went crazy in the object view. Crate new event based script which will be triggered by your outdoor temp. Paste this script there and create new object 1/2/3 as int16 and this new object should be in your modbus resident script. RE: setup modbus tcp slave - Patrik1985 - 13.02.2018 Hey! thanks for the help yesterday ! now the first 3 temps working fine not the 2 last, when i restart the script its gets all temps. But when the knx doing a update every 20min the last 2 values turn to 0 ? RE: setup modbus tcp slave - Patrik1985 - 13.02.2018 this is the script, its updating the 3 first register mapping data but not the 2 last. if i change order in them the values works. but still change the 2 last value to 0 after the update from knx. if i deactivate and activte the script, it shows again in the modbus till the next update. Code: if not mb then RE: setup modbus tcp slave - Daniel - 13.02.2018 Hi In line 12 you have dt.bool for the 4th registry. Boolean should be done as coil. If 4/1/7 is bool then move it to coil. For the 15/1/4 you didn't specify regdt at all. BR RE: setup modbus tcp slave - Patrik1985 - 13.02.2018 okey, i tought i just put in what diffrent type data its could read . So if all the is values is the same data ishould put in it like this ? one typ for every GA. -- list of register data types, element count must match registers table regdt = { dt.int16, dt.int16, dt.int16, dt.int16, dt.int16 } RE: setup modbus tcp slave - Daniel - 13.02.2018 (13.02.2018, 11:39)Patrik1985 Wrote: okey, i tought i just put in what diffrent type data its could read . yes RE: setup modbus tcp slave - Patrik1985 - 13.02.2018 thanks a lot ! now everything works fine RE: setup modbus tcp slave - buuuudzik - 01.03.2018 I've tried to use this modbus TCP slave script and it works perfectly but only when other LM which is master reads by a script it doesn't work via mapper. The minimum version of profile which I've tested: Code: { This is the first part of slave script from LM4: Code: if not mb then This is currently used master script (it is working very nice, i let only 1 address): Code: require('json') So currently I am working with above script but I want switch it to the mapper. But in above mapper settings it's not working e.g. when I change value on slave it isn't changed by new read on master. Maybe some advice from some experienced Modbus TCP user? P.S. No, two scripts don't working in same time RE: setup modbus tcp slave - admin - 01.03.2018 Do you have mb:setslave(1) call in slave script? Anyway, I would not use modbus to connect two LMs :) RE: setup modbus tcp slave - buuuudzik - 01.03.2018 (01.03.2018, 08:20)admin Wrote: Do you have mbetslave(1) call in slave script? Anyway, I would not use modbus to connect two LMs I've tried both with and without defining slave ID. It works by script but not mapper. I also not preferring but unfortunately, for some time I cannot use KNX IP because I have also some others KNX routers which could pass telegrams to KNX TP and now I am working on integration with PEGO humidifiers and I have round about 140 new GAs and perfectly is when they are in virtual GAs range on 2 LMs. I thinked about BACNET but I have LM LB and currently I haven't BACNET library on it. But BACNET would be another system... I've sent you yesterday ask about BACNET library, if you can please send me But what is your solution when you want sent some maybe bigger data(in 2 ways) between LMs and you don't want use normal KNX? |