33A3BEPM-W4 At power-up in RUN mode, or when the processor is switched from PROG to RUN, the user program enables a block transfer read. Then it initiates a block transfer write to configure the module and send data values. Thereafter, the program continuously performs read block transfers and write block transfers. Two’s Complement Binary Two’s complement binary is used when performing mathematical calculations internal to the processor. To complement a number means to change it to a negative number. For example, the following binary number is equal to decimal 22. 0 101102 = 2210 First, the two’s complement method places an extra bit (sign bit) in the left–most position, and lets this bit determine whether the number is positive or negative. The number is positive if the sign bit is 0 and negative if the sign bit is 1. Using the complement method: 0 10110 = 22 To get the negative using the two’s complement method, you must invert each bit from right to left after the first ”1” is detected. In the above example: 0 10110 = +22 Its two’s complement would be: 1 01010 = –22 Note that in the above representation for +22, starting from the right, the first digit is a 0 so it is not inverted; the second digit is a 1 so it is not inverted. All digits after this one are inverted. If a negative number is given in two’s complement, its complement (a positive number) is found in the same way: 1 10010 = –14 0 01110 = +14 All bits from right to left are inverted after the first ”1” is detected. TIP You must create the data file for the block transfers before you enter the block transfer instructions Publication 1794-UM062B-EN-P - March 2020 84 Module Programming The two’s complement of 0 is not found, since no first ”1” is ever encountered in the number. The two’s complement of 0 then is still 0. Analog Data Format The data returned from the analog-to-digital converter in the module is 12-bit resolute. This value is left-justified into a 16-bit field, reserving the most significant bit for a sign bit. Current and Voltage Mode Values Current (mA) 4…20 mA Mode 0…20 mA Mode Voltage (V) ± 10V Mode 0…10V Mode Input Output -10.50 8000 8000 0.00 0000 -10.00 8620 8618 1.00 0618 -9.00 9250 9248 2.00 0C30 -8.00 9E80 9E78 3.00 1248 -7.00 AAB0 AAA8 4.00 0000 1860 -6.00 B6E0 B6D8 5.00 0787 1E78 -5.00 C310 C310 6.00 0F0F 2490 -4.00 CF40 CF40 7.00 1696 2AA8 -3.00 DB70 DB70 8.00 1E1E 30C0 -2.00 E7A0 E7A0 9.00 25A5 36D8 -1.00 F3D0 F3D0 10.00 2D2D 3CF0 0.00 0000 0000 0000 11.00 34B4 4310 1.00 0C30 0C30 0C30 12.00 3C3C 4928 2.00 1860 1860 1860 13.00 43C3 4F40 3.00 2490 2490 2490 14.00 4B4B 5558 4.00 30C0 30C0 30C0 15.00 52D2 5B70 5.00 3CF0 3CF0 3CF0 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 11 10 09 08 07 06 05 04 03 02 01 00 S S 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 10 09 08 07 06 05 04 03 02 01 00 S S 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 11 10 09 08 07 06 05 04 03 02 01 00 0* A/D unipolar data A/D bipolar data D/A data Output Input Analog value Analog value Analog value * = Always positive xxxxx Publication 1794-UM062B-EN-P - March 2020 Module Programming 85 Scaling Example To scale your data to a different range: • SLC™ 500 – use the scaling instruction. • PLC-5 – determine a constant (slope) by dividing the desired range by the actual range. Multiply the result by your data, and add or subtract any offset. Example using Compute Instructions This rung scales FLEX I/O analog data to a different range. In this example, we want the 4…20 mA input data to represent 0…537.7°C (32…1000°F) in the PLC-5. N13:0 = 30,840 (7878 in hex). Two compute instructions are needed because of the way the destination value is rounded if we use an integer location 16.00 5A5A 6188 6.00 4920 4928 4928 17.00 61E1 67A0 7.00 5550 5558 5558 18.00 6969 6DB8 8.00 6180 6188 6188 19.00 70F0 73D0 9.00 6DB0 6DB8 6DB8 20.00 7878 79E8 10.00 79E0 79E8 79E8 21.00 7FFF 7FF8 10.50 7FF0 7FF8 7FF8 Current and Voltage Mode Values Current (mA) 4…20 mA Mode 0…20 mA Mode Voltage (V) ± 10V Mode 0…10V Mode Input Output EXAMPLE A 4…20 mA input places data at N13:0 (see figure PLC-5 Family Sample Program Structure for a 1794-OE4 Module on page 82), with a range of 0…30,840. (30,840 = 7878 hex – see table Current and Voltage Mode Values on page 84). You want the 4…20 mA (0…30,840) to be 0…537.7°C (32…1000°F) in the PLC-5. Use the following formula: = {[(1000 - 32)/30,840] X N13:0} + 32 F8:0 Scaled Data (degrees) @ N30:0 = {[(Desired Range)/Actual Range] X Analog Input Data} + O ffset = F8:0 + 32 Scaled Data (degrees) @ N30:0 (See ladder logic below) = F8:0 + 32 Publication 1794-UM062B-EN-P - March 2020 86 Module Programming instead of a floating point in the first compute instruction. The second compute instruction has a final destination of an integer location. CPT 1 B3:0 DN ER 02 05 03 Enable Done Error Power-up Bit1 B4:8 15 1 Power-up bit included in Series B modules only. 1 2 TIP You must create the data file for the block transfers before you enter the block transfer instructions. Publication 1794-UM062B-EN-P - March 2020 80 Module Programming PLC-3 Family Sample Program Structure for a 1794-OE4 Module Program Action At power-up in RUN mode, or when the processor is switched from PROG to RUN, the user program enables a block transfer read. Then it initiates a block transfer write to configure the module and send data values. Thereafter, the program continuously performs read block transfers and write block transfers. PLC-3 Family Sample Program Structure for a 1794-IE4XOE2 Module EN BTR BLOCK TRANSFER READ RACK: GROUP: SLOT: DATA FILE: 7 1 0 B7:0 LENGTH: CONTROL: 1 B6:0 05 B6:0 15 DN ER Block Transfer Read Done Bit B6:0 Block Transfer Write Done Bit 12 15 13 Enable Done Error EN BTR BLOCK TRANSFER WRITE RACK: GROUP: SLOT: DATA FILE: 7 1 0 B8:0 LENGTH: CONTROL: 14 B6:0 DN ER 02 05 03 Enable Done Error 1 2 TIP You must create the data file for the block transfers before you enter the block transfer instructions EN BTR BLOCK TRANSFER READ RACK: GROUP: SLOT: DATA FILE: 7 2 0 B10:0 LENGTH: CONTROL: 5 B9:0 05 B9:0 15 DN ER Block Transfer Read Done Bit B9:0 Block Transfer Write Done Bit EN BTR BLOCK TRANSFER WRITE RACK: GROUP: SLOT: DATA FILE: 7 2 0 B11:0 LENGTH: CONTROL: 8 B9:0 DN ER 1 2 Publication 1794-UM062B-EN-P - March 2020 Module Programming 81 Program Action At power-up in RUN mode, or when the processor is switched from PROG to RUN, the user program enables a block transfer read. Then it initiates a block transfer write to configure the module and send data values. Thereafter, the program continuously performs read block transfers and write block transfers. PLC-5 Programming The PLC-5® program is very similar to the PLC-3 program with the following exceptions: • block transfer enable bits are used instead of done bits as the conditions on each rung. • separate block transfer control files are used for the block transfer instructions. PLC-5 Family Sample Program Structure for a 1794-IE8 Module Program Action At power-up in RUN mode, or when the processor is switched from PROG to RUN, the user program enables a block transfer read. Then it initiates a block transfer write to configure the modul |