Difference between revisions of "Component: Timer (Timing)"

From Flowcode Help
Jump to navigationJump to search
 
(10 intermediate revisions by one other user not shown)
Line 5: Line 5:
 
|-
 
|-
 
| width="20%" style="color:gray;" | Version
 
| width="20%" style="color:gray;" | Version
| 1.1
+
| 14.0
 
|-
 
|-
 
| width="20%" style="color:gray;" | Category
 
| width="20%" style="color:gray;" | Category
Line 15: Line 15:
 
Allows you to measure the passage of time via the use of a hardware timer peripheral. Works like a stopwatch with macros to start, stop and reset the timer counter. Returns time as integer Seconds, Milliseconds, Microseconds and also Floating Point and String.
 
Allows you to measure the passage of time via the use of a hardware timer peripheral. Works like a stopwatch with macros to start, stop and reset the timer counter. Returns time as integer Seconds, Milliseconds, Microseconds and also Floating Point and String.
  
==Component Source Code==
+
==Version information==
 +
 
 +
Library Version, Component Version, Date, Author, Info
 +
  
Please click here for the component source code: [https://www.flowcode.co.uk/wikicopy/componentsource/FC_Comp_Source_TimerComponent.fcfx FC_Comp_Source_TimerComponent.fcfx]
 
  
 
==Detailed description==
 
==Detailed description==
 +
 +
 +
 +
 +
 +
 +
 +
  
  
Line 29: Line 39:
  
  
''<span style="color:red;">No additional examples</span>''
+
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
Here is a basic example showing the operation of the timer component used to time a section of code or the duration of a specific event.
 +
 
 +
{{Fcfile|TimerExample.fcfx|Timer Example}}
  
 
==Macro reference==
 
==Macro reference==
  
 +
===GetCountMicroSeconds===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetCountSeconds'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetCountMicroSeconds'''
 
|-
 
|-
| colspan="2" | Returns the count value as a number of whole seconds, rounded down to the nearest second&nbsp;
+
| colspan="2" | Returns the count value as a number of whole microseconds, rounded down to the nearest microsecond&nbsp;
 
|-
 
|-
 
|-
 
|-
Line 46: Line 71:
  
  
 +
===GetCountMilliseconds===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StartCounter'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetCountMilliseconds'''
 
|-
 
|-
| colspan="2" | Starts the timer counting.&nbsp;
+
| colspan="2" | Returns the count value as a number of whole milliseconds, rounded down to the nearest millisecond&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | ResetCounters
 
|-
 
| colspan="2" | Range: 0-1 where 0=Do Not Reset and 1=Reset&nbsp;
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===GetCountReal===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetCountString'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetCountReal'''
 
|-
 
|-
| colspan="2" | Returns the count value as a floating point string in seconds.&nbsp;
+
| colspan="2" | Returns the count value as a floating point value in seconds.&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="90%" | Precision
 
|-
 
| colspan="2" | Number of decimal places to display in string&nbsp;
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
 
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===GetCountSeconds===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetCountMicroSeconds'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetCountSeconds'''
 
|-
 
|-
| colspan="2" | Returns the count value as a number of whole microseconds, rounded down to the nearest microsecond&nbsp;
+
| colspan="2" | Returns the count value as a number of whole seconds, rounded down to the nearest second&nbsp;
 
|-
 
|-
 
|-
 
|-
Line 95: Line 113:
  
  
 +
===GetCountString===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetCountMilliseconds'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetCountString'''
 +
|-
 +
| colspan="2" | Returns the count value as a floating point string in seconds.&nbsp;
 +
|-
 
|-
 
|-
| colspan="2" | Returns the count value as a number of whole milliseconds, rounded down to the nearest millisecond&nbsp;
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Precision
 
|-
 
|-
 +
| colspan="2" | Number of decimal places to display in string&nbsp;
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===GetRawCount===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StopCounter'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetRawCount'''
 
|-
 
|-
| colspan="2" | Stops the timer counting.&nbsp;
+
| colspan="2" | Efficient command to collect the integer number of instructions since the timer was started.&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===ResetCounter===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 134: Line 160:
  
  
 +
===StartCounter===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetCountReal'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StartCounter'''
 +
|-
 +
| colspan="2" | Starts the timer counting.&nbsp;
 +
|-
 
|-
 
|-
| colspan="2" | Returns the count value as a floating point value in seconds.&nbsp;
+
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
 +
| width="90%" | ResetCounters
 
|-
 
|-
 +
| colspan="2" | Range: 0-1 where 0=Do Not Reset and 1=Reset&nbsp;
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===StopCounter===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetRawCount'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StopCounter'''
 
|-
 
|-
| colspan="2" | Efficient command to collect the integer number of instructions since the timer was started.&nbsp;
+
| colspan="2" | Stops the timer counting.&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
 
 
  
  
Line 174: Line 205:
 
|-
 
|-
 
| colspan="2" | Timer Peripheral to use to monitor the passage of time.&nbsp;
 
| colspan="2" | Timer Peripheral to use to monitor the passage of time.&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 +
| width="90%" | Prescaler
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 +
| width="90%" | Postscaler
 +
|-
 +
| colspan="2" | &nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
 
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
Line 214: Line 255:
 
| colspan="2" | &nbsp;
 
| colspan="2" | &nbsp;
 
|}
 
