How can I program a saw tooth-alike signal run?
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").
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.
||Test environment 1
||Test environment 2|
||Pentium III 800MHz, 264 MB
||Pentium III 800MHz, 264 MB|
|WinAC Basis V4.0|