RTO
Retentive Timer On
Libraries:
Description
The RTO block implements the RTO
ladder logic
instruction. When the rung conditions are true, the block accumulates time until:
The timer is disabled
The timer completes
Ports
Input
EnableIn — Enable Input
off (default) | on
Controls the execution of the block. EnableIn reflects the rung state preceding the block. If the rung state preceding the block is false, EnableIn is false, the block does not execute and the outputs are not updated.
Output
EN — Enable Output
off (default) | on
By default, EnableOut follows the state of EnableIn. If the EnableIn input to the block is false, the logic implemented by the block is not executed and EnableOut signal is set to false.
Parameters
Timer Tag — Timer Structure
T (default) | character vector
Specify the timer parameters in the format of tags
. In Ladder
Diagrams, tags (variables) are used to represent inputs, outputs, and internal memory
with attributes such as Data Type
, Initial Value
,
and size
. To change the attributes of the Operand
Tag
, open the Program Variables table within the
Ladder Diagram Program block. The Data Type
of the
timer tag is of the Bus:TIMER
type with its initial value specified
as a structure containing the following fields:
Field | Description | Default Value |
---|---|---|
PRE | The preset value specifies the value (1 millisecond units) which the accumulated value must reach before the instruction indicates it is done | 0 |
ACC | The accumulated value specifies the number of milliseconds that
have elapsed since the | 0 |
EN | The enable bit contains rung-condition-in when the instruction was last executed. | 0 |
TT | The timing bit when set indicates the timing operation is in process. | 0 |
DN | The done bit when set indicates the timing operation is complete (or paused). | 0 |
Programmatic Use
Block Parameter:
PLCOperandTag |
Type: character vector |
Value: character vector |
Default: 'T' |
More About
Setting Timer Preset Values
When setting the fields in the Timer Tag parameter,
you must set the timer preset value, PRE
, in milliseconds. When the
value of the timer accumulated value field, ACC
, equals the preset
value, the block sets the DN
bit to 1
for the
TON and RTO blocks and 0
for the
TOF block.
Before you set the timer preset values:
Load the built-in timer data types by using the
plcloadtypes
function. At the MATLAB® command line, enter:plcloadtypes
Open the ladder diagram block library. At the MATLAB command line, enter:
plcladderlib
Select a PLC Controller Suite block and add it to your model. Navigate to the ladder diagram program by double-clicking PLC Controller Suite > Task > Program. Alternatively, you can:
Add a JSR (RTN) Subroutine block and navigate to the ladder diagram program block by double-clicking JSR (RTN) Subroutine > Routine Logic.
Add a Function Block (AOI) block and navigate to the ladder diagram program block by double-clicking Function Block (AOI) > Logic Routine.
Add a TON, TOF, or RTO block to the ladder diagram program. Double-click the TON, TOF, or RTO block and enter a name. For example, name your block as
T1
.When you add a TON, TOF, or RTO block, Simulink® PLC Coder™ creates the associated timer structure and names your structure as
TimerName_InitialValue
. For example, if your timer block name isT1
, the structure name isT1_InitialValue
.
To set the timer preset values you can:
Assign the timer preset values at the MATLAB command line. For example, if your block names are
T1
,T2
, andT3
, at the MATLAB command line, enter:T1_InitialValue = FB_TON.InitialValue; T1_InitialValue.PRE = 5000; T2_InitialValue = FB_TOF.InitialValue; T2_InitialValue.PRE = 5000; T3_InitialValue = FB_RTO.InitialValue; T3_InitialValue.PRE = 5000;
Use a MATLAB script that executes when the model loads. For example, if your block names are
T1
,T2
, andT3
, in theInitFcn
model callback property, enter:T1_InitialValue = FB_TON.InitialValue; T1_InitialValue.PRE = 5000; T2_InitialValue = FB_TOF.InitialValue; T2_InitialValue.PRE = 5000; T3_InitialValue = FB_RTO.InitialValue; T3_InitialValue.PRE = 5000;
Set the timer preset values by using a MATLAB script file. You must first create a script file and then call the script file in the
LoadFcn
model callback. For example, create a script file calledmytimerpresets
. In this script file, enter:T1_InitialValue = FB_TON.InitialValue; T1_InitialValue.PRE = 5000; T2_InitialValue = FB_TOF.InitialValue; T2_InitialValue.PRE = 5000; T3_InitialValue = FB_RTO.InitialValue; T3_InitialValue.PRE = 5000;
To programmaticaly assign the
mytimerpresets
script file to theLoadFcn
callback, at the MATLAB command line, enter:set_param(gcb,'LoadFcn',mytimerpresets);
Version History
Introduced in R2019a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)