PLC rung definition and evaluation
You are correct in your execution sequence and your statement that a rung can be several lines.

Ladder vs text

In the old days many of the PLCs programmers could switch between ladder and text or 'op-codes' (I can't remember the correct terminology). Mitsubishi still support this. Allen-Bradley does in that you can edit a rung of ladder with a text editor and I've used this function to create ladder logic in Excel (incrementing inputs and outputs by formula) and pasting the results back into the ladder editor. The text version gives a better clue as to the execution. Your code, for example, becomes:

   A      B                  X
--| |----| |--+-------------( )-
              |
   C          |
--| |---------+

OP            VAL    ACC    Comment
ST    A       0      0      ! Store A in ACCumulator
AND   B       0      0      ! Logical AND of B with ACCumulator
OR    C       1      1      ! Logical OR of C with ACCumulator
OUT   X       1             ! Copy ACCumulator to X


Tricky branches require BST (branch start) and BND (branch end) or equivalent which allow intermediate results to be pushed onto a stack.

A quick web search threw up this site which isn't brilliant but may be of some use.



NOT contacts

For anyone else new to this, 'not' contacts are represented by a '/'. See X1 and NOT X2 in the example below. (Many PLCs use 'X' for input and 'Y' for output.)

   X1     X2                 Y0
--| |----|/|--+-------------( )-
              |
   X3         |
--| |---------+




The OP is correct in a sense that it might give more of a visual clue to the order of execution if the ladder was drawn as follows:

   X1     X2   
--| |----|/|--+
              |
   X3         |              Y0
--| |---------+-------------( )-


The brainwave of ladder logic, however, was that it presented logic in the form of an electrical schematic that electricians were familiar with. An electrician would 'know' that current could flow 'up' the or branch to the coil. One of the common problems in electrician training was to get across the concept that, while the ladder listing looks as though everything operates simultaneously, in fact it is being executed sequentially.

Taking advantage of sequential scan

The home-made one-shot example below shows an example of using sequential logic which might not work with real relay logic.

! C0 fires for one scan when X1 turns on
! provided the one-shot memory is off.
   X1     C1                 C0
--| |----|/|----------------( )-

! C1 'remembers' that X1 was on.
   X1                        C1
--| |-----------------------( )-

! Y0 fires for one program scan.
   C0                        Y0
--| |-----------------------( )-


The logic should be fairly clear. Trying to do this with relays would create a race condition (although there would be other solutions in that case).



Program execution order

Typically PLCs task execution order runs as follows:


Read the inputs.
Execute the logic.
Write the outputs.
Handle other tasks, etc.


Each 'scan' on newer processors takes &lt; 1 ms which has come down a lot from the early days where 20 - 50 ms would have been common for larger programs.



Online status monitoring

For those new to the subject: the ladder diagram is also very useful for online debugging. The status of the contacts or 'power flow' is indicated by changing colour or wire representation.

   X1     X2                 Y0
--| |--==|/|==+=============( )-
              |
   X3         |
==| |=========+


In the example above we can see that we have an open contact in the first branch (indicating that X1 is off) whereas the lower branch has a complete circuit through X3 to Y0 which turns on. This gives an easy to understand visualisation of the program logic.