|
|
(9 intermediate revisions by 2 users not shown) |
Line 17: |
Line 17: |
| ==Component Source Code== | | ==Component Source Code== |
| | | |
− | Please click here to download the component source project: [https://www.flowcode.co.uk/wikicopy/componentsource/FC_Comp_Source_TimerIntervalComponent.fcfx FC_Comp_Source_TimerIntervalComponent.fcfx] | + | Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_TimerIntervalComponent.fcfx FC_Comp_Source_TimerIntervalComponent.fcfx] |
| | | |
| Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_TimerIntervalComponent.fcfx FC_Comp_Source_TimerIntervalComponent.fcfx] | | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_TimerIntervalComponent.fcfx FC_Comp_Source_TimerIntervalComponent.fcfx] |
Line 23: |
Line 23: |
| ==Detailed description== | | ==Detailed description== |
| | | |
| + | The Timed Interval component takes the headache out of setting up timer interrupts to interrupt an amount of fixed microseconds, milliseconds, seconds, minutes, hours or days. |
| | | |
| + | [[File:Timed Interval1.png]] |
| | | |
| | | |
| | | |
| + | After selecting the Time Unit, and entering Time Period, the estimated best will show the exact time the callback macro is accessed. |
| | | |
| + | [[File:Timed Interval2.png]] |
| | | |
| | | |
| + | You can even send the required delay within simulation (Timer Delay (ms). |
| | | |
| + | Unfortunately there is a small simulation only bug that is preventing the global variable within callback macro from updating, it all works on your embedded hardware. |
| | | |
| + | The workaround (included within the example) for your own project is as follows. |
| | | |
− | ''No detailed description exists yet for this component''
| + | First set up your timed interval component within properties along with the callback macro |
− | | |
− | ==Examples==
| |
− | | |
− | | |
− | | |
− | | |
− | | |
| | | |
| + | Within the timed interval example, select the TimedInterval callback macro ,then select the Built-in Function::Debug.PrintLn(" ") |
| + | |
| + | [[File:Timed Interval3.png]] |
| | | |
| + | Right-click then select copy. |
| | | |
| + | Paste the Built-in Function within the callback macro of your new project. |
| | | |
| + | Now the interval timer component will simulate correctly. |
| | | |
| + | ==Examples== |
| | | |
| | | |
− | ''<span style="color:red;">No additional examples</span>''
| + | Example program showing how to use the Timed component to trigger a callback macro at precise intervals e.g. 1 second. |
| | | |
| + | {{Fcfile|Timed_interval_example.fcfx|One second timed interval component example }} |
| | | |
| ==Macro reference== | | ==Macro reference== |
| | | |
| + | ===StartTimerInterval=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 66: |
Line 75: |
| | | |
| | | |
| + | ===StopTimerInterval=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 77: |
Line 87: |
| | width="90%" style="border-top: 2px solid #000;" | ''Return'' | | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
| |} | | |} |
− |
| |
− |
| |
− |
| |
− |
| |
− | ==Property reference==
| |
− |
| |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Interval Properties
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Time Unit
| |
− | |-
| |
− | | colspan="2" | Unit of time used for the time period. For example you might want every 4 milliseconds or every 3 hours.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| |
− | | width="90%" | Time Period
| |
− | |-
| |
− | | colspan="2" | Value of time used for the time period. For example you might want every 4 milliseconds or every 3 hours.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
| |
− | | width="90%" | Estimated Best Period
| |
− | |-
| |
− | | colspan="2" | The closest we can get to the required time period based on prescaler and postscaler settings. Smaller scalers provide finer resolution but impose limits on the maximum delay.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
| |
− | | width="90%" | Max Time Measurement
| |
− | |-
| |
− | | colspan="2" | The maximum time we can do based on the current timer and scaler settings.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-22-icon.png]]
| |
− | | width="90%" | Callback Macro
| |
− | |-
| |
− | | colspan="2" | User defined macro automatically called on a periodic basis.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Timer Properties
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Timer
| |
− | |-
| |
− | | colspan="2" | Timer Peripheral to use to monitor the passage of time.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| |
− | | width="90%" | Bit Depth
| |
− | |-
| |
− | | colspan="2" | 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.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Prescaler
| |
− | |-
| |
− | | colspan="2" | Scaler applied to the timer, Small scalers allow for finer resolution but will limit the max time and also put more load on the microcontroller. Recommended to use as large a setting as possible which still provides enough accuracy.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | PostScaler
| |
− | |-
| |
− | | colspan="2" | Scaler applied to the timer, Small scalers allow for finer resolution but will limit the max time and also put more load on the microcontroller. Recommended to use as large a setting as possible which still provides enough accuracy.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| |
− | | width="90%" | Timer Delay (ms)
| |
− | |-
| |
− | | colspan="2" | 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.
| |
− | |}==Macro reference==
| |
− |
| |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StartTimerInterval'''
| |
− | |-
| |
− | | colspan="2" | Starts the timer interval.
| |
− | |-
| |
− | |-
| |
− | | 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''
| |
− | |}
| |
− |
| |
− |
| |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StopTimerInterval'''
| |
− | |-
| |
− | | colspan="2" | Stops the timer interval.
| |
− | |-
| |
− | |-
| |
− | | 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''
| |
− | |}
| |
− |
| |
− |
| |
− |
| |
− |
| |
− | ==Property reference==
| |
− |
| |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Interval Properties
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Time Unit
| |
− | |-
| |
− | | colspan="2" | Unit of time used for the time period. For example you might want every 4 milliseconds or every 3 hours.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| |
− | | width="90%" | Time Period
| |
− | |-
| |
− | | colspan="2" | Value of time used for the time period. For example you might want every 4 milliseconds or every 3 hours.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
| |
− | | width="90%" | Estimated Best Period
| |
− | |-
| |
− | | colspan="2" | The closest we can get to the required time period based on prescaler and postscaler settings. Smaller scalers provide finer resolution but impose limits on the maximum delay.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
| |
− | | width="90%" | Max Time Measurement
| |
− | |-
| |
− | | colspan="2" | The maximum time we can do based on the current timer and scaler settings.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-22-icon.png]]
| |
− | | width="90%" | Callback Macro
| |
− | |-
| |
− | | colspan="2" | User defined macro automatically called on a periodic basis.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Timer Properties
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Timer
| |
− | |-
| |
− | | colspan="2" | Timer Peripheral to use to monitor the passage of time.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| |
− | | width="90%" | Bit Depth
| |
− | |-
| |
− | | colspan="2" | 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.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Prescaler
| |
− | |-
| |
− | | colspan="2" | Scaler applied to the timer, Small scalers allow for finer resolution but will limit the max time and also put more load on the microcontroller. Recommended to use as large a setting as possible which still provides enough accuracy.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | PostScaler
| |
− | |-
| |
− | | colspan="2" | Scaler applied to the timer, Small scalers allow for finer resolution but will limit the max time and also put more load on the microcontroller. Recommended to use as large a setting as possible which still provides enough accuracy.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| |
− | | width="90%" | Timer Delay (ms)
| |
− | |-
| |
− | | colspan="2" | 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.
| |
− | |}==Macro reference==
| |
− |
| |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StartTimerInterval'''
| |
− | |-
| |
− | | colspan="2" | Starts the timer interval.
| |
− | |-
| |
− | |-
| |
− | | 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''
| |
− | |}
| |
− |
| |
− |
| |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StopTimerInterval'''
| |
− | |-
| |
− | | colspan="2" | Stops the timer interval.
| |
− | |-
| |
− | |-
| |
− | | 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''
| |
− | |}
| |
− |
| |
− |
| |
| | | |
| | | |
Author
|
Matrix TSL
|
Version
|
1.1
|
Category
|
Timing
|
Timed Interval component
Allows you to setup a specific timed interval via the use of a hardware timer peripheral. Useful for regular time accurate periodic polling and sampling.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_TimerIntervalComponent.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_TimerIntervalComponent.fcfx
Detailed description
The Timed Interval component takes the headache out of setting up timer interrupts to interrupt an amount of fixed microseconds, milliseconds, seconds, minutes, hours or days.
After selecting the Time Unit, and entering Time Period, the estimated best will show the exact time the callback macro is accessed.
You can even send the required delay within simulation (Timer Delay (ms).
Unfortunately there is a small simulation only bug that is preventing the global variable within callback macro from updating, it all works on your embedded hardware.
The workaround (included within the example) for your own project is as follows.
First set up your timed interval component within properties along with the callback macro
Within the timed interval example, select the TimedInterval callback macro ,then select the Built-in Function::Debug.PrintLn(" ")
Right-click then select copy.
Paste the Built-in Function within the callback macro of your new project.
Now the interval timer component will simulate correctly.
Examples
Example program showing how to use the Timed component to trigger a callback macro at precise intervals e.g. 1 second.
One second timed interval component example
Macro reference
StartTimerInterval
|
StartTimerInterval
|
Starts the timer interval.
|
- VOID
|
Return
|
StopTimerInterval
|
StopTimerInterval
|
Stops the timer interval.
|
- VOID
|
Return
|
Property reference
|
Properties
|
|
Interval Properties
|
|
Time Unit
|
Unit of time used for the time period. For example you might want every 4 milliseconds or every 3 hours.
|
|
Time Period
|
Value of time used for the time period. For example you might want every 4 milliseconds or every 3 hours.
|
|
Estimated Best Period
|
The closest we can get to the required time period based on prescaler and postscaler settings. Smaller scalers provide finer resolution but impose limits on the maximum delay.
|
|
Max Time Measurement
|
The maximum time we can do based on the current timer and scaler settings.
|
|
Callback Macro
|
User defined macro automatically called on a periodic basis.
|
|
Timer Properties
|
|
Timer
|
Timer Peripheral to use to monitor the passage of time.
|
|
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.
|
|
Prescaler
|
Scaler applied to the timer, Small scalers allow for finer resolution but will limit the max time and also put more load on the microcontroller. Recommended to use as large a setting as possible which still provides enough accuracy.
|
|
PostScaler
|
Scaler applied to the timer, Small scalers allow for finer resolution but will limit the max time and also put more load on the microcontroller. Recommended to use as large a setting as possible which still provides enough accuracy.
|
|
Simulation
|
|
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.
|