pub struct VoltageCurrentBricklet { /* private fields */ }
Expand description

Measures power, DC voltage and DC current up to 720W/36V/20A

Implementations

Creates an object with the unique device ID uid. This object can then be used after the IP Connection ip_connection is connected.

Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.

For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled by set_response_expected. For setter functions it is disabled by default and can be enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is send and errors are silently ignored, because they cannot be detected.

See set_response_expected for the list of function ID constants available for this function.

Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is send and errors are silently ignored, because they cannot be detected.

Changes the response expected flag for all setter and callback configuration functions of this device at once.

This receiver is triggered periodically with the period that is set by set_current_callback_period. The parameter is the current of the sensor.

The get_current_callback_receiver receiver is only triggered if the current has changed since the last triggering.

This receiver is triggered periodically with the period that is set by set_voltage_callback_period. The parameter is the voltage of the sensor.

The get_voltage_callback_receiver receiver is only triggered if the voltage has changed since the last triggering.

This receiver is triggered periodically with the period that is set by set_power_callback_period. The parameter is the power of the sensor.

The get_power_callback_receiver receiver is only triggered if the power has changed since the last triggering.

This receiver is triggered when the threshold as set by set_current_callback_threshold is reached. The parameter is the current of the sensor.

If the threshold keeps being reached, the receiver is triggered periodically with the period as set by set_debounce_period.

This receiver is triggered when the threshold as set by set_voltage_callback_threshold is reached. The parameter is the voltage of the sensor.

If the threshold keeps being reached, the receiver is triggered periodically with the period as set by set_debounce_period.

This receiver is triggered when the threshold as set by set_power_callback_threshold is reached. The parameter is the power of the sensor.

If the threshold keeps being reached, the receiver is triggered periodically with the period as set by set_debounce_period.

Returns the current. The value is in mA and between -20000mA and 20000mA.

If you want to get the current periodically, it is recommended to use the get_current_callback_receiver receiver and set the period with set_current_callback_period.

Returns the voltage. The value is in mV and between 0mV and 36000mV.

If you want to get the voltage periodically, it is recommended to use the get_voltage_callback_receiver receiver and set the period with set_voltage_callback_period.

Returns the power. The value is in mW and between 0mV and 720000mW.

If you want to get the power periodically, it is recommended to use the get_power_callback_receiver receiver and set the period with set_power_callback_period.

Sets the configuration of the Voltage/Current Bricklet. It is possible to configure number of averages as well as voltage and current conversion time.

Averaging:

ValueNumber of Averages
01
14
216
364
4128
5256
6512
>=71024

Voltage/Current conversion:

ValueConversion time
0140µs
1204µs
2332µs
3588µs
41.1ms
52.116ms
64.156ms
>=78.244ms

The default values are 3, 4 and 4 (64, 1.1ms, 1.1ms) for averaging, voltage conversion and current conversion.

Associated constants:

  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_1
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_4
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_16
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_64
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_128
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_256
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_512
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_1024

Returns the configuration as set by set_configuration.

Associated constants:

  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_1
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_4
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_16
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_64
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_128
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_256
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_512
  • VOLTAGE_CURRENT_BRICKLET_AVERAGING_1024

Since the shunt resistor that is used to measure the current is not perfectly precise, it needs to be calibrated by a multiplier and divisor if a very precise reading is needed.

For example, if you are expecting a measurement of 1000mA and you are measuring 1023mA, you can calibrate the Voltage/Current Bricklet by setting the multiplier to 1000 and the divisor to 1023.

Returns the calibration as set by set_calibration.

Sets the period in ms with which the get_current_callback_receiver receiver is triggered periodically. A value of 0 turns the receiver off.

The get_current_callback_receiver receiver is only triggered if the current has changed since the last triggering.

The default value is 0.

Returns the period as set by set_current_callback_period.

Sets the period in ms with which the get_voltage_callback_receiver receiver is triggered periodically. A value of 0 turns the receiver off.

The get_voltage_callback_receiver receiver is only triggered if the voltage has changed since the last triggering.

The default value is 0.

Returns the period as set by set_voltage_callback_period.

Sets the period in ms with which the get_power_callback_receiver receiver is triggered periodically. A value of 0 turns the receiver off.

The get_power_callback_receiver receiver is only triggered if the power has changed since the last triggering.

The default value is 0.

Returns the period as set by get_power_callback_period.

Sets the thresholds for the get_current_reached_callback_receiver receiver.

The following options are possible:

OptionDescription
‘x’Receiver is turned off
‘o’Receiver is triggered when the current is outside the min and max values
‘i’Receiver is triggered when the current is inside the min and max values
‘<’Receiver is triggered when the current is smaller than the min value (max is ignored)
‘>’Receiver is triggered when the current is greater than the min value (max is ignored)

The default value is (‘x’, 0, 0).

Associated constants:

  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OFF
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OUTSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_INSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_SMALLER
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_GREATER

Returns the threshold as set by set_current_callback_threshold.

Associated constants:

  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OFF
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OUTSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_INSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_SMALLER
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_GREATER

Sets the thresholds for the get_voltage_reached_callback_receiver receiver.

The following options are possible:

OptionDescription
‘x’Receiver is turned off
‘o’Receiver is triggered when the voltage is outside the min and max values
‘i’Receiver is triggered when the voltage is inside the min and max values
‘<’Receiver is triggered when the voltage is smaller than the min value (max is ignored)
‘>’Receiver is triggered when the voltage is greater than the min value (max is ignored)

The default value is (‘x’, 0, 0).

Associated constants:

  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OFF
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OUTSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_INSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_SMALLER
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_GREATER

Returns the threshold as set by set_voltage_callback_threshold.

Associated constants:

  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OFF
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OUTSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_INSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_SMALLER
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_GREATER

Sets the thresholds for the get_power_reached_callback_receiver receiver.

The following options are possible:

OptionDescription
‘x’Receiver is turned off
‘o’Receiver is triggered when the power is outside the min and max values
‘i’Receiver is triggered when the power is inside the min and max values
‘<’Receiver is triggered when the power is smaller than the min value (max is ignored)
‘>’Receiver is triggered when the power is greater than the min value (max is ignored)

The default value is (‘x’, 0, 0).

Associated constants:

  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OFF
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OUTSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_INSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_SMALLER
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_GREATER

Returns the threshold as set by set_power_callback_threshold.

Associated constants:

  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OFF
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_OUTSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_INSIDE
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_SMALLER
  • VOLTAGE_CURRENT_BRICKLET_THRESHOLD_OPTION_GREATER

Sets the period in ms with which the threshold receivers

are triggered, if the thresholds

keep being reached.

The default value is 100.

Returns the debounce period as set by set_debounce_period.

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be ‘a’, ‘b’, ‘c’ or ‘d’.

The device identifier numbers can be found here. |device_identifier_constant|

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.