Skip to main content

Device Registers


Registers​

The Harp protocol relies on registers with specific functionalities and data types, and are essentially used to exchange information with the device.

The Harp Current Driver registers are declared in the device's device.yml file.

These register names are used by the software and will be described here according with their functionality, for quick reference and easier understanding.

Some registers support multiple states, by using bit masks, where each bit represents a specific state. In contrast, group masks are typically used for configuration, allowing only one state to be active at a time.

bit mask

A bit mask is a binary pattern used to manipulate specific bits within a value. It helps selectively enable, disable, or extract particular bits in the registers.


LED current​

The current of each LED output is configured, in mA, through the Led0Current and Led1Current registers. The accepted range is 0 to 500 mA. In the Manual channel mode, the new value is applied immediately.

The Led0MaxCurrent and Led1MaxCurrent registers specify the maximum current, in mA, allowed for the corresponding LED output, and can be used to protect LEDs rated for currents below 500 mA. The default value is 100 mA.

maximum current

Always check the maximum continuous and pulsed current of the connected LED in its datasheet before configuring the current of the output.


DAC voltage​

The voltage of each DAC output is configured, in mV, through the Dac0Voltage and Dac1Voltage registers. The accepted range is 0 to 5000 mV.

The DAC of each channel is shared between its DAC output and its LED output. For the LED output, the DacXVoltage value corresponds to a current of:

I_LED [mA] = DacXVoltage [mV] / 10

i.e. Dac0Voltage = 2500 mV corresponds to 250 mA in the LED0 output.


LED drivers​

Each LED driver can be enabled or disabled without changing its configured set point. Both drivers are disabled after power-up.

For each one of the registers LedEnable, LedDisable and LedState, you can set the correspondent bit mask for the LED output(s) you need to configure:

NameHex maskBinary mask
Led00x010b00000001
Led10x020b00000010
  • LedEnable: enables the LED drivers whose bits are set in the written mask.
  • LedDisable: disables the LED drivers whose bits are set in the written mask.
  • LedState: writes the state of both LED drivers at once (bit set enables the driver, bit cleared disables it).

Pulses​

The pulse function makes a channel alternate between its configured value and zero. It is enabled through the PulseEnable register, using the same bit mask as the LED drivers:

NameHex maskBinary mask
Led00x010b00000001
Led10x020b00000010

The pulse train of each channel is configured through:

  • PulseFrequencyLed0 / PulseFrequencyLed1: frequency of the pulse train, in Hz (1 to 255).
  • PulseDutyCycleLed0 / PulseDutyCycleLed1: percentage of each period in which the output is on (1 to 100).

Pulses are generated by the device with a time resolution of 1 ms, so the on and off times are rounded to the millisecond. At high frequencies, choose duty cycles that result in integer on times (e.g. at 100 Hz, the period is 10 ms and each 10 % of duty cycle corresponds to 1 ms).

configuration order

Configure the frequency before the duty cycle, as the pulse timings are computed from both values.


Ramps​

Ramps make the transitions between two different values of a channel linear over time, instead of immediate. The duration of the ramp of each channel is configured, in ms, through the RampLed0 and RampLed1 registers (1 to 65535 ms).

The RampConfig register selects on which transitions the ramps are applied, using the following bit mask:

NameHex maskBinary maskDescription
Led0Rise0x010b00000001Ramp on rising transitions of LED0
Led0Fall0x020b00000010Ramp on falling transitions of LED0
Led1Rise0x040b00000100Ramp on rising transitions of LED1
Led1Fall0x080b00001000Ramp on falling transitions of LED1
ramps and pulses

Ramps are only applied while the pulse function of the corresponding channel is disabled.


Channel modes​

Each channel can operate in one of four modes, configured through the Channel0Mode and Channel1Mode registers using the following group mask:

NameValueDescription
Manual0The output changes as soon as a new current/voltage value is written (default).
Protocol1The protocol is configured beforehand and triggered in software.
StartProtocolTrigger2The protocol settings must be defined beforehand and triggered in hardware when the respective DI state changes from LOW to HIGH.
StartAndStopProtocolTrigger3The protocol starts when the respective DI state changes from LOW to HIGH and ends when it changes from HIGH to LOW.

Channel 0 is triggered by DI0 and channel 1 by DI1.

changing mode

Changing the mode of a channel resets it and sets its output to zero. When switching back to Manual, the configured current/voltage is applied again.

Protocols​

In the protocol modes, the current/voltage, pulse and ramp configuration of the channel is stored and only applied to the output when the protocol starts. A protocol is defined by:

  • Protocol0Delay / Protocol1Delay: time between the start of the protocol and the moment the output goes to the configured value (0 to 65535). A value of 0 applies it immediately.
  • Protocol0Duration / Protocol1Duration: time the output is held at the configured value before returning to zero (0 to 65535). A value of 0 keeps the output on until the protocol is stopped. The duration is ignored in the StartAndStopProtocolTrigger mode, where the protocol only ends on the falling edge of the DI.

