beautypg.com

Example: time-out, E example: time-out, Time-out – Delta RMC151 User Manual

Page 406

background image

RMC70/150 and RMCTools User Manual

DINT, and will wrap around to -2147483648 after it reaches its maximum value of

2147483647.

Example

Consider an application that toggles a discrete output every 10 seconds. One method of

achieving this is as follows. Notice that this is not necessarily the best way to achieve this

application. However, the point here is to illustrate how to make a timer. This is intended

to be a starting point for the reader to create more complicated timer applications.

1. Define a Variable

Define a variable, called Time0. Define it as a DINT:

2. Write a User Program

The User Program will consist of the following:

Toggle the output.

Assign Time0 = _SysMS.

Wait until _SysMS minus Time0 is equal to the time increment before

repeating the step. In this case the time increment is 10 seconds, or 10000

milliseconds. One loop time will be lost in jumping to the next step. Assuming

the loop time is 1 msec, the comparison will be to 10000 minus 1, which is

9999.


This program will loop forever until the task is stopped.
Handling _SysMS Wrapping
Notice that the _SysMS value in the above example will wrap its 32-bit limit eventually,

but the math in the Link Condition will still be correct even through a wrap. However, if

the inequality in the link condition is rearranged, it may not handle the wrapping

correctly. For example, ”_SysMS >= Timer0 + 9999”, though mathematically identical,

will not handle _SysMS wrapping.

5.16.7. Example: Time-out

This example illustrates how to create a time-out. After issuing a move command, the user

program has a time-out period (this example will use 5000 milliseconds) in which the axis

must reach position. If the axis does not reach position within the time-out period, a discrete

output turns on. If the axis does reach position within the time-out period, a different discrete

output turns on.

386

Delta Computer Systems, Inc.

This manual is related to the following products: