The
PLC
Guy

  Controlling Your World One Contact At A Time  


AB to AD - Instruction Set

(Math instructions have been covered under Number Types)

Most of the ladder logic will be familiar as it is similar across multiple PLC platforms. Here is one of the differences from AB.

Instead of Latch (L) and Unlatch (U) the equivalent operations are SET and Reset (RST). One nice addition is that the SET or RST command can be applied to a set of contiguous bit locations as marked by the two possible operands to these instructions. If only the first operand is entered then only one location is affected.

Most of the other instructions are analogous to those in the AB PLCs. Just be sure to read the syntax thoroughly.

Ladder Layout

AB has available a multiple file ladder logic structure. Though a complete program could be coded in file 2 any necessary subroutines must be in other files and called by JSR instructions. Indeed, many complex programs are broken up into these files to increase understandability.

The AD ladder is a single file format. The standard ladder rungs are placed in order followed at the end by rung with an unconditioned END instruction. This is the minimal program. Any subroutines, interrupt routines or fixed data sections (DLBL) follow the END rung.

Ladder Rungs
END Rung
Interrupt Routines
Subroutines
Data Labels (DLBL)

Two 'Gotchas' – here are two quirks you are sure to run into.

Gotcha 1 - “AND Above a Join”

What a cryptic error message! The following rung structure is ok in AB:

----|1|----|2|----|3|--+--|4|----(OUTPUT 1)
                       |
                       +---------(OUTPUT 2)


Unfortunately, trying to set this up in AD will result in the error message. The tapping off from before the last conditioning contact is the fault. The information on the truth of the rung after the 3rd contact simply does not exist after the 4th conditioning contact. There is no instruction which will cause it to be saved. The best work-around is this:

----|1|----|2|----|3|--+--------(OUTPUT 2)
                       |
                       +--|4|---(OUTPUT 1)


But let's say you want this:

----|1|----|2|----|3|--+--|4|----(OUTPUT 1)
                       |
                       +--|5|----(OUTPUT 2)


There is no single rung work around. You'll need to do something like this:

----|1|----|2|----|3|--+---------(CR1)
                       |
                       +--|4|----(OUTPUT 1)

----|CR1|---------|5|------------(OUTPUT 2)


That's just the way it is. So deal with it.

Gotcha 2 - The Non-Conditioned Rung

A non-conditioned rung (one with no contacts, only outputs) is only valid as the first rung of the ladder, the first rung of a stage, subroutine or interrupt routine or before an END or RET instruction (and in the case of the last two, it is mandatory)

Any rung after the first, if there are no conditioning contacts, picks up the logical truth which existed at the end of the preceding rung. DirectSOFT, in fact, on accepting re-draws the rungs into 1 rung to show exactly that relationship. If you want a rung which always executes the output you must condition it with an always on contact (for example - SP1). Like the previous 'gotcha' – that's the way it is.

Accumulator Stack

Read section 5 in the DL06 manual titled “Accumulator / Stack Load and Output Data Instructions”

It was mentioned in the section on numeric types that the steps for mathematical instructions which, in the AB world, are combined into a single box, are set as individual boxes in the AD CPUs. Another example of the breaking out of complex operations into individual steps are those that may require more information to complete. An AB Copy command needs the source, number of items and the destination all expressed in a single box.

In the AD world a similar command is executed by first loading information in to the accumulator. The MOVe command requires that the number of locations be loaded first, Then the address of the beginning source location is loaded. Each LoaD pushes the current contents of the accumulator one up on the stack and then enters its operand into the accumulator. (Don't worry, there is no 'accumulator stack overflow' error. The top information of the 8 level stack is just lost.) Finally the MOV command is invoked whose operand is the starting destination register. The first two items could be logicly conditioned breaking up the actual command execution over a few rungs but with much more flexibility.

Understanding the nature of the accumulator stack can result in much more interesting programming.

Back To Introduction

Please email comments to me at the address below.





Copyright © 2005, 2006, 2007 Bernard Carlton
berniec@theplcguy.com