Steeplechase VLC Timers description

K

Thread Starter

Ken E.

Jiri,

This is from the VLC help file:

*******************************

In the VLC Control Designer, you use timers by creating a timer tag. You then use the timer tag name in combination with other special variable names to access timer functions. The VLC Control Designer automatically creates these special variables. You can*t add, delete, or modify these special timer variables (other than by adding,
deleting, or modifying the timer tag).
The VLC Control Designer creates the variables shown in the table below for every timer tag you create. For example, if you create a timer tag called sim_timer, you preset it by assigning a value to sim_timer.preset.

Timer Variable Type Function
Timer_Tag_name.accum Integer Accumulated time since enabled (read
only).
Timer_Tag_name.clear Boolean Write to clear the accumulator.
Timer_Tag_name.done Boolean ON when accumulator reaches the preset
value (read only).
Timer_Tag_name.enable Boolean Set to ON to start. Set to OFF to
stop. While ON, .accum increments until it reaches .preset.
Timer_Tag_name.preset Integer Sets the time-out value.
Timer_Tag_name.rllaccum Integer For RLL programs, the
accumulated time since enabled (read only).
Timer_Tag_name.rllclear Integer For RLL programs, write to clear the accumulator for an RLL timer.
Timer_Tag_name.rlldone Boolean For RLL programs, ON when accumulator reaches the preset value (read only).
Timer_Tag_name.prescale Integer The number of milliseconds between each increment of the accumulator.
Timer_Tag_name.scaleaccum Integer The accumulated time within each increment of the accumulator (increments up to prescale, and then
rolls over to zero).
There are several important characteristics of timers that are a function of the way the VLC RunTime updates variables (including timers) during each scan cycle. These characteristics are:

* A timer that you clear or start in a scan cycle remains zero during that cycle.

WARNING!

Assigning any value to a Timer_Tag_name.clear variable clears the accumulator in a flow chart program

The Visual Logic Controller, the VLC Control Designer, the VLC RunTime, the VLC MMI, and the VLC Control Maintainer are trademarks or
registered trademarks of Steeplechase Software, Inc. Commercial names of products from other manufacturers or developers that appear in this
documentation are registered or unregistered trademarks of those respective manufacturers or developers, which have expressed neither
approval nor disapproval of Steeplechase products.

*******************

~Ken




>>> Jiri Baum <[email protected]> 11/02 7:04 PM >>>
Ken Emmons, Jr.:
> Timers should have the resolution of milliseconds. Even if the
default
> prescalar multiplies the value by 1000 (to get seconds), the core
> structure should be based on a millisecond tick.

I said real-valued, and intend to keep the time as Linux gives it to
me
(which turns out to be microseconds).

We are not limited to integer constants here.

(Yes, I know floats have resolution problems; I'll be careful. Just
never
add or subtract two reals unless you know what you are doing.)

> Suggestion: Steeplechase assigns timers to their IO table

Yes, they should be in the IO table. But that will take some
designing, and
that demo has been bothering me ever since I wrote it. These will
probably
come in handy anyway.

> To interface to the Timer they define a structure like so:

> TimerName.Done
> TimerName.Enable
> TimerName.Preset
> TimerName.Clear
> TimerName.Accum
> Timer.Prescale

> (These might not be exact, but you get the idea ...)

> In the end I think this would make a nice way to interface to
them.

Do you have a description of the above functions? I can guess some of
them,
but not all, and not the details...

> Are these functions you mention just primitives for higher level
code to
> use???

That's probably how they will wind up, mostly. But they are intended
to be
sensible enough to be directly used by C code.

Jiri
--
Jiri Baum <[email protected]>
What we do Every Night! Take Over the World!




_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
Ken Emmons, Jr.:
> This is from the VLC help file:

OK, I've changed some of the function names and comments to these, where it made sense to me.

> Timer_Tag_name.done Boolean ON when accumulator reaches the preset
> value (read only).
> Timer_Tag_name.preset Integer Sets the time-out value.

How important are these two? Currently I have them combined, so that you pass the preset value to the done() function each time. Is that sensible? (That means one timer can be used with several presets, where that makes sense.)

> Timer_Tag_name.prescale Integer The number of milliseconds between
> each increment of the accumulator.
> Timer_Tag_name.scaleaccum Integer The accumulated time within each
> increment of the accumulator (increments up to prescale, and then rolls
> over to zero).

I don't have these, instead I use floating-point (and seconds).

> * A timer that you clear or start in a scan cycle remains zero during
> that cycle.

Being C (and therefore not cycle-oriented), this is not the case. The RLL translator should probably do that, though...

> Assigning any value to a Timer_Tag_name.clear variable clears the
> accumulator in a flow chart program

That's not a feature, that's a bug! Actually, I suppose it's a result of bad design, function-calls are missing and faked using magic variables.

Jiri
--
Jiri Baum <[email protected]>
What we do Every Night! Take Over the World!
 
All of these timer structures are used in a flow chart program (steeplechase default interface) in order to interface with timers easily at the user level. As I said before, they are stored in the IO
table for easy user access. the "Done" flag is an easy test to see when the timer has timed out. The preset value is absolutely necessary because it is the initial timer value. Basically the preset is the number that you load into the timer that will count done to zero and expire (counting up or down is not important, but this is it conceptually). When the preset value has counted to sero, the Done flag is true. It is very simple and very effective.

I cannot stress enough the importance of millisecond timers. If you use a prescale, you can use milliseconds as your basis for timing ticks(internal to your function), and have your function calls default to a prescalar of 1000, which would in essence make them "second" timers unless explicitly stated for a prescalar of 1, which would be for milliseconds.

The clear flag is not a bug. It simply clears the accumulator so that you can restart your timer.

~Ken
 
D

D. Daniel McGlothin

Hi:
Ken's arguments are cogent.

Think of .Done and .Preset as a timer class' properties:

.Done is a read-only that identifies whether a timer is done timing.

.Preset is the writable property that tells the timer how long of a elapsed time must pass before being .Done.

and .Clear is like a member function that resets the timer by simply resetting the .Accum property to zero.


Yes, the RLL should not start/clear the timer until after the cycle scan.
Roughly the same arguments as in the discussion about A-B ControlLogix's asynchronous updates.

A question about the use of reals for the timebase. Are you providing a set of comparisons (handling the precision error in converting from base2<->base10) that allow me to ask the timer a question like

if .Accum = 1.0 then ...

when the .Accum is actually containing 0.999999. (This is functionally similar to your suggestion that the preset is passed to done() to return a boolean).

Using an integer based timebase allows the user (without precision concerns) to define the resolution of the timer in .Scale and then manipulate the results of queries to .Accum in terms of ordinal units of that resolution. E.G., if the resolution is millisecond, then .Accum should be elapsed milliseconds; if resolution is second, then .Accum should be elapsed seconds.


Not familiar with Steeplechase, but the same concepts (different syntax) of timers are used in A-B & ISaGRAF PLCs)
Regards,
Daniel McGlothin
(Allen-Bradley & ISaGRAF)
 
Top