show the entry list
STEP 7 (TIA Portal) -- Creating S7 programs -- Executing operations
How do you filter only the places before and after the decimal point from a real value in STEP 7 (TIA Portal) V11?
How do you calculate the linear values for the y-coordinate of point P in STEP 7 (TIA Portal) V11?
How can you add together physical flow measurements (mass flow rate, for example) to a total value in STEP 7 (TIA Portal) V11?
How do you implement numerical differentiation in STEP 7 (TIA Portal) V11?
How do you convert data types in the TIA Portal for the S7-1200/1500?
How can you convert a hexadecimal number into ASCII characters with STEP 7 (TIA Portal) V11?
How can you determine the bit position of an active bit in a marker word with STEP 7 V11 and monitor a 32-bit field?
How can you delay the output signal in relation to the input signal in STEP 7 (TIA Portal) V11?
In STEP 7 (TIA Portal) V11, how can you scale integer values in real numbers and real values in integer numbers for analog measurements?
How do you copy memory areas in STEP 7 (TIA Portal) V11?
How in STEP 7 V11 can you access the unstructured data types bit-by-bit, byte-by-byte or word-by-word and symbolically?
How do you program the overlapping of tags with the keyword "AT" in the TIA Portal V11?
How do you program a pulse encoder in STEP 7 (TIA Portal)?
How do you program a shift register with the LAD/FBD statements in STEP 7 V5.5 and in V11?
What properties do you have to watch out for in STEP 7 V11 when you are inserting characters into a string with the "INSERT" statement?
How can you determine the bit position of an active bit in a marker word with STEP 7 V11 and monitor a 32-bit field?
Part number:

Description
The STEP 7 (TIA Portal) V11 program "STEP7_V11_Bit_Field_Pos" includes two functions that you can use to determine the bit position of an active bit in a marker word and monitor a 32-bit field for incoming and outgoing events.

Evaluation of the bit position of the active bit in a marker word
The "Bit_Pos" function calculates the active bit in a marker word. If, for example, you program a sequence control in a marker word for a sequential process, then in this marker step word only one bit is ever active corresponding to the currently active step of the sequencer. Using the bit count you can visualize the active step as plaintext via symbol lists in a visualization system, for example. For visualization it is better to receive the bit position and thus the currently active step as an integer value.


Fig. 01

When just one bit is always set, this yields the following correlation:

2X = Y
X = lnY / ln2

Here X is the bit position and Y is the value of the marker word. For the bit position you must increment X by 1. In addition, the "Bit_Pos" function takes into account the two special cases where the value Y must not be zero or negative (sign).

Monitoring of a 32-bit field
In order to monitor a 32-bit field for incoming and outgoing events, you can use the "Monitor_Bit" function to query the bits to be monitored for positive and negative edges. However, just as in the example described above, a double-word is defined here as DINT and the set bit is calculated.

Programming in the "Monitor_Bit" function is implemented as follows:

  • In order to filter out from any number of bits set the bit that has changed its status in this cycle you use an EXCLUSIVE OR DOUBLE WORD operation between the value of the last cycle and that of the current cycle. An EXCLUSIVE OR yields only that bit which occurs exclusively for one of the two values.
  • Using another AND query you determine whether that bit is an incoming or outgoing signal.
  • If only one bit is set for this double integer, then the definition described above applies for the DI value Y. You obtain the X value from this conversion: X = lnY / ln2 and the bit position is yielded with the increment: X + 1.

Note
You can determine the incoming and outgoing events for Bits 1 to 31 arbitrarily, which applies for the value range of 0 to +2147483647. Bit 32 is valid for the sign. If Bit 32 receives the signal status 1, the number for the set Bit 32 is output ("Bit" output) and the bit for the "Event_Come" output (for incoming event) is set. However, if you continue to use the function and want to determine more incoming and outgoing events, you must reset Bit 32 to zero beforehand.


Fig. 02

In the example in Fig. 02 the signal status at Bit 16 has changed from 0 to 1. The determined bit no. 16 is output at the "Bit" output and the "Event_Come" output receives the True signal (for an incoming event).

Copy the "STEP7_V11_Bit_Field_Pos.zip" file into a separate directory and then start the file with a double-click. The STEP 7 project is now unpacked automatically with all the associated subdirectories. You can then use STEP 7 V11 to open and process the extracted project. The two functions include German and English comments.

STEP7_V11_Bit_Field_Pos.zip ( 2492 KB )  

Creation environment
The screens and download in this FAQ response were created with STEP 7 (TIA Portal) V11. The following table lists the components that have been used to create this entry and verify the functions described.
 
Test environment Version
PC platform Intel(R) Core(TM)2 Duo CPU P8700 2.53 GHz
PC operating system MS Windows XP SP3
STEP 7 (TIA Portal) V11 + SP2
CPU 1214C (6ES7214-1AE30-0XB0) Firmware V2.0

 Entry ID:48816937   Date:2012-05-21 
I regard this article....as helpfulas not helpful                                 
mySupport
My Documentation Manager 
Newsletter 
CAx-Download-Manager 
Support Request
To this entry
Print
Create PDF 
Send to a friend
QuickLinks
Compatibility tool 
Help
Online Help
Guided Tour