SCADA Know-How | Five Tips to Help You with SCADA Bitwise Value Extraction!
2025-06-26 07:01:38

Tip 1: Write Your Own Function


As the destined one, what if you lack the right weapons? Wukong teaches you how to borrow treasures from the Dragon Palace on your own efforts, and we will teach you how to write your own function to extract the bits you need!


Step 1: Create a custom function to convert a value to binary. 


Here, we define a function called DecimalToBinary, with the conversion logic as shown in the figure below. You can also define your own function — any function that can successfully convert a value to binary is a good one.


1、Function Conversion Logic.png


Step 2: Edit the script to define the bit extraction logic.


Here, we use the custom binary conversion function we just created. First, make sure that the bit we are extracting does not exceed the length of the converted binary string. After confirming the length and position, we use the function Mid to read the converted string. Since the function Mid reads from right to left, while binary starts from the left, we need to determine the position to be read from the function's perspective. For example, in "00100", if we want to read the 3rd bit (0), in the function Mid, it is the 2nd bit. The length LEN is 5, and the position is 3. Since string indexing starts at 0 (order, not value), counting from the left, it is the 4th digit, but from the right, it is the 2nd one — this is the position the function Mid should read.


2、Determine Bit Position Logic.png


Effect:


3、Effect.png


Tip 2: Call a Built-in Function


Bit: "Are you the reinforcement SCADA called for?"


Here, we directly call the function gGetBit from the library to get the value at a specified position in the string.


4、Call the Function.png


First, define an intermediate variable "bit", assign the extracted value to it, and then display it in the text box.


5、Effect.png


Tip 3: Secondary Calculation


Wukong fought the Lady White Bone three times — we only calculate twice, maximizing efficiency!


In the database management page, we add a secondary calculation variable tag, select the expression tag, and obtain the tag from which we need to extract the bitwise value (here, the original value is "tag1"), as Tag("tag1") shown in the figure below. Then, in "Bit Extractor", select the bit position where the value will be extracted (here, left-to-right in the binary string). Next, add a label in the Graphics and bind it to the secondary calculation tag. Once we assign a value to the original tag, we can directly see the extracted bit value.


6、Secondary Calculation.png


Effect:


7、Effect.png


Tip 4: Tag I/O Address (Currently Only Supported for Modbus Protocol)


"Demons use magic weapons — what's wrong with me using Modbus?" Wukong: "So you're a demon too?"


Set up the Modbus TCP driver, add a tag with the type (Digital/Integer/Real), and assign 1 or 0 to it. Then, in Type of Data, select BIT and the position where you want to extract the value (starting from 0).


8、Starting from 0.png


Next, add a label in the Graphics, link it to the variable, and use a digital variable to assign 1 or 0 to it. Check the output value in the simulation.


When Bit0 is 1:


9、When Bit0 is 1.png


When Bit15 is 1:


10、When Bit15 is 1.png


When Bit0 and Bit15 are both 1:


11、When Bit0 and Bit15 are both 1.png


Tip 5: Graphics Expression


Black Myth has no map? We do! A big, feature-rich Graphics!!


In the Graphics, add a label, select the expression, and use GETB to directly extract the value. Here, tag1 is the original value, and tag2 is the bit position from the first function. Any tags in the Graphics can be used. After setup, assign values to both tags to display the result.


12、Graphics Expression.png


Effect:


13、Effect.png


Other News
SCADA Essentials:Know & Do.png
SOLISCADA Software Project Restoration and Backup
2025-07-03 09:01:45
SCADA Essentials:Know & Do.png
SOLISCADA Recipe Function Guide
2025-07-03 08:25:55
SCADA Essentials:Know & Do.png
SCADA Know-How | Event Settings
2025-06-26 06:02:47
The Next Wave of SCADA Technology.jpg
Where is SCADA Technology Heading in the Era of Industrial Digitalization?
2025-06-23 03:14:19
封面图.png
SCADA Know-How | SOLISCADA Client/Server & Redundancy Architecture
2025-06-06 08:50:13
封面图.png
SCADA Know-How | SOLISCADA Historical Trend (Data) Configuration
2025-06-06 08:10:05
SOLISCADA SCADA Software- Top Questions Answered.png
New to SOLISCADA? Your Top Questions Answered
2025-05-29 06:08:31
669059318231109 (1).png
SOLISCADA: The Advanced SCADA Software for Industrial Monitoring & Control
2025-03-18 09:37:23
We are passionate pioneers in industrial monitoring and intelligent automation, offering revolutionary SCADA software that inspires engineers, connects industries, and drives intelligent, sustainable innovation worldwide.
Get Started
soliscada@supcon.com
Copyright @ 2025 SUPCON. All rights reserved. Privacy Policy