class Tinkerforge::BrickletIndustrialAnalogOut

Generates configurable DC voltage and current, 0V to 10V and 4mA to 20mA

Public Class Methods

new(uid, ipcon) click to toggle source

Creates an object with the unique device ID uid and adds it to the IP Connection ipcon.

Calls superclass method
# File lib/tinkerforge/bricklet_industrial_analog_out.rb, line 38
def initialize(uid, ipcon)
  super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME

  @api_version = [2, 0, 0]

  @response_expected[FUNCTION_ENABLE] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_DISABLE] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_IS_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_VOLTAGE] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_CURRENT] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE


  @ipcon.add_device self
end

Public Instance Methods

disable() click to toggle source

Disables the output of voltage and current.

The default is disabled.

# File lib/tinkerforge/bricklet_industrial_analog_out.rb, line 70
def disable
  check_validity

  send_request FUNCTION_DISABLE, [], '', 8, ''
end
enable() click to toggle source

Enables the output of voltage and current.

The default is disabled.

# File lib/tinkerforge/bricklet_industrial_analog_out.rb, line 61
def enable
  check_validity

  send_request FUNCTION_ENABLE, [], '', 8, ''
end
get_configuration() click to toggle source

Returns the configuration as set by BrickletIndustrialAnalogOut#set_configuration.

# File lib/tinkerforge/bricklet_industrial_analog_out.rb, line 139
def get_configuration
  check_validity

  send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
end
get_current() click to toggle source

Returns the current as set by BrickletIndustrialAnalogOut#set_current.

# File lib/tinkerforge/bricklet_industrial_analog_out.rb, line 111
def get_current
  check_validity

  send_request FUNCTION_GET_CURRENT, [], '', 10, 'S'
end
get_identity() click to toggle source

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', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'.

The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|

# File lib/tinkerforge/bricklet_industrial_analog_out.rb, line 155
def get_identity
  send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
end
get_voltage() click to toggle source

Returns the voltage as set by BrickletIndustrialAnalogOut#set_voltage.

# File lib/tinkerforge/bricklet_industrial_analog_out.rb, line 94
def get_voltage
  check_validity

  send_request FUNCTION_GET_VOLTAGE, [], '', 10, 'S'
end
is_enabled() click to toggle source

Returns true if output of voltage and current is enabled, false otherwise.

# File lib/tinkerforge/bricklet_industrial_analog_out.rb, line 77
def is_enabled
  check_validity

  send_request FUNCTION_IS_ENABLED, [], '', 9, '?'
end
set_configuration(voltage_range, current_range) click to toggle source

Configures the voltage and current range.

Possible voltage ranges are:

  • 0V to 5V

  • 0V to 10V

Possible current ranges are:

  • 4mA to 20mA

  • 0mA to 20mA

  • 0mA to 24mA

The resolution will always be 12 bit. This means, that the precision is higher with a smaller range.

# File lib/tinkerforge/bricklet_industrial_analog_out.rb, line 132
def set_configuration(voltage_range, current_range)
  check_validity

  send_request FUNCTION_SET_CONFIGURATION, [voltage_range, current_range], 'C C', 8, ''
end
set_current(current) click to toggle source

Sets the output current.

The output current and output voltage are linked. Changing the output current also changes the output voltage.

# File lib/tinkerforge/bricklet_industrial_analog_out.rb, line 104
def set_current(current)
  check_validity

  send_request FUNCTION_SET_CURRENT, [current], 'S', 8, ''
end
set_voltage(voltage) click to toggle source

Sets the output voltage.

The output voltage and output current are linked. Changing the output voltage also changes the output current.

# File lib/tinkerforge/bricklet_industrial_analog_out.rb, line 87
def set_voltage(voltage)
  check_validity

  send_request FUNCTION_SET_VOLTAGE, [voltage], 'S', 8, ''
end