Pulse Port Description

A Pulse port is a Digital port that generates a digital pulse with a defined period (measured in milliseconds) and a duty cycle in percent. The pulse is active if the line of this port is High. If Digital enable ports are specified the pulse is also being generated if at least one of the enable ports is High.

The output can be normal or inverted. There are two lists of output digital ports which receive the normal or inverted output respectively.

The actual duration of the pulses depends on the time resolution of the doWork loop. This in turn depends on the TargetFPS setting of the General configuration section. Please see Time in openhatd for more information.

Applications

The Pulse port can be used if you need blinking lights or LEDs, for example for indicators. Please note that a Pulse port is too slow to do PWM, so it should not be used for dimming lights.

A Pulse port can also be used to control internal automation. If itself is included in its output port list it will be automatically deactivated when the pulse becomes low again. This behaviour can be used to trigger other actions, for example reset other ports, after some delay. See the example below for a practical instance of this configuration.

Settings

Type

Fixed value Pulse.

Period

Required. A positive integer value that specifies the pulse duration in milliseconds.

You can specify a ValueResolver whose value is resolved at every iteration of the doWork loop. If the ValueResolver returns an error or a value less than 1 the pulse is set to the disabled state, if specified.

DutyCycle

Required. An integer value between 0 and 100 that specifies the pulse duty cycle in percent.

You can specify a ValueResolver whose value is resolved at every iteration of the doWork loop. If the ValueResolver returns an error, a value less than 0 or a value greater than 100 the pulse is set to the disabled state, if specified.

Negate

If this optional flag is True the logical meaning of the pulse output is inverted. Default is False.

EnablePorts

An optional port list specification for Digital ports. The pulse is generated if at least one of the enable ports is High.

OutputPorts

An optional port list specification for Digital ports. The output of the pulse is applied to these ports directly.

InverseOutputPorts

An optional port list specification for Digital ports. The output of the pulse is inverted and applied to these ports.

DisabledState

Optional value of either Low or High. If this value is set it determines the logical output state of the pulse when it is disabled (i. e. set to Low). The output value is applied directly to the output ports and inverted for the inverted output ports.

Example

[General]
SlaveName = Pulse Port Example

[Connection]
Transport = TCP

[Root]
Pulse1 = 1
Enabler = 2
Output1 = 3
Output2 = 4
Pulse2 = 5
PeriodDial = 6
DutyCycleDial = 7
Output3 = 8
Pulse3 = 9
Output4 = 10
WebServer = 9999

; A pulse with 2 seconds duration and a duty cycle of 50%.
; Enable this pulse or the Enabler port and observe how Output1
; and Output2 change.
[Pulse1]
Type = Pulse
Period = 2000
DutyCycle = 50
EnablePorts = Enabler
OutputPorts = Output1
InverseOutputPorts = Output2
DisabledState = Low

; This port enables Pulse1.
[Enabler]
Type = DigitalPort
Mode = Output

[Output1]
Type = DigitalPort

[Output2]
Type = DigitalPort

; A pulse whose period and duty cycle are set via Value Resolvers.
[Pulse2]
Type = Pulse
Period = PeriodDial
DutyCycle = DutyCycleDial
OutputPorts = Output3
Line = High

[PeriodDial]
Type = DialPort
Minimum = 2000
Maximum = 5000

[DutyCycleDial]
Type = DialPort
Position = 50

[Output3]
Type = DigitalPort
; The refreshes of the Web GUI may not be fast enough.
; Observe how the Line of this port changes from the log messages.
LogVerbosity = Debug

; This pulse is configured to automatically reset Output4
; after one second when it has become High.
[Pulse3]
Type = Pulse
Period = 2000
DutyCycle = 50
EnablePorts = Output4
; Note that the Pulse port refers to itself in its output list.
OutputPorts = Output4 Pulse3

[Output4]
Type = DigitalPort
Mode = Output

; This node starts a web server at http://localhost:8080
[WebServer]
Type = Plugin
Driver = ../plugins/WebServerPlugin/WebServerPlugin
Readonly = True