Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

We Value Your Feedback!
Could you please spare a few minutes to share your thoughts on Cloud Connected vs On-Premise Services. Your feedback can help us shape the future of services.
Learn more about the survey or Click here to Launch the survey
Schneider Electric Services Innovation Team!

homeLYnk V1.3.0 as a modbus tcp slaveserver

SpaceLogic KNX Forum

Schneider Electric SpaceLogic KNX forum to get support and share knowledge including selection, installation and troubleshooting for spaceLYnk, Wiser for KNX, eConfigure KNX, SpaceLogic KNX Hybrid module and other topics.

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • EcoStruxure Building
  • Light and Room Control
  • SpaceLogic KNX Forum
  • homeLYnk V1.3.0 as a modbus tcp slaveserver
Options
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
Thomas_Rohde
Sisko Thomas_Rohde Sisko
123
Erwin-vd-Zwart
Sisko Erwin-vd-Zwart Sisko
54
Heribert_Dölger
Lt. Commander Heribert_Dölger Lt. Commander
30
FZetina
Lt. Commander FZetina Lt. Commander
27
View All
Related Products
product field
SpaceLogic KNX - 4ʺ Touch Unit
product field
KNX Push Button Dynamic Labeling, universal
product field
Wiser for KNX : logic controller

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to SpaceLogic KNX Forum
Solved
Koen_Rowies
Lt. Commander Koen_Rowies Lt. Commander
Lt. Commander

Posted: ‎2015-03-13 06:19 AM . Last Modified: ‎2024-07-15 12:02 AM

0 Likes
3
515
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2015-03-13 06:19 AM

homeLYnk V1.3.0 as a modbus tcp slaveserver

Hello,

I am testing the AN016_V1.0 spacelynk as a modbus slave.

When updating KNX registers they are updated to the "slave modbus registers in HL" that works fine.

Now I want to update KNX registers when a modbus master writes to HL as a slave.

I used the code in the application note and slightly modified it.

When writing to MB register 1, 2 or 3 this need to be updated in the KNX group addresses 4/5/1-4/5/2-4/5/3, and thois part don't work

I did the test with PMC modbus to write to HL slave registers and this seems to work, when after writing i read these registers the value is updated.

But internally it is not send to the KNX group address...

PMC modbus write to HL as a slave

5920

and when i read the registers with PMC modbus

5924

But in HL they are not mapped to the KNX registers... therefore i use the code below, Modbus IP handler=>

------------------------------------------------------------------------------

-- modbus init

if not mb then

  --****************************************************

  -->>>>>>>>>Modbus slave setting<<<<<<<<<<<<<<<<<<<<<<<

  require('luamodbus')

  mb = luamodbus.tcp()

  -- IP:192.168.0.69, port: 502

  mb:open('192.168.0.69', 502)

  mb:connect()

  -- slave id

  mb:setslave(10)

  -- init slave storage for coils, discrete inputs, holding registers and input registers

  mb:setmapping(10, 10, 10, 10)

  --*****************************************************

  -->>>>>>>>>>>Register write callback<<<<<<<<<<<<<<<<<<<

  mb:setwriteregistercb(function(register, value)

      alert("register %d has been changed to %d", register, value)

      if register == 1 then

       grp.write('4/5/1',value)

      end

    end)

  --*****************************************************

   -->>>>>>>>>>>Register write callback<<<<<<<<<<<<<<<<<<<

  mb:setwriteregistercb(function(register, value)

      alert("register %d has been changed to %d", register, value)

      if register == 2 then

       grp.write('4/5/2',value)

      end

    end)

  --*****************************************************

    -->>>>>>>>>>>Register write callback<<<<<<<<<<<<<<<<<<<

  mb:setwriteregistercb(function(register, value)

      alert("register %d has been changed to %d", register, value)

      if register == 3 then

       grp.write('4/5/3',value)

      end

    end)

  --*****************************************************

end

-- server part init

if not server then

  require('rpc')

  -- incoming data handler

  local handler = function(request)

    local fn, res

    fn = tostring(request.fn)

    if not mb[ fn ] then

      return { nil, 'unknown function ' .. fn }

    end

    if type(request.params) == 'table' then

      table.insert(request.params, 1, mb) res = { mb[ fn ](unpack(request.params)) }

    else

      res = { mb[ fn ](mb) }

    end

    return res

  end

  server = rpc.server('127.0.0.1', 28002, 'mbproxy', handler, 0.01)

end

mb:handleslave()

server:step()

-----------------------------------------------------------------------

5925

Another question, when defining the number of registers for -> MB:setmapping(10, 10, 10, 10)

Is this starting from modbus address 0 or will this mapping start from the first callback address...

What is the maximum number of registers that you would advise so HL would not get instable...

Kind regards

Koen

  • Thumbnail of SpaceLogic KNX - 4ʺ Touch Unit
    SpaceLogic KNX - 4ʺ Touch Unit
  • Thumbnail of KNX Push Button Dynamic Labeling, universal
    KNX Push Button Dynamic Labeling, universal
  • Thumbnail of Wiser for KNX : logic controller
    Wiser for KNX : logic controller
View products (3)
Attachments
AN016_SL_Spacelynk as Modbus slave.zip
Reply
  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
sesa299442
sesa299442 Schneider Alumni (Retired)
Schneider Alumni (Retired)

Posted: ‎2015-03-17 05:01 AM

0 Likes
2
460
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2015-03-17 05:01 AM

Hello Koen,

I have just test it with both version 1.0 and 1.1 and it works OK.

You are asking good question about the registers. It starts from zero in spaceLYnk.

It means that register 0 in sL corresponds to register 1 in your PMC.

