|
DMD0527 CTREGWR - CTRIO Write Register |
|||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||
|
The CTRIO Write Register (CTREGWR) instruction is used to write a value from a location in the Do-more controller to the selected internal register of the CTRIO.
The red triangle in the upper left corner indicates the CTRIO Write Register (CTREGWR) is a Fully Asynchronous instruction.
Note: The CTREGWR instruction can be used with both the CTRIO and CTRIO2 modules. |
| ||||||||||||||||||||||||||||||||||||||||||
Inputs:This input is edge-triggered, meaning that each time this input logic transitions from OFF to ON, the CTRIO Write Register (CTREGWR) will:
|
|||||||||||||||||||||||||||||||||||||||||||
Parameters:Note: Use the F9 key (Element Browser) at any time to see a complete list of the memory locations that are valid in the current field of the instruction.
Part of the configuration for any device is assigning a name to the device. It is that name which will show up in the Module Device selection drop-down menu. For more information on configuring CTRIO devices go to the Module Configuration Section under System Configuration.
Note: no devices available - indicates that there are no CTRIO modules that have been pre-configured to perform this instruction.
Module Structure -
Source - designates the location to store the value read from the CTRIO module. This can be any 32-bit readable numeric location.
Destination Register - selects which of the following internal registers to write:
On Success - designates which of the following actions to take if the CTRIO Write Register operation is successful.
On Error - designates which of the following two actions to take if the CTRIO Write Register operation is unsuccessful. For example if the specified CTRIO Discrete output is not configured correctly.
Note: any time the On Error condition occurs, the CTRIO generates an Error Code that can be read in the <Module Name>.ErrorCode (Module Name is the name assigned to the CTRIO in the Module Configuration). The List of Error Code values (in decimal) follows:
|
|||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||
Status Display:The Status display of the CTRIO Write Register (CTREGWR) instruction shows:
|
| ||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||
See Also:
|
|||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||
Example 1 of 2: |
Description of a Typical CTRIO Write Register (CTREGWR) Stage Diagram:
Initially the Config stage sets the CTRIO2 axis up. Once this is configured it transitions to the Restore stage.
The Restore stage reads the retentive location where the output position was stored previously and writes it back to the CTRIO2 module. Once this is restored it transitions to the Position stage.
The Position stage puts the CTRIO2 pulse output into the Dynamic Position mode. Once this is complete (Ready = ON) then the Move stage is enabled (not transitioned to) so that both stages are running in parallel. The reason for this is because the Position stage must be left enabled to keep the CTRIO2 pulse output in the Dynamic Position mode through all the moves. Also inside this stage the current output position is continuously updating the retentive location in case of power failure.
Once the CTRIO pulse output has reached its new position (AtPosition = ON), then it transitions to the InPos stage.
In the InPos stage another position can be loaded and then the NextMove can be set ON to transition back to the Move stage to move the motor to another position, or the Done button can be set ON to finish things up. If Done is set ON, then both the Position and InPos (In Position) stages converge and transition to the Stop stage.
|
Description of a Typical CTRIO Write Register (CTREGWR) Stage Ladder:
Note: Even though the output position structure member (.OutputPosition) is retentive, the CTRIO2 itself, on a power up, clears this value to zero.
This example presupposes the use of a CTRIO2 (instead of a CTRIO) module and the existence of the following System Configuration for the CTRIO2 (PLC --> System Configuration --> Module Configuration(s) --> CTRIO_000 -->):
The general operation of this example is to configure a CTRIO2 axis using the CTAXCFG (CTRIO2 Axis Configuration) instruction (for more information click here), restore the output position of the CTRIO2 using the CTREGWR (CTRIO Write Register) instruction, and then to enable the CTAXDYNP (CTRIO2 Axis Run Dynamic Position Mode) instruction (for more information click here) and allow moves to any number of positions provided by HMI_Position variable while storing the CTRIO2's output position in a retentive memory location (CurrentPosition) in the Do-more controller.
Config is the initial stage and configures an axis in the CTRIO2. When this is completed without error it transitions to the Restore stage. If there is an error it transitions to the ErrorStage stage where logic (not shown here) should exist that would properly handle the error (e.g. to process the $CTRIO_000.ErrorCode value).
Restore stage writes the contents of the CurrentPosition memory location to the 4 - Out0 Position register in the CTRIO2. This CurrentPosition variable will contain the last output position of the CTRIO2 output that this same Program code block provided from a previous run. If this is the first time this Program code block has been run, then this will simply write a value of 0 to this internal register which is harmless because the CTRIO2 will have already zeroed-out this register on power up any way. This stage also sets Begin ON to enable the CTAXDYNP in the Position stage. When the CTREGWR instruction completes without error it transitions to the Position stage. If there is an error it transitions to the ErrorStage stage.
Position is the main CTAXDYNP instruction stage. Upon the first entry into this stage the CurrentPosition is moved to the HMI_Position. This is done so that the CTAXDYNP will not move if HMI_Position happens to have a wrong value in it. Notice that for every scan of this stage the CTRIO2's output position ($CTRIO_000_Out0.OutputPosition) is stored in the memory location CurrentPosition.
This stage remains enabled for all moves. Instead of transitioning to the next stage (Move), the next stage is merely enabled. Begin is already ON when first entering this stage and will enable the CTAXDYNP instruction. Then the following things occur:
The Begin bit will remain ON for all moves. It will be cleared OFF at the completion of the last move.
The CTAXDYNP's SUS (Suspend) input is controlled by the Suspend bit. This bit must remain OFF for any given move to complete. Turning this bit ON will cause the CTRIO2's output to decelerate to a stop. Turning it back OFF will cause the CTRIO2's output to accelerate complete a move.
The On Success parameter jumps to the Stop stage. This will occur when Begin is cleared OFF and everything was successful.
The On Error parameter jumps to the ErrorStage stage
Once the CTAXDYNP is enabled, the $CTRIO_000_Out0.OutputEnabled bit will be set ON by the Pulse Output Device. When this occurs the next stage (Move) is enabled.
Move stage accomplishes the first move and any subsequent moves. Initially it is assumed a new position has been written to the HMI_Position variable. To move, the $CTRIO_000_Out0.GotoPosition bit is set ON. The Pulse Output Device will clear this bit when the move begins. Once the bit is cleared, then the $CTRIO_000_Out0.AtPosition bit is monitored for completion of the move. Once that bit is set ON by the Pulse Output Device, this move is complete and the Move stage transitions to the InPos stage.
The InPos stage turns ON Positioned to indicate the position has been reached. This is the ideal spot in the Program code block for a power loss. The reason-being that CurrentPosition will definitely contain the last output position because it has just been reached. If power is lost during a move, then it is possible that the motor attached to the CTRIO2 may drift from the last recorded output position. In such a case restoring the output position in the manner that this Program code block does may not be sufficient for the application. Instead, the application may demand that the output position be re-homed. This Program code block does not provide that homing sequence.
This stage waits for either the NextMove bit or the Done bit to be toggled ON. It is assumed these bits are momentary contacts. If another position is desired, then HMI_Position is provided a new value and the NextMove bit is toggled. When NextMove bit comes ON the InPos stage transitions back to the Move stage. If this is the last move, then the Done bit is toggled. When Done comes ON then Begin bit is cleared OFF and InPos stage disables itself (SGRST). When the InPos stage is transitioned out of, it will turn the Positioned bit OFF to indicate another move is in progress or all moves are complete.
The Begin bit resets the CTAXDYNP instruction in the Position stage above. This causes the following to happen:
The Stop stage merely exits this Program code block. |
|
|
Example 2 of 2: |
![]() |
|
|