Skip to content

Commit

Permalink
Pulse Generator is a IBinSignal
Browse files Browse the repository at this point in the history
  • Loading branch information
sjuergen committed Nov 13, 2023
1 parent 882defb commit 90b36da
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/PulseGenerator.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,60 @@ USING System.Timer;
USING Simatic.Ax.IO.Input;

NAMESPACE Simatic.Ax.Generators

{axcode:docs-v0:@simatic-ax/generators:PulseGenerator.md}
CLASS PulseGenerator
IMPLEMENTS IBinSignal
VAR PUBLIC
PulseTime : LTIME := T#1s; // Pulse duration
PauseTime : LTIME := T#1s; // Pause duration ( PulseTime + PauseTime = Period )
PulseTime : LTIME := T#1s; // Pulse duration
PauseTime : LTIME := T#1s; // Pause duration ( PulseTime + PauseTime = Period )
END_VAR

VAR PRIVATE
_timePulse : OnDelay;
_timePause : OnDelay;
_timerIsRunning : BOOL;
_internalTimerStatus : BOOL;
_signal : BinSignal;
END_VAR

/// Execute(): Cyclically called method

METHOD PUBLIC Execute

_timePulse();
_timePause();

// evaluate pulse signal
IF (_timePause.output OR NOT(_timerIsRunning)) THEN
IF (_timePause.output OR NOT (_timerIsRunning)) THEN
_timePulse(signal := TRUE, duration := PulseTime);
_timePause(signal := FALSE);
_timerIsRunning := TRUE;
_internalTimerStatus := TRUE;
END_IF;

// evaluate a pause signal
IF (_timePulse.output ) THEN
IF (_timePulse.output) THEN
_timePause(signal := TRUE, duration := PauseTime);
_timePulse(signal := FALSE);
_internalTimerStatus := FALSE;
END_IF;

END_IF;
_signal.ReadCyclic(signal := _internalTimerStatus);

END_METHOD

/// Returns the clock signal
METHOD PUBLIC Clock : BOOL
Clock := _signal.Q();
END_METHOD

/// Returns the rising edge of the clock signal
METHOD PUBLIC ClockRis : BOOL
ClockRis := _signal.QRis();
METHOD PUBLIC Q : BOOL
Q := _signal.Q();
END_METHOD
/// Returns the rising edge of the clock signal

METHOD PUBLIC QRis : BOOL
QRis := _signal.QRis();
END_METHOD
/// Returns the falling edge of the clock signal
METHOD PUBLIC ClockFal : BOOL
ClockFal := _signal.QFal();

METHOD PUBLIC QFal : BOOL
QFal := _signal.QFal();
END_METHOD

METHOD PUBLIC QBad : BOOL
QBad := FALSE;
END_METHOD
END_CLASS

END_NAMESPACE

0 comments on commit 90b36da

Please sign in to comment.