|
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.
|