Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 6 of 70

SLC 500 Instruction Set Reference Manual, pages 51 to 60

Pages 51 to 60 of 694

The original document is the PDF (7.2 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Allen-Bradley 1747-L514

Page 51

Basic Instructions

2-15

Using Status Bits Table 2.11 Setting CTD Status Bits This Bit

Is Set When

And Remains Set Until One of the Following

Count Down Underflow Bit UN (Bit 11)

accumulated value wraps around to +32,767 (from -32,768) and continues counting down from there a RES instruction having the same address as the CTD instruction is enabled. OR the count is incremented greater than or equal to +32,767 with a CTU instruction

Done Bit DN (Bit 13)

accumulated value is equal to or greater than the preset value the accumulated value becomes less than the preset

Count Down Enable Bit CD (Bit 14)

rung conditions are true rung conditions go false OR a RES instruction having the same address as the CTD instruction is enabled

The accumulated value is retained after the CTD instruction goes false, or when power is removed from and then restored to the controller. Also, the on or off status of counter done, overflow, and underflow bits is retentive. The accumulated value and control bits are reset when the appropriate RES instruction is executed. The CD bits are always set prior to entering the REM Run or REM Test modes.

High-speed Counter (HSC)

HSC HIGH SPEED COUNTER Counter C5:0 Preset 120 Accum 0

(CU) (DN)

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 • Output Instruction

The High-speed Counter is a variation of the CTU counter. The HSC instruction is enabled when the rung logic is true and disabled when the rung logic is false.

IMPORTANT

Do not place the XIC instruction with address I:0/0 in series with the HSC instruction because counts will be lost.

The HSC instruction counts transitions that occur at input terminal I:0/0. The HSC instruction does not count rung transitions. You enable or disable the HSC rung to enable or disable the counting of transitions occurring at input terminal I:0/0. We recommend placing the HSC instruction in an unconditional rung. The HSC is a special CTU counter for use with 24 VDC SLC fixed controllers. The HSC’s status bits and accumulated values are non-retentive.

Publication 1747-RM001G-EN-P - November 2008

Page 52

2-16

Basic Instructions

This instruction provides high-speed counting for fixed I/O controllers with 24 VDC inputs. One HSC instruction is allowed per controller. To use the instruction, you must cut the jumper as shown below. A shielded cable is recommended to reduce noise to the input.

High-speed Counter Data Elements Address C5:0 is the HSC counter 3-word element.

Table 2.12 High Speed Counter Structure 15

14

13

12

11

10

CU

CD

DN

OV

UN

UA

09

08

07

06

05

04

03

02

Not Used

01

00

Word 0

Preset Value

1

Accumulator Value

2

CU

Count up enable (Bit 15)

CD

Count down enable (Bit 14)

DN

Done bit (Bit 13)

OV

Overflow bit (Bit 12)

UN

Underflow bit (Bit 11)

UA

Update accumulator (HSC only) (Bit 10)

• Word 0 contains the following status bits of the HSC instruction. – Bit 10 (UA) updates the accumulator word of the HSC to reflect the immediate state of the HSC when true. – Bit 12 (OV) indicates if a HSC overflow has occurred. – Bit 13 (DN) indicates if the HSC preset value has been reached. – Bit 15 (CU) shows the Enable/Disable state of the HSC instruction. • Word 1 contains the preset value that is loaded into the HSC when either the RES instruction is executed, when the Done bit is set, or when powerup takes place. The valid range is + 1 to + 32767. • Word 2 contains the HSC accumulator value. This word is updated each time the HSC instruction is evaluated and when the update accumulator bit is set using an OTE instruction. This accumulator is read only. Any value written to the accumulator is overwritten by the actual high-speed counter on instruction evaluation, reset, or REM Run mode entry.

Publication 1747-RM001G-EN-P - November 2008

Page 53

Basic Instructions

2-17

High-speed Counter Operation For high-speed counter operation you must: 1. Turn off power to the fixed controller. 2. Remove the SLC 500 cover. 3. Locate and cut jumper wire J2. Do not remove completely but make certain that the ends of the cut jumper wire are not touching each other. The High-speed Counter jumper is located either beneath the battery connector OR to the right of the battery connector.

4. Replace the cover. Input I:0/0 then operates in the high-speed mode. The address of the high-speed counter enable bit is C5:0/CU. When rung conditions are true, C5:0/CU is set and transitions occurring at input I:0/0 are counted. To begin high-speed counting, load a preset value into C5:0.PRE and enable the counter rung. To load a preset value, do one of the following. • Change to the REM Run or REM Test mode from another mode • Power up the processor in the REM Run mode • Reset the HSC using the RES instruction Automatic reloading occurs when the HSC itself sets the DN bit on interrupt. Each input transition that occurs at input I:0/0 causes the HSC accumulated value to increment. When the accumulated value equals the preset value, the Done bit (C5:0/DN) is set, the accumulated value is cleared, and the preset value (C5:0.PRE) is loaded into the HSC in preparation for the next high-speed transition at input I:0/0. Your ladder program should poll the Done bit (C5:0/DN) to determine the state of the HSC. Once the Done bit has been detected as set, the ladder program should clear bit C5:0/DN (using the unlatch OTU instruction) before the HSC accumulated again reaches the preset value, or the overflow bit (C5:0/OV) will be set. Publication 1747-RM001G-EN-P - November 2008

Page 54

2-18

Basic Instructions

The HSC differs from the CTU and CTD counters. The CTU and CTD are software counters. The HSC is a hardware counter and operates asynchronously to the ladder program scan. The HSC accumulated value (C5:0.ACC) is normally updated each time the HSC rung is evaluated in the ladder program. This means that the HSC hardware accumulator value is transferred to the HSC software accumulator. Only use the OTE instruction to transfer this value. The HSC instruction immediately clears bit C5:0/UA following the accumulated update. Many HSC counts may occur between HSC evaluations, which would make C5:0.ACC inaccurate when used throughout a ladder program. To allow for an accurate HSC accumulated value, the update accumulator bit (C5:0/UA) causes C5:0.ACC to be immediately updated to the state of the hardware accumulator when set. Use the RES instruction to reset the high-speed counter at address C5:0. The HSC instruction clears the status bits, the accumulator, and loads the preset value during: • power up. • entry into the REM Run mode. • a reset.

Application Example In the following figures, rungs 1, 18, and 31 of the main program file each consist of an XIC instruction addressed to the HSC done bit and a JSR instruction. These rungs poll the status of the HSC done bit. When the Done bit is set at any of these poll points, program execution moves to subroutine file 3, executing the HSC logic. After the HSC logic is executed, the Done bit is reset by an unlatch instruction, and program execution returns to the main program file.

Publication 1747-RM001G-EN-P - November 2008

Page 55

Basic Instructions

2-19

Application Example - File 2 (Poll for DN Bit in Main Program)

JSR

Rung

1

C5:0 ] [ DN

Rung

2

] [

] [

] [

( )

] [

] [

( )

JUMP TO SUBROUTINE

• • •

Rung

17

] [

Rung

18

C5:0 ] [ DN

Rung

19

] [

] [

] [

( )

] [

] [

( )

• • •

Rung

30

] [

Rung

31

C5:0 ] [ DN

Rung

32

] [

3

JSR JUMP TO SUBROUTINE

3

JSR JUMP TO SUBROUTINE

( )

] [

] [

3

Application Example - File 3 (Execute HSC Logic)

Rung

0

] [

Rung

1

] [

( ) ] [

Application Logic

( )

] [

• • • Rung

20

Rung

21

C5:0 (U) DN

Unlatch DN Bit

RET RETURN

Publication 1747-RM001G-EN-P - November 2008

Page 56

2-20

Basic Instructions

Use a RES instruction to reset a timer or counter. When the RES instruction is enabled, it resets the Timer On Delay (TON), Retentive Timer (RTO), Count Up (CTU), or Count Down (CTD) instruction having the same address as the RES instruction.

Reset (RES)

Table 2.13 Using an RES Instruction

(RES)

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

Using a RES instruction for a:

The processor resets the:

Timer (Do not use a RES instruction with a TOF.)

ACC value to 0 DN bit TT bit EN bit

Counter

ACC value to 0 OV bit UN bit DN bit CU bit CD bit

Control

POS value to 0 EN bit EU bit DN bit EM bit ER bit UL bit IN and FD go to last state

•

Output Instruction

When resetting a counter, if the RES instruction is enabled and the counter rung is enabled, the CU or CD bit is reset. If the counter preset value is negative, the RES instruction sets the accumulated value to zero. This in turn causes the done bit to be set by a count down or count up instruction.

ATTENTION

Publication 1747-RM001G-EN-P - November 2008

Because the RES instruction resets the accumulated value, and the done, timing, and enabled bits, do not use the RES instruction to reset a timer address used in a TOF instruction. Otherwise, unpredictable machine operation or injury to personnel may occur.

Page 57

Chapter

3

Comparison Instructions

This chapter contains general information about comparison instructions and explains how they function in your application program. Each of the comparison instructions includes information on: • the instruction symbol. • instruction usage. Table 3.1 Comparison Instructions Instruction Mnemonic EQU

Instruction Name Equal

NEQ

Not Equal

LES

Less Than

LEQ

Less Than or

Equal GRT

Greater Than

GEQ

Greater Than or Equal

MEQ

Masked

Comparison for Equal

LIM

Limit Test

About the Comparison Instructions

Purpose Page Test whether two values are 3-2 equal. Test whether one value is not 3-2 equal to a second value. Test whether one value is less 3-3 than a second value. Test whether one value is less 3-3 than or equal to a second value. Test whether one value is greater 3-3 than another. Test whether one value is greater 3-4 than or equal to a second value. Test portions of two values to see 3-4 whether they are equal. Compares 16-bit data of a source address to 16-bit data at a reference address through a mask. Test whether one value is within 3-5 the limit range of two other values.

Comparison instructions are used to test pairs of values to condition the logical continuity of a rung. As an example, suppose a LES instruction is presented with two values. If the first value is less than the second, then the comparison instruction is true. To learn more about the compare instructions, we suggest that you read the Compare Instructions Overview that follows.

1

Publication 1747-RM001G-EN-P - November 2008

Page 58

3-2

Comparison Instructions

Comparison Instructions Overview

The following general information applies to comparison instructions.

Using Indexed Word Addresses When using comparison instructions, you have the option of using indexed word addresses for instruction parameters specifying word addresses.

Using Indirect Word Addresses You have the option of using indirect word-level and bit-level addresses for instructions specifying word addresses when using an SLC 5/03 OS302, SLC 5/04 OS401, or SLC 5/05 processors.

Equal (EQU) EQU Equal Source A

Use the EQU instruction to test whether two values are equal. If source A and source B are equal, the instruction is logically true. If these values are not equal, the instruction is logically false.

N7:0 0< N7:1 0<

Source B

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

Source A must be an address. Source B can either be a program constant or a address. Negative integers are stored in two’s complement form.

•

Input Instruction

Not Equal (NEQ) NEQ Not Equal Source A Source B

Use the NEQ instruction to test whether two values are not equal. If source A and source B are not equal, the instruction is logically true. If the two values are equal, the instruction is logically false.

N7:2 0< N7:3 0<

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

•

Input Instruction

Publication 1747-RM001G-EN-P - November 2008

Source A must be an address. Source B can be either a program constant or an address. Negative integers are stored in two’s complement form.

Page 59

Comparison Instructions

Less Than (LES)

Use the LES instruction to test whether one value (source A) is less than another (source B). If source A is less than the value at source B, the instruction is logically true. If the value at source A is greater than or equal to the value at source B, the instruction is logically false.

LES Less Than (A<B) Source A N7:4 0< Source B N7:5 0<

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

3-3

•

Source A must be an address. Source B can either be a program constant or an address. Negative integers are stored in two’s complement form.

•

Input Instruction

Less Than or Equal (LEQ) LEQ Less Than or Eql (A<=B) Source A N7:6 0< Source B N7:7 0<

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

Use the LEQ instruction to test whether one value (source A) is less than or equal to another (source B). If the value at source A is less than or equal to the value at source B, the instruction is logically true. If the value at source A is greater than the value at source B, the instruction is logically false. Source A must be an address. Source B can either be a program constant or an address. Negative integers are stored in two’s complement form.

•

Input Instruction

Greater Than (GRT)

Use the GRT instruction to test whether one value (source A) is greater than another (source B). If the value at source A is greater than the value at source B, the instruction is logically true. If the value at source A is less than or equal to the value at source B, the instruction is logically false.

GRT Greater Than (A>B) Source A N7:8 0< Source B N7:9 0<

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

Source A must be an address. Source B can either be a program constant or an address. Negative integers are stored in two’s complement form.

•

Input Instruction

Publication 1747-RM001G-EN-P - November 2008

Page 60

3-4

Comparison Instructions

Greater Than or Equal (GEQ) GEQ Grtr Than or Eql (A>=B) Source A N7:10 0< Source B N7:11 0<

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

Use the GEQ instruction to test whether one value (source A) is greater than or equal to another (source B). If the value at source A is greater than or equal to the value at source B, the instruction is logically true. If the value at source A is less than the value at source B, the instruction is logically false. Source A must be an address. Source B can either be a program constant or an address. Negative integers are stored in two’s complement form.

•

Input Instruction

Masked Comparison for Equal (MEQ)

Use the MEQ instruction to compare data at a source address with data at a compare address. Use of this instruction allows portions of the data to be masked by a separate word.

MEQ Masked Equal Source N7:12 0< Mask 00FFh 255< Compare 255 255<

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

•

Input Instruction

Entering Parameters • Source is the address of the value you want to compare. • Mask is the address of the mask through which the instruction moves data. The mask can also be a hexadecimal value (constant). • Compare is an integer value or the address of the reference. If the 16 bits of data at the source address are equal to the 16 bits of data at the compare address (less masked bits), the instruction is true. The instruction becomes false as soon as it detects a mismatch. Bits in the mask word mask data when reset; they pass data when set.

Publication 1747-RM001G-EN-P - November 2008