Machinekit Documentation
HAL Component — TIME
INSTANTIABLE COMPONENTS — General
All instantiable components can be loaded in two manners
Using loadrt with or without count= | names= parameters as per legacy components
Using newinst, which names the instance and allows further parameters and arguments
primarily pincount= which can set the number of pins created for that instance (where applicable)
NAME
time — Time on in Hours, Minutes, Seconds
SYNOPSIS
time
USAGE SYNOPSIS
loadrt time
OR
newinst time <newinstname> [ pincount=N | iprefix=prefix ] [instanceparamX=X | argX=X ]
( args in [ ] denote possible args and parameters, may not be used in all components )
DESCRIPTION
Time
When the time.N.start bit goes true the cycle timer resets and starts to time until time.N.start goes false. If you connect time.N.start to halui.is-running as a cycle timer it will reset during a pause. See the example connections below to keep the timer timing during a pause.
Time returns the hours, minutes, and seconds that time.N.start is true.
Sample pyVCP code to display the hours:minutes:seconds.
<pyvcp> <hbox> <label> <text>"Cycle Time"</text> <font>("Helvetica",14)</font> </label> <u32> <halpin>"time-hours"</halpin> <font>("Helvetica",14)</font> <format>"2d"</format> </u32> <label> <text>":"</text> <font>("Helvetica",14)</font> </label> <u32> <halpin>"time-minutes"</halpin> <font>("Helvetica",14)</font> <format>"2d"</format> </u32> <label> <text>":"</text> <font>("Helvetica",14)</font> </label> <u32> <halpin>"time-seconds"</halpin> <font>("Helvetica",14)</font> <format>"2d"</format> </u32> </hbox> </pyvcp>
In your post-gui.hal file you might use the following to connect it up
loadrt time loadrt not addf time.0 servo-thread addf not.0 servo-thread net prog-running not.0.in <= halui.program.is-idle net cycle-timer time.0.start <= not.0.out net cycle-seconds pyvcp.time-seconds <= time.0.seconds net cycle-minutes pyvcp.time-minutes <= time.0.minutes net cycle-hours pyvcp.time-hours <= time.0.hours
The start pin will start or restart the counter cumulatively
The zero pin will zero the counter for a fresh count attach to a momentary push button
FUNCTIONS
time.N.funct ( OR <newinstname>.funct (requires a floating-point thread) )
PINS
time.N.start bit in (default: 0) ( OR <newinstname>.start bit in (default: 0) ) - Timer On
time.N.zero bit in (default: 0) ( OR <newinstname>.zero bit in (default: 0) ) - Zero timer
time.N.seconds u32 out (default: 0) ( OR <newinstname>.seconds u32 out (default: 0) ) - Seconds
time.N.minutes u32 out (default: 0) ( OR <newinstname>.minutes u32 out (default: 0) ) - Minutes
time.N.hours u32 out (default: 0) ( OR <newinstname>.hours u32 out (default: 0) ) - Hours
AUTHOR
John Thornton - adapted by ArcEye to instcomp
LICENCE
GPL