How to Modify a Single Bit of a DWORD in SIMIT Simulation Models
To modify an individual bit within a 32-bit Double Word (DWORD) in SIMIT Simulation Platform without overwriting or resetting the remaining 31 bits, use a combination of bit-splitting and recombination components or apply binary bitmasking logic. Connecting an isolated bit directly into conversion blocks like Bit2Byte or Byte2DWord causes unassigned pins to default to FALSE (zero), inadvertently wiping out surrounding process flags. To preserve unaffected data, split the incoming DWORD into constituent bytes or bits using DWord2Byte and Byte2Bit, overwrite only the targeted boolean index, and recombine the modified signals back into a DWORD using Bit2Byte and Byte2DWord.
Table of Contents
- SIMIT Component Signal Architecture and Default Pin Evaluation
- Why Direct Conversion Blocks Overwrite Adjacent Bits
- Method 1: Splitting and Recombining Bits Using Standard Components
- Method 2: Applying Mathematical Bitwise Logic (AND/OR Masking)
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
SIMIT Component Signal Architecture and Default Pin Evaluation
In SIMIT (V10.x, V11.x), simulation diagrams model physical field devices and controller coupling signals (such as S7-PLCSIM or Virtual Controller couplings):
- Typed Coupling Signals: Data exchanged with the automation system is mapped as strongly typed signals (BOOL, BYTE, WORD, DWORD, REAL).
- Open Pin Default Behavior: When conversion components from the SIMIT Basic Library (such as Bit2Byte, Byte2Word, or Byte2DWord) are placed on a diagram, every open, unconnected input pin automatically assumes a static default value—typically FALSE for boolean pins and 0 for numerical pins.
- The Overwrite Hazard: If an engineer connects only bit 3 to a Bit2Byte block, bits 0, 1, 2, 4, 5, 6, and 7 evaluate to FALSE. Recombining this byte into a DWORD overwrites all other 31 process status bits sent to the PLC.
Why Direct Conversion Blocks Overwrite Adjacent Bits
Process equipment status words (such as motor control words, variable frequency drive status words, or valve interlock registers) frequently pack multiple operational states into a single DWORD:
* Bit 0: Ready to start
* Bit 1: Running confirmation
* Bit 2: Electrical fault trip
* Bit 3: Local isolation switch status
If a test scenario requires simulating only the electrical fault trip (Bit 2), writing directly to a newly generated DWORD zeroes out Bits 0, 1, and 3. In the simulated controller, the motor block immediately trips on missing run confirmation rather than responding to the simulated fault. Preserving signal integrity requires a closed loop where the current value of the DWORD is read, modified at the exact bit position, and re-transmitted.
Method 1: Splitting and Recombining Bits Using Standard Components
The visual, component-based method in the SIMIT diagram editor uses the standard conversion library:
Step 1: Deconstruct the Incoming DWORD
- Drag the incoming coupling variable (the current DWORD signal from PLCSIM or the model) onto the SIMIT chart.
- From the Components -> Basic -> Conversions catalog, insert:
- OneDWord2Byteblock.
- FourByte2Bitblocks (or oneByte2Bitblock corresponding to the target byte). - Connect the DWORD to the input of
DWord2Byte. - Connect the target output byte (e.g., Byte 0: bits 0–7) to the input of
Byte2Bit.
Step 2: Modify the Target Bit
- Locate the specific bit output pin on
Byte2Bit(e.g.,Bit2). - Insert a Multiplexer (
Mux) or Switch component. - Wire the original
Bit2signal to Input 0 of the switch, and wire your simulation override signal (e.g., pushbutton or fault simulation flag) to Input 1.
Step 3: Reconstruct the Modified DWORD
- Insert a
Bit2Bytecomponent. - Wire all untouched bit outputs (
Bit0,Bit1,Bit3throughBit7) and the modified output from the switch into the matching input pins ofBit2Byte. - Insert a
Byte2DWordcomponent. - Wire the modified byte and the remaining three untouched bytes from
DWord2ByteintoByte2DWord. - Connect the output of
Byte2DWordto the target PLC coupling output tag.
Method 2: Applying Mathematical Bitwise Logic (AND/OR Masking)
For advanced simulation engineers using SIMIT Component Type Editor (CTE) or arithmetic logic components, bitmasking provides a compact mathematical solution:
Clearing a Bit (Bitwise AND with Inverse Mask):
To force Bit n to 0 without altering other bits, perform a bitwise AND operation with a mask where Bit n is 0 and all other bits are 1:
$$\text{Output} = \text{Input} \ \& \ \sim(1 \ll n)$$
Setting a Bit (Bitwise OR with Positive Mask):
To force Bit n to 1 without altering other bits, perform a bitwise OR operation with a mask where Bit n is 1 and all other bits are 0:
$$\text{Output} = \text{Input} \ | \ (1 \ll n)$$
Toggling / Overwriting a Dynamic Bit:
To write an arbitrary boolean value B (0 or 1) to Bit n:
1. Clear the bit: $\text{Cleared} = \text{Input} \ \& \ \sim(1 \ll n)$
2. Shift the new bit: $\text{MaskedBit} = (B \ \& \ 1) \ll n$
3. Combine: $\text{Output} = \text{Cleared} \ | \ \text{MaskedBit}$
In SIMIT, this can be implemented in a single custom CTE script block or using arithmetic formula components (Formula block).
Verification
To verify that only the targeted bit is modified:
- Open SIMIT in Simulation Online Mode.
- Add the input DWORD and output DWORD to the Signal Monitor window.
- Display the signal values in Hexadecimal and Binary formats.
- Toggle the simulated bit from 0 to 1: confirm that only the specific binary digit changes (e.g., 16#00000001 becomes 16#00000005 when setting Bit 2).
- Monitor the connected PCS 7 CFC chart online: verify that the target block registers the simulated state while adjacent interlock flags remain stable.
Limitations and Operational Precautions
- Cycle Execution Latency: When splitting and recombining signals across multiple standard components on a single SIMIT diagram, ensure all blocks reside in the same calculation slice (Slice 1) to prevent 1-cycle pipeline delays.
- Coupling Loop Hazards: Do not create direct circular references where an output coupling signal is fed back into its own input coupling without a state memory or latch component; circular algebraic loops cause SIMIT calculation engine errors.
- Component Type Editor (CTE) Licensing: Custom scripting via CTE requires a SIMIT Engineering license that includes CTE authorization.
Engineer FAQ
Can I write directly to a single bit of a PLC coupling DWORD in SIMIT?
If the PLC coupling tag is configured as a composite DWORD in the symbol table, SIMIT addresses the entire 32-bit variable. Individual bit addressing is only directly supported if the signal is configured as an array of booleans or separated into discrete I/O bits.
Which SIMIT library contains the DWord2Byte and Byte2Bit blocks?
These components are located in the Standard Library under the Basic -> Conversions folder in the SIMIT component task card.
Does SIMIT support hexadecimal constants in formula components?
Yes. Hexadecimal values can be entered with standard notation (e.g., 16#0004 or 0x0004) depending on the expression syntax configured in the formula block.
What happens if I disconnect an input on a Byte2DWord block?
The unconnected byte input automatically evaluates to 0x00, resulting in zeroes across that 8-bit section of the output DWORD.
Technical References
- Siemens Industry Online Support: SIMIT Simulation Platform Operating Manual (V11.x).
- SIOS Entry 109742323: PCS 7 Compendium Part A - Simulation and Virtual Commissioning.
- SIOS Entry 109809264: SIMATIC Process Control System PCS 7 Virtual Controller and SIMIT Coupling.
- Siemens Application Example: Virtual Commissioning of PCS 7 Projects with SIMIT.
Related Articles
- How to Pack and Unpack Double Words (DWORD) in SIMATIC PCS 7 CFC
- How to Configure and Simulate AS-to-AS Communication in S7-PLCSIM
- How to Move and Copy Block Interconnections in the PCS 7 CFC Editor
Related Tags
- SIMIT
- Simulation
- DWORD
- Bit Manipulation
- PLCSIM
- Virtual Commissioning
- Industrial Automation