show the entry list
STEP 7 (TIA Portal) -- Creating S7 programs -- Creating program sequences
How can you migrate alarms in the TIA Portal from the S7-300/400 to the S7-1500?
In STEP 7 (TIA Portal) V12, why do you have to insert a SET instruction after a jump command in order to ensure a first scan?
Where in STEP 7 (TIA Portal) V11 is there a program for the S7-1200 that lets different bit patterns rotate or flash under time control?
Recommended programming for S7-1200 and S7-1500 with STEP 7 (TIA Portal) V12
In STEP 7 (TIA Portal) V11, how do you calculate a current arithmetic average value from any number of values read in?
In STEP 7 (TIA Portal) V11, how do you calculate the minimum and maximum limit values for a temperature range?
How do you convert degrees into radians and vice versa in STEP 7 (TIA Portal) V11?
In STEP 7 (TIA Portal) V11, how can you buffer the return values from the "RETVAL" parameter consecutively in a DB?
How do you calculate in STEP 7 (TIA Portal) V11 the distance "D" between two points in a rectangular coordinate system?
How do you define a setpoint value with ramp function in STEP 7 (TIA Portal) V11?
How do you establish a MODBUS-RTU communication with STEP 7 (TIA Portal) for the SIMATIC S7-1200?
In STEP 7 (TIA Portal) V11 how can you invert an output signal of the "Bool" data type after each positive edge?
In STEP 7 (TIA Portal) V11, how can you count forwards and backwards in a bandwidth between -2147483648 and +2147483647?
How can you process 64-bit floating-point numbers in STEP 7 V11 with a SIMATIC S7-300/400 CPU?
In STEP 7 (TIA Portal) V11, how can you count forwards and backwards in a bandwidth between -2147483648 and +2147483647?
Part number:

Instructions
The attached download "STEP7_D_Count_V11_SP2.zip" performs counting forwards and backwards in a bandwidth between -2147483648 and +2147483647 by an edge change at the "Up" and "Down" inputs. An edge change at the "L_Preset" input transfers a value preset at the "Preset" parameter to the "Count" output. The forwards and backwards counting via the parameters "Up" and "Down" increments/decrements the value at the "Count" output accordingly by "1". If during counting the "Count" output reaches a value that is equal to or greater than the value entered at the "Compare" input, "Q_Compare" output receives the signal "1".


Fig. 01

Sample application
Boxes are transported from A to B on a conveyor belt.

  • Scan 1 detects the boxes placed on the conveyor and with the input E0.0 the value at the "Count" output is incremented by "1".
  • Scan 2 detects the boxes removed from the conveyor and with the input E0.1 the value at the "Count" output is decremented by "1".
  • If boxes are removed or sorted out during the course of the transport and are not detected by Scan 2, then the value at the "Count" output increases due to the difference by "1" for each box removed. For example, if a value of 20 boxes is set at the "Compare" parameter and the "Count" output reaches the value 20, the output A0.0 receives the signal "1". This is the difference value of the boxes removed in addition or lost.

Through a plug-in (not included in the download FB100), you can program stopping of the conveyor belt with reference to the signal at output A0.0.


Fig. 02

The table below describes how to program the function block FB100 shown in Fig. 01. FB100 is called with its instance DB DB100 in OB1.
   
No. Description of program in FB100
1 Network 1:
A positive edge at the input "Up" (type: BOOL) increments the static variable "S_Count" (type: DINT) so that counting goes forwards by "1" at every edge change here.
2 Network 2:
A positive edge at the input "Down" (type: BOOL) decrements the static variable "S_Count" (type: DINT) so that counting goes backwards by "1" at every edge change here.
3 Network 3:
A positive edge at the input "L_Preset" (type: BOOL)  transfers the preset value between the input "Preset" (type: DINT) and the static variable "S_Count".
4 Network 4:
The value of the static variable "S_Count" actually calculated from Networks 1, 2 or 3 is transferred to the output "Count" (type: DINT).
5 Network 5:
Here there is query as to whether the value at the output "Count" is greater or equal to the comparison value entered at the input "Compare" (type: DINT). In this case the output "Q_Compare" (type: BOOL) receives the signal "1".
Table 01

The attached download contains a STEP 7 project with the blocks described above (FB100, instance DB100 and OB1).

STEP7_D_Count_V11_SP2.zip ( 1459 KB )   

Copy the "STEP7_D_Count_V11_SP2" file into a separate directory and then start the file with a double-click. The STEP 7 (TIA Portal) V11 project is now unpacked automatically with all the associated subdirectories. You can then use STEP 7 (TIA Portal) V11 to open and process the extracted project.

Creation environment
The pictures and download in this FAQ were created with STEP 7 V11+SP2.

 Entry ID:39309294   Date:2012-02-29 
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