SeattlePLC
Member
What would a RLL diagram for If A then B else C look like?
I get the |--|A|---|B|---??? but I'm confused on the else C portion.
I get the |--|A|---|B|---??? but I'm confused on the else C portion.
| A B |
|---| |-------( )---|
| |
| A C |
|---|/|-------( )---|
| |
For Relay Ladder Logic (RLL) diagrams, your symbols must distinguish between relay contacts (inputs) "---| |---" and relay coils (results or outputs) "---( )---.
| A B |
|---| |-------(S)---|
| |
| A C |
|---|/|-------(S)---|
| |
The PLC ain't got an Else so instead, don't call them "if then else" statements, read them to yourself as "if then, if not then" as you write them in RLL just like lancie did.
If A THEN B // This state does not turn of B if false
IF NOT A THEN C // this statement does not turn of C if true
It becomesIf A then B Else C becomes
B := A
C := NOT A
B:=B OR A;
C:=C OR NOT A;
If a then
b=true;
else
c=true;
endif
breaks down in to assembly code like this:
LD A
JZ L000
LD 1
ST B
JMP L001
L000:
LD 1
ST C
L001:
You are over-thinking one little part of this: It is RELAY logic. I happen to know that for a Relay Coil B controlled by A Input, when the Input is OFF, the Relay Coil B goes off by default (it has no power). If this were not true, the hundreds of relay panels that I wired up in the past 60 years would not have worked!There is nothing in if A then B else C that would turn of B or C
I think I am correct - this is for a student relay logic diagram.What would a RLL diagram for If A then B else C look like?
A B
-----] [-----( )--
(* Computer Science 'Type' Translation *)
IF A THEN
B := TRUE;
ELSE
B := FALSE;
END_IF;
(* Safer Direct Assignment 'Type' Translation *)
B := A;