Class: Tinkerforge::BrickletIndustrialAnalogOut
- Defined in:
- lib/tinkerforge/bricklet_industrial_analog_out.rb
Overview
Generates configurable DC voltage and current, 0V to 10V and 4mA to 20mA
Constant Summary collapse
- DEVICE_IDENTIFIER =
:nodoc:
258
- DEVICE_DISPLAY_NAME =
:nodoc:
'Industrial Analog Out Bricklet'
- FUNCTION_ENABLE =
:nodoc:
1
- FUNCTION_DISABLE =
:nodoc:
2
- FUNCTION_IS_ENABLED =
:nodoc:
3
- FUNCTION_SET_VOLTAGE =
:nodoc:
4
- FUNCTION_GET_VOLTAGE =
:nodoc:
5
- FUNCTION_SET_CURRENT =
:nodoc:
6
- FUNCTION_GET_CURRENT =
:nodoc:
7
- FUNCTION_SET_CONFIGURATION =
:nodoc:
8
- FUNCTION_GET_CONFIGURATION =
:nodoc:
9
- FUNCTION_GET_IDENTITY =
:nodoc:
255
- VOLTAGE_RANGE_0_TO_5V =
:nodoc:
0
- VOLTAGE_RANGE_0_TO_10V =
:nodoc:
1
- CURRENT_RANGE_4_TO_20MA =
:nodoc:
0
- CURRENT_RANGE_0_TO_20MA =
:nodoc:
1
- CURRENT_RANGE_0_TO_24MA =
:nodoc:
2
Constants inherited from Device
Device::DEVICE_IDENTIFIER_CHECK_MATCH, Device::DEVICE_IDENTIFIER_CHECK_MISMATCH, Device::DEVICE_IDENTIFIER_CHECK_PENDING, Device::RESPONSE_EXPECTED_ALWAYS_TRUE, Device::RESPONSE_EXPECTED_FALSE, Device::RESPONSE_EXPECTED_INVALID_FUNCTION_ID, Device::RESPONSE_EXPECTED_TRUE
Instance Attribute Summary
Attributes inherited from Device
#callback_formats, #expected_response_function_id, #expected_response_sequence_number, #high_level_callbacks, #registered_callbacks, #replaced, #uid
Instance Method Summary collapse
-
#disable ⇒ Object
Disables the output of voltage and current.
-
#enable ⇒ Object
Enables the output of voltage and current.
-
#get_configuration ⇒ Object
Returns the configuration as set by BrickletIndustrialAnalogOut#set_configuration.
-
#get_current ⇒ Object
Returns the current as set by BrickletIndustrialAnalogOut#set_current.
-
#get_identity ⇒ Object
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
-
#get_voltage ⇒ Object
Returns the voltage as set by BrickletIndustrialAnalogOut#set_voltage.
-
#initialize(uid, ipcon) ⇒ BrickletIndustrialAnalogOut
constructor
Creates an object with the unique device ID
uid
and adds it to the IP Connectionipcon
. -
#is_enabled ⇒ Object
Returns true if output of voltage and current is enabled, false otherwise.
-
#set_configuration(voltage_range, current_range) ⇒ Object
Configures the voltage and current range.
-
#set_current(current) ⇒ Object
Sets the output current.
-
#set_voltage(voltage) ⇒ Object
Sets the output voltage.
Methods inherited from Device
#check_validity, #dequeue_response, #enqueue_response, #get_api_version, #get_response_expected, #send_request, #set_response_expected, #set_response_expected_all
Constructor Details
#initialize(uid, ipcon) ⇒ BrickletIndustrialAnalogOut
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/tinkerforge/bricklet_industrial_analog_out.rb', line 39 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 |
Instance Method Details
#disable ⇒ Object
Disables the output of voltage and current.
The default is disabled.
71 72 73 74 75 |
# File 'lib/tinkerforge/bricklet_industrial_analog_out.rb', line 71 def disable check_validity send_request FUNCTION_DISABLE, [], '', 8, '' end |
#enable ⇒ Object
Enables the output of voltage and current.
The default is disabled.
62 63 64 65 66 |
# File 'lib/tinkerforge/bricklet_industrial_analog_out.rb', line 62 def enable check_validity send_request FUNCTION_ENABLE, [], '', 8, '' end |
#get_configuration ⇒ Object
Returns the configuration as set by BrickletIndustrialAnalogOut#set_configuration.
140 141 142 143 144 |
# File 'lib/tinkerforge/bricklet_industrial_analog_out.rb', line 140 def get_configuration check_validity send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C' end |
#get_current ⇒ Object
Returns the current as set by BrickletIndustrialAnalogOut#set_current.
112 113 114 115 116 |
# File 'lib/tinkerforge/bricklet_industrial_analog_out.rb', line 112 def get_current check_validity send_request FUNCTION_GET_CURRENT, [], '', 10, 'S' end |
#get_identity ⇒ Object
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|
156 157 158 |
# File 'lib/tinkerforge/bricklet_industrial_analog_out.rb', line 156 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end |
#get_voltage ⇒ Object
Returns the voltage as set by BrickletIndustrialAnalogOut#set_voltage.
95 96 97 98 99 |
# File 'lib/tinkerforge/bricklet_industrial_analog_out.rb', line 95 def get_voltage check_validity send_request FUNCTION_GET_VOLTAGE, [], '', 10, 'S' end |
#is_enabled ⇒ Object
Returns true if output of voltage and current is enabled, false otherwise.
78 79 80 81 82 |
# File 'lib/tinkerforge/bricklet_industrial_analog_out.rb', line 78 def is_enabled check_validity send_request FUNCTION_IS_ENABLED, [], '', 9, '?' end |
#set_configuration(voltage_range, current_range) ⇒ Object
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.
133 134 135 136 137 |
# File 'lib/tinkerforge/bricklet_industrial_analog_out.rb', line 133 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) ⇒ Object
Sets the output current.
The output current and output voltage are linked. Changing the output current also changes the output voltage.
105 106 107 108 109 |
# File 'lib/tinkerforge/bricklet_industrial_analog_out.rb', line 105 def set_current(current) check_validity send_request FUNCTION_SET_CURRENT, [current], 'S', 8, '' end |
#set_voltage(voltage) ⇒ Object
Sets the output voltage.
The output voltage and output current are linked. Changing the output voltage also changes the output current.
88 89 90 91 92 |
# File 'lib/tinkerforge/bricklet_industrial_analog_out.rb', line 88 def set_voltage(voltage) check_validity send_request FUNCTION_SET_VOLTAGE, [voltage], 'S', 8, '' end |