eBook: Integration and Automation of Manufacturing Systems
   



TOC PREV NEXT

10.13 INSTRUCTION TYPES


There are basic categories of instructions,

Basic (discussed before)
- relay instructions
- timer instructions
- counter instructions
Program Control
- branching/looping
- immediate inputs/outputs
- fault/interrupt detection
Basic Data Handling
- moves
- computation instructions
- boolean instructions
- conversion
Logical
- comparisons
Advanced Data Handling
- file instructions
- shift registers/stacks
Complex
- PID
- communications
- high speed counters
- ASCII string functions

The reader should be aware that some functions are positive edge triggered (i.e. they only work the scan is active). while most are active any time the input is active. Some examples of edge triggered and non-edge triggered functions are listed below,

Edge Triggered
CTU, CTD
Non-edge triggered
TON, TRO, TOF, ADD, MUL, etc.

10.13.1 Program Control Structures

These change the flow of execution of the ladder logic.

10.13.2 Branching and Looping

These functions allow control found in languages like Fortran

IF-THEN is like MCR (Master Control Reset)
GOTO is like JMP (Jump)
SUBROUTINES is like Program Files

MCR blocks have been used earlier, but they are worth mentioning again.



Block of ladder logic can be bypassed using a jump statment.



Subroutines allow reusable programs to be written and called as needed. They are different from jump statements because they are not part of the main program (they are other program files), and arguments can be passed and returned.



For next loops can also be done to repeat blocks of ladder logic inside a single scan. Care must be used for this instruction so that the ladder logic does not get caught in an infinite, or long loop - if this happens the PLC will experience a fault and halt.



Ladder logic programs always have an end statement, but it is often taken for granted and ignored. Most modern software automatically inserts this. Some PLCs will experience faults if this is not present.



There is also a temporary end (TND) that for a single ladder scan will skip the remaining portion of a program.

A one shot contact can be used to turn on a ladder run for a single scan. When the run has a positive rising edge the oneshot will turn on the run for a single scan. Bit `B3:0' is used here to track to rung status.



10.13.2.1 - Immediate I/O Instructions



This approach avoids problems caused by logic setting and resetting outputs before done.

If we have a problem we may want to update an output immediately, and not wait for the PLC to complete its scan of the ladder logic. To do this we use immediate inputs and outputs.



10.13.2.2 - Fault Detection and Interrupts

The PLC can be set up to run programs automatically. This is normally done for a few reasons,

- to deal with errors that occur (eg. divide by zero)
- to run a program at a regular timed interval (eg. SPC calculations)
- to respond when a long instruction is complete (eg. analog input)
- when a certain input changed (eg. panic button)

Two types of errors will occur - terminal (critical) and warnings (non-critical). A critical failure will normally stop the PLC.

In some applications faults and failures must be dealt with in logic if possible, if not the system must be shut down.

There are some memory locations that store indications of warning and fatal errors that have occurred. The routine in program file [S:29] needs to be able to detect and clear the fault.

S:29 - program file number to run when a fault occurs

To set a timed interrupt we will set values in the status memory as indicated below. The program in file [S:31] will be run every [S:30]ms.

S:30 - timed delay between program execution - an integer number of ms
S:31 - the program number to be run

To cause an interrupt when a bit changes the following bits can be set.

S:46 - the program file to run when the input bit changes
S:47 - the rack and group number (eg. if in the main rack it is 000)
S:48 - mask for the input address (eg. 0000000000000100 watches 02)
S:49 - for positive edge triggered =1 for negative edge triggered = 0
S:50 - the number of counts before the interrupt occurs 1 = always up to 32767

10.13.3 Basic Data Handling

Some handy functions found in PLC-5's (similar functions are available in other PLC's)

10.13.3.1 - Move Functions

There are two types of move functions,

MOV(value,destination) - moves a value to a memory location
MVM(value,mask,destination) - moves a value to a memory location, but with a mask to select specific bits.

The following function moves data values between memory locations. The following example moves a floating point number from floating point memory 7 to 23



The following example moves a floating point number from floating point memory F8:7 to integer memory N7:23



The following example puts an integer value 123 in integer memory N7:23



A more complex example of the move functions follows,



TOC PREV NEXT

Search for More:

Custom Search