class Tinkerforge::BrickletAnalogOut
Generates configurable DC voltage between 0V and 5V
Public Class Methods
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
# File lib/tinkerforge/bricklet_analog_out.rb, line 32 def initialize(uid, ipcon) super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME @api_version = [2, 0, 0] @response_expected[FUNCTION_SET_VOLTAGE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_MODE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE @ipcon.add_device self end
Public Instance Methods
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.rb, line 94 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end
Returns the mode as set by BrickletAnalogOut#set_mode
.
# File lib/tinkerforge/bricklet_analog_out.rb, line 78 def get_mode check_validity send_request FUNCTION_GET_MODE, [], '', 9, 'C' end
Returns the voltage as set by BrickletAnalogOut#set_voltage
.
# File lib/tinkerforge/bricklet_analog_out.rb, line 56 def get_voltage check_validity send_request FUNCTION_GET_VOLTAGE, [], '', 10, 'S' end
Sets the mode of the analog value. Possible modes:
-
0: Normal Mode (Analog value as set by
BrickletAnalogOut#set_voltage
is applied) -
1: 1k Ohm resistor to ground
-
2: 100k Ohm resistor to ground
-
3: 500k Ohm resistor to ground
Setting the mode to 0 will result in an output voltage of 0 V. You can jump to a higher output voltage directly by calling BrickletAnalogOut#set_voltage
.
# File lib/tinkerforge/bricklet_analog_out.rb, line 71 def set_mode(mode) check_validity send_request FUNCTION_SET_MODE, [mode], 'C', 8, '' end
Sets the voltage. Calling this function will set the mode to 0 (see BrickletAnalogOut#set_mode
).
# File lib/tinkerforge/bricklet_analog_out.rb, line 49 def set_voltage(voltage) check_validity send_request FUNCTION_SET_VOLTAGE, [voltage], 'S', 8, '' end