34
Word And File Moves Word And File Moves MOV,MOVM,COP,FLL,BSL,BSR, MOV,MOVM,COP,FLL,BSL,BSR, FRD,TOD FRD,TOD

Word And File Moves

  • Upload
    chesmu

  • View
    31

  • Download
    5

Embed Size (px)

DESCRIPTION

Word And File Moves. MOV,MOVM,COP,FLL,BSL,BSR, FRD,TOD. Move (MOV). Description: The MOV instruction is an output instruction that copies the Source address to a Destination. As long as the rung remains true, the instruction moves the data each scan. - PowerPoint PPT Presentation

Citation preview

Page 1: Word And File Moves

Word And File MovesWord And File Moves

MOV,MOVM,COP,FLL,BSL,BSR,MOV,MOVM,COP,FLL,BSL,BSR,

FRD,TODFRD,TOD

Page 2: Word And File Moves

Move (MOV)Move (MOV)

• Description: The MOV Description: The MOV instruction is an output instruction is an output instruction that copies the instruction that copies the Source address to a Source address to a Destination. As long as the Destination. As long as the rung remains true, the rung remains true, the instruction moves the data instruction moves the data each scan.each scan.

• The source and destination The source and destination data types should be the data types should be the same because the instruction same because the instruction does not perform a does not perform a conversion.conversion.

Page 3: Word And File Moves

• Move (MOV):Move (MOV):• This out put instruction moves the source value to This out put instruction moves the source value to

the destination location. As long as the rung the destination location. As long as the rung remains true, the instruction moves the data each remains true, the instruction moves the data each scan.scan.

• Entering Parameters:Entering Parameters:• Enter the following parameters when Enter the following parameters when

programming this instruction:programming this instruction:• Source Source is the address or constant of the data you is the address or constant of the data you

want to move.want to move.• DestinationDestination is the address where the instruction is the address where the instruction

moves the data.moves the data.• Application Note:Application Note: If you wish to move one word If you wish to move one word

of data without affecting the math flags, use a of data without affecting the math flags, use a copy (COP) instruction with a length of 1 word copy (COP) instruction with a length of 1 word instead of the MOV instruction.instead of the MOV instruction.

Page 4: Word And File Moves

• Entering Parameters: Entering Parameters: To program this To program this instruction, you must instruction, you must provide the provide the processor with the processor with the following:following:

Page 5: Word And File Moves

Masked Move (MVM)Masked Move (MVM)

• Description: The MVM instruction is an Description: The MVM instruction is an output instruction that copies the output instruction that copies the Source to a Destination, and allows Source to a Destination, and allows portions of the data to be masked. As portions of the data to be masked. As long as the rung remains true, the long as the rung remains true, the instructions moves data each scan.instructions moves data each scan.

• You can use the MVM instruction to copy You can use the MVM instruction to copy I/O image, binary, or integer values. I/O image, binary, or integer values.

Page 6: Word And File Moves

• Masked Move (MVM):Masked Move (MVM):• The MVM instruction is a word instruction that The MVM instruction is a word instruction that

moves data from a source location to a moves data from a source location to a destination, and allows portions of the destination destination, and allows portions of the destination data to be masked by a separate word. As long data to be masked by a separate word. As long as the rung remains true, the instruction moves as the rung remains true, the instruction moves the data each scan.the data each scan.

• Entering Parameters:Entering Parameters:• Enter the following parameters when Enter the following parameters when

programming this instruction:programming this instruction:• SourceSource is the address of the data you want to is the address of the data you want to

move.move.• MaskMask is the address of the mask through which is the address of the mask through which

the instruction moves data; the mask can be a the instruction moves data; the mask can be a hex value (constant).hex value (constant).

• DestinationDestination is the address where the instruction is the address where the instruction moves the data.moves the data.

Page 7: Word And File Moves

Entering Parameters: To program this instruction, you must Entering Parameters: To program this instruction, you must provide the processor with the following:provide the processor with the following:

Page 8: Word And File Moves
Page 9: Word And File Moves

Use the shift register instruction to stimulate the movement or Use the shift register instruction to stimulate the movement or flow of parts and information.flow of parts and information.

Page 10: Word And File Moves

Copy File (COP)Copy File (COP)

• The destination file type determines the The destination file type determines the number of words that an instruction transfers. number of words that an instruction transfers.

• After a COP or FLL instruction is executed, After a COP or FLL instruction is executed, index register S: 24 is cleared to zero.index register S: 24 is cleared to zero.

• This instruction copies blocks of data from This instruction copies blocks of data from one location into another. It uses no status one location into another. It uses no status bits. If you need an enable bit, program an bits. If you need an enable bit, program an output instruction (OTE) in parallel using an output instruction (OTE) in parallel using an internal bit as the output address. internal bit as the output address.

