Skip to content

Commit

Permalink
added documentation for timers
Browse files Browse the repository at this point in the history
  • Loading branch information
Specter-13 committed Aug 7, 2023
1 parent 408abb4 commit 3d2f140
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 0 deletions.
53 changes: 53 additions & 0 deletions docfx/articles/timers/OFFDELAYTIMER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# AxOpen.Timers.OffDelayTimer

`OffDelayTimer` class contains `OffDelay` method, where logic of OffDelayTimer is implemented. `OffDelay` method has following input:

```C#
VAR_INPUT
Parent : IAxoObject; // or IAxoContext, parent provides RTC implementation
inSignal : BOOL; // starts timer with falling edge, resets timer with rising edge
TimeDelay : LTIME; // time to pass, before output is set
END_VAR
```

The OffDelay method returns `output`, which *is FALSE, `TimeDelay` seconds after falling edge of `inSignal` is detected*.

The `OffDelayTimer` have also public variables which can be used to access timer results:

```C#
VAR PUBLIC
output : BOOL; // is FALSE, TimeDelay seconds after falling edge of inSignal is detected
elapsedTime : LTIME; // elapsed time
END_VAR
```


The LOGIC of `OffDelayTimer` is following:


When `inSignal` is TRUE, `output` is TRUE and `elapsedTime` is 0. As soon as `inSignal` becomes FALSE, the time will begin to be counted in `elapsedTime` until its value is equal to that of `TimeDelay`. It will then remain constant. The `output` is FALSE when `inSignal` is FALSE and `elapsedTime` is equal to `TimeDelay`. Otherwise it is TRUE. Thus, `output` has a falling edge when the time indicated in `TimeDelay` has run out.


Example usage of `OffDelay` timer:

```
USING AXOpen.Timers;
VAR
_signal : BOOL; // input signal, which is set somewhere in application
_testTimerOffDelay: AXOpen.Timers.OffDelayTimer; // timer instance
_testTimeDelay: LTIME := LTIME#5s; // time delay
END_VAR
// call OffDelay method somewhere in application
// THIS must type of IAxoObject
_testTimerOffDelay.OffDelay(THIS, _signal, _testTimeDelay);
// check for output
IF(_testTimerOffDelay.output) THEN
// handle result
ENDIF;
```
51 changes: 51 additions & 0 deletions docfx/articles/timers/ONDELAYTIMER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# AxOpen.Timers.OnDelayTimer

`OnDelayTimer` class contains `OnDelay` method, where logic of OnDelayTimer is implemented. `OnDelay` method has following input:

```C#
VAR_INPUT
Parent : IAxoObject; // or IAxoContext, parent provides RTC implementation
inSignal : BOOL; // starts timer with rising edge, resets timer with falling edge
TimeDelay : LTIME; // time to pass, before output is set
END_VAR
```

The OnDelay method returns `output`, which *is TRUE, `TimeDelay` seconds after rising edge of `inSignal` is detected*.

The `OnDelayTimer` have also public variables which can be used to access timer results:

```C#
VAR PUBLIC
output : BOOL; // is TRUE, TimeDelay seconds after rising edge of inSignal is detected.
elapsedTime : LTIME; // elapsed time
END_VAR
```


The LOGIC of `OnDelayTimer` is following:

If `inSignal` is FALSE, `output` is FALSE and `elapsedTime` is 0. As soon as `input` becomes TRUE, the time will begin to be counted in `elapsedTime` until its value is equal to `TimeDelay`. It will then remain constant. The `output` is TRUE when `inSignal` is TRUE and `elapsedTime` is equal to `TimeDelay`. Otherwise it is FALSE. Thus, `output` has a rising edge when the time indicated in `TimeDelay` has run out.

Example usage of `OnDelay` timer:

```
USING AXOpen.Timers;
VAR
_signal : BOOL; // input signal
_testTimerOnDelay: AXOpen.Timers.OnDelayTimer; // timer instance
_testTimeDelay: LTIME := LTIME#5s; // time delay
END_VAR
// call OnDelay method somewhere in application
// THIS must type of IAxoObject
_testTimerOnDelay.OnDelay(THIS, _signal, _testTimeDelay);
// check for output
IF(_testTimerOnDelay.output) THEN
// handle result
ENDIF;
```
52 changes: 52 additions & 0 deletions docfx/articles/timers/PULSETIMER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# AxOpen.Timers.PulseTimer

`PulseTimer` class contains `Pulse` method, where logic of PulseTimer is implemented. `Pulse` method has following input:

```C#
VAR_INPUT
Parent : IAxoObject; // or IAxoContext, parent provides RTC implementation
inSignal : BOOL; // Trigger for start of the pulse signal
PulseLenght : LTIME; // the length of the pulse signal
END_VAR
```

The Pulse timer returns output, which *is TRUE only during time counting*. It creates pulses with a defined pulse duration.


The `PulseTimer` have also public variables which can be used to access timer results:

```C#
VAR PUBLIC
output : BOOL; // the pulse
elapsedTime : LTIME; // the current phase of the pulse
END_VAR
```


The LOGIC of `PulseTimer` is following:

If `inSignal` is FALSE, the `output` is FALSE and `elapsedTime` is 0. As soon as `inSignal` becomes TRUE, `output` also becomes TRUE and remains TRUE for the pulse duration `PulseLength`. As long as `output` is TRUE, the time is incremented in `elapsedTime`, until the value reaches PT. The value then remains constant. The `output` remains TRUE until the pulse duration has elapsed, irrespective of the state of the input `inSignal`. The `output` therefore supplies a signal over the interval specified in `PulseLength`.

Example usage of `Pulse` timer:

```
USING AXOpen.Timers;
VAR
_signal : BOOL; // input signal, which is set somewhere in application
_testTimerPulse: AXOpen.Timers.PulseTimer; // timer instance
_testPulseLength: LTIME := LTIME#5s; // pulse length
END_VAR
// call Pulse method somewhere in application
// THIS must type of IAxoObject
_testTimerPulse.Pulse(THIS, _signal, _testPulseLength);
// check for output
IF(_testTimerPulse.output) THEN
// handle result
ENDIF;
```
11 changes: 11 additions & 0 deletions docfx/articles/timers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# AXOpen.Timers

**AXOpen.Timers** provide implementations of basic timers used in PLC programming. Timers are implemented in separated classes within corresponding methods.
Functionality of Timers is based on *Real Time Clock* implementation provided from **AXContext**.


[!INCLUDE [OnDelayTimer](ONDELAYTIMER.md)]

[!INCLUDE [OffDelayTimer](OFFDELAYTIMER.md)]

[!INCLUDE [Pulse](PULSETIMER.md)]
10 changes: 10 additions & 0 deletions docfx/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
items:
- name: Installation
href: ~/articles/security/INSTALLATION.md

- name: AXOpen.Timers
href: ~/articles/timers/README.md
items:
- name: OnDelayTimer
href: ~/articles/timers/ONDELAYTIMER.md
- name: OffDelayTimer
href: ~/articles/timers/OFFDELAYTIMER.md
- name: Pulse
href: ~/articles/timers/PULSETIMER.md
- name: Template themes
href: ~/articles/themes/README.md
- name: Template localization
Expand Down

0 comments on commit 3d2f140

Please sign in to comment.