tinkerforge 2.1.24 → 2.1.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +156 -75
- data/lib/tinkerforge/brick_hat.rb +69 -31
- data/lib/tinkerforge/brick_hat_zero.rb +55 -23
- data/lib/tinkerforge/brick_imu.rb +185 -78
- data/lib/tinkerforge/brick_imu_v2.rb +209 -106
- data/lib/tinkerforge/brick_master.rb +491 -183
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +186 -102
- data/lib/tinkerforge/brick_silent_stepper.rb +247 -167
- data/lib/tinkerforge/brick_stepper.rb +211 -99
- data/lib/tinkerforge/bricklet_accelerometer.rb +57 -23
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +104 -54
- data/lib/tinkerforge/bricklet_air_quality.rb +116 -59
- data/lib/tinkerforge/bricklet_ambient_light.rb +50 -21
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +44 -24
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +65 -27
- data/lib/tinkerforge/bricklet_analog_in.rb +62 -25
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +56 -23
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +66 -25
- data/lib/tinkerforge/bricklet_analog_out.rb +22 -9
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +19 -8
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +53 -20
- data/lib/tinkerforge/bricklet_barometer.rb +100 -27
- data/lib/tinkerforge/bricklet_barometer_v2.rb +98 -37
- data/lib/tinkerforge/bricklet_can.rb +83 -19
- data/lib/tinkerforge/bricklet_can_v2.rb +171 -38
- data/lib/tinkerforge/bricklet_co2.rb +33 -14
- data/lib/tinkerforge/bricklet_co2_v2.rb +97 -38
- data/lib/tinkerforge/bricklet_color.rb +68 -27
- data/lib/tinkerforge/bricklet_color_v2.rb +86 -33
- data/lib/tinkerforge/bricklet_compass.rb +77 -30
- data/lib/tinkerforge/bricklet_current12.rb +57 -24
- data/lib/tinkerforge/bricklet_current25.rb +57 -24
- data/lib/tinkerforge/bricklet_dc_v2.rb +521 -0
- data/lib/tinkerforge/bricklet_distance_ir.rb +56 -23
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +82 -31
- data/lib/tinkerforge/bricklet_distance_us.rb +39 -16
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +66 -25
- data/lib/tinkerforge/bricklet_dmx.rb +87 -34
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -10
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +63 -24
- data/lib/tinkerforge/bricklet_dual_relay.rb +26 -11
- data/lib/tinkerforge/bricklet_dust_detector.rb +39 -16
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +87 -32
- data/lib/tinkerforge/bricklet_energy_monitor.rb +72 -27
- data/lib/tinkerforge/bricklet_gps.rb +63 -26
- data/lib/tinkerforge/bricklet_gps_v2.rb +116 -47
- data/lib/tinkerforge/bricklet_hall_effect.rb +42 -23
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +70 -27
- data/lib/tinkerforge/bricklet_humidity.rb +50 -21
- data/lib/tinkerforge/bricklet_humidity_v2.rb +82 -31
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +37 -14
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +80 -29
- data/lib/tinkerforge/bricklet_industrial_counter.rb +100 -39
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +44 -17
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +76 -29
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +35 -14
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +72 -27
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +39 -16
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -30
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +48 -19
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +137 -31
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +60 -23
- data/lib/tinkerforge/bricklet_industrial_ptc.rb +475 -0
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +35 -14
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +66 -25
- data/lib/tinkerforge/bricklet_io16.rb +54 -21
- data/lib/tinkerforge/bricklet_io16_v2.rb +89 -34
- data/lib/tinkerforge/bricklet_io4.rb +54 -23
- data/lib/tinkerforge/bricklet_io4_v2.rb +95 -36
- data/lib/tinkerforge/bricklet_isolator.rb +72 -29
- data/lib/tinkerforge/bricklet_joystick.rb +58 -25
- data/lib/tinkerforge/bricklet_joystick_v2.rb +67 -26
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +81 -32
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +95 -36
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +191 -70
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +44 -18
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +57 -23
- data/lib/tinkerforge/bricklet_led_strip.rb +59 -22
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +90 -46
- data/lib/tinkerforge/bricklet_line.rb +33 -14
- data/lib/tinkerforge/bricklet_linear_poti.rb +50 -21
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +54 -21
- data/lib/tinkerforge/bricklet_load_cell.rb +60 -23
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +79 -30
- data/lib/tinkerforge/bricklet_moisture.rb +39 -16
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +61 -27
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +70 -27
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -13
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +75 -28
- data/lib/tinkerforge/bricklet_nfc.rb +126 -62
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +28 -11
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +65 -24
- data/lib/tinkerforge/bricklet_oled_64x48.rb +28 -11
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -28
- data/lib/tinkerforge/bricklet_particulate_matter.rb +74 -30
- data/lib/tinkerforge/bricklet_performance_dc.rb +682 -0
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +18 -9
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +21 -10
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +79 -42
- data/lib/tinkerforge/bricklet_ptc.rb +73 -42
- data/lib/tinkerforge/bricklet_ptc_v2.rb +94 -48
- data/lib/tinkerforge/bricklet_real_time_clock.rb +44 -33
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +77 -44
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +38 -19
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +59 -24
- data/lib/tinkerforge/bricklet_rotary_poti.rb +52 -28
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +56 -23
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +117 -44
- data/lib/tinkerforge/bricklet_rs485.rb +222 -95
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +74 -35
- data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
- data/lib/tinkerforge/bricklet_silent_stepper_v2.rb +1024 -0
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +34 -18
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +71 -31
- data/lib/tinkerforge/bricklet_temperature.rb +39 -16
- data/lib/tinkerforge/bricklet_temperature_ir.rb +56 -23
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +70 -27
- data/lib/tinkerforge/bricklet_temperature_v2.rb +60 -25
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +104 -44
- data/lib/tinkerforge/bricklet_thermocouple.rb +44 -24
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +64 -27
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +35 -18
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +84 -37
- data/lib/tinkerforge/bricklet_voltage.rb +51 -28
- data/lib/tinkerforge/bricklet_voltage_current.rb +90 -73
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +89 -68
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +79 -30
- data/lib/tinkerforge/device_display_names.rb +170 -0
- data/lib/tinkerforge/ip_connection.rb +153 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +11 -3
@@ -1,14 +1,16 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2021-05-06. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.29 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
|
+
require_relative './ip_connection'
|
13
|
+
|
12
14
|
module Tinkerforge
|
13
15
|
# Silently drives one bipolar stepper motor with up to 46V and 1.6A per phase
|
14
16
|
class BrickSilentStepper < Device
|
@@ -16,8 +18,7 @@ module Tinkerforge
|
|
16
18
|
DEVICE_DISPLAY_NAME = 'Silent Stepper Brick' # :nodoc:
|
17
19
|
|
18
20
|
# This callback is triggered when the input voltage drops below the value set by
|
19
|
-
# BrickSilentStepper#set_minimum_voltage. The parameter is the current voltage
|
20
|
-
# in mV.
|
21
|
+
# BrickSilentStepper#set_minimum_voltage. The parameter is the current voltage.
|
21
22
|
CALLBACK_UNDER_VOLTAGE = 40
|
22
23
|
|
23
24
|
# This callback is triggered when a position set by BrickSilentStepper#set_steps or
|
@@ -95,6 +96,8 @@ module Tinkerforge
|
|
95
96
|
FUNCTION_GET_PROTOCOL1_BRICKLET_NAME = 241 # :nodoc:
|
96
97
|
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
97
98
|
FUNCTION_RESET = 243 # :nodoc:
|
99
|
+
FUNCTION_WRITE_BRICKLET_PLUGIN = 246 # :nodoc:
|
100
|
+
FUNCTION_READ_BRICKLET_PLUGIN = 247 # :nodoc:
|
98
101
|
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
99
102
|
|
100
103
|
STEP_RESOLUTION_1 = 8 # :nodoc:
|
@@ -153,7 +156,7 @@ module Tinkerforge
|
|
153
156
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
154
157
|
# the IP Connection <tt>ipcon</tt>.
|
155
158
|
def initialize(uid, ipcon)
|
156
|
-
super uid, ipcon
|
159
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
157
160
|
|
158
161
|
@api_version = [2, 0, 1]
|
159
162
|
|
@@ -212,36 +215,45 @@ module Tinkerforge
|
|
212
215
|
@response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
213
216
|
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
214
217
|
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
218
|
+
@response_expected[FUNCTION_WRITE_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_FALSE
|
219
|
+
@response_expected[FUNCTION_READ_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
215
220
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
216
221
|
|
217
|
-
@callback_formats[CALLBACK_UNDER_VOLTAGE] = 'S'
|
218
|
-
@callback_formats[CALLBACK_POSITION_REACHED] = 'l'
|
219
|
-
@callback_formats[CALLBACK_ALL_DATA] = 'S l l S S S'
|
220
|
-
@callback_formats[CALLBACK_NEW_STATE] = 'C C'
|
222
|
+
@callback_formats[CALLBACK_UNDER_VOLTAGE] = [10, 'S']
|
223
|
+
@callback_formats[CALLBACK_POSITION_REACHED] = [12, 'l']
|
224
|
+
@callback_formats[CALLBACK_ALL_DATA] = [24, 'S l l S S S']
|
225
|
+
@callback_formats[CALLBACK_NEW_STATE] = [10, 'C C']
|
221
226
|
|
227
|
+
@ipcon.add_device self
|
222
228
|
end
|
223
229
|
|
224
|
-
# Sets the maximum velocity of the stepper motor
|
230
|
+
# Sets the maximum velocity of the stepper motor.
|
225
231
|
# This function does *not* start the motor, it merely sets the maximum
|
226
232
|
# velocity the stepper motor is accelerated to. To get the motor running use
|
227
233
|
# either BrickSilentStepper#set_target_position, BrickSilentStepper#set_steps, BrickSilentStepper#drive_forward or
|
228
234
|
# BrickSilentStepper#drive_backward.
|
229
235
|
def set_max_velocity(velocity)
|
230
|
-
|
236
|
+
check_validity
|
237
|
+
|
238
|
+
send_request FUNCTION_SET_MAX_VELOCITY, [velocity], 'S', 8, ''
|
231
239
|
end
|
232
240
|
|
233
241
|
# Returns the velocity as set by BrickSilentStepper#set_max_velocity.
|
234
242
|
def get_max_velocity
|
235
|
-
|
243
|
+
check_validity
|
244
|
+
|
245
|
+
send_request FUNCTION_GET_MAX_VELOCITY, [], '', 10, 'S'
|
236
246
|
end
|
237
247
|
|
238
|
-
# Returns the *current* velocity of the stepper motor
|
248
|
+
# Returns the *current* velocity of the stepper motor.
|
239
249
|
def get_current_velocity
|
240
|
-
|
250
|
+
check_validity
|
251
|
+
|
252
|
+
send_request FUNCTION_GET_CURRENT_VELOCITY, [], '', 10, 'S'
|
241
253
|
end
|
242
254
|
|
243
|
-
# Sets the acceleration and deacceleration of the stepper motor.
|
244
|
-
#
|
255
|
+
# Sets the acceleration and deacceleration of the stepper motor.
|
256
|
+
# An acceleration of 1000 means, that
|
245
257
|
# every second the velocity is increased by 1000 *steps/s*.
|
246
258
|
#
|
247
259
|
# For example: If the current velocity is 0 and you want to accelerate to a
|
@@ -250,16 +262,18 @@ module Tinkerforge
|
|
250
262
|
#
|
251
263
|
# An acceleration/deacceleration of 0 means instantaneous
|
252
264
|
# acceleration/deacceleration (not recommended)
|
253
|
-
#
|
254
|
-
# The default value is 1000 for both
|
255
265
|
def set_speed_ramping(acceleration, deacceleration)
|
256
|
-
|
266
|
+
check_validity
|
267
|
+
|
268
|
+
send_request FUNCTION_SET_SPEED_RAMPING, [acceleration, deacceleration], 'S S', 8, ''
|
257
269
|
end
|
258
270
|
|
259
271
|
# Returns the acceleration and deacceleration as set by
|
260
272
|
# BrickSilentStepper#set_speed_ramping.
|
261
273
|
def get_speed_ramping
|
262
|
-
|
274
|
+
check_validity
|
275
|
+
|
276
|
+
send_request FUNCTION_GET_SPEED_RAMPING, [], '', 12, 'S S'
|
263
277
|
end
|
264
278
|
|
265
279
|
# Executes an active full brake.
|
@@ -271,14 +285,18 @@ module Tinkerforge
|
|
271
285
|
#
|
272
286
|
# Call BrickSilentStepper#stop if you just want to stop the motor.
|
273
287
|
def full_brake
|
274
|
-
|
288
|
+
check_validity
|
289
|
+
|
290
|
+
send_request FUNCTION_FULL_BRAKE, [], '', 8, ''
|
275
291
|
end
|
276
292
|
|
277
293
|
# Sets the current steps of the internal step counter. This can be used to
|
278
294
|
# set the current position to 0 when some kind of starting position
|
279
295
|
# is reached (e.g. when a CNC machine reaches a corner).
|
280
296
|
def set_current_position(position)
|
281
|
-
|
297
|
+
check_validity
|
298
|
+
|
299
|
+
send_request FUNCTION_SET_CURRENT_POSITION, [position], 'l', 8, ''
|
282
300
|
end
|
283
301
|
|
284
302
|
# Returns the current position of the stepper motor in steps. On startup
|
@@ -287,7 +305,9 @@ module Tinkerforge
|
|
287
305
|
# BrickSilentStepper#drive_backward). It also is possible to reset the steps to 0 or
|
288
306
|
# set them to any other desired value with BrickSilentStepper#set_current_position.
|
289
307
|
def get_current_position
|
290
|
-
|
308
|
+
check_validity
|
309
|
+
|
310
|
+
send_request FUNCTION_GET_CURRENT_POSITION, [], '', 12, 'l'
|
291
311
|
end
|
292
312
|
|
293
313
|
# Sets the target position of the stepper motor in steps. For example,
|
@@ -300,12 +320,16 @@ module Tinkerforge
|
|
300
320
|
# a call of BrickSilentStepper#set_steps with the parameter
|
301
321
|
# (*x* - BrickSilentStepper#get_current_position).
|
302
322
|
def set_target_position(position)
|
303
|
-
|
323
|
+
check_validity
|
324
|
+
|
325
|
+
send_request FUNCTION_SET_TARGET_POSITION, [position], 'l', 8, ''
|
304
326
|
end
|
305
327
|
|
306
328
|
# Returns the last target position as set by BrickSilentStepper#set_target_position.
|
307
329
|
def get_target_position
|
308
|
-
|
330
|
+
check_validity
|
331
|
+
|
332
|
+
send_request FUNCTION_GET_TARGET_POSITION, [], '', 12, 'l'
|
309
333
|
end
|
310
334
|
|
311
335
|
# Sets the number of steps the stepper motor should run. Positive values
|
@@ -313,12 +337,16 @@ module Tinkerforge
|
|
313
337
|
# The velocity, acceleration and deacceleration as set by
|
314
338
|
# BrickSilentStepper#set_max_velocity and BrickSilentStepper#set_speed_ramping will be used.
|
315
339
|
def set_steps(steps)
|
316
|
-
|
340
|
+
check_validity
|
341
|
+
|
342
|
+
send_request FUNCTION_SET_STEPS, [steps], 'l', 8, ''
|
317
343
|
end
|
318
344
|
|
319
345
|
# Returns the last steps as set by BrickSilentStepper#set_steps.
|
320
346
|
def get_steps
|
321
|
-
|
347
|
+
check_validity
|
348
|
+
|
349
|
+
send_request FUNCTION_GET_STEPS, [], '', 12, 'l'
|
322
350
|
end
|
323
351
|
|
324
352
|
# Returns the remaining steps of the last call of BrickSilentStepper#set_steps.
|
@@ -326,7 +354,9 @@ module Tinkerforge
|
|
326
354
|
# BrickSilentStepper#get_remaining_steps is called after the motor has run for 500 steps,
|
327
355
|
# it will return 1500.
|
328
356
|
def get_remaining_steps
|
329
|
-
|
357
|
+
check_validity
|
358
|
+
|
359
|
+
send_request FUNCTION_GET_REMAINING_STEPS, [], '', 12, 'l'
|
330
360
|
end
|
331
361
|
|
332
362
|
# Sets the step resolution from full-step up to 1/256-step.
|
@@ -340,45 +370,55 @@ module Tinkerforge
|
|
340
370
|
#
|
341
371
|
# If you often change the speed with high acceleration you should turn the
|
342
372
|
# interpolation off.
|
343
|
-
#
|
344
|
-
# The default is 1/256-step with interpolation on.
|
345
373
|
def set_step_configuration(step_resolution, interpolation)
|
346
|
-
|
374
|
+
check_validity
|
375
|
+
|
376
|
+
send_request FUNCTION_SET_STEP_CONFIGURATION, [step_resolution, interpolation], 'C ?', 8, ''
|
347
377
|
end
|
348
378
|
|
349
379
|
# Returns the step mode as set by BrickSilentStepper#set_step_configuration.
|
350
380
|
def get_step_configuration
|
351
|
-
|
381
|
+
check_validity
|
382
|
+
|
383
|
+
send_request FUNCTION_GET_STEP_CONFIGURATION, [], '', 10, 'C ?'
|
352
384
|
end
|
353
385
|
|
354
386
|
# Drives the stepper motor forward until BrickSilentStepper#drive_backward or
|
355
387
|
# BrickSilentStepper#stop is called. The velocity, acceleration and deacceleration as
|
356
388
|
# set by BrickSilentStepper#set_max_velocity and BrickSilentStepper#set_speed_ramping will be used.
|
357
389
|
def drive_forward
|
358
|
-
|
390
|
+
check_validity
|
391
|
+
|
392
|
+
send_request FUNCTION_DRIVE_FORWARD, [], '', 8, ''
|
359
393
|
end
|
360
394
|
|
361
395
|
# Drives the stepper motor backward until BrickSilentStepper#drive_forward or
|
362
396
|
# BrickSilentStepper#stop is triggered. The velocity, acceleration and deacceleration as
|
363
397
|
# set by BrickSilentStepper#set_max_velocity and BrickSilentStepper#set_speed_ramping will be used.
|
364
398
|
def drive_backward
|
365
|
-
|
399
|
+
check_validity
|
400
|
+
|
401
|
+
send_request FUNCTION_DRIVE_BACKWARD, [], '', 8, ''
|
366
402
|
end
|
367
403
|
|
368
404
|
# Stops the stepper motor with the deacceleration as set by
|
369
405
|
# BrickSilentStepper#set_speed_ramping.
|
370
406
|
def stop
|
371
|
-
|
407
|
+
check_validity
|
408
|
+
|
409
|
+
send_request FUNCTION_STOP, [], '', 8, ''
|
372
410
|
end
|
373
411
|
|
374
|
-
# Returns the stack input voltage
|
412
|
+
# Returns the stack input voltage. The stack input voltage is the
|
375
413
|
# voltage that is supplied via the stack, i.e. it is given by a
|
376
414
|
# Step-Down or Step-Up Power Supply.
|
377
415
|
def get_stack_input_voltage
|
378
|
-
|
416
|
+
check_validity
|
417
|
+
|
418
|
+
send_request FUNCTION_GET_STACK_INPUT_VOLTAGE, [], '', 10, 'S'
|
379
419
|
end
|
380
420
|
|
381
|
-
# Returns the external input voltage
|
421
|
+
# Returns the external input voltage. The external input voltage is
|
382
422
|
# given via the black power input connector on the Silent Stepper Brick.
|
383
423
|
#
|
384
424
|
# If there is an external input voltage and a stack input voltage, the motor
|
@@ -391,40 +431,58 @@ module Tinkerforge
|
|
391
431
|
# the external connection, it will immediately be driven by the high
|
392
432
|
# stack voltage
|
393
433
|
def get_external_input_voltage
|
394
|
-
|
434
|
+
check_validity
|
435
|
+
|
436
|
+
send_request FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE, [], '', 10, 'S'
|
395
437
|
end
|
396
438
|
|
397
|
-
# Sets the current
|
398
|
-
# The minimum value is 360mA, the maximum value 1640mA and the
|
399
|
-
# default value is 800mA.
|
439
|
+
# Sets the current with which the motor will be driven.
|
400
440
|
#
|
401
441
|
# .. warning::
|
402
442
|
# Do not set this value above the specifications of your stepper motor.
|
403
443
|
# Otherwise it may damage your motor.
|
404
444
|
def set_motor_current(current)
|
405
|
-
|
445
|
+
check_validity
|
446
|
+
|
447
|
+
send_request FUNCTION_SET_MOTOR_CURRENT, [current], 'S', 8, ''
|
406
448
|
end
|
407
449
|
|
408
450
|
# Returns the current as set by BrickSilentStepper#set_motor_current.
|
409
451
|
def get_motor_current
|
410
|
-
|
452
|
+
check_validity
|
453
|
+
|
454
|
+
send_request FUNCTION_GET_MOTOR_CURRENT, [], '', 10, 'S'
|
411
455
|
end
|
412
456
|
|
413
457
|
# Enables the driver chip. The driver parameters can be configured (maximum velocity,
|
414
458
|
# acceleration, etc) before it is enabled.
|
415
459
|
def enable
|
416
|
-
|
460
|
+
check_validity
|
461
|
+
|
462
|
+
send_request FUNCTION_ENABLE, [], '', 8, ''
|
417
463
|
end
|
418
464
|
|
419
465
|
# Disables the driver chip. The configurations are kept (maximum velocity,
|
420
466
|
# acceleration, etc) but the motor is not driven until it is enabled again.
|
467
|
+
#
|
468
|
+
# .. warning::
|
469
|
+
# Disabling the driver chip while the motor is still turning can damage the
|
470
|
+
# driver chip. The motor should be stopped calling BrickSilentStepper#stop function
|
471
|
+
# before disabling the motor power. The BrickSilentStepper#stop function will **not**
|
472
|
+
# wait until the motor is actually stopped. You have to explicitly wait for the
|
473
|
+
# appropriate time after calling the BrickSilentStepper#stop function before calling
|
474
|
+
# the BrickSilentStepper#disable function.
|
421
475
|
def disable
|
422
|
-
|
476
|
+
check_validity
|
477
|
+
|
478
|
+
send_request FUNCTION_DISABLE, [], '', 8, ''
|
423
479
|
end
|
424
480
|
|
425
481
|
# Returns *true* if the driver chip is enabled, *false* otherwise.
|
426
482
|
def is_enabled
|
427
|
-
|
483
|
+
check_validity
|
484
|
+
|
485
|
+
send_request FUNCTION_IS_ENABLED, [], '', 9, '?'
|
428
486
|
end
|
429
487
|
|
430
488
|
# Sets the basic configuration parameters for the different modes (Stealth, Coolstep, Classic).
|
@@ -434,12 +492,12 @@ module Tinkerforge
|
|
434
492
|
# the configured motor phase current will be driven until the configured
|
435
493
|
# Power Down Time is elapsed. After that the phase current will be reduced to the standstill
|
436
494
|
# current. The elapsed time for this reduction can be configured with the Standstill Delay Time.
|
437
|
-
# The
|
495
|
+
# The maximum allowed value is the configured maximum motor current
|
438
496
|
# (see BrickSilentStepper#set_motor_current).
|
439
497
|
#
|
440
498
|
# * Motor Run Current: The value sets the motor current when the motor is running.
|
441
499
|
# Use a value of at least one half of the global maximum motor current for a good
|
442
|
-
# microstep performance. The
|
500
|
+
# microstep performance. The maximum allowed value is the current
|
443
501
|
# motor current. The API maps the entered value to 1/32 ... 32/32 of the maximum
|
444
502
|
# motor current. This value should be used to change the motor current during motor movement,
|
445
503
|
# whereas the global maximum motor current should not be changed while the motor is moving
|
@@ -448,44 +506,35 @@ module Tinkerforge
|
|
448
506
|
# * Standstill Delay Time: Controls the duration for motor power down after a motion
|
449
507
|
# as soon as standstill is detected and the Power Down Time is expired. A high Standstill Delay
|
450
508
|
# Time results in a smooth transition that avoids motor jerk during power down.
|
451
|
-
# The value range is 0 to 307ms
|
452
509
|
#
|
453
510
|
# * Power Down Time: Sets the delay time after a stand still.
|
454
|
-
# The value range is 0 to 5222ms.
|
455
511
|
#
|
456
|
-
# * Stealth Threshold: Sets the upper threshold for Stealth mode
|
457
|
-
#
|
512
|
+
# * Stealth Threshold: Sets the upper threshold for Stealth mode.
|
513
|
+
# If the velocity of the motor goes above this value, Stealth mode is turned
|
458
514
|
# off. Otherwise it is turned on. In Stealth mode the torque declines with high speed.
|
459
515
|
#
|
460
|
-
# * Coolstep Threshold: Sets the lower threshold for Coolstep mode
|
461
|
-
#
|
516
|
+
# * Coolstep Threshold: Sets the lower threshold for Coolstep mode.
|
517
|
+
# The Coolstep Threshold needs to be above the Stealth Threshold.
|
462
518
|
#
|
463
|
-
# * Classic Threshold: Sets the lower threshold for classic mode.
|
464
|
-
#
|
519
|
+
# * Classic Threshold: Sets the lower threshold for classic mode.
|
520
|
+
# In classic mode the stepper becomes more noisy, but the torque is maximized.
|
465
521
|
#
|
466
|
-
# * High Velocity
|
522
|
+
# * High Velocity Chopper Mode: If High Velocity Chopper Mode is enabled, the stepper control
|
467
523
|
# is optimized to run the stepper motors at high velocities.
|
468
524
|
#
|
469
525
|
# If you want to use all three thresholds make sure that
|
470
526
|
# Stealth Threshold < Coolstep Threshold < Classic Threshold.
|
471
|
-
#
|
472
|
-
# The default values are:
|
473
|
-
#
|
474
|
-
# * Standstill Current: 200
|
475
|
-
# * Motor Run Current: 800
|
476
|
-
# * Standstill Delay Time: 0
|
477
|
-
# * Power Down Time: 1000
|
478
|
-
# * Stealth Threshold: 500
|
479
|
-
# * Coolstep Threshold: 500
|
480
|
-
# * Classic Threshold: 1000
|
481
|
-
# * High Velocity Shopper Mode: false
|
482
527
|
def set_basic_configuration(standstill_current, motor_run_current, standstill_delay_time, power_down_time, stealth_threshold, coolstep_threshold, classic_threshold, high_velocity_chopper_mode)
|
483
|
-
|
528
|
+
check_validity
|
529
|
+
|
530
|
+
send_request FUNCTION_SET_BASIC_CONFIGURATION, [standstill_current, motor_run_current, standstill_delay_time, power_down_time, stealth_threshold, coolstep_threshold, classic_threshold, high_velocity_chopper_mode], 'S S S S S S S ?', 8, ''
|
484
531
|
end
|
485
532
|
|
486
533
|
# Returns the configuration as set by BrickSilentStepper#set_basic_configuration.
|
487
534
|
def get_basic_configuration
|
488
|
-
|
535
|
+
check_validity
|
536
|
+
|
537
|
+
send_request FUNCTION_GET_BASIC_CONFIGURATION, [], '', 23, 'S S S S S S S ?'
|
489
538
|
end
|
490
539
|
|
491
540
|
# Note: If you don't know what any of this means you can very likely keep all of
|
@@ -495,22 +544,22 @@ module Tinkerforge
|
|
495
544
|
# controls the motor current flow. More information can be found in the TMC2130 datasheet on page
|
496
545
|
# 47 (7 spreadCycle and Classic Chopper).
|
497
546
|
#
|
498
|
-
# * Slow Decay Duration: Controls duration of off time setting of slow decay phase.
|
499
|
-
#
|
547
|
+
# * Slow Decay Duration: Controls duration of off time setting of slow decay phase.
|
548
|
+
# 0 = driver disabled, all bridges off. Use 1 only with Comparator Blank time >= 2.
|
500
549
|
#
|
501
550
|
# * Enable Random Slow Decay: Set to false to fix chopper off time as set by Slow Decay Duration.
|
502
551
|
# If you set it to true, Decay Duration is randomly modulated.
|
503
552
|
#
|
504
|
-
# * Fast Decay Duration: Sets the fast decay duration.
|
553
|
+
# * Fast Decay Duration: Sets the fast decay duration. This parameters is
|
505
554
|
# only used if the Chopper Mode is set to Fast Decay.
|
506
555
|
#
|
507
|
-
# * Hysteresis Start Value: Sets the hysteresis start value.
|
556
|
+
# * Hysteresis Start Value: Sets the hysteresis start value. This parameter is
|
508
557
|
# only used if the Chopper Mode is set to Spread Cycle.
|
509
558
|
#
|
510
|
-
# * Hysteresis End Value: Sets the hysteresis end value.
|
559
|
+
# * Hysteresis End Value: Sets the hysteresis end value. This parameter is
|
511
560
|
# only used if the Chopper Mode is set to Spread Cycle.
|
512
561
|
#
|
513
|
-
# * Sine Wave Offset: Sets the sine wave offset.
|
562
|
+
# * Sine Wave Offset: Sets the sine wave offset. This parameters is
|
514
563
|
# only used if the Chopper Mode is set to Fast Decay. 1/512 of the value becomes added to the absolute
|
515
564
|
# value of the sine wave.
|
516
565
|
#
|
@@ -527,25 +576,17 @@ module Tinkerforge
|
|
527
576
|
#
|
528
577
|
# * Fast Decay Without Comparator: If set to true the current comparator usage for termination of the
|
529
578
|
# fast decay cycle is disabled.
|
530
|
-
#
|
531
|
-
# The default values are:
|
532
|
-
#
|
533
|
-
# * Slow Decay Duration: 4
|
534
|
-
# * Enable Random Slow Decay: 0
|
535
|
-
# * Fast Decay Duration: 0
|
536
|
-
# * Hysteresis Start Value: 0
|
537
|
-
# * Hysteresis End Value: 0
|
538
|
-
# * Sine Wave Offset: 0
|
539
|
-
# * Chopper Mode: 0
|
540
|
-
# * Comparator Blank Time: 1
|
541
|
-
# * Fast Decay Without Comparator: false
|
542
579
|
def set_spreadcycle_configuration(slow_decay_duration, enable_random_slow_decay, fast_decay_duration, hysteresis_start_value, hysteresis_end_value, sine_wave_offset, chopper_mode, comparator_blank_time, fast_decay_without_comparator)
|
543
|
-
|
580
|
+
check_validity
|
581
|
+
|
582
|
+
send_request FUNCTION_SET_SPREADCYCLE_CONFIGURATION, [slow_decay_duration, enable_random_slow_decay, fast_decay_duration, hysteresis_start_value, hysteresis_end_value, sine_wave_offset, chopper_mode, comparator_blank_time, fast_decay_without_comparator], 'C ? C C c c C C ?', 8, ''
|
544
583
|
end
|
545
584
|
|
546
585
|
# Returns the configuration as set by BrickSilentStepper#set_basic_configuration.
|
547
586
|
def get_spreadcycle_configuration
|
548
|
-
|
587
|
+
check_validity
|
588
|
+
|
589
|
+
send_request FUNCTION_GET_SPREADCYCLE_CONFIGURATION, [], '', 17, 'C ? C C c c C C ?'
|
549
590
|
end
|
550
591
|
|
551
592
|
# Note: If you don't know what any of this means you can very likely keep all of
|
@@ -557,11 +598,11 @@ module Tinkerforge
|
|
557
598
|
# stealth mode is disabled, even if the speed is below the threshold set in BrickSilentStepper#set_basic_configuration.
|
558
599
|
#
|
559
600
|
# * Amplitude: If autoscale is disabled, the PWM amplitude is scaled by this value. If autoscale is enabled,
|
560
|
-
# this value defines the maximum PWM amplitude change per half wave.
|
601
|
+
# this value defines the maximum PWM amplitude change per half wave.
|
561
602
|
#
|
562
603
|
# * Gradient: If autoscale is disabled, the PWM gradient is scaled by this value. If autoscale is enabled,
|
563
604
|
# this value defines the maximum PWM gradient. With autoscale a value above 64 is recommended,
|
564
|
-
# otherwise the regulation might not be able to measure the current.
|
605
|
+
# otherwise the regulation might not be able to measure the current.
|
565
606
|
#
|
566
607
|
# * Enable Autoscale: If set to true, automatic current control is used. Otherwise the user defined
|
567
608
|
# amplitude and gradient are used.
|
@@ -571,22 +612,17 @@ module Tinkerforge
|
|
571
612
|
#
|
572
613
|
# * Freewheel Mode: The freewheel mode defines the behavior in stand still if the Standstill Current
|
573
614
|
# (see BrickSilentStepper#set_basic_configuration) is set to 0.
|
574
|
-
#
|
575
|
-
# The default values are:
|
576
|
-
#
|
577
|
-
# * Enable Stealth: true
|
578
|
-
# * Amplitude: 128
|
579
|
-
# * Gradient: 4
|
580
|
-
# * Enable Autoscale: true
|
581
|
-
# * Force Symmetric: false
|
582
|
-
# * Freewheel Mode: 0 (Normal)
|
583
615
|
def set_stealth_configuration(enable_stealth, amplitude, gradient, enable_autoscale, force_symmetric, freewheel_mode)
|
584
|
-
|
616
|
+
check_validity
|
617
|
+
|
618
|
+
send_request FUNCTION_SET_STEALTH_CONFIGURATION, [enable_stealth, amplitude, gradient, enable_autoscale, force_symmetric, freewheel_mode], '? C C ? ? C', 8, ''
|
585
619
|
end
|
586
620
|
|
587
621
|
# Returns the configuration as set by BrickSilentStepper#set_stealth_configuration.
|
588
622
|
def get_stealth_configuration
|
589
|
-
|
623
|
+
check_validity
|
624
|
+
|
625
|
+
send_request FUNCTION_GET_STEALTH_CONFIGURATION, [], '', 14, '? C C ? ? C'
|
590
626
|
end
|
591
627
|
|
592
628
|
# Note: If you don't know what any of this means you can very likely keep all of
|
@@ -595,7 +631,7 @@ module Tinkerforge
|
|
595
631
|
# Sets the configuration relevant for Coolstep.
|
596
632
|
#
|
597
633
|
# * Minimum Stallguard Value: If the Stallguard result falls below this value*32, the motor current
|
598
|
-
# is increased to reduce motor load angle.
|
634
|
+
# is increased to reduce motor load angle. A value of 0 turns Coolstep off.
|
599
635
|
#
|
600
636
|
# * Maximum Stallguard Value: If the Stallguard result goes above
|
601
637
|
# (Min Stallguard Value + Max Stallguard Value + 1) * 32, the motor current is decreased to save
|
@@ -610,29 +646,23 @@ module Tinkerforge
|
|
610
646
|
# * Minimum Current: Sets the minimum current for Coolstep current control. You can choose between
|
611
647
|
# half and quarter of the run current.
|
612
648
|
#
|
613
|
-
# * Stallguard Threshold Value: Sets the level for stall output (see BrickSilentStepper#get_driver_status).
|
614
|
-
#
|
649
|
+
# * Stallguard Threshold Value: Sets the level for stall output (see BrickSilentStepper#get_driver_status).
|
650
|
+
# A lower value gives a higher sensitivity. You have to find a suitable value for your
|
615
651
|
# motor by trial and error, 0 works for most motors.
|
616
652
|
#
|
617
653
|
# * Stallguard Mode: Set to 0 for standard resolution or 1 for filtered mode. In filtered mode the Stallguard
|
618
654
|
# signal will be updated every four full-steps.
|
619
|
-
#
|
620
|
-
# The default values are:
|
621
|
-
#
|
622
|
-
# * Minimum Stallguard Value: 2
|
623
|
-
# * Maximum Stallguard Value: 10
|
624
|
-
# * Current Up Step Width: 0
|
625
|
-
# * Current Down Step Width: 0
|
626
|
-
# * Minimum Current: 0
|
627
|
-
# * Stallguard Threshold Value: 0
|
628
|
-
# * Stallguard Mode: 0
|
629
655
|
def set_coolstep_configuration(minimum_stallguard_value, maximum_stallguard_value, current_up_step_width, current_down_step_width, minimum_current, stallguard_threshold_value, stallguard_mode)
|
630
|
-
|
656
|
+
check_validity
|
657
|
+
|
658
|
+
send_request FUNCTION_SET_COOLSTEP_CONFIGURATION, [minimum_stallguard_value, maximum_stallguard_value, current_up_step_width, current_down_step_width, minimum_current, stallguard_threshold_value, stallguard_mode], 'C C C C C c C', 8, ''
|
631
659
|
end
|
632
660
|
|
633
661
|
# Returns the configuration as set by BrickSilentStepper#set_coolstep_configuration.
|
634
662
|
def get_coolstep_configuration
|
635
|
-
|
663
|
+
check_validity
|
664
|
+
|
665
|
+
send_request FUNCTION_GET_COOLSTEP_CONFIGURATION, [], '', 15, 'C C C C C c C'
|
636
666
|
end
|
637
667
|
|
638
668
|
# Note: If you don't know what any of this means you can very likely keep all of
|
@@ -648,18 +678,17 @@ module Tinkerforge
|
|
648
678
|
# the synchronization is turned off. Otherwise the synchronization is done through the formula
|
649
679
|
# f_sync = f_clk/(value*64). In Classic Mode the synchronization is automatically switched off.
|
650
680
|
# f_clk is 12.8MHz.
|
651
|
-
#
|
652
|
-
# The default values are:
|
653
|
-
#
|
654
|
-
# * Disable Short To Ground Protection: 0
|
655
|
-
# * Synchronize Phase Frequency: 0
|
656
681
|
def set_misc_configuration(disable_short_to_ground_protection, synchronize_phase_frequency)
|
657
|
-
|
682
|
+
check_validity
|
683
|
+
|
684
|
+
send_request FUNCTION_SET_MISC_CONFIGURATION, [disable_short_to_ground_protection, synchronize_phase_frequency], '? C', 8, ''
|
658
685
|
end
|
659
686
|
|
660
687
|
# Returns the configuration as set by BrickSilentStepper#set_misc_configuration.
|
661
688
|
def get_misc_configuration
|
662
|
-
|
689
|
+
check_validity
|
690
|
+
|
691
|
+
send_request FUNCTION_GET_MISC_CONFIGURATION, [], '', 10, '? C'
|
663
692
|
end
|
664
693
|
|
665
694
|
# Returns the current driver status.
|
@@ -677,7 +706,7 @@ module Tinkerforge
|
|
677
706
|
# * Motor Stalled: Is true if a motor stall was detected.
|
678
707
|
#
|
679
708
|
# * Actual Motor Current: Indicates the actual current control scaling as used in Coolstep mode.
|
680
|
-
#
|
709
|
+
# It represents a multiplier of 1/32 to 32/32 of the
|
681
710
|
# ``Motor Run Current`` as set by BrickSilentStepper#set_basic_configuration. Example: If a ``Motor Run Current``
|
682
711
|
# of 1000mA was set and the returned value is 15, the ``Actual Motor Current`` is 16/32*1000mA = 500mA.
|
683
712
|
#
|
@@ -690,41 +719,47 @@ module Tinkerforge
|
|
690
719
|
# * Stealth Voltage Amplitude: Shows the actual PWM scaling. In Stealth mode it can be used to detect motor load and
|
691
720
|
# stall if autoscale is enabled (see BrickSilentStepper#set_stealth_configuration).
|
692
721
|
def get_driver_status
|
693
|
-
|
722
|
+
check_validity
|
723
|
+
|
724
|
+
send_request FUNCTION_GET_DRIVER_STATUS, [], '', 16, 'C C C ? C ? C C'
|
694
725
|
end
|
695
726
|
|
696
|
-
# Sets the minimum voltage
|
727
|
+
# Sets the minimum voltage, below which the CALLBACK_UNDER_VOLTAGE callback
|
697
728
|
# is triggered. The minimum possible value that works with the Silent Stepper
|
698
729
|
# Brick is 8V.
|
699
730
|
# You can use this function to detect the discharge of a battery that is used
|
700
731
|
# to drive the stepper motor. If you have a fixed power supply, you likely do
|
701
732
|
# not need this functionality.
|
702
|
-
#
|
703
|
-
# The default value is 8V.
|
704
733
|
def set_minimum_voltage(voltage)
|
705
|
-
|
734
|
+
check_validity
|
735
|
+
|
736
|
+
send_request FUNCTION_SET_MINIMUM_VOLTAGE, [voltage], 'S', 8, ''
|
706
737
|
end
|
707
738
|
|
708
739
|
# Returns the minimum voltage as set by BrickSilentStepper#set_minimum_voltage.
|
709
740
|
def get_minimum_voltage
|
710
|
-
|
741
|
+
check_validity
|
742
|
+
|
743
|
+
send_request FUNCTION_GET_MINIMUM_VOLTAGE, [], '', 10, 'S'
|
711
744
|
end
|
712
745
|
|
713
746
|
# Sets the time base of the velocity and the acceleration of the Silent Stepper
|
714
|
-
# Brick
|
747
|
+
# Brick.
|
715
748
|
#
|
716
749
|
# For example, if you want to make one step every 1.5 seconds, you can set
|
717
750
|
# the time base to 15 and the velocity to 10. Now the velocity is
|
718
751
|
# 10steps/15s = 1steps/1.5s.
|
719
|
-
#
|
720
|
-
# The default value is 1.
|
721
752
|
def set_time_base(time_base)
|
722
|
-
|
753
|
+
check_validity
|
754
|
+
|
755
|
+
send_request FUNCTION_SET_TIME_BASE, [time_base], 'L', 8, ''
|
723
756
|
end
|
724
757
|
|
725
758
|
# Returns the time base as set by BrickSilentStepper#set_time_base.
|
726
759
|
def get_time_base
|
727
|
-
|
760
|
+
check_validity
|
761
|
+
|
762
|
+
send_request FUNCTION_GET_TIME_BASE, [], '', 12, 'L'
|
728
763
|
end
|
729
764
|
|
730
765
|
# Returns the following parameters: The current velocity,
|
@@ -741,26 +776,32 @@ module Tinkerforge
|
|
741
776
|
#
|
742
777
|
# There is also a callback for this function, see CALLBACK_ALL_DATA callback.
|
743
778
|
def get_all_data
|
744
|
-
|
779
|
+
check_validity
|
780
|
+
|
781
|
+
send_request FUNCTION_GET_ALL_DATA, [], '', 24, 'S l l S S S'
|
745
782
|
end
|
746
783
|
|
747
784
|
# Sets the period with which the CALLBACK_ALL_DATA callback is triggered
|
748
785
|
# periodically. A value of 0 turns the callback off.
|
749
786
|
def set_all_data_period(period)
|
750
|
-
|
787
|
+
check_validity
|
788
|
+
|
789
|
+
send_request FUNCTION_SET_ALL_DATA_PERIOD, [period], 'L', 8, ''
|
751
790
|
end
|
752
791
|
|
753
792
|
# Returns the period as set by BrickSilentStepper#set_all_data_period.
|
754
793
|
def get_all_data_period
|
755
|
-
|
794
|
+
check_validity
|
795
|
+
|
796
|
+
send_request FUNCTION_GET_ALL_DATA_PERIOD, [], '', 12, 'L'
|
756
797
|
end
|
757
798
|
|
758
799
|
# The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is
|
759
800
|
# enabled, the Brick will try to adapt the baudrate for the communication
|
760
801
|
# between Bricks and Bricklets according to the amount of data that is transferred.
|
761
802
|
#
|
762
|
-
# The baudrate will be increased exponentially if lots of data is
|
763
|
-
# decreased linearly if little data is
|
803
|
+
# The baudrate will be increased exponentially if lots of data is sent/received and
|
804
|
+
# decreased linearly if little data is sent/received.
|
764
805
|
#
|
765
806
|
# This lowers the baudrate in applications where little data is transferred (e.g.
|
766
807
|
# a weather station) and increases the robustness. If there is lots of data to transfer
|
@@ -774,20 +815,20 @@ module Tinkerforge
|
|
774
815
|
# BrickSilentStepper#set_spitfp_baudrate. If the dynamic baudrate is disabled, the baudrate
|
775
816
|
# as set by BrickSilentStepper#set_spitfp_baudrate will be used statically.
|
776
817
|
#
|
777
|
-
# The minimum dynamic baudrate has a value range of 400000 to 2000000 baud.
|
778
|
-
#
|
779
|
-
# By default dynamic baudrate is enabled and the minimum dynamic baudrate is 400000.
|
780
|
-
#
|
781
818
|
# .. versionadded:: 2.0.4$nbsp;(Firmware)
|
782
819
|
def set_spitfp_baudrate_config(enable_dynamic_baudrate, minimum_dynamic_baudrate)
|
783
|
-
|
820
|
+
check_validity
|
821
|
+
|
822
|
+
send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 8, ''
|
784
823
|
end
|
785
824
|
|
786
825
|
# Returns the baudrate config, see BrickSilentStepper#set_spitfp_baudrate_config.
|
787
826
|
#
|
788
827
|
# .. versionadded:: 2.0.4$nbsp;(Firmware)
|
789
828
|
def get_spitfp_baudrate_config
|
790
|
-
|
829
|
+
check_validity
|
830
|
+
|
831
|
+
send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 13, '? L'
|
791
832
|
end
|
792
833
|
|
793
834
|
# Returns the timeout count for the different communication methods.
|
@@ -797,11 +838,12 @@ module Tinkerforge
|
|
797
838
|
# This function is mostly used for debugging during development, in normal operation
|
798
839
|
# the counters should nearly always stay at 0.
|
799
840
|
def get_send_timeout_count(communication_method)
|
800
|
-
|
841
|
+
check_validity
|
842
|
+
|
843
|
+
send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 12, 'L'
|
801
844
|
end
|
802
845
|
|
803
|
-
# Sets the baudrate for a specific Bricklet port
|
804
|
-
# baudrate can be in the range 400000 to 2000000.
|
846
|
+
# Sets the baudrate for a specific Bricklet port.
|
805
847
|
#
|
806
848
|
# If you want to increase the throughput of Bricklets you can increase
|
807
849
|
# the baudrate. If you get a high error count because of high
|
@@ -812,17 +854,19 @@ module Tinkerforge
|
|
812
854
|
# function corresponds to the maximum baudrate (see BrickSilentStepper#set_spitfp_baudrate_config).
|
813
855
|
#
|
814
856
|
# Regulatory testing is done with the default baudrate. If CE compatibility
|
815
|
-
# or similar is necessary in
|
857
|
+
# or similar is necessary in your applications we recommend to not change
|
816
858
|
# the baudrate.
|
817
|
-
#
|
818
|
-
# The default baudrate for all ports is 1400000.
|
819
859
|
def set_spitfp_baudrate(bricklet_port, baudrate)
|
820
|
-
|
860
|
+
check_validity
|
861
|
+
|
862
|
+
send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 8, ''
|
821
863
|
end
|
822
864
|
|
823
865
|
# Returns the baudrate for a given Bricklet port, see BrickSilentStepper#set_spitfp_baudrate.
|
824
866
|
def get_spitfp_baudrate(bricklet_port)
|
825
|
-
|
867
|
+
check_validity
|
868
|
+
|
869
|
+
send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 12, 'L'
|
826
870
|
end
|
827
871
|
|
828
872
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -837,7 +881,9 @@ module Tinkerforge
|
|
837
881
|
# The errors counts are for errors that occur on the Brick side. All
|
838
882
|
# Bricklets have a similar function that returns the errors on the Bricklet side.
|
839
883
|
def get_spitfp_error_count(bricklet_port)
|
840
|
-
|
884
|
+
check_validity
|
885
|
+
|
886
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 24, 'L L L L'
|
841
887
|
end
|
842
888
|
|
843
889
|
# Enables the status LED.
|
@@ -847,7 +893,9 @@ module Tinkerforge
|
|
847
893
|
#
|
848
894
|
# The default state is enabled.
|
849
895
|
def enable_status_led
|
850
|
-
|
896
|
+
check_validity
|
897
|
+
|
898
|
+
send_request FUNCTION_ENABLE_STATUS_LED, [], '', 8, ''
|
851
899
|
end
|
852
900
|
|
853
901
|
# Disables the status LED.
|
@@ -857,12 +905,16 @@ module Tinkerforge
|
|
857
905
|
#
|
858
906
|
# The default state is enabled.
|
859
907
|
def disable_status_led
|
860
|
-
|
908
|
+
check_validity
|
909
|
+
|
910
|
+
send_request FUNCTION_DISABLE_STATUS_LED, [], '', 8, ''
|
861
911
|
end
|
862
912
|
|
863
913
|
# Returns *true* if the status LED is enabled, *false* otherwise.
|
864
914
|
def is_status_led_enabled
|
865
|
-
|
915
|
+
check_validity
|
916
|
+
|
917
|
+
send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 9, '?'
|
866
918
|
end
|
867
919
|
|
868
920
|
# Returns the firmware and protocol version and the name of the Bricklet for a
|
@@ -871,17 +923,21 @@ module Tinkerforge
|
|
871
923
|
# This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet
|
872
924
|
# plugins.
|
873
925
|
def get_protocol1_bricklet_name(port)
|
874
|
-
|
926
|
+
check_validity
|
927
|
+
|
928
|
+
send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 52, 'C C3 Z40'
|
875
929
|
end
|
876
930
|
|
877
|
-
# Returns the temperature
|
931
|
+
# Returns the temperature as measured inside the microcontroller. The
|
878
932
|
# value returned is not the ambient temperature!
|
879
933
|
#
|
880
934
|
# The temperature is only proportional to the real temperature and it has an
|
881
935
|
# accuracy of ±15%. Practically it is only useful as an indicator for
|
882
936
|
# temperature changes.
|
883
937
|
def get_chip_temperature
|
884
|
-
|
938
|
+
check_validity
|
939
|
+
|
940
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
885
941
|
end
|
886
942
|
|
887
943
|
# Calling this function will reset the Brick. Calling this function
|
@@ -891,19 +947,43 @@ module Tinkerforge
|
|
891
947
|
# calling functions on the existing ones will result in
|
892
948
|
# undefined behavior!
|
893
949
|
def reset
|
894
|
-
|
950
|
+
check_validity
|
951
|
+
|
952
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
953
|
+
end
|
954
|
+
|
955
|
+
# Writes 32 bytes of firmware to the bricklet attached at the given port.
|
956
|
+
# The bytes are written to the position offset * 32.
|
957
|
+
#
|
958
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
959
|
+
# necessary to call it in a normal user program.
|
960
|
+
def write_bricklet_plugin(port, offset, chunk)
|
961
|
+
check_validity
|
962
|
+
|
963
|
+
send_request FUNCTION_WRITE_BRICKLET_PLUGIN, [port, offset, chunk], 'k C C32', 8, ''
|
964
|
+
end
|
965
|
+
|
966
|
+
# Reads 32 bytes of firmware from the bricklet attached at the given port.
|
967
|
+
# The bytes are read starting at the position offset * 32.
|
968
|
+
#
|
969
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
970
|
+
# necessary to call it in a normal user program.
|
971
|
+
def read_bricklet_plugin(port, offset)
|
972
|
+
check_validity
|
973
|
+
|
974
|
+
send_request FUNCTION_READ_BRICKLET_PLUGIN, [port, offset], 'k C', 40, 'C32'
|
895
975
|
end
|
896
976
|
|
897
977
|
# Returns the UID, the UID where the Brick is connected to,
|
898
978
|
# the position, the hardware and firmware version as well as the
|
899
979
|
# device identifier.
|
900
980
|
#
|
901
|
-
# The position
|
981
|
+
# The position is the position in the stack from '0' (bottom) to '8' (top).
|
902
982
|
#
|
903
983
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
904
984
|
# |device_identifier_constant|
|
905
985
|
def get_identity
|
906
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
986
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
907
987
|
end
|
908
988
|
|
909
989
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|