Page 11: Word And File Moves
Page 12: Word And File Moves

• Entering Parameters:Entering Parameters:• Enter the following parameters when programming this Enter the following parameters when programming this

instruction:instruction:• SourceSource is the address of the file you want to copy. You must is the address of the file you want to copy. You must

use the file indicator (#) in the address. When using either use the file indicator (#) in the address. When using either an SLC 5/03 (OS301 or higher), SLC 5/04 (OS401), or SLC an SLC 5/03 (OS301 or higher), SLC 5/04 (OS401), or SLC 5/05 processor, floating point and string values are 5/05 processor, floating point and string values are supported.supported.

• DestinationDestination is the starting address where the instruction is the starting address where the instruction stores the copy. You must use the file indicator (#) in the stores the copy. You must use the file indicator (#) in the address. When using either and SLC 5/03 (OS301 or higher), address. When using either and SLC 5/03 (OS301 or higher), SLC 5/04 (OS401), or SLC 5/05 processor, floating point and SLC 5/04 (OS401), or SLC 5/05 processor, floating point and string values are supported.string values are supported.

• LengthLength is the number of is the number of elementselements in the file you want to in the file you want to copy.copy.

• * * for SLC processors, if the destination file is 3 words per for SLC processors, if the destination file is 3 words per element (timer or counter), you can specify a maximum element (timer or counter), you can specify a maximum length of 42. If the destination file type is 1 word per length of 42. If the destination file type is 1 word per element , you can specify a maximum length of 128 words.element , you can specify a maximum length of 128 words.

Page 13: Word And File Moves

NOTENOTE: The maximum lengths apply when the source is of : The maximum lengths apply when the source is of the same file type.the same file type.All elements are copied from the source file into the All elements are copied from the source file into the destination file each time the instruction is executed. destination file each time the instruction is executed. Elements are copied in ascending order.Elements are copied in ascending order.If your destination file type is a timer, counter, or control If your destination file type is a timer, counter, or control file, be sure that the source words corresponding to the file, be sure that the source words corresponding to the status words of your destination file contains zeros.status words of your destination file contains zeros.Be sure that you accurately specify the starting address Be sure that you accurately specify the starting address and length of the data block you are copying. The and length of the data block you are copying. The instruction will not write over a file boundary (such as instruction will not write over a file boundary (such as between files N16 and N17) at the destination. An error between files N16 and N17) at the destination. An error occurs if a write is attempted over a file boundary.occurs if a write is attempted over a file boundary.You can perform file shifts by specifying a source element You can perform file shifts by specifying a source element address one or more elements greater than the destination address one or more elements greater than the destination element address within the same file. This shifts data to element address within the same file. This shifts data to lower element addresses.lower element addresses.

Page 14: Word And File Moves

Fill File (FLL)Fill File (FLL)

• This instruction loads elements of a This instruction loads elements of a file with either a program constant or file with either a program constant or value from an element address.value from an element address.

• The instruction fills the words of a file The instruction fills the words of a file with a source value. It uses no with a source value. It uses no status bits. If you need an enable status bits. If you need an enable bit, program a parallel output that bit, program a parallel output that uses a storage address. uses a storage address.

Page 15: Word And File Moves
Page 16: Word And File Moves

• Entering Parameters:Entering Parameters:• Enter the following parameters when programming this Enter the following parameters when programming this

instruction.instruction.• SourceSource is the program constant or element address. The file is the program constant or element address. The file

indicator (#) is indicator (#) is notnot required for an element address. When using required for an element address. When using either an SLC5/03 (OS301 or higher), SLC 5/04 (OS401), or either an SLC5/03 (OS301 or higher), SLC 5/04 (OS401), or SLC5/05 processor, floating point and string values are supported.SLC5/05 processor, floating point and string values are supported.

• DestinationDestination is the destination starting address of the file you is the destination starting address of the file you want to fill. You must use the file indicator (#) in the address. want to fill. You must use the file indicator (#) in the address. When using either an SLC5/03 (OS301 or higher), SLC 5/04 When using either an SLC5/03 (OS301 or higher), SLC 5/04 (OS401), or SLC5/05 processor, floating point and string values are (OS401), or SLC5/05 processor, floating point and string values are supported.supported.

• LengthLength is the number of is the number of elements elements in the file you want filled.in the file you want filled.• - for SLC processors, if the destination file type is 3 words per - for SLC processors, if the destination file type is 3 words per

element (timer or counter), you can specify a maximum length of element (timer or counter), you can specify a maximum length of 42. If the destination file type is 1 word per element, you can 42. If the destination file type is 1 word per element, you can specify a maximum length of 128 words.specify a maximum length of 128 words.

• All elements are filled from the source value (typically a constant) All elements are filled from the source value (typically a constant) into the specified destination file each scan the rung is true. into the specified destination file each scan the rung is true. Elements are filled in ascending order.Elements are filled in ascending order.

• The instruction will not write over a file boundary (such as The instruction will not write over a file boundary (such as between filesN16 and N17) at the destination. An error is declared between filesN16 and N17) at the destination. An error is declared if a write is attempted over a file boundary.if a write is attempted over a file boundary.

Page 17: Word And File Moves

Control Data File (R6:)Control Data File (R6:)

• These instructions use various control These instructions use various control bits. These are 3-word elements, used bits. These are 3-word elements, used with Bit Shift, FIFO, LIFO, Sequencer with Bit Shift, FIFO, LIFO, Sequencer instructions, and ASCII instructions instructions, and ASCII instructions ABL, ACB, AHL, ARD, ARL, AWA, and ABL, ACB, AHL, ARD, ARL, AWA, and AWT. Word 0 is the status word, word AWT. Word 0 is the status word, word 1 indicates the length of stored data, 1 indicates the length of stored data, and word 2 indicates position. This is and word 2 indicates position. This is shown in the following figure:shown in the following figure:

Page 18: Word And File Moves

In the control element there are eight status bits and an error code In the control element there are eight status bits and an error code byte.byte.

EN EU DN EM ER UL IN FD EN EU DN EM ER UL IN FD error error codecode

Length of Bit array or file (LEN)Length of Bit array or file (LEN)

Bit Pointer or Position (POS)Bit Pointer or Position (POS)

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 wordword

00

11

22

Page 19: Word And File Moves

• Addressable Bits:Addressable Bits: Addressable Words:Addressable Words:

• EN= enableEN= enable LEN= lengthLEN= length

• EU= unload enableEU= unload enable POS=POS= positionposition

• DN= doneDN= done

• EM= stack emptyEM= stack empty• ER= error ER= error (error code value is displayed in HEX and is not (error code value is displayed in HEX and is not

addressable)addressable)

• UL= unload UL= unload (bit shift only)(bit shift only)

• IN= inhibit IN= inhibit (this is the running bit (RN bit 9) for ASCII instructions)(this is the running bit (RN bit 9) for ASCII instructions)

• FD= found FD= found (SQC only)(SQC only)

Page 20: Word And File Moves

Using Bit Shift Instructions:Using Bit Shift Instructions:

• Description: Bit shift Description: Bit shift instructions shift all instructions shift all bits within the bits within the specified address one specified address one bit position with each bit position with each false-to-true rung false-to-true rung transition. These transition. These instructions are: instructions are:

• * Bit Shift Left (BSL)* Bit Shift Left (BSL)• * Bit Shift Right (BSR)* Bit Shift Right (BSR)

Page 21: Word And File Moves

Bit Shift Left (BSL) & Bit Bit Shift Left (BSL) & Bit Shift Right (BSR):Shift Right (BSR):

• BSL and BSR are output instructions that load data into a bit BSL and BSR are output instructions that load data into a bit array one bit at a time. The data is shifted through the array one bit at a time. The data is shifted through the array, then unloaded one bit at a time. array, then unloaded one bit at a time.

• Using BSL:Using BSL:• When the rung goes from false-to-true, the processor sets When the rung goes from false-to-true, the processor sets

the enable bit (EN bit 15) and the data block is shifted to the the enable bit (EN bit 15) and the data block is shifted to the left (to a higher bit number) one bit position. The specified left (to a higher bit number) one bit position. The specified bit at the bit address is shifted into the first bit position. The bit at the bit address is shifted into the first bit position. The last bit is shifted out of the array and stored in the unload last bit is shifted out of the array and stored in the unload bit (UL bit 10). The shift is completed immediately.bit (UL bit 10). The shift is completed immediately.

• For wraparound operation, set the position of the bit address For wraparound operation, set the position of the bit address to the last bit of the array or to the UL bit, whichever to the last bit of the array or to the UL bit, whichever applies.applies.

• The figure below illustrates how the Bit Shift Left instruction The figure below illustrates how the Bit Shift Left instruction works.works.

• If you wish to shift more than one bit per scan, you must If you wish to shift more than one bit per scan, you must create a loop in your application using the JMP, LBL, and create a loop in your application using the JMP, LBL, and CTU instructions.CTU instructions.

Page 22: Word And File Moves
Page 23: Word And File Moves

• Using BSR:Using BSR:• When the rung goes from false-to-true, the When the rung goes from false-to-true, the

enable bit (EN bit 15) is set and the data block is enable bit (EN bit 15) is set and the data block is shifted to the right (to a lower bit number) one bit shifted to the right (to a lower bit number) one bit position. The specified bit at the bit address is position. The specified bit at the bit address is shifted into the last bit position. The first bit is shifted into the last bit position. The first bit is shifted out of the array and stored in the unload shifted out of the array and stored in the unload bit (UL bit 10) in the status byte of the control bit (UL bit 10) in the status byte of the control element. The shift is completed immediately.element. The shift is completed immediately.

• For wraparound operation, set the position of the For wraparound operation, set the position of the bit address to the first bit of the array or the UL bit address to the first bit of the array or the UL bit, whichever applies.bit, whichever applies.

Page 24: Word And File Moves
Page 25: Word And File Moves

Entering Parameters: To program a bit shift instruction, you Entering Parameters: To program a bit shift instruction, you need to provide the processor with the following information:need to provide the processor with the following information:

Page 26: Word And File Moves

Using Status Bits: To use the BSL and BSR instruction Using Status Bits: To use the BSL and BSR instruction correctly, examine status bits in the control element. You correctly, examine status bits in the control element. You address these bits by mnemonic.address these bits by mnemonic.

Page 27: Word And File Moves

• Important: When enabled, the bit Important: When enabled, the bit pointer is set to the value of the pointer is set to the value of the length the bit array is shifted. After length the bit array is shifted. After all of the bits are shifted, the all of the bits are shifted, the instruction resets the .EN, .ER, instruction resets the .EN, .ER, and .DN bits are the bit pointer when and .DN bits are the bit pointer when input conditions go false.input conditions go false.

Page 28: Word And File Moves

• The conversion The conversion instructions convert instructions convert integer to BCD to integer to BCD to integer (using TOD and integer (using TOD and FRD). Use TOD and FRD). Use TOD and FRD for signals to/from FRD for signals to/from BCD I/O devices, for BCD I/O devices, for display purposes, or display purposes, or for number for number compatibility with PLC-compatibility with PLC-2 family processors. 2 family processors.

Page 29: Word And File Moves

Convert to BCD (TOD)Convert to BCD (TOD)

• Use this instruction to Use this instruction to convert 16-bit integers into convert 16-bit integers into BCD values. BCD values.

• With Fixed and SLC 5/01 With Fixed and SLC 5/01 processors, the destination processors, the destination can only be the math can only be the math register. With SLC 5/02 and register. With SLC 5/02 and higher processors and higher processors and MicroLogix 1000 ocntrollers, MicroLogix 1000 ocntrollers, the destination parameter the destination parameter can be word address in any can be word address in any data file, or it can be the data file, or it can be the math register, S;13 and S:14.math register, S;13 and S:14.

• If the integer value you enter If the integer value you enter is negative the absolute is negative the absolute value of the number is used value of the number is used for conversion.for conversion.

Page 30: Word And File Moves

Convert from BCD (FRD):Convert from BCD (FRD):

• Use this instruction to Use this instruction to convert BCD values to convert BCD values to integer values. With integer values. With Fixed and SLC 5/01 Fixed and SLC 5/01 processors, the source processors, the source can only be the math can only be the math register. With SLC 5/02 register. With SLC 5/02 and higher processors and and higher processors and Mirologix 1000 Mirologix 1000 controllers, the source controllers, the source parameter can be a word parameter can be a word address in any data file, address in any data file, or it can be the math or it can be the math register, S:13.register, S:13.

Page 31: Word And File Moves

Convert to BCD (TOD)Convert to BCD (TOD)

• Description: Use the TOD instruction to convert an Description: Use the TOD instruction to convert an integer value to a BCD value. If the integer value is integer value to a BCD value. If the integer value is greater than 9999, the processor stores 9999 and greater than 9999, the processor stores 9999 and sets the overflow bit. If the integer value is sets the overflow bit. If the integer value is negative, the processor stores 0 in the destination negative, the processor stores 0 in the destination ands sets the overflow and zero status bits.ands sets the overflow and zero status bits.

Page 32: Word And File Moves
Page 33: Word And File Moves

Convert from BCD (FRD)Convert from BCD (FRD)

Page 34: Word And File Moves

• Description: Use the FRD instruction to Description: Use the FRD instruction to convert a BCD value to an integer value. convert a BCD value to an integer value. Convert BCD values to integer before you Convert BCD values to integer before you manipulate those values with ladder logic manipulate those values with ladder logic because the processor treats BCD values as because the processor treats BCD values as integer values. The actual BCD value may integer values. The actual BCD value may be lost or distorted.be lost or distorted.