class Tinkerforge::BrickletAnalogOutV2

Generates configurable DC voltage between 0V and 12V

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_analog_out_v2.rb, line 27
def initialize(uid, ipcon)
  super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME

  @api_version = [2, 0, 0]

  @response_expected[FUNCTION_SET_OUTPUT_VOLTAGE] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_OUTPUT_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_INPUT_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE


  @ipcon.add_device self
end

Public Instance Methods

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_analog_out_v2.rb, line 72
def get_identity
  send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
end
get_input_voltage() click to toggle source

Returns the input voltage.

# File lib/tinkerforge/bricklet_analog_out_v2.rb, line 56
def get_input_voltage
  check_validity

  send_request FUNCTION_GET_INPUT_VOLTAGE, [], '', 10, 'S'
end
get_output_voltage() click to toggle source

Returns the voltage as set by BrickletAnalogOutV2#set_output_voltage.

# File lib/tinkerforge/bricklet_analog_out_v2.rb, line 49
def get_output_voltage
  check_validity

  send_request FUNCTION_GET_OUTPUT_VOLTAGE, [], '', 10, 'S'
end
set_output_voltage(voltage) click to toggle source

Sets the voltage.

# File lib/tinkerforge/bricklet_analog_out_v2.rb, line 42
def set_output_voltage(voltage)
  check_validity

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