When you map 10 registers using command MB:setmapping(10, 10, 10, 10),

10 holding registers is created, it means 0-9 in spaceLYnk point of view.

We have not performed tests for modbus slave load yet. But it is in our plan.

I cannot say maximum number of registers, but it is more about the modbus activity then count of modbus registers.

Even if you have 1 modbus resgister and you write into its value very often (in order of hundreds per minute), it can be very exhaustive load for spaceLYnks.

I am copying my modbus handler script here:

-- modbus init

if not mb then

--****************************************************

-->>>>>>>>>Modbus slave setting<<<<<<<<<<<<<<<<<<<<<<<

require('luamodbus')

mb = luamodbus.tcp()

-- IP:10.154.12.78, port: 502

mb:open('10.154.12.78', 502)

mb:connect()

-- slave id

mb:setslave(10)

-- init slave storage for coils, discrete inputs, holding registers and input registers

mb:setmapping(10, 10, 10, 10)

--*****************************************************

-->>>>>>>>>>>Register write callback<<<<<<<<<<<<<<<<<<<

mb:setwriteregistercb(function(register, value)

  if register == 0 then

  grp.write('4/5/1',value)

      elseif register == 1 then

        grp.write('4/5/2',value)

      elseif register == 2 then

        grp.write('4/5/3', value)

      end

alert('register: %d = %d', register, value)

end)

--*****************************************************

end

-- server part init

if not server then

require('rpc')

-- incoming data handler

local handler = function(request)

local fn, res

fn = tostring(request.fn)

if not mb[ fn ] then

return { nil, 'unknown function ' .. fn }

end

if type(request.params) == 'table' then

table.insert(request.params, 1, mb)

res = { mb[ fn ](unpack(request.params)) }

else

res = { mb[ fn ](mb) }

end

return res

end

server = rpc.server('127.0.0.1', 28002, 'mbproxy', handler, 0.01)

end

mb:handleslave()

server:step()

See Answer In Context

Reply
Replies 3
sesa299442
sesa299442 Schneider Alumni (Retired)
Schneider Alumni (Retired)

Posted: ‎2015-03-17 05:01 AM

0 Likes
2
461
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2015-03-17 05:01 AM

Hello Koen,

I have just test it with both version 1.0 and 1.1 and it works OK.

You are asking good question about the registers. It starts from zero in spaceLYnk.

It means that register 0 in sL corresponds to register 1 in your PMC.

When you map 10 registers using command MB:setmapping(10, 10, 10, 10),

10 holding registers is created, it means 0-9 in spaceLYnk point of view.

We have not performed tests for modbus slave load yet. But it is in our plan.

I cannot say maximum number of registers, but it is more about the modbus activity then count of modbus registers.

Even if you have 1 modbus resgister and you write into its value very often (in order of hundreds per minute), it can be very exhaustive load for spaceLYnks.

I am copying my modbus handler script here:

-- modbus init

if not mb then

--****************************************************

-->>>>>>>>>Modbus slave setting<<<<<<<<<<<<<<<<<<<<<<<

require('luamodbus')

mb = luamodbus.tcp()

-- IP:10.154.12.78, port: 502

mb:open('10.154.12.78', 502)

mb:connect()

-- slave id

mb:setslave(10)

-- init slave storage for coils, discrete inputs, holding registers and input registers

mb:setmapping(10, 10, 10, 10)

--*****************************************************

-->>>>>>>>>>>Register write callback<<<<<<<<<<<<<<<<<<<

mb:setwriteregistercb(function(register, value)

  if register == 0 then

  grp.write('4/5/1',value)

      elseif register == 1 then

        grp.write('4/5/2',value)

      elseif register == 2 then

        grp.write('4/5/3', value)

      end

alert('register: %d = %d', register, value)

end)

--*****************************************************

end

-- server part init

if not server then

require('rpc')

-- incoming data handler

local handler = function(request)

local fn, res

fn = tostring(request.fn)

if not mb[ fn ] then

return { nil, 'unknown function ' .. fn }

end

if type(request.params) == 'table' then

table.insert(request.params, 1, mb)

res = { mb[ fn ](unpack(request.params)) }

else

res = { mb[ fn ](mb) }

end

return res

end

server = rpc.server('127.0.0.1', 28002, 'mbproxy', handler, 0.01)

end

mb:handleslave()

server:step()

Reply
Koen_Rowies
Lt. Commander Koen_Rowies Lt. Commander
Lt. Commander

Posted: ‎2015-04-01 03:25 AM

0 Likes
1
460
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2015-04-01 03:25 AM

Hello Tomas, this script works fine, Thank you!

I have noticed when scanning for modbusdevices with PMC that he recognises multiple devices and not only slave on address 10,

6096

Also when writing to the HL he will save the value even if you put in a different slave address...

Could it be because we are on Modbus/TCP, so the IP address is unique to the slave... and the slave address doesn't matter that much?

Reply
sesa299442
sesa299442 Schneider Alumni (Retired)
Schneider Alumni (Retired)

Posted: ‎2015-04-01 03:38 AM

1 Like
0
460
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2015-04-01 03:38 AM

Koen,

you are right. The slaveid has no function in this case.

The slave device is fully determined by IP address and port number.

Note:

You can use this specification (IP,port+slave ID) in homeLYnk as a master, when you want to connect to Modbus gateway and access the devices behind the gateway.

If you use e.g. Smartlink IP, you can connect to Smartlink via modbus IP and read the the values from Modbus RTU devices(specified by slaveid) connected to Smartlink.

This is the situation when you can use both IP,port specification and slaveid together.

Reply
Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

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.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of