show the entry list
Saw tooth generator with parametrizable increment and duration
Part number:

QUESTION:
How can I program a saw tooth-alike signal run?

ANSWER:  
Principally, a saw tooth signal corresponds to the change of a value towards a positive direction ( for a rising saw tooth) or towards a negative direction (for a decreasing saw tooth), whereupon the value at each case is present for a certain while.  
Following that, it is possible to use the function modules SFB 0 "CTU" incrementer, SFB 1 "CTD" reverse counter and SFB 2 "CTUD" incrementer/reverse counter in order to generate a saw tooth signal. The system function modules change its values via a positive flank at an input. The increment is 1.

Description of the Programming example
In order to avoid that a saw tooth signal is limited to count up or to count down, the following function was programmed which allows to generate a saw tooth which is both parametrizable for the increment and the duration. It is also possible to parametrize the number of the saw teeth to be generated.  
The number of the saw teeth determine the final value of the saw tooth generator.
Moreover, the saw tooth can be set as increasing and decreasing as well as "endless" or "singular". "Endless" signifies that the saw tooth - when reaching the final value- tips again towards the initial value, newly constructing the saw tooth. When setting "singular", the saw tooth is only being constructed once from the initial value towards the final value.  

The active saw tooth generator edits the current value of the saw tooth. Once the final value has been reached, this is signalised via the Status = TRUE.

 

Image 1:  Signal run at the Output "ActualValue"

The desired signal run is being generated by the parametrization of the function module (FB1 = Sawtooth_Generator). For both, the increasing and decreasing saw tooth curve, a data block has been used as Programming example. In OB1 the block is being called up alternately generating a  continous signal run.

Image 2: Called Interface referring data block FB1 (Saw tooth generator)

The attached download includes STEP 7 Project "Sawtooth_Generator"  with the described data block (FB1). The data block has been generated in AWL and can be modified if required. (The comment can be switched between German and English by the function "Manage texts multilingually").

  Saw_tooth.exe

Copy the file into a separate directory and start the file by double click. The STEP 7  Project is now being unpacked automatically including all subdirectories. Afterwards you can open and process the unpacked project by the SIMATIC Manager.

Capability of procedure and test environment
The example is applicable referring to all CPU-versions of SIMATIC S7-300, S7-400 and WinAC.
The following table lists all components   which generated this article, having verified the described mode of operation.
Components Test environment 1 Test environment 2
PC Platform Pentium III  800MHz, 264 MB Pentium III  800MHz, 264 MB
Operating system  Windows XP Windows XP
STEP 7  V5.2 V5.2
S7-CPU CPU314C-2PtP 
(6ES7314-6BF00-0AB0  V1.2)
WinAC Basis V4.0

Filter criteria:
Hardware platform: SIMATIC S7-300/S7-400
Software: STEP 7 up to V5.x
Entry contents: Function blocks/tools
 Entry ID:15236067   Date:2003-05-20 
I regard this article....as helpfulas not helpful                                 
related links
Search for minimum / maximum valu ...
How is numerical integration prog ...
pre-assigning / filling in a data ...
Writing user-specific information ...
How do you calculate a current ar ...
mySupport
My Documentation Manager 
Newsletter 
CAx-Download-Manager 
Support Request
Contact
Support Request
Contacts worldwide
Technical Forum
QuickLinks
Compatibility tool 
Performance Data 
Micro Automation Sets
Help
Online Help
Guided Tour
More info on the AV Card
More info on the AV Card