This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

AHU MODBUS TCP VALUE
#1
Hi, I try to connect to Schneider-electric Homelynx and get the airflow from an IVP AHU ventilation unit with a climactix controller.
I need to compare two values in order to control a mixing valve.
The valve opens and closes until the two values are as equal as possible.
The value is to be retrieved from a Holding register with the address 4x0055 and 4x0056.
But unfortunately I do not get any values, it seems that it does not connect or I have typed the wrong code to get the air value correctly.

Code:
123456789101112131415161718192021222324
require('luamodbus') if not mb then    mb = luamodbus.tcp()    mb:open('192.168.201.53')    mb:connect() end mb:setdebug(true) openvalue =  grp.getvalue('6/3/1') tfvalue = mb:readinputregisters(54) ffvalue = mb:readinputregisters(55) mb:close() if tfvalue > ffvalue then  if openvalue < 220 then    openvalue = openvalue + 25  end end if ffvalue < ffvalue then  if openvalue > 25 then    openvalue = openvalue - 25  end end grp.write('6/3/1', openvalue)

I would be very grateful if you can help me with this problem
/Tommy
Reply
#2
Hi,

First of all you have not set a port on the Modbus TCP connection:
Code:
1
mb:open('192.168.201.53', 502)
Try also:
Code:
123
tfvalue, ffvalue = mb:readregisters(55, 2) log(tfvalue,ffvalue)
If that does not work try changing 55 to 54

BR,

Erwin
Reply
#3
(01.11.2018, 19:42)Elmyran Wrote: Hi, I try to connect to Schneider-electric Homelynx and get the airflow from an IVP AHU ventilation unit with a climactix controller.
I need to compare two values in order to control a mixing valve.
The valve opens and closes until the two values are as equal as possible.
The value is to be retrieved from a Holding register with the address 4x0055 and 4x0056.
But unfortunately I do not get any values, it seems that it does not connect or I have typed the wrong code to get the air value correctly.

Code:
123456789101112131415161718192021222324
require('luamodbus') if not mb then    mb = luamodbus.tcp()    mb:open('192.168.201.53')    mb:connect() end mb:setdebug(true) openvalue =  grp.getvalue('6/3/1') tfvalue = mb:readinputregisters(54) ffvalue = mb:readinputregisters(55) mb:close() if tfvalue > ffvalue then  if openvalue < 220 then    openvalue = openvalue + 25  end end if ffvalue < ffvalue then  if openvalue > 25 then    openvalue = openvalue - 25  end end grp.write('6/3/1', openvalue)

I would be very grateful if you can help me with this problem
/Tommy
Hi Tommy,
To establish modbus TCP connection between modbus master and modbus slave, you need to specify the port and the slave Id.


B.R,
Chouaibou.
Reply
#4
Hi,

Not 100% sure but i believe slave id is optional by TCP device (without it the default is used).

BR,

Erwin
Reply
#5
Is it a resident or a scheduled script? If it's resident then it will only work once because you are closing the connection via mb:close(). Setting slave id for TCP is optional by standard (255 is used when not set) but some devices might require it.

Start by logging each step return results:
Code:
12345678910111213
require('luamodbus') local mb = luamodbus.tcp() local res, err = mb:open('192.168.201.53') log('open', res, err) local res, err = mb:connect() log('connect', res, err) local res, err = mb:readinputregisters(54) log('read', res, err) mb:close()
Reply
#6
Thanks for your help, I got the script to work today. When I contacted AHU, I realized that it was the wrong values I received. There were inputs 95 and 96 that I needed to compare.
Here is the final working code:

Code:
12345678910111213141516171819202122232425
require('luamodbus') if not mb then    mb = luamodbus.tcp()    mb:open('192.168.201.53', 502)    mb:connect() end openvalue =  grp.getvalue('6/3/1', dt.uint8) tfvalue = mb:readinputregisters(94, dt.uint16) -- 3x0095 Supply air flow ffvalue = mb:readinputregisters(95, dt.uint16) -- 3x0096 Exhaust air flow if tfvalue and ffvalue == 0 then   openvalue = 0 end if tfvalue < ffvalue then   if openvalue < 220 then     openvalue = openvalue + 25   end end if tfvalue > ffvalue then if openvalue > 25 then openvalue = openvalue - 25 end end grp.write('6/3/1', openvalue, dt.int8)

it was as simple as that. Big Grin
Reply


Forum Jump: