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.

Reading 8 coil points as a 1 byte in Modbus
#1
Hello,
We are trying to Communicate with a Toshiba VRV device. Point List is attached as a picture in this thread. 
We were able to communicate with all points except Fan Speed and Operation Mode those are marked red in the attached picture. 

You can find our Profile below. We did it everything. We tried to communicate bit to bit and tried to merge in Logic Machine also. What do you suggest to communicate Fan Speed and Operation Mode points ? How we can change our profile file shown below ?

Regards,


{
  "manufacturer": "Toshiba VRV",
  "description": "Toshiba VRV",
  "mapping": [
{ "address": 0, "name": "VRV 1 ON OFF", "bus_datatype": "bool", "type": "coil", "writable":1},
{ "address": 8, "name": "VRV 1 Mod", "bus_datatype": "uint8", "type": "coil", "writable":1},
{ "address": 16, "name": "VRV 1 Fan Hizi", "bus_datatype": "uint8", "type": "coil", "writable":1},
{ "address": 0, "name": "VRV 1 ON OFF_Status", "bus_datatype": "bool", "type": "discreteinput"},
{ "address": 2, "name": "VRV 1 Alarm", "bus_datatype": "bool", "type": "discreteinput"},
{ "address": 8, "name": "VRV 1 Mod Status", "bus_datatype": "uint8", "type": "discreteinput"},
{ "address": 16, "name": "VRV 1 Fan Hizi Status", "bus_datatype": "uint8", "type": "discreteinput"},
{ "address": 0, "name": "VRV 1 Oda Sicakligi", "bus_datatype": "uint16", "type": "inputregister", "value_multiplier": 0.1},
{ "address": 1, "name": "VRV 1 Sicaklik Set Deger Status", "bus_datatype": "uint16", "type": "inputregister", "value_multiplier": 0.1},
{ "address": 0, "name": "VRV 1 Sicaklik Set Deger", "bus_datatype": "uint16", "type": "register", "value_multiplier": 0.1, "writable":1}
]
}

Attached Files Thumbnail(s)
   
Reply
#2
It's not possible to do this via a profile, you will have to use scripts. You can access the same RS485 port from both profiles and scripts using mbproxy.

You can read multiple coils/inputs via a script and convert to a number.
Code:
function bitstonumber(bits)
  local res = 0

  for bnum, bval in ipairs(bits) do
    if bval then
      res = bit.bor(res, bit.lshift(1, bnum - 1))
    end
  end

  return res
end

mb = require('mbproxy').new()
mb:setslave(1)

bits = { mb:readcoils(8, 8) }
if #bits == 8 then
  mode = bitstonumber(bits)
  log(mode)
else
  log(bits)
end

The addressing probably starts from 0 so you have to subtract 1 from the documented addresses.
Temperature will not work with "value_multiplier": 0.1, try using "datatype": "float16" and "bus_datatype": "float16" without "value_multiplier".
Reply
#3
Hi I got an error when i use this script in log screen.
* table:[2] * string: broadcast read not allowed

What could be the reason ?

Quote:It's not possible to do this via a profile, you will have to use scripts. You can access the same RS485 port from both profiles and scripts using mbproxy.

You can read multiple coils/inputs via a script and convert to a number.
Code:
function bitstonumber(bits)
  local res = 0

  for bnum, bval in ipairs(bits) do
    if bval then
      res = bit.bor(res, bit.lshift(1, bnum - 1))
    end
  end

  return res
end

mb = require('mbproxy').new()
mb:setslave(1)

bits = { mb:readcoils(8, 8) }
if #bits == 8 then
  mode = bitstonumber(bits)
  log(mode)
else
  log(bits)
end

The addressing probably starts from 0 so you have to subtract 1 from the documented addresses.
Temperature will not work with "value_multiplier": 0.1, try using "datatype": "float16" and "bus_datatype": "float16" without "value_multiplier".
Reply
#4
Check if you have mb:setslave(0) in your code. You don't have to set the slave ID to 1 lower but the coil/register addresses. Script already has correct reading address 8 instead of 9.
Reply


Forum Jump: