advertisement
Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES)
Timer On Delay (TON)
Mnemonic
.EN
.TT
.DN
.PRE
.ACC
The TON instruction is a non-retentive timer that accumulates time when the instruction is enabled (rung-condition-in is true).
This instruction is available in structured text and function block as TONR, see page 116 .
Operands:
Relay Ladder
Operand
Timer
Preset
Accum
Type
TIMER
DINT
DINT
Format Description
tag timer structure immediate how long to delay (accumulate time) immediate total msec the timer has counted initial value is typically 0
TIMER Structure
Data Type
BOOL
BOOL
BOOL
DINT
DINT
Description
The enable bit indicates that the TON instruction is enabled.
The timing bit indicates that a timing operation is in process
The done bit is set when .ACC
≥
.PRE.
The preset value specifies the value (1 msec units) which the accumulated value must reach before the instruction sets the .DN bit.
The accumulated value specifies the number of milliseconds that have elapsed since the
TON instruction was enabled.
Description:
The TON instruction accumulates time until:
• the TON instruction is disabled
• the .ACC
≥
.PRE
The time base is always 1 msec. For example, for a 2-second timer, enter 2000 for the .PRE value.
104
Publication 1756-RM003K-EN-P - July 2008
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3
When the TON instruction is disabled, the .ACC value is cleared.
rung condition in timer enable bit (.EN) timer timing bit (.TT) timer done bit (.DN)
ON delay preset timer did not reach
.PRE value timer accumulated value (.ACC)
0 16649
A timer runs by subtracting the time of its last scan from the time now:
ACC = ACC + (current_time - last_time_scanned)
After it updates the ACC, the timer sets last_time_scanned =
current_time. This gets the timer ready for the next scan.
IMPORTANT
Make sure to scan the timer at least every 69 minutes while it runs. Otherwise, the ACC value won’t be correct.
The
last_time_scanned value has a range of up to 69 minutes. The timer’s calculation rolls over if you don’t scan the timer within 69 minutes. The ACC value won’t be correct if this happens.
While a timer runs, scan it within 69 minutes if you put it in a:
• subroutine
• section of code that is between JMP and LBL instructions
• sequential function chart (SFC)
• event or periodic task
• state routine of a phase
Arithmetic Status Flags:
not affected
Fault Conditions:
A Major Fault Will Occur If Fault Type
.PRE < 0 4
.ACC < 0 4
Fault Code
34
34
Publication 1756-RM003K-EN-P - July 2008
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
105
Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES)
Condition
prescan rung-condition-in is false
Execution:
Relay Ladder Action
The .EN, .TT, and .DN bits are cleared.
The .ACC value is cleared.
The rung-condition-out is set to false.
The .EN, .TT, and .DN bits are cleared.
The .ACC value is cleared.
The rung-condition-out is set to false.
rung-condition-in is true examine .DN bit
.DN bit = 1
.DN bit = 0
.EN bit is set
.TT bit is set examine .EN bit
.EN bit = 0
.EN bit = 1
.TT bit is set
.ACC = .ACC + (current_time - last_time) examine .ACC
.ACC
≥
.PRE
.ACC < .PRE
.DN is set
.TT bit is cleared
.ACC value rolls over yes
.ACC = 2,147,483,647 no rung-condition-out is set to
true
postscan The rung-condition-out is set to false.
end
106
Publication 1756-RM003K-EN-P - July 2008
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3
Example:
When limit_switch_1 is set, light_2 is on for 180 msec (timer_1 is timing). When
timer_1.acc reaches 180, light_2 goes off and light_3 goes on. Light_3 remains on until the TON instruction is disabled. If limit_switch_1 is cleared while timer_1 is timing, light_2 goes off.
Publication 1756-RM003K-EN-P - July 2008
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
107
advertisement
Related manuals
advertisement
Table of contents
- 24 Introduction
- 24 Who Should Use This Manual
- 25 Purpose of This Manual
- 26 Common Information for All Instructions
- 26 Conventions and Related Terms
- 26 Set and clear
- 27 Relay ladder rung condition
- 28 Function block states
- 30 Introduction
- 31 Digital Alarm (ALMD)
- 37 State Diagrams when Acknowledgement Required
- 38 State Diagrams when Acknowledgment Not Required
- 39 ALMD Alarm Acknowledge Required and Latched
- 40 ALMD Alarm Acknowledge Required and Not Latched
- 40 ALMD Alarm Acknowledge Not Required and Latched
- 41 ALMD Alarm Acknowledge Not Required and Not Latched
- 43 Analog Alarm (ALMA)
- 55 State Diagrams when Acknowledgement Required
- 56 State Diagrams when Acknowledgement Not Required
- 59 ALMA Level Condition Acknowledge Required
- 60 ALMA Level Condition Acknowledge Not Required
- 61 ALMA Rate of Change Acknowledge Required
- 62 ALMA Rate of Change Acknowledge Not Required
- 64 Configure an Alarm Instruction
- 66 Enter Alarm Message Text
- 68 Message String Variables
- 69 Multiple Language Versions of Alarm Messages
- 70 Monitor Alarm Status
- 70 Buffering Alarms
- 71 Programmatically Access Alarm Information
- 72 Suppress or Disable Alarms
- 73 Controller-based Alarm Execution
- 74 Controller Memory Use
- 76 Scan Time
- 78 Introduction
- 79 Examine If Closed (XIC)
- 81 Examine If Open (XIO)
- 83 Output Energize (OTE)
- 85 Output Latch (OTL)
- 87 Output Unlatch (OTU)
- 89 One Shot (ONS)
- 92 One Shot Rising (OSR)
- 95 One Shot Falling (OSF)
- 97 One Shot Rising with Input (OSRI)
- 100 One Shot Falling with Input (OSFI)
- 104 Introduction
- 105 Timer On Delay (TON)
- 109 Timer Off Delay (TOF)
- 113 Retentive Timer On (RTO)
- 117 Timer On Delay with Reset (TONR)
- 121 Timer Off Delay with Reset (TOFR)
- 125 Retentive Timer On with Reset (RTOR)
- 129 Count Up (CTU)
- 133 Count Down (CTD)
- 137 Count Up/Down (CTUD)
- 142 Reset (RES)
- 144 Introduction
- 145 Message (MSG)
- 153 MSG Error Codes
- 153 Error Codes
- 155 Extended Error Codes
- 157 PLC and SLC Error Codes (.ERR)
- 159 Block-Transfer Error Codes
- 160 Specify the Configuration Details
- 161 Specify CIP Data Table Read and Write messages
- 162 Reconfigure an I/O module
- 163 Specify CIP Generic messages
- 164 Specify PLC-5 messages
- 166 Specify SLC messages
- 166 Specify block-transfer messages
- 167 Specify PLC-3 messages
- 168 Specify PLC-2 messages
- 169 MSG Configuration Examples
- 170 Specify the Communication Details
- 170 Specify a path
- 173 For Block Transfers
- 173 Specify a Communication Method Or Module Address
- 174 Choose a cache option
- 176 Guidelines
- 177 Get System Value (GSV) and Set System Value (SSV)
- 180 GSV/SSV Objects
- 181 Access the CONTROLLER object
- 182 Access the CONTROLLERDEVICE object
- 184 Access the CST object
- 185 Access the DF1 object
- 188 Access the FAULTLOG object
- 189 Access The MESSAGE Object
- 191 Access The MODULE Object
- 192 Access The MOTIONGROUP Object
- 193 Access The PROGRAM Object
- 194 Access The Routine object
- 194 Access The SERIALPORT Object
- 196 Access The TASK Object
- 198 Access The WALLCLOCKTIME Object
- 199 GSV/SSV Programming Example
- 199 Get Fault Information
- 201 Set Enable And Disable Flags
- 202 Immediate Output (IOT)
- 206 Introduction
- 207 Compare (CMP)
- 209 CMP expressions
- 209 Valid operators
- 210 Format Expressions
- 210 Determine The Order of Operation
- 211 Use Strings In an Expression
- 212 Equal to (EQU)
- 216 Greater than or Equal to (GEQ)
- 220 Greater Than (GRT)
- 224 Less Than or Equal to (LEQ)
- 228 Less Than (LES)
- 232 Limit (LIM)
- 238 Mask Equal to (MEQ)
- 239 Entering an Immediate Mask Value
- 243 Not Equal to (NEQ)
- 248 Introduction
- 249 Compute (CPT)
- 251 Valid operators
- 251 Format Expressions
- 252 Determine the order of operation
- 253 Add (ADD)
- 256 Subtract (SUB)
- 259 Multiply (MUL)
- 262 Divide (DIV)
- 267 Modulo (MOD)
- 271 Square Root (SQR)
- 275 Negate (NEG)
- 278 Absolute Value (ABS)
- 282 Introduction
- 284 Move (MOV)
- 286 Masked Move (MVM)
- 287 Enter an immediate mask value
- 289 Masked Move with Target (MVMT)
- 292 Bit Field Distribute (BTD)
- 295 Bit Field Distribute with Target (BTDT)
- 298 Clear (CLR)
- 300 Swap Byte (SWPB)
- 304 Bitwise AND (AND)
- 307 Bitwise OR (OR)
- 311 Bitwise Exclusive OR (XOR)
- 315 Bitwise NOT (NOT)
- 318 Boolean AND (BAND)
- 321 Boolean OR (BOR)
- 324 Boolean Exclusive OR (BXOR)
- 327 Boolean NOT (BNOT)
- 330 Introduction
- 331 Selecting Mode of Operation
- 331 All mode
- 332 Numerical mode
- 334 Incremental mode
- 336 File Arithmetic and Logic (FAL)
- 345 FAL Expressions
- 345 Valid operators
- 346 Format Expressions
- 346 Determine the order of operation
- 347 File Search and Compare (FSC)
- 352 FSC expressions
- 353 Valid Operators
- 353 Format Expressions
- 354 Determine the order of operation
- 355 Use Strings In an Expression
- 356 Copy File (COP) Synchronous Copy File (CPS)
- 362 File Fill (FLL)
- 366 File Average (AVE)
- 371 File Sort (SRT)
- 376 File Standard Deviation (STD)
- 382 Size In Elements (SIZE)
- 386 Introduction
- 387 Bit Shift Left (BSL)
- 391 Bit Shift Right (BSR)
- 395 FIFO Load (FFL)
- 401 FIFO Unload (FFU)
- 407 LIFO Load (LFL)
- 413 LIFO Unload (LFU)
- 420 Introduction
- 421 Sequencer Input (SQI)
- 422 Enter an Immediate Mask Value
- 424 Use SQI without SQO
- 425 Sequencer Output (SQO)
- 426 Enter an Immediate Mask Value
- 428 Using SQI with SQO
- 428 Resetting the position of SQO
- 429 Sequencer Load (SQL)
- 434 Introduction
- 435 Label (LBL)
- 437 Subroutine (SBR) Return (RET)
- 448 Jump to External Routine (JXR)
- 451 Temporary End (TND)
- 453 Master Control Reset (MCR)
- 455 User Interrupt Disable (UID) User Interrupt Enable (UIE)
- 457 Always False Instruction (AFI)
- 458 No Operation (NOP)
- 459 End of Transition (EOT)
- 461 SFC Pause (SFP)
- 463 SFC Reset (SFR)
- 465 Trigger Event Task (EVENT)
- 465 a Task
- 470 Introduction
- 471 For (FOR)
- 474 Break (BRK)
- 475 Return (RET)
- 478 Introduction
- 479 File Bit Comparison (FBC)
- 481 Selecting the Search Mode
- 487 Diagnostic Detect (DDT)
- 489 Selecting the search mode
- 495 Data Transitional (DTR)
- 496 Enter an immediate mask value
- 498 Proportional Integral Derivative (PID)
- 503 Configure a PID Instruction
- 504 Specify Tuning
- 505 Specify Configuration
- 505 Specifying Alarms
- 506 Specifying Scaling
- 506 Using PID Instructions
- 509 PID instruction timing
- 513 Bumpless Restart
- 514 Derivative Smoothing
- 515 Set the Deadband
- 515 Use Output Limiting
- 516 Feedforward or Output Biasing
- 516 Cascading Loops
- 517 Control a Ratio
- 518 PID Theory
- 518 PID Process
- 518 PID Process With Master/slave Loops
- 520 Introduction
- 521 Sine (SIN)
- 524 Cosine (COS)
- 527 Tangent (TAN)
- 530 Arc Sine (ASN)
- 533 Arc Cosine (ACS)
- 536 Arc Tangent (ATN)
- 540 Introduction
- 541 Natural Log (LN)
- 544 Log Base 10 (LOG)
- 547 X to the Power of Y (XPY)
- 550 Introduction
- 551 Degrees (DEG)
- 554 Radians (RAD)
- 557 Convert to BCD (TOD)
- 560 Convert to Integer (FRD)
- 562 Truncate (TRN)
- 566 Introduction
- 567 Instruction Execution
- 569 ASCII Error Codes
- 569 String Data Types
- 571 ASCII Test For Buffer Line (ABL)
- 574 ASCII Chars in Buffer (ACB)
- 576 ASCII Clear Buffer (ACL)
- 578 ASCII Handshake Lines (AHL)
- 582 ASCII Read (ARD)
- 586 ASCII Read Line (ARL)
- 590 ASCII Write Append (AWA)
- 595 ASCII Write (AWT)
- 600 Introduction
- 601 String Data Types
- 602 String Concatenate (CONCAT)
- 604 String Delete (DELETE)
- 606 Find String (FIND)
- 608 Insert String (INSERT)
- 610 Middle String (MID)
- 612 Introduction
- 614 String Data Types
- 615 String To DINT (STOD)
- 617 String To REAL (STOR)
- 620 DINT to String (DTOS)
- 622 REAL to String (RTOS)
- 624 Upper Case (UPPER)
- 626 Lower Case (LOWER)
- 628 Introduction
- 628 Breakpoints (BPT)
- 629 String Format
- 632 Tracepoints (TPT)
- 632 String Format
- 636 Introduction
- 636 Immediate Values
- 636 Data Conversions
- 638 SINT or INT to DINT
- 640 Integer to REAL
- 640 DINT to SINT or INT
- 641 REAL to an Integer
- 642 Introduction
- 642 Choose the Function Block Elements
- 643 Latching Data
- 645 Order of Execution
- 646 Resolve a Loop
- 648 Resolve Data Flow Between Two Blocks
- 648 Create a One Scan Delay
- 649 Summary
- 649 Function Block Responses to Overflow Conditions
- 650 Timing Modes
- 652 Common Instruction Parameters for Timing Modes
- 654 Overview of Timing Modes
- 655 Program/Operator Control
- 660 Introduction
- 660 Structured Text Syntax
- 662 Assignments
- 663 Specify a non-retentive assignment
- 664 Assign an ASCII character to a string
- 664 Expressions
- 666 Use arithmetic operators and functions
- 667 Use relational operators
- 669 Use logical operators
- 670 Use bitwise operators
- 670 Determine the order of execution
- 671 Instructions
- 672 Constructs
- 672 Some key words are reserved for future use
- 673 IF...THEN
- 676 CASE...OF
- 679 FOR…DO
- 682 WHILE…DO
- 685 REPEAT…UNTIL
- 688 Comments
- 700 ASCII Character Codes