3 - Programming Your Incremental Encoder Module. Allen-Bradley FLEX I/O 1794-ID2
Advertisement
Advertisement
What This Chapter
Contains
Enter Block Transfer
Instructions
Chapter
3
To initiate communication between the incremental encoder module and your PLC processor, you must enter block transfer instructions into your ladder logic program. Use this chapter to enter the necessary block transfer instructions into your ladder logic program.
To edit your ladder logic you See page
Enter Block Transfer Instructions . . . . . . . . . . . . . . . . . . . . . 3–1
PLC-2 Family Processors . . . . . . . . . . . . . . . . . . . . . . . . 3–2
PLC-5 Family Processors . . . . . . . . . . . . . . . . . . . . . . . . 3–2
SLC-5 Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3–3
The incremental encoder module communicates with the PLC processor through bidirectional block transfers. This is the sequential operation of both read and write block transfer instructions.
Before you configure the module, you need to enter block transfer instructions into your ladder logic. The following example programs illustrate the minimum programming required for communication to take place between the module and a PLC processor. These programs can be modified to suit your application requirements.
A configuration block transfer write (BTW) is initiated when the module is first powered up, and subsequently only when the programmer wants to enable or disable features of the module. The configuration BTW sets the bits which enable the programmable features of the module, such as scalars and alarm values, etc. Block transfer reads are performed to retrieve information from the module.
Block transfer read (BTR) programming moves status and data from the module to the processor’s data table. The processor user program initiates the request to transfer data from the module to the processor.
The transferred words contain module status, channel status and input data from the module.
Your program should monitor status bits, block transfer read and block transfer write activity.
Allen-Bradley Motors
Publication 1794-6.5.15 – December 1998
3–2
Programming Your Incremental Encoder Module
PLC-2 Family Processor
The 1794 incremental encoder module is not recommended for use with PLC-2 family programmable controllers due to the number of digits needed for high resolution.
Important:
The incremental encoder module functions with reduced performance in PLC-2 systems. Because the module does not support BCD and the PLC-2 processor is limited to values of 4095 (12 bit binary), many values returned in the BTR file may not provide meaningful data to the PLC-2 processor.
PLC-5 Family Processor
Block transfer instructions with the PLC-5 processor use a control file and a data file. The block transfer control file contains the data table section for module location, the address of the block transfer data file and other related data. The block transfer data file stores data that you want transferred to the module (when programming a
BTW) or from the module (when programming a BTR).
The programming terminal prompts you to create a control file when a block transfer instruction is being programmed. A different block
transfer control file is used for the read and write instructions
for your module.
Publication 1794-6.5.15 – December 1998
Programming Your Incremental Encoder Module
3–3
PLC-5 Processor
Program Example
Rung 2:0
The ID2 module is located in rack 1, I/O group 0, slot 0. The integer control file starts at N17:0. The data sent by the
PLC-5 processor to the ID2 module starts at N18:0 and is 4 words long. At power up in RUN mode, or when the processor is first switched from PROG to RUN, the user program enables a block transfer write to configure the module..
First scan of ladder or SFC
S:1
15
ID2 BTW
Control File
BTW
BLOCK TRANSFER WRITE
Module Type
Rack
Group
Slot
Control
Data File
Length
Continuous
Generic BT
001
0
0
N17:0
N18:0
4
N
EN
DN
ER
Rung 2:1
The ID2 module is located in rack 1, group 2, slot 0. The integer control file starts at N17:10,. The data obtained by the
PLC-5 processor from the ID2 module is placed in memory starting at N18:10 and is 8 words long. lThe program continuously performs read block transfers to read data from the module.
ID2 BTR
Enable Bit
N17:10
15
ID2 BTR
Control File
BTR
BLOCK TRANSFER READ
Module Type
Rack
Group
Slot
Control
Data File
Length
Continuous
Generic BT
001
0
0
N17:10
N18:10
8
N
EN
DN
ER
SLC-5 Programming
More
The SLC-5 programs (using the 1747-SN scanner) follow the same logic as the PLC-5 family programs in the previous example.
Differences occur in the implementation of block transfers due to the use of “M” files in the SLC system.
Configuration data for the FLEX I/O incremental encoder module and the 1747-SN scanner must be in place before executing the following programs. Chapter 4 contains information on module configuration.
For more information on using the 1747-SN scanner module and block transfer programming, refer to publication 1747-6.6, “Remote
I/O Scanner User Manual.”
Allen-Bradley Motors
Publication 1794-6.5.15 – December 1998
3–4
Programming Your Incremental Encoder Module
Program Action
This rung configures the block transfer operation type, length, and RIO address at power-up. Bit
B3:100/7 must be set to 1 to indicate a BTR and bit B3:110/7 must be 0 to indicate a BTW.
0000
Figure 3.1SLC Programming for the 1794-OF4I Isolated
Analog Output Module
PowerUp Bit
S2:1
15
BTR_CONTROL
COP
COPY FILE
SOURCE
DEST
LENGTH
BTW_CONTROL
COP
COPY FILE
SOURCE
DEST
LENGTH
#B3:100
#M0:1.100
3
#B3:110
#M0:1.200
3
0001
BTR status is copied to the B3:0 area when a BTR is in progress.
BTR PENDING
B3:5
0
CHECK BTR STATUS
B3:5
1
BTR DONE BIT
B3:0
13
0002
Unlatch the bit that continues to check the BTR status.
BTR ERROR BIT
B3:0
12
BTW PENDING
B3:15
0
0003
BTW status is copied to the B3:100 area when a
BTW is in progress.
0004
Unlatch the bit that continues to check the BTW status.
CHECK BTW STATUS
B3:15
1
BTW DONE BIT
B3:10
13
To next page.
BTW ERROR BIT
B3:10
12
COP
COPY FILE
SOURCE
DEST
LENGTH
COP
COPY FILE
SOURCE
DEST
LENGTH
#M1:1.100
#B3:0
4
CHECK BTR STATUS
B3:5
U
1
#M1:1.200
#B3:10
4
CHECK BTW STATUS
B3:15
U
1
Publication 1794-6.5.15 – December 1998
Programming Your Incremental Encoder Module
Program Action
When a BTR successfully completes and the done bit is detected, the BTR data is copied into the N7:0 to N7:7 area.
0005
BTR DONE BIT
B3:0
13
COP
COPY FILE
SOURCE
DEST
LENGTH
#M1:1.110
#N7:0
8
BTR PENDING
B3:5
U
0
BTR ENABLE BIT
B3:100
U
15
CHECK BTR STATUS
B3:5
L
1
Whe a BTR error occurs, the error code is moved to N7:9.
0006
BTR ERROR BIT
B3:0
12
MOV
MOVE
SOURCE
DEST
When a BTW successfully completes and the done bit is detected, the BTR data is copied into the N7:0 to N7:7 area.
0007
To next page.
BTW DONE BIT
B3:10
13
#M1:1.103
6
#N7:6
0<
BTR PENDING
B3:5
U
0
BTR ENABLE BIT
B3:100
U
15
CHECK BTR STATUS
B3:5
L
1
BTW PENDING
B3:15
U
0
BTW ENABLE BIT
B3:110
U
15
CHECK BTW STATUS
B3:15
L
1
3–5
Allen-Bradley Motors
Publication 1794-6.5.15 – December 1998
3–6
When a BTW occurs, the error code is moved to N7:17.
Programming Your Incremental Encoder Module
Program Action
0008
BTW ERROR BIT
B3:10
12
MOV
MOVE
SOURCE
DEST
#M1:1.203
6
#N7:17
0<
BTW PENDING
B3:15
U
0
BTW ENABLE BIT
B3:110
U
15
CHECK BTW STATUS
B3:15
L
1
This rung executes BTRs continuously, as fast as possible.
0009
BTR ENABLE BIT BTR DONE BIT
B3:100 B3:0
15 13
BTR ERROR BIT
B3:0
12
BTR PENDING
B3:5
L
0
BTR ENABLE BIT
B3:100
L
15
0010
One BTW is triggered at power up. Four words of data starting at N7:10 is sent to the 1794-ID2 module.
TRIGGER
FOR
BTW
B7:20
0
BTW
ENABLE
BIT
B3:110
15
BTW
DONE
BIT
B3:10
13
BTW
ERROR
BIT
B3:10
12
COP
COPY FILE
SOURCE
DEST
LENGTH
#N7:10
#M1:1.210
7
BTW ENABLE BIT
B3:110
L
15
BTW PENDING
B3:15
L
0
To next page.
Publication 1794-6.5.15 – December 1998
Programming Your Incremental Encoder Module
Program Action
This BTR control word is moved to the M0 file for the scanner module while the BTR is in progress until the enable, done and error bits are turned off
0011
BTR ENABLE BIT
B3:100
15
BTR DONE BIT
B3:0
13
BTR ERROR BIT
B3:0
12
This BTW control word is moved to the M0 file for the scanner module while the BTW is in progress until the enable, done and error bits are turned off.
0012
BTW ENABLE BIT
B3:110
15
BTW DONE BIT
B3:10
13
BTW ERROR BIT
B3:10
12
BTR CONTROL
MOV
MOVE
SOURCE
DEST
B3:100
00000001000000<
M0:1.100
?<
BTW CONTROL
MOV
MOVE
SOURCE
DEST
B3:110
00000000000000
M0:1.200
?<
3–7
0013
END
Allen-Bradley Motors
Publication 1794-6.5.15 – December 1998
3–8
Programming Your Incremental Encoder Module
Chapter Summary
In this chapter, you learned how to program your ID2 incremental encoder module using block transfer instructions and ladder logic.
Now, you can configure your module.
Configure the
ID2 Module
Publication 1794-6.5.15 – December 1998
Chapter
4
Writing Configuration to and
Reading Status from Your
Module with a Remote I/O
Adapter
What This Chapter
Contains
In this chapter, we tell you about:
For information on See page
Configuring Your Module . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–1
Reading Data from Your Module . . . . . . . . . . . . . . . . . . . . . . 4–2
Mapping Data for the Module . . . . . . . . . . . . . . . . . . . . . . . . 4–2
Incremental Encoder Module (1794-ID2) Image Table Mapping
Block Transfer Read Word Assignments . . . . . . . . . . . . . . . . 4–3
Bit/Word Definitions for Block Transfer Read Words . . . . . . . . 4–3
Block Transfer Write Word Assignments . . . . . . . . . . . . . . . . 4–5
Bit/Word Definitions for the Block Transfer Write Words . . . . . 4–5
Configuring Your
Incremental Encoder
Module
The incremental encoder module is configured using a group of data table words that are transferred to the module using a block transfer write instruction.
Some of the software configurable features available are:
• number of inputs
• encoder multiplier
• gate function
• latch function
• rollover
Configure your module for its intended operation by means of your programming terminal and write block transfers.
Note: Programmable controllers that use 6200 software (release 4.2
or higher) programming tools can take advantage of the IOCONFIG
Addendum utility to configure this module. IOCONFIG Addendum uses menu–based screens for configuration without having to set individual bits in particular locations. Refer to your 6200 software literature for details.
Important:
It is strongly recommended that you use IOCONFIG
Addendum to configure this module. The IOCONFIG
Addendum utility greatly simplifies configuration. If the IOCONFIG Addendum is not available, you must enter data directly into the data table. Use this chapter as a reference when performing this task.
Allen-Bradley Motors
Publication 1794-6.5.15 – December 1998
4–2
Writing Configuration to and Reading Status from Your Module with a Remote I/O Adapter
During normal operation, the processor transfers from 1 to 4 words to the module when you program a BTW instruction to the module’s address.
Reading Data From Your
Module
Mapping Data for the
Module
I/O Image
Input Size
1 to 8 Words
Read programming moves status and data from the frequency input module to the processor’s data table in one I/O scan. The processor’s user program initiates the request to transfer data from the incremental encoder module to the processor.
The following read and write words and bit/word descriptions describe the information written to and read from the incremental encoder module. The module uses up to 8 words of input data and up to 4 words of output data. Each word is composed of 16 bits.
Incremental Encoder Module (1794-ID2) Image Table Mapping
Module Image
R PR1 PR0 S1 S0 C1 C0 G1 Z1 B1 A1 G0 Z0 B0 A0
Store 0 – Stored Counter Value on channel 0
Store 1 – Stored Counter Value on channel 1
Channel 0 – current counter value
Channel 1 – current counter value
Channel 0 – Counter word readback
Channel 1 – Counter word readback
Code for identification of software version
Output Size
0 to 4 Words
Channel 0 Control Word – Sets the function of counter 0
Channel 1 Control Word – Sets the function of counter 1
Channel 0 Preset – value to load or compare with counter 0
Preset 1 – value to load or compare with counter 1
Publication 1794-6.5.15 – December 1998
Writing Configuration to and Reading Status from Your Module with a Remote I/O Adapter
Block Transfer Read Word Assignments for the Incremental
Encoder Module (1794-ID2)
(Octal Bit
⇒
) 17
Dec. Bit
⇒
Word
⇓
0
1
15
16
14
Not used
15 14 13 12 11 10 07 06 05 04
13 12 11 10 09 08 07 06
Read
05 04
PR1 PR0 S1 S0 C1 C0 G1 Z1 B1
Channel 0 – Stored counter value on channel 0
A1
Channel 1 – Stored counter value on channel 1
Channel 0 – current counter value on channel 0
2
3
4
5
Channel 1 – current counter value on channel 1
Channel 0 – Counter word readback
6
7
Channel 1 – Counter word readback
Revision read – software version code
Where: A0 = Status of input A, channel 0 – bit = 1 when input is on
B0 = Status of input B, channel 0 – bit = 1 when input is on
Z0 = Status of input Z, channel 0 – bit = 1 when input is on
G0 = Status of input G, channel 0 – bit = 1 when input is on
G1 = Status of input G, channel 1 – bit = 1 when input is on
A1 = Status of input A, channel 1 – bit = 1 when input is on
B1 = Status of input B, channel 1 – bit = 1 when input is on
Z1 = Status of input Z, channel 1 – bit = 1 when input is on
C0 = Cal 0 – when bit is set, counter 0 has been calibrated (reset by CalReset)
C1 = Cal 1 – when bit is set, counter 1 has been calibrated (reset by CalReset)
S0 = Stored 0 – when bit is set, counter 0 value has been saved in Store 0 (reset by StoreReset)
S1 = Stored 1 – when bit is set, counter 1 value has been saved in Store 1 (reset by StoreReset)
Once a Store occurs, L0 and L1 are on until cleared by StoreReset (counter word bit 14)
PR0 = Preset 0 reached – when bit is set, counter 0 has reached value of preset
(reset by PresetReset)
PR1 = Preset 1 reached – when bit is set, counter 1 has reached value of preset
(reset by PresetReset)
03
03
G0
02
02
Z0
01
01
B0
00
00
A0
Bit/Word Definitions for Block Transfer Read Words
for the
Incremental Encoder Module
Read
Word
Bit
Bit 00
Bit 01
Bit 02
Bit 03
Bit 04
Bit 05
Definition
Status for input A (pulse transmitter 0) – This bit, when set, indicates a signal at A.
Status for input B (pulse transmitter 0) – This bit, when set, indicates a signal at B.
Status for input Z (pulse transmitter 0) – This bit, when set, indicates a signal at Z.
Status for input G (pulse transmitter 0) –This bit, when set, indicates a signal at G.
Status for input A (pulse transmitter 1) – This bit, when set, indicates a signal at A.
Status for input B (pulse transmitter 1) – This bit, when set, indicates a signal at B.
4–3
Allen-Bradley Motors
Publication 1794-6.5.15 – December 1998
4–4
Writing Configuration to and Reading Status from Your Module with a Remote I/O Adapter
Read
Word
Word 0
Word 1
Word 2
Word 3
Word 4
Word 5
Word 6
Word 7
Bit Definition
Bit 06
Bit 07
Status for input Z (pulse transmitter 1) – This bit, when set, indicates a signal at Z.
Status for input G (pulse transmitter 1) – This bit, when set, indicates a signal at G.
Bit 08 (10) Cal 0 – This bit, when set (1), indicates that counter 0 has been calibrated. This bit is reset by CalReset.
Bit 09 (11) Cal 1 – This bit, when set (1), indicates that counter 1 has been calibrated. This bit is reset by CalReset.
Bit 10 (12) Store 0 – This bit, when set (1), indicates a counter value is saved in store 0. This bit is reset by StoreReset.
Bit 11 (13) Store 1 – This bit, when set (1), indicates a counter value is saved in store 1. This bit is reset by StoreReset.
Bit 12 (14)
Bit 13 (15)
Preset Reached 0 (PR0) – When this bit is set (1), in all configuration modes, the counter 0 value equals the preset 0 value, either in a positive or negative direction. This bit is reset by PresetReset0 and can only be set again after at least 1 more pulse.
Preset Reached 1 (PR1) – When this bit is set (1), in all configuration modes, the counter 1 value equals the preset 1 value, either in a positive or negative direction. This bit is reset by PresetReset1 and can only be set again after at least 1 more pulse.
Bit 14–15
(16–17)
Bits 00–15
(00–17)
Bits 00–15
(00–17)
Bits 00–15
(00–17)
Bits 00–15
(00–17)
Bits 00–15
(00–17)
Bits 00–15
(00–17)
Bits 00–15
(00–17)
Not used – set to 0
Store 0 – Saved counter value on channel 0
Store 1 – Saved counter value on channel 1
Channel 0 Current Counter Value– Current value in counter 0
Channel 1 Current Counter Value– Current value in counter 1
Channel 0 Readback– Counter word readback – last value written to write word 0
Channel 0 Readback– Counter word readback – last value written to write word 1
Revision Read – identification of latest software version code
Publication 1794-6.5.15 – December 1998
Writing Configuration to and Reading Status from Your Module with a Remote I/O Adapter
4–5
(Octal Bit)
⇒
17
Dec. Bit
⇒
Word
⇓
0
15
1
2
3
16
14
15
13
14
12
Block Transfer Write Word Assignments for the Incremental
Encoder Module
13 12 11 10 07 06 05 04
11 10 09 08
Write
07 06 05 04
Channel 0 Control Word – Sets the function of counter 0
Channel 1 Control Word – Sets the function of counter 1
Channel 0 Preset – value to load or compare with counter 0
Channel 1 Preset – value to load or compare with counter 1
03
03
02
02
01
01
00
00
Bit/Word Definitions for the Block Transfer Write Words for the
Incremental Encoder Module
Write
Word
Write
Bit
Definition
0–15 (0–17) Channel 0 Control Word – Control word for setting the function of counter 0.
Bits 00–02 02 01 00 Mode Selection bits
Bit 03
Bit 04
Bit 05
Bits 06–08
Bits 09–10
0
0
0
0
1
0 0
0 1
1 0
1 1
0 0
Counting on positive (rising) edge of input signal A. (Up/dwn counting determined by B.)
Quadrature encoder X1
Quadrature encoder X2
Quadrature encoder X4
Counting up on the positive edge of input signal A, and down on positive edge of input signal B.
1
1
0 1
1 0
No count function.
No count function.
1 1 1 No count function.
Preset (Reset) bit – A positive edge on this bit moves the value in Preset X to Counter X, independent of Preset
Enable. NOTE: To use Preset as Reset, use a count value of 0000 in the Preset value word.
Enable Z Preset bit – When this bit is set (1), a positive edge on Z preloads Counter X = Preset X, independent of
Cal Enable. NOTE: If Z is configured to do Store and Preset (Reset), the Store will occur first.
Count Enable bit – When this is set (1), the incremental encoder is enabled.
Calibration Control bits – bits 06, 07 and 08
06 Enable bit – When this bit is set (1), the counter can be calibrated.
07 Direction bit – When this bit set (1), calibration is performed in a negative direction; when reset (0), calibration is performed in a positive direction.
08 Reset bit – Calibration is acknowledged and a new calibration is enabled on a positive edge on this bit.
0
1
10 09
Gate Control bits
0 0 No gate function on input G
1
1
0
1
Counting only if G is high (active)
Counting only if G is low (inactive)
The counter can be calibrated when G is high (active).
Allen-Bradley Motors
Publication 1794-6.5.15 – December 1998
4–6
Writing Configuration to and Reading Status from Your Module with a Remote I/O Adapter
Write
Word
Write
Write
Bit
Definition
Bits 11–12 12 11 Store Control bits – These bits will trigger a Store only if the channel Store status bit (L0 or L1) is cleared (0).
0
0
0
1
Save the counter value on the positive edge of Z (if Stored X = 0)
Save the counter value on the positive edge of G (if Stored X = 0)
1
1
0
1
Save the counter value on the negative edge of G (if Stored X = 0)
Save the counter value on the positive edge and negative edge of G (if Stored X = 0)
Bit 13 (15) Rollover bit – When set (1), the counter counts up to the preset and then restarts at 0. If this bit is reset (0) (not rollover), the rollover preset value = FFFF (hex = 65535 (decimal).
Bit 14 (16) Store Reset bit – A positive edge on this bit resets Store X in Signals.
Bit 15 (17) Preset Reset bit – A positive edge on this bit resets Preset Reached in Signals.
Channel 1 Control Word – Control word for setting the function of counter 1.
Bits 00–02 02 01 00
Mode Selection bits
Bit 03
Bit 04
Bit 05
1
1
1
0
0
0
0
0
0
1
1
0
0
1
0
1
0
1
0
1
0
Counting on positive (rising) edge of input signal A. (Up/dwn counting determined by B.)
Quadrature encoder X1
Quadrature encoder X2
Quadrature encoder X4
Counting up on the positive edge of input signal A, and down on positive edge of input signal B.
No count function.
No count function.
1 1 1 No count function.
Preset bit – A positive edge on this bit moves the value in Preset X to Counter X, independent of Preset Enable.
Preset Enable bit – When this bit is set (1), a positive edge on Z preloads Counter X = Preset X, independent of
Cal Enable.
Count Enable bit – When this is set (1), the incremental encoder is counting.
Publication 1794-6.5.15 – December 1998
Writing Configuration to and Reading Status from Your Module with a Remote I/O Adapter
4–7
Write
Word
Word 1
Word 2
Word 3
Bit
Definition
Bits 06–08 Calibration Control bits – bits 06, 07 and 08
06 Enable bit – When this bit is set (1), the counter can be calibrated.
07 Direction bit – When this bit set (1), calibration is performed in a negative direction; when reset (0), calibration is performed in a positive direction.
08 Reset bit – Calibration is acknowledged and a new calibration is enabled on a positive edge on this bit.
Bits 09–10 10 09
Gate Control bits
0
0
0
1
No gate function on input G
Counting only if G is high (active)
Bits 11–12
1
1
0
1
Counting only if G is low (inactive)
Calibration if G is high (active) and ???
12 11 Store Control bits – These bits will trigger a Store only if the channel Store status bit (L0 or L1) is cleared (0).
0 0 Save the counter value on the positive edge of Z (if Store X = 0)
0
1
1
1 Save the counter value on the positive edge of G (if Store X = 0)
0 Save the counter value on the negative edge of G (if Store X = 0)
1 Save the counter value on the positive edge and negative edge of G (if Store X = 0)
Bit 13 Rollover bit – When set (1), the counter counts up to the preset and then restarts at 0. If this bit is reset (0) (not rollover), the rollover preset value = FFFF (hex = 65535 (decimal).
Store Reset bit – A positive edge on this bit resets Store X in Signals.
Bit 14
Bit 15 Store Reset bit – A positive edge on this bit resets Preset Reached in Signals.
Bits 00–15 Preset 0 – Value to load or compare with counter 0
Bits 00–15 Preset 1 – Value to load or compare with counter 1
Chapter Summary
In this chapter, you learned how to configure your module’s features and enter your data.
Allen-Bradley Motors
Publication 1794-6.5.15 – December 1998
4–8
Writing Configuration to and Reading Status from Your Module with a Remote I/O Adapter
Publication 1794-6.5.15 – December 1998

Public link updated
The public link to your chat has been updated.
Advertisement