Kkula
Browse Questions » Meet & Talk: Is Able To you give me an example about Fuzzy Algorithm Within Statement list Within S7-300?

About User

Questions Asked: 24.4K

Answers Given: 0

0
  • Open

Meet & Talk: Is Able To you give me an example about Fuzzy Algorithm Within Statement list Within S7-300?

hi H -H, can you give me an example about Fuzzy logic in STL in S7-300. 1 Input, 1 output. 3 rule. we write in FC2.
thank you very much !

0 Likes 0 Favourites 0 Followers 0 Comments
Answers(1)

Fuzzy Logic in STL (S7-300) Example

Here's a simplified example of fuzzy logic implementation in STL for an S7-300 PLC using FC2, with 1 input, 1 output, and 3 rules. This demonstrates the *concept*; direct fuzzy logic blocks are not native to S7-300 STL. You'll be simulating fuzzy behavior.

Scenario: Temperature Control

Input: Temperature (Analog Value, 0-100 representing 0-100°C)

Output: Heater Control (0-100, representing heater power)

Rules:

  1. IF Temperature is Low THEN Heater Control is High
  2. IF Temperature is Medium THEN Heater Control is Medium
  3. IF Temperature is High THEN Heater Control is Low

STL Code (in FC2 - example)


// Define Fuzzy Regions (Adjust these thresholds)
#define LOW_TEMP 30
#define HIGH_TEMP 70

// Input & Output Variables
VAR_INPUT
  Temperature : INT;
END_VAR

VAR_OUTPUT
  HeaterControl : INT;
END_VAR

// Local Variables
VAR
  TempValue : INT;
END_VAR

BEGIN
  // Fuzzy Logic Implementation (Simplified)

  IF Temperature < LOW_TEMP THEN
    HeaterControl := 100;  // High Heater Power
  ELSIF Temperature > HIGH_TEMP THEN
    HeaterControl := 0;   // Low Heater Power
  ELSE
    HeaterControl := 50;  // Medium Heater Power
  END_IF;

END_FUNCTION

Important Notes:

  • This is a *very* basic simulation of fuzzy logic. True fuzzy logic involves membership functions and inference engines.
  • Adjust LOW_TEMP and HIGH_TEMP to refine the fuzzy regions.
  • For complex fuzzy logic, consider using Siemens libraries or third-party tools for higher PLCs (S7-1200/1500) that offer native fuzzy logic support.

For more detailed information on S7-300 programming and STL, please refer to the SiePortal documentation: Siemens Industry Support Portal

0
Add a comment