Kkula
Browse Questions » LOGO! - Projects: Compare Continuous Signal values

About User

Questions Asked: 24.4K

Answers Given: 0

0
  • Open

LOGO! - Projects: Compare Continuous Signal values

Hello ixo65,
i want to compare to analog values,
Case one e.g a>b
Case two a<=b
is the code that you have posted suitable for my case or can you give me an example for my application.I saw your code but still i dont get the point about comparing values!
Thank you in advance
------------------------------------------------------------------------------------------
Split from
Comparing an analog input to a setpoint variable from an HMI
.

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

Comparing Analog Values in TIA Portal

Hello! Regarding your need to compare two analog values (a > b and a <= b), the previous code snippets provide a foundation, but let's clarify and tailor it to your application. The core concept revolves around using comparison instructions within your TIA Portal program (S7-1200/1500).

Comparison Logic

You'll use the following instructions, typically within a Function Block (FB) or Function (FC):

  • > (Greater Than): Compares if 'a' is greater than 'b'.
  • <= (Less Than or Equal To): Compares if 'a' is less than or equal to 'b'.

Example Code (LAD/FBD)

Here's a basic example in LAD. Adapt this to your specific data types (INT, REAL, etc.):

NETWORK 1:
  // a > b
  CMP >  IW60, IW62  // Compare Input Word 60 (a) > Input Word 62 (b)
  JMP_IF_TRUE  Greater_Than_Block

NETWORK 2:
  // a <= b
  CMP <= IW60, IW62  // Compare Input Word 60 (a) <= Input Word 62 (b)
  JMP_IF_TRUE  Less_Equal_Block

// ... Blocks for handling the results (Greater_Than_Block, Less_Equal_Block)

Important: Replace IW60 and IW62 with your actual analog input addresses or variable names. The 'CMP' instruction sets a status bit based on the comparison result, which 'JMP_IF_TRUE' uses to branch your logic.

Further Resources

If you provide details about your specific PLC (S7-1200/1500), the data types of your analog values, and how you want to *use* the comparison result (e.g., trigger an output, set a flag), I can provide a more targeted example.

0
Add a comment