set bit in word value
-
Hello
Is there any system function that allows to set a bit in a word?
I would like to change the word value using the bit controls in the visualization. -
@mentor_13 said in set bit in word value:
Hello
Is there any system function that allows to set a bit in a word?
I would like to change the word value using the bit controls in the visualization.You are going to have to be more specific. Are you talking about in a script or in a custom dashboard for example? Please give more details so we can help you.
-
Hi mentor_13, welcome to the forum!
Without knowing what protocol you're talking about, it's much more difficult to provide the right answer.
You are talking about Modbus, yes? If so, then yes. A binary data type point defined in the Holding Register or input Register ranges can be one a single bit of the register (16 bits) and set to only that bit, via the bit setting on the point locator.
-
thank you for the quick reply
@phildunlap your solution fixes my problem
I thought about the script solution because I thought that in this way I would save the license tags
I did not think that virtual variables are also counted to the total data points.
I automated several systems in my home and wanted to visualize it. 300 variables seemed enough to me. I assumed that just like the local variables in scada siemens winncc or vijeo citect will not count for the license. Now when I know that 300 variables to quite few
I have to think seriously about whether to continue on this system. I have already spent a lot of time learning about iterface and functionality and I don't want to change the program. -
Technically the free / unlicensed core in 3.x is only to be used for personal, educational, and other non-commercial uses, so I hope that limitation is being honored along with the 300 point limit.
There are other ways to do it that would not use a data point, and then not get you closer to the limit. Still operating under the assumption this is Modbus, the Modbus4J code is open source and you could create the right requests from a script and submit them to the Modbus master. A script solution is also completely possible (where you read the registers as a different data type and then do bitmasking in a script as you suggest. You would just have to encode what to do to the Modbus point into the point that updates the script's context, and do something like,
//untested var data = input.value.split("-"); var mask = 1 << parseInt(data[1]); if( data[0] === "0" ) modbusPoint.set( modbusPoint.value & ~mask ); else modbusPoint.set( modbusPoint.value | mask );
Or for that matter scripts can use the JsonEmport tool to modify points during script runtime.