DMD0526

CTREGRD - CTRIO Read Register


The CTRIO Read Register (CTREGRD) instruction is used to read the value from the selected internal register of the CTRIO and store that value in a location in the Do-more controller.

 

The red triangle in the upper left corner indicates the CTRIO Read Register (CTREGRD) is a Fully Asynchronous instruction.

 

Note: The CTREGRD 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 Read Register (CTREGRD) will:

  • Read the value from the selected location in the CTRIO module
     

  • Run to completion, even if the input logic goes OFF before the operation is complete.

 

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.

 

Module Device - designates which CTRIO module to interact with.

 

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 - This field displays the name of the Module Structure that will be used by this instruction. This structure was created when the CTRIO module was configured during the Module Configuration phase.

 

Source Register - selects which of the following internal registers to read:

  • 0 - Ch1Fn1 Accumulator: Channel 1 Function 1 raw count value (e.g. .iReg1 if Ch1Fn1 is unscaled or .iReg2 if Ch1Fn1 is scaled)

  • 1 - Ch1Fn2 Accumulator: Channel 1 Function 1 raw count value (e.g. .iReg1 if Ch1Fn2 is unscaled or .iReg2 if Ch1Fn2 is scaled)

  • 2 - Ch2Fn1 Accumulator: Channel 1 Function 1 raw count value (e.g. .iReg1 if Ch2Fn1 is unscaled or .iReg2 if Ch2Fn1 is scaled)

  • 3 - Ch2Fn2 Accumulator: Channel 1 Function 1 raw count value (e.g. .iReg1 if Ch2Fn2 is unscaled or .iReg2 if Ch2Fn2 is scaled)

  • 4 - Out 0 Position: Output 0's position value.

  • 5 - Out 1 Position: Output 1's position value.

  • 6 - Out 2 Position: Output 2's position value.

  • 7 - Out 3 Position: Output 3's position value.

  • 12 - Ch1A Filter Time (CTRIO2): Software noise filter value in nanoseconds for Channel 1 Input A (for full explanation see here).

  • 13 - Ch1B Filter Time (CTRIO2): Software noise filter value in nanoseconds for Channel 1 Input B (for full explanation see here).

  • 14 - Ch1C Filter Time (CTRIO2): Software noise filter value in nanoseconds for Channel 1 Input C (for full explanation see here).

  • 15 - Ch1D Filter Time (CTRIO2): Software noise filter value in nanoseconds for Channel 1 Input D (for full explanation see here).

  • 16 - Ch2A Filter Time (CTRIO2): Software noise filter value in nanoseconds for Channel 2 Input A (for full explanation see here).

  • 17 - Ch2B Filter Time (CTRIO2): Software noise filter value in nanoseconds for Channel 2 Input B (for full explanation see here).

  • 18 - Ch2C Filter Time (CTRIO2): Software noise filter value in nanoseconds for Channel 2 Input C (for full explanation see here).

  • 19 - Ch2D Filter Time (CTRIO2): Software noise filter value in nanoseconds for Channel 2 Input D (for full explanation see here).

 

Destination - designates the memory location to store the value read from the CTRIO module. This can be any 32-bit writable numeric location.

 

On Success - designates which of the following actions to take if the CTRIO Read Register operation is successful.

 

  • SET BIT - The specific BIT location will be turned OFF when the CTRIO Read Register (CTREGRD) instruction is first enabled, and then SET ON if the operation is successful. This value can be any writable bit location.
     

  • JMP to Stage - JMP to the specified Stage. The target Stage must be in the same Program code block as the CTRIO Read Register (CTREGRD) instruction, you cannot specify a Stage in a different Program code block. This selection will function like a standalone Jump to Stage instruction. Click here for more information on the Jump To Stage instruction.

 

On Error - designates which of the following two actions to take if the CTRIO Read Register operation is unsuccessful. For example if the specified CTRIO Discrete output is not configured correctly.

 

  • SET BIT - The specific BIT location will be turned OFF when the CTRIO Read Register (CTREGRD) instruction is first enabled, and then SET ON if the operation is unsuccessful. This value can be any writable bit location.
     

  • JMP to Stage - JMP to the specified Stage. The target Stage must be in the same Program code block as the CTRIO Read Register (CTREGRD) instruction, you cannot specify a Stage in a different Program code block. This selection will function the same as a standalone Jump to Stage instruction. Click here for more information on the Jump To Stage instruction.

 

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:

 

Error Code

Description

000

No Error

100

Specified command code is unknown or unsupported

