Controlling Your World One Contact At A Time
AB to AD - Instruction Set
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 LayoutAB 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.
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:
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:
But let's say you want this:
There is no single rung work around. You'll need to do something like this:
That's just the way it is. So deal with it.
Gotcha 2 - The Non-Conditioned RungA 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 StackRead 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.