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, and 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] / 5

i.e. Dac0Voltage = 2500 mV corresponds to the full scale of 500 mA in the LED0 output.

pulses and ramps

In the current firmware version, the pulse and ramp functions act on the value of the DacXVoltage registers. To generate pulses or ramps on an LED output, configure the corresponding DacXVoltage register (with values up to 2500 mV, according to the equation above) instead of the LedXCurrent register.


LED drivers​

Each LED driver can be enabled or disabled without changing its configured set point. Both drivers are enabled 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
LED0_UP0x010b00000001Ramp on rising transitions of LED0
LED0_DOWN0x020b00000010Ramp on falling transitions of LED0
LED1_UP0x040b00000100Ramp on rising transitions of LED1
LED1_DOWN0x080b00001000Ramp on falling transitions of LED1
ramps and pulses

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


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 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. The digital inputs event is enabled by default.

NameHex maskBinary mask
DIs0x010b00000001

Register summary​

AddressRegisterAccessTypeDescription
32DigitalInputStateEventU8State of the digital inputs.
33OutputSetWriteU16Sets the specified digital output lines.
34OutputClearWriteU16Clears the specified digital output lines.
35OutputToggleWriteU16Toggles the specified digital output lines.
36OutputStateWriteU16Writes the state of all digital output lines.
37Led0CurrentWriteFloatCurrent of LED 0 output [0:500] mA.
38Led1CurrentWriteFloatCurrent of LED 1 output [0:500] mA.
39Dac0VoltageWriteFloatVoltage of DAC 0 output [0:5000] mV.
40Dac1VoltageWriteFloatVoltage of DAC 1 output [0:5000] mV.
41LedEnableWriteU8Enables the specified LED drivers.
42LedDisableWriteU8Disables the specified LED drivers.
43LedStateWriteU8Writes the state of both LED drivers.
44Led0MaxCurrentWriteFloatMaximum current allowed in LED 0 output, in mA.
45Led1MaxCurrentWriteFloatMaximum current allowed in LED 1 output, in mA.
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.
54–57Reserved0–Reserved3ReadU8Reserved.
58EnableEventsWriteU8Specifies the active events in the device.