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.

Write in a Single Bit of a Word
#7
Thank you very much both!

So this script is correct if I wanna set Bit0 of register 1280 to 0 when 32/1/1's value is 1
Code:
function setbit(value, bitnr)
  local mask = bit.lshift(1, bitnr)
  return bit.bor(value, mask)
end

value = 0

if grp.getvalue('32/1/1') then
  value = setbit(value, 0)
end

log(value)

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

-- set register at address 1000 to 123
mb:writeregisters(1280, 0)


mb:close()
And another question the 123 near the code below what value is??
Code:
-- set register at address 1000 to 123
Reply


Messages In This Thread
RE: Write in a Single Bit of a Word - by UfficioTecnicoEE - 14.02.2020, 14:29

Forum Jump: