Class: Tinkerforge::BrickletPTC
- Defined in:
- lib/tinkerforge/bricklet_ptc.rb
Overview
Reads temperatures from Pt100 und Pt1000 sensors
Constant Summary collapse
- DEVICE_IDENTIFIER =
:nodoc:
226
- DEVICE_DISPLAY_NAME =
:nodoc:
'PTC Bricklet'
- CALLBACK_TEMPERATURE =
This callback is triggered periodically with the period that is set by BrickletPTC#set_temperature_callback_period. The parameter is the temperature of the connected sensor.
The CALLBACK_TEMPERATURE callback is only triggered if the temperature has changed since the last triggering.
13
- CALLBACK_TEMPERATURE_REACHED =
This callback is triggered when the threshold as set by BrickletPTC#set_temperature_callback_threshold is reached. The parameter is the temperature of the connected sensor.
If the threshold keeps being reached, the callback is triggered periodically with the period as set by BrickletPTC#set_debounce_period.
14
- CALLBACK_RESISTANCE =
This callback is triggered periodically with the period that is set by BrickletPTC#set_resistance_callback_period. The parameter is the resistance of the connected sensor.
The CALLBACK_RESISTANCE callback is only triggered if the resistance has changed since the last triggering.
15
- CALLBACK_RESISTANCE_REACHED =
This callback is triggered when the threshold as set by BrickletPTC#set_resistance_callback_threshold is reached. The parameter is the resistance of the connected sensor.
If the threshold keeps being reached, the callback is triggered periodically with the period as set by BrickletPTC#set_debounce_period.
16
- CALLBACK_SENSOR_CONNECTED =
This callback is triggered periodically according to the configuration set by BrickletPTC#set_sensor_connected_callback_configuration.
The parameter is the same as BrickletPTC#is_sensor_connected.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
24
- FUNCTION_GET_TEMPERATURE =
:nodoc:
1
- FUNCTION_GET_RESISTANCE =
:nodoc:
2
- FUNCTION_SET_TEMPERATURE_CALLBACK_PERIOD =
:nodoc:
3
- FUNCTION_GET_TEMPERATURE_CALLBACK_PERIOD =
:nodoc:
4
- FUNCTION_SET_RESISTANCE_CALLBACK_PERIOD =
:nodoc:
5
- FUNCTION_GET_RESISTANCE_CALLBACK_PERIOD =
:nodoc:
6
- FUNCTION_SET_TEMPERATURE_CALLBACK_THRESHOLD =
:nodoc:
7
- FUNCTION_GET_TEMPERATURE_CALLBACK_THRESHOLD =
:nodoc:
8
- FUNCTION_SET_RESISTANCE_CALLBACK_THRESHOLD =
:nodoc:
9
- FUNCTION_GET_RESISTANCE_CALLBACK_THRESHOLD =
:nodoc:
10
- FUNCTION_SET_DEBOUNCE_PERIOD =
:nodoc:
11
- FUNCTION_GET_DEBOUNCE_PERIOD =
:nodoc:
12
- FUNCTION_SET_NOISE_REJECTION_FILTER =
:nodoc:
17
- FUNCTION_GET_NOISE_REJECTION_FILTER =
:nodoc:
18
- FUNCTION_IS_SENSOR_CONNECTED =
:nodoc:
19
- FUNCTION_SET_WIRE_MODE =
:nodoc:
20
- FUNCTION_GET_WIRE_MODE =
:nodoc:
21
- FUNCTION_SET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION =
:nodoc:
22
- FUNCTION_GET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION =
:nodoc:
23
- FUNCTION_GET_IDENTITY =
:nodoc:
255
- THRESHOLD_OPTION_OFF =
:nodoc:
'x'
- THRESHOLD_OPTION_OUTSIDE =
:nodoc:
'o'
- THRESHOLD_OPTION_INSIDE =
:nodoc:
'i'
- THRESHOLD_OPTION_SMALLER =
:nodoc:
'<'
- THRESHOLD_OPTION_GREATER =
:nodoc:
'>'
- FILTER_OPTION_50HZ =
:nodoc:
0
- FILTER_OPTION_60HZ =
:nodoc:
1
- WIRE_MODE_2 =
:nodoc:
2
- WIRE_MODE_3 =
:nodoc:
3
- WIRE_MODE_4 =
:nodoc:
4
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
-
#get_debounce_period ⇒ Object
Returns the debounce period as set by BrickletPTC#set_debounce_period.
-
#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_noise_rejection_filter ⇒ Object
Returns the noise rejection filter option as set by BrickletPTC#set_noise_rejection_filter.
-
#get_resistance ⇒ Object
Returns the value as measured by the MAX31865 precision delta-sigma ADC.
-
#get_resistance_callback_period ⇒ Object
Returns the period as set by BrickletPTC#set_resistance_callback_period.
-
#get_resistance_callback_threshold ⇒ Object
Returns the threshold as set by BrickletPTC#set_resistance_callback_threshold.
-
#get_sensor_connected_callback_configuration ⇒ Object
Returns the configuration as set by BrickletPTC#set_sensor_connected_callback_configuration.
-
#get_temperature ⇒ Object
Returns the temperature of connected sensor.
-
#get_temperature_callback_period ⇒ Object
Returns the period as set by BrickletPTC#set_temperature_callback_period.
-
#get_temperature_callback_threshold ⇒ Object
Returns the threshold as set by BrickletPTC#set_temperature_callback_threshold.
-
#get_wire_mode ⇒ Object
Returns the wire mode as set by BrickletPTC#set_wire_mode.
-
#initialize(uid, ipcon) ⇒ BrickletPTC
constructor
Creates an object with the unique device ID
uid
and adds it to the IP Connectionipcon
. -
#is_sensor_connected ⇒ Object
Returns true if the sensor is connected correctly.
-
#register_callback(id, &block) ⇒ Object
Registers a callback with ID
id
to the blockblock
. -
#set_debounce_period(debounce) ⇒ Object
Sets the period with which the threshold callback.
-
#set_noise_rejection_filter(filter) ⇒ Object
Sets the noise rejection filter to either 50Hz (0) or 60Hz (1).
-
#set_resistance_callback_period(period) ⇒ Object
Sets the period with which the CALLBACK_RESISTANCE callback is triggered periodically.
-
#set_resistance_callback_threshold(option, min, max) ⇒ Object
Sets the thresholds for the CALLBACK_RESISTANCE_REACHED callback.
-
#set_sensor_connected_callback_configuration(enabled) ⇒ Object
If you enable this callback, the CALLBACK_SENSOR_CONNECTED callback is triggered every time a Pt sensor is connected/disconnected.
-
#set_temperature_callback_period(period) ⇒ Object
Sets the period with which the CALLBACK_TEMPERATURE callback is triggered periodically.
-
#set_temperature_callback_threshold(option, min, max) ⇒ Object
Sets the thresholds for the CALLBACK_TEMPERATURE_REACHED callback.
-
#set_wire_mode(mode) ⇒ Object
Sets the wire mode of the sensor.
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) ⇒ BrickletPTC
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
Instance Method Details
#get_debounce_period ⇒ Object
Returns the debounce period as set by BrickletPTC#set_debounce_period.
258 259 260 261 262 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 258 def get_debounce_period check_validity send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L' 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|
338 339 340 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 338 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end |
#get_noise_rejection_filter ⇒ Object
Returns the noise rejection filter option as set by BrickletPTC#set_noise_rejection_filter
276 277 278 279 280 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 276 def get_noise_rejection_filter check_validity send_request FUNCTION_GET_NOISE_REJECTION_FILTER, [], '', 9, 'C' end |
#get_resistance ⇒ Object
Returns the value as measured by the MAX31865 precision delta-sigma ADC.
The value can be converted with the following formulas:
-
Pt100: resistance = (value * 390) / 32768
-
Pt1000: resistance = (value * 3900) / 32768
If you want to get the resistance periodically, it is recommended to use the CALLBACK_RESISTANCE callback and set the period with BrickletPTC#set_resistance_callback_period.
150 151 152 153 154 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 150 def get_resistance check_validity send_request FUNCTION_GET_RESISTANCE, [], '', 12, 'l' end |
#get_resistance_callback_period ⇒ Object
Returns the period as set by BrickletPTC#set_resistance_callback_period.
186 187 188 189 190 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 186 def get_resistance_callback_period check_validity send_request FUNCTION_GET_RESISTANCE_CALLBACK_PERIOD, [], '', 12, 'L' end |
#get_resistance_callback_threshold ⇒ Object
Returns the threshold as set by BrickletPTC#set_resistance_callback_threshold.
234 235 236 237 238 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 234 def get_resistance_callback_threshold check_validity send_request FUNCTION_GET_RESISTANCE_CALLBACK_THRESHOLD, [], '', 17, 'k l l' end |
#get_sensor_connected_callback_configuration ⇒ Object
Returns the configuration as set by BrickletPTC#set_sensor_connected_callback_configuration.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
322 323 324 325 326 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 322 def get_sensor_connected_callback_configuration check_validity send_request FUNCTION_GET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION, [], '', 9, '?' end |
#get_temperature ⇒ Object
Returns the temperature of connected sensor.
If you want to get the temperature periodically, it is recommended to use the CALLBACK_TEMPERATURE callback and set the period with BrickletPTC#set_temperature_callback_period.
134 135 136 137 138 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 134 def get_temperature check_validity send_request FUNCTION_GET_TEMPERATURE, [], '', 12, 'l' end |
#get_temperature_callback_period ⇒ Object
Returns the period as set by BrickletPTC#set_temperature_callback_period.
168 169 170 171 172 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 168 def get_temperature_callback_period check_validity send_request FUNCTION_GET_TEMPERATURE_CALLBACK_PERIOD, [], '', 12, 'L' end |
#get_temperature_callback_threshold ⇒ Object
Returns the threshold as set by BrickletPTC#set_temperature_callback_threshold.
210 211 212 213 214 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 210 def get_temperature_callback_threshold check_validity send_request FUNCTION_GET_TEMPERATURE_CALLBACK_THRESHOLD, [], '', 17, 'k l l' end |
#get_wire_mode ⇒ Object
Returns the wire mode as set by BrickletPTC#set_wire_mode
303 304 305 306 307 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 303 def get_wire_mode check_validity send_request FUNCTION_GET_WIRE_MODE, [], '', 9, 'C' end |
#is_sensor_connected ⇒ Object
Returns true if the sensor is connected correctly.
If this function returns false, there is either no Pt100 or Pt1000 sensor connected, the sensor is connected incorrectly or the sensor itself is faulty.
287 288 289 290 291 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 287 def is_sensor_connected check_validity send_request FUNCTION_IS_SENSOR_CONNECTED, [], '', 9, '?' end |
#register_callback(id, &block) ⇒ Object
Registers a callback with ID id
to the block block
.
343 344 345 346 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 343 def register_callback(id, &block) callback = block @registered_callbacks[id] = callback end |
#set_debounce_period(debounce) ⇒ Object
Sets the period with which the threshold callback
-
CALLBACK_TEMPERATURE_REACHED,
-
CALLBACK_RESISTANCE_REACHED
is triggered, if the threshold
-
BrickletPTC#set_temperature_callback_threshold,
-
BrickletPTC#set_resistance_callback_threshold
keeps being reached.
251 252 253 254 255 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 251 def set_debounce_period(debounce) check_validity send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, '' end |
#set_noise_rejection_filter(filter) ⇒ Object
Sets the noise rejection filter to either 50Hz (0) or 60Hz (1). Noise from 50Hz or 60Hz power sources (including harmonics of the AC power’s fundamental frequency) is attenuated by 82dB.
268 269 270 271 272 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 268 def set_noise_rejection_filter(filter) check_validity send_request FUNCTION_SET_NOISE_REJECTION_FILTER, [filter], 'C', 8, '' end |
#set_resistance_callback_period(period) ⇒ Object
Sets the period with which the CALLBACK_RESISTANCE callback is triggered periodically. A value of 0 turns the callback off.
The CALLBACK_RESISTANCE callback is only triggered if the resistance has changed since the last triggering.
179 180 181 182 183 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 179 def set_resistance_callback_period(period) check_validity send_request FUNCTION_SET_RESISTANCE_CALLBACK_PERIOD, [period], 'L', 8, '' end |
#set_resistance_callback_threshold(option, min, max) ⇒ Object
Sets the thresholds for the CALLBACK_RESISTANCE_REACHED callback.
The following options are possible:
"Option", "Description"
"'x'", "Callback is turned off"
"'o'", "Callback is triggered when the temperature is *outside* the min and max values"
"'i'", "Callback is triggered when the temperature is *inside* the min and max values"
"'<'", "Callback is triggered when the temperature is smaller than the min value (max is ignored)"
"'>'", "Callback is triggered when the temperature is greater than the min value (max is ignored)"
227 228 229 230 231 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 227 def set_resistance_callback_threshold(option, min, max) check_validity send_request FUNCTION_SET_RESISTANCE_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 8, '' end |
#set_sensor_connected_callback_configuration(enabled) ⇒ Object
If you enable this callback, the CALLBACK_SENSOR_CONNECTED callback is triggered every time a Pt sensor is connected/disconnected.
- .. versionadded
-
2.0.2$nbsp;(Plugin)
313 314 315 316 317 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 313 def set_sensor_connected_callback_configuration(enabled) check_validity send_request FUNCTION_SET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION, [enabled], '?', 8, '' end |
#set_temperature_callback_period(period) ⇒ Object
Sets the period with which the CALLBACK_TEMPERATURE callback is triggered periodically. A value of 0 turns the callback off.
The CALLBACK_TEMPERATURE callback is only triggered if the temperature has changed since the last triggering.
161 162 163 164 165 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 161 def set_temperature_callback_period(period) check_validity send_request FUNCTION_SET_TEMPERATURE_CALLBACK_PERIOD, [period], 'L', 8, '' end |
#set_temperature_callback_threshold(option, min, max) ⇒ Object
Sets the thresholds for the CALLBACK_TEMPERATURE_REACHED callback.
The following options are possible:
"Option", "Description"
"'x'", "Callback is turned off"
"'o'", "Callback is triggered when the temperature is *outside* the min and max values"
"'i'", "Callback is triggered when the temperature is *inside* the min and max values"
"'<'", "Callback is triggered when the temperature is smaller than the min value (max is ignored)"
"'>'", "Callback is triggered when the temperature is greater than the min value (max is ignored)"
203 204 205 206 207 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 203 def set_temperature_callback_threshold(option, min, max) check_validity send_request FUNCTION_SET_TEMPERATURE_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 8, '' end |
#set_wire_mode(mode) ⇒ Object
Sets the wire mode of the sensor. Possible values are 2, 3 and 4 which correspond to 2-, 3- and 4-wire sensors. The value has to match the jumper configuration on the Bricklet.
296 297 298 299 300 |
# File 'lib/tinkerforge/bricklet_ptc.rb', line 296 def set_wire_mode(mode) check_validity send_request FUNCTION_SET_WIRE_MODE, [mode], 'C', 8, '' end |