Description:The S7-200 provides the option of counting pulse trains using high-speed counters. Using the attached "Frequency" library, the frequency of the pulse train is calculated from the counter signal, from which the speed of stepper motors, for example, can be determined after relevant conversion.
1. Define a fast counter to capture the pulse train frequencyFirst, using the STEP 7 Micro/WIN Instruction Wizard you must generate a high-speed counter that counts the external pulses.
Table 01 shows which high-speed counters the S7-200 provides, which inputs these use and the maximum measurable frequency.
High-speed counters | Clock input | Max. input frequency | CPUs |
HC0 | E0.0 | 30 kHz | 221, 222, 224, 224XP, 224XPsi, 226 |
HC1 | E0.6 | 30 kHz | 221, 222, 224, 224XP, 224XPsi, 226 |
HC2 | E1.2 | 30 kHz | 221, 222, 224, 224XP, 224XPsi, 226 |
HC3 | E0.1 | 30 kHz | 221, 222, 224, 224XP, 224XPsi, 226 |
HC4 | E0.3 | 200 kHz | 224XP, 224XPsi |
HC5 | E0.4 | 200 kHz | 224XP, 224XPsi |
Table 01
Procedure:
No. | Description |
1 | Open the Instruction Wizard via the "Tools" menu in STEP 7 Micro/WIN.
Fig. 01
|
2 | There you select the high-speed counter "HSC" from the configuration catalog. Then click on "Next >".
Fig. 02
|
3 | Leave the mode set to "0" for single-phase up/down counting and select a counter (e.g. "HC4").
Fig. 03
Note:Please refer to Table 01 for selecting the high-speed counter.
|
4 | Leave the settings for the subprograms, counter presettings, counter value and counting direction. Click on "Next".
Fig. 04
|
5 | In the next window, also leave the presetting, and do not set a check mark for "Interrupt on Current Value equal Preset Value (CV = PV)".
Fig. 05
|
6 | Close the Instructions Wizard with the "Finish" button.
Fig. 06
|
Table 02
2. Create the program code
No. | Description |
1 | In network 1 of the operation block use the initialization bit SM0.1 to call the initialization block generated by the Instructions Wizard for the high-speed counter.
Fig. 07
|
2 | In network 2 you cyclically call (SM0.0) the "Frequency" block from the library with the same name in the list.
Fig. 08
Enable the function via the connection of the "Active" input (when disabled, the "Hz" parameter outputs the value "0"). Address the "Counter" with the counter selected with the Instructions Wizard. Address the IN-OUT parameter "Hz" with a free double-word (Format: REAL) for displaying the frequency measured in Hertz. The "Trigger" output provides a pulse signal for optional recording of the frequency characteristic via the Data Log function (see Step 5).
|
3 | The "Frequency" library needs 16 bytes in the global variable memory. For this you specify an address via "File" -> "Library Memory Allocation...".
Fig. 09
|
4 | Via the "Symbol Table" view you get to symbolic addressing of the "Frequency" library. The "Time_interval" symbol defines the measuring interval in seconds for the frequency calculation. The default setting is an interval time of 1 second, but you can change this.
Fig. 10
|
5 | As an option, in network 3 of the sample project "Frequency", the Data Log function is incorporated for capturing the frequency time on a memory module. Via the AND operation of the "Active" and "Trigger" signals, when you activate the "Frequency" block, each frequency is recorded at the intervals of the "Time_interval" set.
Fig. 11
Note:The Data Log function is executed via the Data Log Wizard and the values recorded can be read out via the S7-200 Explorer. More information on the Data Log function is available in the SIMATIC S7-200 Video Tutorial (Entry ID: 30839030).
|
Table 03
3. Convert the frequency determined into a speedApply the following formula to obtain a speed:
n = 60 * f / p
n = Speed in minutes-1 f = Frequency in Hz p = Number of pulses required for one motor revolution
Download:The download "frequency.zip" contains the following files:
File | Description |
"frequency.mwl" library | - contains the "Frequency" block (see Table 03, Step 2) |
"frequency.mwp" project | - sample project for this FAQ |
"tspeed01.mwp" project | - alternative implementation of this task via a cycle-independent time interrupt (setting range: 1 to 255 ms |
Note:Information on inserting libraries in STEP 7 Micro/WIN is available in Entry ID: 16689345
|
0 comments :
Post a Comment