When a protocol ends, the output returns to zero, using the falling ramp if it is enabled in RampConfig. Starting a protocol that is already running restarts it, including its delay.

In the Protocol mode, the protocols are started and stopped through the EnableProtocol and DisableProtocol registers, using the following bit mask:

NameHex maskBinary mask
Led00x010b00000001
Led10x020b00000010
  • EnableProtocol: starts the protocol of the channels whose bits are set in the written mask.
  • DisableProtocol: stops the protocol of the channels whose bits are set in the written mask.
software triggers

EnableProtocol and DisableProtocol only act on channels configured in the Protocol mode.

Channel state​

The ChannelState event reports whether each channel output is at a non-zero value (bit set, HIGH) or at zero (bit cleared, LOW). An event is sent every time a channel reaches one of these states, i.e. on each pulse edge, at the end of each ramp, or when a new value is applied immediately. The register uses the same bit mask as the LED drivers.

events

If no events are received from the ChannelState register, ensure that the correspondent bit of the EnableEvents register bit mask is set, specifically ChannelState(0x2).


Digital IOs​

Two digital inputs and two digital outputs are available in the device.

Digital inputs​

The state of the digital inputs is reported by the DigitalInputState event, which is emitted every time a transition is detected on an input line. The digital inputs are also used as hardware triggers for the protocols. The register uses the following bit mask:

NameHex maskBinary mask
DI00x010b00000001
DI10x020b00000010
events

If no events are received from the DigitalInputState register, ensure that the correspondent bit of the EnableEvents register bit mask is set, specifically DIs(0x1).

Digital outputs​

The digital outputs can be controlled through the registers OutputSet, OutputClear, OutputToggle and OutputState.

For each one of these registers, you can set the correspondent bit mask for the digital output(s) you need to configure:

NameHex maskBinary mask
DO00x010b00000001
DO10x020b00000010
  • OutputSet: sets the output lines whose bits are set in the written mask.
  • OutputClear: clears the output lines whose bits are set in the written mask.
  • OutputToggle: toggles the output lines whose bits are set in the written mask.
  • OutputState: writes the state of all output lines at once.
state registers

State registers enable setting and clearing multiple states simultaneously, which is especially useful for precise timing, e.g. when the user needs to switch multiple outputs with different states at the same time.


Events​

The events published by the device are configured through the EnableEvents register, using the bit mask below. Only the events whose bit is set are sent by the device. Both events are enabled by default.

NameHex maskBinary maskEvent
DIs0x010b00000001DigitalInputState
ChannelState0x020b00000010ChannelState

Register summary​

AddressRegisterAccessTypeDescription
32DigitalInputStateEventU8State of the digital inputs.
33OutputSetWriteU8Sets the specified digital output lines.
34OutputClearWriteU8Clears the specified digital output lines.
35OutputToggleWriteU8Toggles the specified digital output lines.
36OutputStateWriteU8Writes the state of all digital output lines.
37LedEnableWriteU8Enables the specified LED drivers.
38LedDisableWriteU8Disables the specified LED drivers.
39LedStateWriteU8Writes the state of both LED drivers.
40Led0CurrentWriteFloatCurrent of LED 0 output [0:500] mA.
41Led1CurrentWriteFloatCurrent of LED 1 output [0:500] mA.
42Led0MaxCurrentWriteFloatMaximum current allowed in LED 0 output [0:500] mA.
43Led1MaxCurrentWriteFloatMaximum current allowed in LED 1 output [0:500] mA.
44Dac0VoltageWriteFloatVoltage of DAC 0 output [0:5000] mV.
45Dac1VoltageWriteFloatVoltage of DAC 1 output [0:5000] mV.
46PulseEnableWriteU8Enables the pulse function for the specified channels.
47PulseDutyCycleLed0WriteU8Duty cycle of the channel 0 pulses [1:100] %.
48PulseDutyCycleLed1WriteU8Duty cycle of the channel 1 pulses [1:100] %.
49PulseFrequencyLed0WriteU8Frequency of the channel 0 pulses, in Hz.
50PulseFrequencyLed1WriteU8Frequency of the channel 1 pulses, in Hz.
51RampLed0WriteU16Duration of the channel 0 ramps, in ms.
52RampLed1WriteU16Duration of the channel 1 ramps, in ms.
53RampConfigWriteU8Specifies on which transitions the ramps are applied.
54Protocol0DurationWriteU16Duration of the channel 0 protocol.
55Protocol1DurationWriteU16Duration of the channel 1 protocol.
56Protocol0DelayWriteU16Delay of the channel 0 protocol.
57Protocol1DelayWriteU16Delay of the channel 1 protocol.
58EnableProtocolWriteU8Starts the protocol of the specified channels.
59DisableProtocolWriteU8Stops the protocol of the specified channels.
60Channel0ModeWriteU8Mode of operation of channel 0.
61Channel1ModeWriteU8Mode of operation of channel 1.
62ChannelStateEventU8Sent when a channel reaches its LOW or HIGH state.
63–67Reserved0–Reserved4ReadU8Reserved.
68EnableEventsWriteU8Specifies the active events in the device.