AND, OR and NOT
Part of the Structured Text section of Coddy's PLC Programming journey. Lesson 2 of 17.
Series and parallel contacts become words. Contacts in series are AND, a parallel branch is OR, and a normally closed contact is NOT.
The same two rungs as text:
Horn := (PB1 OR PB2) AND SW1;
Red := NOT SW1;Watch the brackets. AND is worked out before OR, the way multiplication comes before addition. Without brackets, PB1 OR PB2 AND SW1 means PB1 OR (PB2 AND SW1): PB1 would sound the horn with SW1 off.
Challenge
Easy- Sound
HornwhileSW1is on andPB1orPB2is held. - Light
RedwhileSW1is off.
Press Run, try it on the machine, then Check.
Try it yourself
// The horn: (PB1 or PB2) and SW1
// The red lamp: while SW1 is off
All lessons in Structured Text
1From Rungs to Text
Your First StatementAND, OR and NOTThe Seal-In in TextIF and THENVariables in VARPractice on your own: PLC playground