|}
 +
 +
==Component Source Code==
 +
 +
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_TimerComponent.fcfx FC_Comp_Source_TimerComponent.fcfx]
 +
 +
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_TimerComponent.fcfx FC_Comp_Source_TimerComponent.fcfx]

Latest revision as of 14:48, 24 July 2024

Author Matrix TSL
Version 14.0
Category Timing


Timer component

Allows you to measure the passage of time via the use of a hardware timer peripheral. Works like a stopwatch with macros to start, stop and reset the timer counter. Returns time as integer Seconds, Milliseconds, Microseconds and also Floating Point and String.

Version information

Library Version, Component Version, Date, Author, Info


Detailed description

No detailed description exists yet for this component

Examples

Here is a basic example showing the operation of the timer component used to time a section of code or the duration of a specific event.

FC6 Icon.png Timer Example

Macro reference

GetCountMicroSeconds

Fc9-comp-macro.png GetCountMicroSeconds
Returns the count value as a number of whole microseconds, rounded down to the nearest microsecond 
Fc9-u32-icon.png - ULONG Return


GetCountMilliseconds

Fc9-comp-macro.png GetCountMilliseconds
Returns the count value as a number of whole milliseconds, rounded down to the nearest millisecond 
Fc9-u32-icon.png - ULONG Return


GetCountReal

Fc9-comp-macro.png GetCountReal
Returns the count value as a floating point value in seconds. 
Fc9-f32-icon.png - FLOAT Return


GetCountSeconds

Fc9-comp-macro.png GetCountSeconds
Returns the count value as a number of whole seconds, rounded down to the nearest second 
Fc9-u32-icon.png - ULONG Return


GetCountString

Fc9-comp-macro.png GetCountString
Returns the count value as a floating point string in seconds. 
Fc9-u8-icon.png - BYTE Precision
Number of decimal places to display in string 
Fc9-string-icon.png - STRING Return


GetRawCount

Fc9-comp-macro.png GetRawCount
Efficient command to collect the integer number of instructions since the timer was started. 
Fc9-u32-icon.png - ULONG Return


ResetCounter

Fc9-comp-macro.png ResetCounter
 
Fc9-void-icon.png - VOID Return


StartCounter

Fc9-comp-macro.png StartCounter
Starts the timer counting. 
Fc9-bool-icon.png - BOOL ResetCounters
Range: 0-1 where 0=Do Not Reset and 1=Reset 
Fc9-void-icon.png - VOID Return


StopCounter

Fc9-comp-macro.png StopCounter
Stops the timer counting. 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png Timer
Timer Peripheral to use to monitor the passage of time. 
Fc9-type-16-icon.png Prescaler
 
Fc9-type-16-icon.png Postscaler
 
Fc9-type-21-icon.png Bit Depth
Number of bits in the timer peripheral. 8-bit timers can count from 0-255 before overflowing. 16-bit timers can count from 0 to 65535 before overflowing. 
Fc9-type-21-icon.png Instruction Rate
 
Fc9-type-15-icon.png Rollover Frequency
 
Fc9-type-15-icon.png Rollover Time
 
Fc9-type-15-icon.png Max Time Measurement
Max time in seconds that we can measure before rolling over and starting again. 
Fc9-conn-icon.png Simulation
Fc9-type-21-icon.png Timer Delay (ms)
Number of milliseconds between timer events which increment the simulated timer counter variable. 10ms will yield the highest resolution. Values less than this will likely just increase the error and making the timer run slow. Higher delays will yield greater accuracy. 
Fc9-type-21-icon.png Decimal Points
 

Component Source Code

Please click here to download the component source project: FC_Comp_Source_TimerComponent.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_TimerComponent.fcfx