101

File number not found in the file system

102

File type is incorrect for specified output function

103

Profile type is unknown

104

Specified input is not configured as a limit on this output

105

Specified limit input edge is out of range

106

Specified input function is unconfigured or invalid

107

Specified input function number is out of range

108

Specified preset function is invalid

109

Preset table is full

110

Specified Table entry is out of range

111

Specified register number is out of range

112

Specified register is an unconfigured input or output

113

Specified output is not configured as a limit on this output

114

Specified preset function invalid in PLS table

115

Specified PLS function invalid in preset table

116

PLS table entries overlap

117

Attempted to use axis function when pulse output is not in Axis Mode

118

Specified output isn't a pulse output

 


Status Display:

The Status display of the CTRIO Read Register (CTREGRD) instruction shows:

  • Values: Destination
     

  • Highlights: None
     

  • ON/OFF: On Success, On Error bits


See Also:

 


Example 1 of 2:

Description of a Typical CTRIO Read Register (CTREGRD) Stage Diagram:

To the right is a stage diagram of a simple sequence control that would move a motor to any number of positions and when finished, read that position back from the CTRIO.

 

Note: This would not be necessary with a CTRIO2 module since the output position is available as a structure member (.OutputPosition). But this particular structure member is not supported in the CTRIO, so the only way to read the output position is via a CTREGRD instruction.

 

The Position stage puts the CTRIO 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 CTRIO pulse output in the Dynamic Position mode through all the moves.

 

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 ReadPos (Read Position) stage.

 

Once the position is read by the ReadPos stage, transition is made to the Stop stage.

 

Description of a Typical CTRIO Read Register (CTREGRD) Stage Ladder:

To the right is the ladder equivalent of the above stage diagram that uses the CTDYNPOS instruction to move a stepper motor attached to the CTRIO's pulse output to any number of positions provided by an HMI device and then uses the CTREGRD instruction to read the final position back from the CTRIO. (For information on the functionality of the CTDYNPOS instruction click here.)

 

Note: Reading the output position with the CTREGRD is not necessary if using a CTRIO2 module since the output position is available as a structure member (.OutputPostion).

 

This example presupposes the use of a CTRIO (instead of a CTRIO2) module and the existence of the following System Configuration for the CTRIO (PLC --> System Configuration --> Module Configuration(s) --> CTRIO_001 -->):

  • Configure I/O --> Outputs --> Out0 --> Pulse (Step/Dir).

  • Pulse Profiles --> File 1 --> Dynamic Positioning --> (values for Minimum Freq, Maximum Freq and Accel Rate).

  • A stepper motor is wired to CTRIO's Output 0 and Output 1.

 

Position is the main CTDYNPOS instruction stage. This stage remains enabled for all moves. Instead of transitioning to the next stage (Move), the next stage is merely enabled. When Begin bit comes ON it will enable the CTDYNPOS instruction. Then the following things occur:

  1. The Pulse Output Device ($CTRIO_001_Out0) will be placed in the "Dynamic Position Mode."

  2. The specified Dynamic Position File Number (1:DynaPos(Dynamic Position)) is loaded into CTRIO memory.

  3. The current position value (internal to CTRIO) is set to 0.

  4. The CTRIO's Pulse Output is enabled ($CTRIO_001_Out0.OutputEnabled = ON).

 

The Begin bit will remain ON for all moves. It will be cleared OFF at the completion of the last move. The CTDYNPOS'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 CTRIO's output to immediately stop. Turning it back OFF will cause the CTRIO's output to abruptly start again and complete a move.

 

The On Success parameter jumps to the ReadPos stage. This will occur when Begin is cleared OFF and everything was successful.

 

The On Error parameter jumps to the ErrorStage stage. In this stage should exist logic (not shown here) that would properly handle the error (e.g. to process the $CTRIO_000.ErrorCode value).

 

Once the CTDYNPOS is enabled, the $CTRIO_001_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_001_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_001_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 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 CTDYNPOS instruction in the Position stage above. This causes the following to happen:

  1. The CTRIO pulse output is disabled ($CTRIO_001_Out0.OutputEnabled = OFF).

  2. The On Success transitions to the ReadPos stage.

 

The ReadPos stage uses the CTREGRD instruction to read the 4 - Out0 Position value from the CTRIO's internal register and stores that value in Read_Position variable. When successful it transitions to the Stop stage.

 

The Stop stage merely exits this Program code block.


Example 2 of 2:


Copyright Host Engineering, Inc. ALL RIGHTS RESERVED