if then else

panthripu

Member
Join Date
Mar 2004
Posts
228
hi
i have one other question for s7 siemens plc.
How can i use IF ... THEN....ELSE statement in my one network of a program.
 
Hello, panthripu;

Program control and Loop instructions are available for Siemens PLCs in SCL, an add-on package to Step 7; SCL uses a Pascal-like programming environment where you can use FOR...Next, IF..Then..Else and Case() instructions.

If you do not have SCL, you can programm STL (Statement List) functions that will do the same as IF..Then..Else:

For example, say this is part of the code for FC1:
L MW24 //load control variable (content of the register MW24)
L 2 //load control value (decimal 2)
> I //evaluate if control variable is greater than control value

JNB _M00 //if not true, go to code at label _M00 (ELSE THEN)
JC _M01 // if true, go to code at label _M01 (IF)

.... // more code


_M00: L MW24
L 1
- I // if first comparision is not true, decrement MW24


_M01 : S Q0.5 //if first comparsion was true, set an output

Look at the help files on STL in the programming editor of Step7 for more details.
Hope this helps,
Daniel Chartier
 
Not to split hairs, but...

That's not exactly true, panic mode.
Typically when referring to an 'if...then...else' construct, the logic in the 'untrue' section is not touched. Your example is more of a double if...then...else:

If A Then
B = 1
Else
B = 0
End_If

If !A Then
C = 1
Else
C = 0
End_If



Daniel's method using jumps is the closest approximation to an if...then...else I know of in the S7.

Keith
 

Similar Topics

11 months ago I ordered a 10" Redlion HMI. I was given an April delivery date. April came and went. I waited, and in June I asked our vendor...
Replies
7
Views
2,369
Hi I'm starting a new job (so i'm a newbie in ftview programming ) and i have the following problem : I must update some pages in a supervision...
Replies
3
Views
5,194
I'm about to have a guy onsite (I'm trying to help troubleshoot remotely) and he doesn't have the proper software. Usually I have the guys install...
Replies
4
Views
1,739
Hey so I have an issue that is driving me insane. I have 6 AB powerflex 527 drives configured in a DLR network over CIP Safety. They go back to a...
Replies
1
Views
1,723
Back
Top Bottom