tinkerforge 2.1.11 → 2.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/lib/tinkerforge/brick_dc.rb +31 -9
  2. data/lib/tinkerforge/brick_imu.rb +62 -40
  3. data/lib/tinkerforge/brick_imu_v2.rb +70 -42
  4. data/lib/tinkerforge/brick_master.rb +47 -23
  5. data/lib/tinkerforge/brick_red.rb +3 -3
  6. data/lib/tinkerforge/brick_servo.rb +40 -18
  7. data/lib/tinkerforge/brick_silent_stepper.rb +829 -0
  8. data/lib/tinkerforge/brick_stepper.rb +47 -25
  9. data/lib/tinkerforge/bricklet_accelerometer.rb +11 -11
  10. data/lib/tinkerforge/bricklet_ambient_light.rb +12 -12
  11. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +8 -8
  12. data/lib/tinkerforge/bricklet_analog_in.rb +18 -18
  13. data/lib/tinkerforge/bricklet_analog_in_v2.rb +15 -15
  14. data/lib/tinkerforge/bricklet_analog_out.rb +3 -3
  15. data/lib/tinkerforge/bricklet_analog_out_v2.rb +3 -3
  16. data/lib/tinkerforge/bricklet_barometer.rb +19 -19
  17. data/lib/tinkerforge/bricklet_can.rb +20 -7
  18. data/lib/tinkerforge/bricklet_co2.rb +14 -14
  19. data/lib/tinkerforge/bricklet_color.rb +19 -19
  20. data/lib/tinkerforge/bricklet_current12.rb +16 -16
  21. data/lib/tinkerforge/bricklet_current25.rb +15 -15
  22. data/lib/tinkerforge/bricklet_distance_ir.rb +14 -14
  23. data/lib/tinkerforge/bricklet_distance_us.rb +9 -9
  24. data/lib/tinkerforge/bricklet_dual_button.rb +5 -5
  25. data/lib/tinkerforge/bricklet_dual_relay.rb +13 -13
  26. data/lib/tinkerforge/bricklet_dust_detector.rb +11 -11
  27. data/lib/tinkerforge/bricklet_gps.rb +21 -21
  28. data/lib/tinkerforge/bricklet_hall_effect.rb +12 -10
  29. data/lib/tinkerforge/bricklet_humidity.rb +21 -21
  30. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +3 -3
  31. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +4 -4
  32. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +4 -4
  33. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +6 -6
  34. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +6 -6
  35. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +5 -5
  36. data/lib/tinkerforge/bricklet_io16.rb +5 -5
  37. data/lib/tinkerforge/bricklet_io4.rb +5 -5
  38. data/lib/tinkerforge/bricklet_joystick.rb +16 -16
  39. data/lib/tinkerforge/bricklet_laser_range_finder.rb +99 -30
  40. data/lib/tinkerforge/bricklet_lcd_16x2.rb +5 -5
  41. data/lib/tinkerforge/bricklet_lcd_20x4.rb +5 -5
  42. data/lib/tinkerforge/bricklet_led_strip.rb +3 -3
  43. data/lib/tinkerforge/bricklet_line.rb +12 -12
  44. data/lib/tinkerforge/bricklet_linear_poti.rb +21 -21
  45. data/lib/tinkerforge/bricklet_load_cell.rb +10 -10
  46. data/lib/tinkerforge/bricklet_moisture.rb +12 -12
  47. data/lib/tinkerforge/bricklet_motion_detector.rb +5 -5
  48. data/lib/tinkerforge/bricklet_multi_touch.rb +3 -3
  49. data/lib/tinkerforge/bricklet_nfc_rfid.rb +20 -20
  50. data/lib/tinkerforge/bricklet_oled_128x64.rb +7 -7
  51. data/lib/tinkerforge/bricklet_oled_64x48.rb +6 -6
  52. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +4 -4
  53. data/lib/tinkerforge/bricklet_piezo_speaker.rb +5 -5
  54. data/lib/tinkerforge/bricklet_ptc.rb +21 -21
  55. data/lib/tinkerforge/bricklet_real_time_clock.rb +7 -7
  56. data/lib/tinkerforge/bricklet_remote_switch.rb +3 -3
  57. data/lib/tinkerforge/bricklet_rgb_led.rb +3 -3
  58. data/lib/tinkerforge/bricklet_rotary_encoder.rb +6 -6
  59. data/lib/tinkerforge/bricklet_rotary_poti.rb +23 -23
  60. data/lib/tinkerforge/bricklet_rs232.rb +19 -16
  61. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +5 -5
  62. data/lib/tinkerforge/bricklet_solid_state_relay.rb +12 -12
  63. data/lib/tinkerforge/bricklet_sound_intensity.rb +13 -12
  64. data/lib/tinkerforge/bricklet_temperature.rb +12 -12
  65. data/lib/tinkerforge/bricklet_temperature_ir.rb +30 -30
  66. data/lib/tinkerforge/bricklet_thermocouple.rb +13 -13
  67. data/lib/tinkerforge/bricklet_tilt.rb +3 -3
  68. data/lib/tinkerforge/bricklet_uv_light.rb +10 -10
  69. data/lib/tinkerforge/bricklet_voltage.rb +18 -18
  70. data/lib/tinkerforge/bricklet_voltage_current.rb +23 -23
  71. data/lib/tinkerforge/version.rb +1 -1
  72. metadata +3 -2
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2017-01-25. #
3
+ # This file was automatically generated on 2017-04-21. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.11 #
5
+ # Ruby Bindings Version 2.1.12 #
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 #
@@ -16,31 +16,31 @@ module Tinkerforge
16
16
  DEVICE_DISPLAY_NAME = 'Master Brick' # :nodoc:
17
17
 
18
18
  # This callback is triggered periodically with the period that is set by
19
- # BrickMaster#set_stack_current_callback_period. The parameter is the current of the
20
- # sensor.
19
+ # BrickMaster#set_stack_current_callback_period. The parameter is the current
20
+ # of the sensor.
21
21
  #
22
- # CALLBACK_STACK_CURRENT is only triggered if the current has changed since the
23
- # last triggering.
22
+ # The CALLBACK_STACK_CURRENT callback is only triggered if the current has changed
23
+ # since the last triggering.
24
24
  #
25
25
  # .. versionadded:: 2.0.5$nbsp;(Firmware)
26
26
  CALLBACK_STACK_CURRENT = 59
27
27
 
28
28
  # This callback is triggered periodically with the period that is set by
29
- # BrickMaster#set_stack_voltage_callback_period. The parameter is the voltage of the
30
- # sensor.
29
+ # BrickMaster#set_stack_voltage_callback_period. The parameter is the voltage
30
+ # of the sensor.
31
31
  #
32
- # CALLBACK_STACK_VOLTAGE is only triggered if the voltage has changed since the
33
- # last triggering.
32
+ # The CALLBACK_STACK_VOLTAGE callback is only triggered if the voltage has changed
33
+ # since the last triggering.
34
34
  #
35
35
  # .. versionadded:: 2.0.5$nbsp;(Firmware)
36
36
  CALLBACK_STACK_VOLTAGE = 60
37
37
 
38
38
  # This callback is triggered periodically with the period that is set by
39
- # BrickMaster#set_usb_voltage_callback_period. The parameter is the USB voltage
40
- # in mV.
39
+ # BrickMaster#set_usb_voltage_callback_period. The parameter is the USB
40
+ # voltage in mV.
41
41
  #
42
- # CALLBACK_USB_VOLTAGE is only triggered if the USB voltage has changed since the
43
- # last triggering.
42
+ # The CALLBACK_USB_VOLTAGE callback is only triggered if the USB voltage has changed
43
+ # since the last triggering.
44
44
  #
45
45
  # Does not work with hardware version 2.1.
46
46
  #
@@ -181,6 +181,7 @@ module Tinkerforge
181
181
  FUNCTION_GET_WIFI2_MESH_COMMON_STATUS = 108 # :nodoc:
182
182
  FUNCTION_GET_WIFI2_MESH_CLIENT_STATUS = 109 # :nodoc:
183
183
  FUNCTION_GET_WIFI2_MESH_AP_STATUS = 110 # :nodoc:
184
+ FUNCTION_GET_SEND_TIMEOUT_COUNT = 233 # :nodoc:
184
185
  FUNCTION_ENABLE_STATUS_LED = 238 # :nodoc:
185
186
  FUNCTION_DISABLE_STATUS_LED = 239 # :nodoc:
186
187
  FUNCTION_IS_STATUS_LED_ENABLED = 240 # :nodoc:
@@ -268,6 +269,14 @@ module Tinkerforge
268
269
  WIFI2_MESH_STATUS_AP_AVAILABLE = 5 # :nodoc:
269
270
  WIFI2_MESH_STATUS_AP_SETUP = 6 # :nodoc:
270
271
  WIFI2_MESH_STATUS_LEAF_AVAILABLE = 7 # :nodoc:
272
+ COMMUNICATION_METHOD_NONE = 0 # :nodoc:
273
+ COMMUNICATION_METHOD_USB = 1 # :nodoc:
274
+ COMMUNICATION_METHOD_SPI_STACK = 2 # :nodoc:
275
+ COMMUNICATION_METHOD_CHIBI = 3 # :nodoc:
276
+ COMMUNICATION_METHOD_RS485 = 4 # :nodoc:
277
+ COMMUNICATION_METHOD_WIFI = 5 # :nodoc:
278
+ COMMUNICATION_METHOD_ETHERNET = 6 # :nodoc:
279
+ COMMUNICATION_METHOD_WIFI_V2 = 7 # :nodoc:
271
280
 
272
281
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
273
282
  # the IP Connection <tt>ipcon</tt>.
@@ -386,6 +395,7 @@ module Tinkerforge
386
395
  @response_expected[FUNCTION_GET_WIFI2_MESH_COMMON_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
387
396
  @response_expected[FUNCTION_GET_WIFI2_MESH_CLIENT_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
388
397
  @response_expected[FUNCTION_GET_WIFI2_MESH_AP_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
398
+ @response_expected[FUNCTION_GET_SEND_TIMEOUT_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
389
399
  @response_expected[FUNCTION_ENABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE
390
400
  @response_expected[FUNCTION_DISABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE
391
401
  @response_expected[FUNCTION_IS_STATUS_LED_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -874,8 +884,8 @@ module Tinkerforge
874
884
  # Sets the period in ms with which the CALLBACK_STACK_CURRENT callback is triggered
875
885
  # periodically. A value of 0 turns the callback off.
876
886
  #
877
- # CALLBACK_STACK_CURRENT is only triggered if the current has changed since the
878
- # last triggering.
887
+ # The CALLBACK_STACK_CURRENT callback is only triggered if the current has changed
888
+ # since the last triggering.
879
889
  #
880
890
  # The default value is 0.
881
891
  #
@@ -894,8 +904,8 @@ module Tinkerforge
894
904
  # Sets the period in ms with which the CALLBACK_STACK_VOLTAGE callback is triggered
895
905
  # periodically. A value of 0 turns the callback off.
896
906
  #
897
- # CALLBACK_STACK_VOLTAGE is only triggered if the voltage has changed since the
898
- # last triggering.
907
+ # The CALLBACK_STACK_VOLTAGE callback is only triggered if the voltage has changed
908
+ # since the last triggering.
899
909
  #
900
910
  # The default value is 0.
901
911
  #
@@ -914,8 +924,8 @@ module Tinkerforge
914
924
  # Sets the period in ms with which the CALLBACK_USB_VOLTAGE callback is triggered
915
925
  # periodically. A value of 0 turns the callback off.
916
926
  #
917
- # CALLBACK_USB_VOLTAGE is only triggered if the voltage has changed since the
918
- # last triggering.
927
+ # The CALLBACK_USB_VOLTAGE callback is only triggered if the voltage has changed
928
+ # since the last triggering.
919
929
  #
920
930
  # The default value is 0.
921
931
  #
@@ -1162,7 +1172,8 @@ module Tinkerforge
1162
1172
  send_request(FUNCTION_SET_ETHERNET_AUTHENTICATION_SECRET, [secret], 'Z64', 0, '')
1163
1173
  end
1164
1174
 
1165
- # Returns the authentication secret as set by BrickMaster#set_ethernet_authentication_secret.
1175
+ # Returns the authentication secret as set by
1176
+ # BrickMaster#set_ethernet_authentication_secret.
1166
1177
  #
1167
1178
  # .. versionadded:: 2.2.0$nbsp;(Firmware)
1168
1179
  def get_ethernet_authentication_secret
@@ -1187,7 +1198,8 @@ module Tinkerforge
1187
1198
  send_request(FUNCTION_SET_WIFI_AUTHENTICATION_SECRET, [secret], 'Z64', 0, '')
1188
1199
  end
1189
1200
 
1190
- # Returns the authentication secret as set by BrickMaster#set_wifi_authentication_secret.
1201
+ # Returns the authentication secret as set by
1202
+ # BrickMaster#set_wifi_authentication_secret.
1191
1203
  #
1192
1204
  # .. versionadded:: 2.2.0$nbsp;(Firmware)
1193
1205
  def get_wifi_authentication_secret
@@ -1645,6 +1657,18 @@ module Tinkerforge
1645
1657
  send_request(FUNCTION_GET_WIFI2_MESH_AP_STATUS, [], '', 50, 'Z32 C4 C4 C4 C6')
1646
1658
  end
1647
1659
 
1660
+ # Returns the timeout count for the different communication methods.
1661
+ #
1662
+ # The methods 0-2 are available for all Bricks, 3-7 only for Master Bricks.
1663
+ #
1664
+ # This function is mostly used for debugging during development, in normal operation
1665
+ # the counters should nearly always stay at 0.
1666
+ #
1667
+ # .. versionadded:: 2.4.3$nbsp;(Firmware)
1668
+ def get_send_timeout_count(communication_method)
1669
+ send_request(FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 4, 'L')
1670
+ end
1671
+
1648
1672
  # Enables the status LED.
1649
1673
  #
1650
1674
  # The status LED is the blue LED next to the USB connector. If enabled is is
@@ -1705,7 +1729,7 @@ module Tinkerforge
1705
1729
  send_request(FUNCTION_RESET, [], '', 0, '')
1706
1730
  end
1707
1731
 
1708
- # Returns the UID, the UID where the Brick is connected to,
1732
+ # Returns the UID, the UID where the Brick is connected to,
1709
1733
  # the position, the hardware and firmware version as well as the
1710
1734
  # device identifier.
1711
1735
  #
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2017-01-25. #
3
+ # This file was automatically generated on 2017-04-21. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.11 #
5
+ # Ruby Bindings Version 2.1.12 #
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 #
@@ -831,7 +831,7 @@ module Tinkerforge
831
831
  send_request(FUNCTION_REMOVE_CUSTOM_PROGRAM_OPTION, [program_id, name_string_id], 'S S', 1, 'C')
832
832
  end
833
833
 
834
- # Returns the UID, the UID where the Brick is connected to,
834
+ # Returns the UID, the UID where the Brick is connected to,
835
835
  # the position, the hardware and firmware version as well as the
836
836
  # device identifier.
837
837
  #
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2017-01-25. #
3
+ # This file was automatically generated on 2017-04-21. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.11 #
5
+ # Ruby Bindings Version 2.1.12 #
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 #
@@ -75,6 +75,7 @@ module Tinkerforge
75
75
  FUNCTION_ENABLE_VELOCITY_REACHED_CALLBACK = 32 # :nodoc:
76
76
  FUNCTION_DISABLE_VELOCITY_REACHED_CALLBACK = 33 # :nodoc:
77
77
  FUNCTION_IS_VELOCITY_REACHED_CALLBACK_ENABLED = 34 # :nodoc:
78
+ FUNCTION_GET_SEND_TIMEOUT_COUNT = 233 # :nodoc:
78
79
  FUNCTION_ENABLE_STATUS_LED = 238 # :nodoc:
79
80
  FUNCTION_DISABLE_STATUS_LED = 239 # :nodoc:
80
81
  FUNCTION_IS_STATUS_LED_ENABLED = 240 # :nodoc:
@@ -83,6 +84,14 @@ module Tinkerforge
83
84
  FUNCTION_RESET = 243 # :nodoc:
84
85
  FUNCTION_GET_IDENTITY = 255 # :nodoc:
85
86
 
87
+ COMMUNICATION_METHOD_NONE = 0 # :nodoc:
88
+ COMMUNICATION_METHOD_USB = 1 # :nodoc:
89
+ COMMUNICATION_METHOD_SPI_STACK = 2 # :nodoc:
90
+ COMMUNICATION_METHOD_CHIBI = 3 # :nodoc:
91
+ COMMUNICATION_METHOD_RS485 = 4 # :nodoc:
92
+ COMMUNICATION_METHOD_WIFI = 5 # :nodoc:
93
+ COMMUNICATION_METHOD_ETHERNET = 6 # :nodoc:
94
+ COMMUNICATION_METHOD_WIFI_V2 = 7 # :nodoc:
86
95
 
87
96
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
88
97
  # the IP Connection <tt>ipcon</tt>.
@@ -125,6 +134,7 @@ module Tinkerforge
125
134
  @response_expected[FUNCTION_ENABLE_VELOCITY_REACHED_CALLBACK] = RESPONSE_EXPECTED_TRUE
126
135
  @response_expected[FUNCTION_DISABLE_VELOCITY_REACHED_CALLBACK] = RESPONSE_EXPECTED_TRUE
127
136
  @response_expected[FUNCTION_IS_VELOCITY_REACHED_CALLBACK_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
137
+ @response_expected[FUNCTION_GET_SEND_TIMEOUT_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
128
138
  @response_expected[FUNCTION_ENABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE
129
139
  @response_expected[FUNCTION_DISABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE
130
140
  @response_expected[FUNCTION_IS_STATUS_LED_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -155,7 +165,7 @@ module Tinkerforge
155
165
  send_request(FUNCTION_IS_ENABLED, [servo_num], 'C', 1, '?')
156
166
  end
157
167
 
158
- # Sets the position in °/100 for the specified servo.
168
+ # Sets the position in °/100 for the specified servo.
159
169
  #
160
170
  # The default range of the position is -9000 to 9000, but it can be specified
161
171
  # according to your servo with BrickServo#set_degree.
@@ -212,14 +222,14 @@ module Tinkerforge
212
222
  send_request(FUNCTION_SET_ACCELERATION, [servo_num, acceleration], 'C S', 0, '')
213
223
  end
214
224
 
215
- # Returns the acceleration for the specified servo as set by
225
+ # Returns the acceleration for the specified servo as set by
216
226
  # BrickServo#set_acceleration.
217
227
  def get_acceleration(servo_num)
218
228
  send_request(FUNCTION_GET_ACCELERATION, [servo_num], 'C', 2, 'S')
219
229
  end
220
230
 
221
231
  # Sets the output voltages with which the servos are driven in mV.
222
- # The minimum output voltage is 2000mV and the maximum output voltage is
232
+ # The minimum output voltage is 2000mV and the maximum output voltage is
223
233
  # 9000mV.
224
234
  #
225
235
  # .. note::
@@ -239,7 +249,7 @@ module Tinkerforge
239
249
 
240
250
  # Sets the minimum and maximum pulse width of the specified servo in µs.
241
251
  #
242
- # Usually, servos are controlled with a
252
+ # Usually, servos are controlled with a
243
253
  # `PWM <https://en.wikipedia.org/wiki/Pulse-width_modulation>`__, whereby the
244
254
  # length of the pulse controls the position of the servo. Every servo has
245
255
  # different minimum and maximum pulse widths, these can be specified with
@@ -252,7 +262,7 @@ module Tinkerforge
252
262
  # Both values have a range from 1 to 65535 (unsigned 16-bit integer). The
253
263
  # minimum must be smaller than the maximum.
254
264
  #
255
- # The default values are 1000µs (1ms) and 2000µs (2ms) for minimum and
265
+ # The default values are 1000µs (1ms) and 2000µs (2ms) for minimum and
256
266
  # maximum pulse width.
257
267
  def set_pulse_width(servo_num, min, max)
258
268
  send_request(FUNCTION_SET_PULSE_WIDTH, [servo_num, min, max], 'C S S', 0, '')
@@ -270,7 +280,7 @@ module Tinkerforge
270
280
  # This only specifies the abstract values between which the minimum and maximum
271
281
  # pulse width is scaled. For example: If you specify a pulse width of 1000µs
272
282
  # to 2000µs and a degree range of -90° to 90°, a call of BrickServo#set_position
273
- # with 0 will result in a pulse width of 1500µs
283
+ # with 0 will result in a pulse width of 1500µs
274
284
  # (-90° = 1000µs, 90° = 2000µs, etc.).
275
285
  #
276
286
  # Possible usage:
@@ -290,7 +300,7 @@ module Tinkerforge
290
300
  # control it with a RC brushless motor controller. In this case you can set the
291
301
  # minimum to 0 and the maximum to 10000. BrickServo#set_position now controls the rpm.
292
302
  #
293
- # Both values have a possible range from -32767 to 32767
303
+ # Both values have a possible range from -32767 to 32767
294
304
  # (signed 16-bit integer). The minimum must be smaller than the maximum.
295
305
  #
296
306
  # The default values are -9000 and 9000 for the minimum and maximum degree.
@@ -306,15 +316,15 @@ module Tinkerforge
306
316
 
307
317
  # Sets the period of the specified servo in µs.
308
318
  #
309
- # Usually, servos are controlled with a
319
+ # Usually, servos are controlled with a
310
320
  # `PWM <https://en.wikipedia.org/wiki/Pulse-width_modulation>`__. Different
311
- # servos expect PWMs with different periods. Most servos run well with a
321
+ # servos expect PWMs with different periods. Most servos run well with a
312
322
  # period of about 20ms.
313
323
  #
314
324
  # If your servo comes with a datasheet that specifies a period, you should
315
325
  # set it accordingly. If you don't have a datasheet and you have no idea
316
326
  # what the correct period is, the default value (19.5ms) will most likely
317
- # work fine.
327
+ # work fine.
318
328
  #
319
329
  # The minimum possible period is 1µs and the maximum is 65535µs.
320
330
  #
@@ -339,17 +349,17 @@ module Tinkerforge
339
349
  end
340
350
 
341
351
  # Returns the stack input voltage in mV. The stack input voltage is the
342
- # voltage that is supplied via the stack, i.e. it is given by a
352
+ # voltage that is supplied via the stack, i.e. it is given by a
343
353
  # Step-Down or Step-Up Power Supply.
344
354
  def get_stack_input_voltage
345
355
  send_request(FUNCTION_GET_STACK_INPUT_VOLTAGE, [], '', 2, 'S')
346
356
  end
347
357
 
348
358
  # Returns the external input voltage in mV. The external input voltage is
349
- # given via the black power input connector on the Servo Brick.
350
- #
359
+ # given via the black power input connector on the Servo Brick.
360
+ #
351
361
  # If there is an external input voltage and a stack input voltage, the motors
352
- # will be driven by the external input voltage. If there is only a stack
362
+ # will be driven by the external input voltage. If there is only a stack
353
363
  # voltage present, the motors will be driven by this voltage.
354
364
  #
355
365
  # .. warning::
@@ -364,7 +374,7 @@ module Tinkerforge
364
374
  # Sets the minimum voltage in mV, below which the CALLBACK_UNDER_VOLTAGE callback
365
375
  # is triggered. The minimum possible value that works with the Servo Brick is 5V.
366
376
  # You can use this function to detect the discharge of a battery that is used
367
- # to drive the stepper motor. If you have a fixed power supply, you likely do
377
+ # to drive the stepper motor. If you have a fixed power supply, you likely do
368
378
  # not need this functionality.
369
379
  #
370
380
  # The default value is 5V (5000mV).
@@ -427,6 +437,18 @@ module Tinkerforge
427
437
  send_request(FUNCTION_IS_VELOCITY_REACHED_CALLBACK_ENABLED, [], '', 1, '?')
428
438
  end
429
439
 
440
+ # Returns the timeout count for the different communication methods.
441
+ #
442
+ # The methods 0-2 are available for all Bricks, 3-7 only for Master Bricks.
443
+ #
444
+ # This function is mostly used for debugging during development, in normal operation
445
+ # the counters should nearly always stay at 0.
446
+ #
447
+ # .. versionadded:: 2.3.2$nbsp;(Firmware)
448
+ def get_send_timeout_count(communication_method)
449
+ send_request(FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 4, 'L')
450
+ end
451
+
430
452
  # Enables the status LED.
431
453
  #
432
454
  # The status LED is the blue LED next to the USB connector. If enabled is is
@@ -487,7 +509,7 @@ module Tinkerforge
487
509
  send_request(FUNCTION_RESET, [], '', 0, '')
488
510
  end
489
511
 
490
- # Returns the UID, the UID where the Brick is connected to,
512
+ # Returns the UID, the UID where the Brick is connected to,
491
513
  # the position, the hardware and firmware version as well as the
492
514
  # device identifier.
493
515
  #
@@ -0,0 +1,829 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2017-04-21. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.12 #
6
+ # #
7
+ # If you have a bugfix for this file and want to commit it, #
8
+ # please fix the bug in the generator. You can find a link #
9
+ # to the generators git repository on tinkerforge.com #
10
+ #############################################################
11
+
12
+ module Tinkerforge
13
+ # Silently drives one bipolar stepper motor with up to 46V and 1.6A per phase
14
+ class BrickSilentStepper < Device
15
+ DEVICE_IDENTIFIER = 19 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'Silent Stepper Brick' # :nodoc:
17
+
18
+ # 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 given
20
+ # in mV.
21
+ CALLBACK_UNDER_VOLTAGE = 40
22
+
23
+ # This callback is triggered when a position set by BrickSilentStepper#set_steps or
24
+ # BrickSilentStepper#set_target_position is reached.
25
+ #
26
+ # .. note::
27
+ # Since we can't get any feedback from the stepper motor, this only works if the
28
+ # acceleration (see BrickSilentStepper#set_speed_ramping) is set smaller or equal to the
29
+ # maximum acceleration of the motor. Otherwise the motor will lag behind the
30
+ # control value and the callback will be triggered too early.
31
+ CALLBACK_POSITION_REACHED = 41
32
+
33
+ # This callback is triggered periodically with the period that is set by
34
+ # BrickSilentStepper#set_all_data_period. The parameters are: the current velocity,
35
+ # the current position, the remaining steps, the stack voltage, the external
36
+ # voltage and the current consumption of the stepper motor.
37
+ CALLBACK_ALL_DATA = 47
38
+
39
+ # This callback is triggered whenever the Slient Stepper Brick enters a new state.
40
+ # It returns the new state as well as the previous state.
41
+ CALLBACK_NEW_STATE = 48
42
+
43
+ FUNCTION_SET_MAX_VELOCITY = 1 # :nodoc:
44
+ FUNCTION_GET_MAX_VELOCITY = 2 # :nodoc:
45
+ FUNCTION_GET_CURRENT_VELOCITY = 3 # :nodoc:
46
+ FUNCTION_SET_SPEED_RAMPING = 4 # :nodoc:
47
+ FUNCTION_GET_SPEED_RAMPING = 5 # :nodoc:
48
+ FUNCTION_FULL_BRAKE = 6 # :nodoc:
49
+ FUNCTION_SET_CURRENT_POSITION = 7 # :nodoc:
50
+ FUNCTION_GET_CURRENT_POSITION = 8 # :nodoc:
51
+ FUNCTION_SET_TARGET_POSITION = 9 # :nodoc:
52
+ FUNCTION_GET_TARGET_POSITION = 10 # :nodoc:
53
+ FUNCTION_SET_STEPS = 11 # :nodoc:
54
+ FUNCTION_GET_STEPS = 12 # :nodoc:
55
+ FUNCTION_GET_REMAINING_STEPS = 13 # :nodoc:
56
+ FUNCTION_SET_STEP_CONFIGURATION = 14 # :nodoc:
57
+ FUNCTION_GET_STEP_CONFIGURATION = 15 # :nodoc:
58
+ FUNCTION_DRIVE_FORWARD = 16 # :nodoc:
59
+ FUNCTION_DRIVE_BACKWARD = 17 # :nodoc:
60
+ FUNCTION_STOP = 18 # :nodoc:
61
+ FUNCTION_GET_STACK_INPUT_VOLTAGE = 19 # :nodoc:
62
+ FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE = 20 # :nodoc:
63
+ FUNCTION_GET_CURRENT_CONSUMPTION = 21 # :nodoc:
64
+ FUNCTION_SET_MOTOR_CURRENT = 22 # :nodoc:
65
+ FUNCTION_GET_MOTOR_CURRENT = 23 # :nodoc:
66
+ FUNCTION_ENABLE = 24 # :nodoc:
67
+ FUNCTION_DISABLE = 25 # :nodoc:
68
+ FUNCTION_IS_ENABLED = 26 # :nodoc:
69
+ FUNCTION_SET_BASIC_CONFIGURATION = 27 # :nodoc:
70
+ FUNCTION_GET_BASIC_CONFIGURATION = 28 # :nodoc:
71
+ FUNCTION_SET_SPREADCYCLE_CONFIGURATION = 29 # :nodoc:
72
+ FUNCTION_GET_SPREADCYCLE_CONFIGURATION = 30 # :nodoc:
73
+ FUNCTION_SET_STEALTH_CONFIGURATION = 31 # :nodoc:
74
+ FUNCTION_GET_STEALTH_CONFIGURATION = 32 # :nodoc:
75
+ FUNCTION_SET_COOLSTEP_CONFIGURATION = 33 # :nodoc:
76
+ FUNCTION_GET_COOLSTEP_CONFIGURATION = 34 # :nodoc:
77
+ FUNCTION_SET_MISC_CONFIGURATION = 35 # :nodoc:
78
+ FUNCTION_GET_MISC_CONFIGURATION = 36 # :nodoc:
79
+ FUNCTION_GET_DRIVER_STATUS = 37 # :nodoc:
80
+ FUNCTION_SET_MINIMUM_VOLTAGE = 38 # :nodoc:
81
+ FUNCTION_GET_MINIMUM_VOLTAGE = 39 # :nodoc:
82
+ FUNCTION_SET_TIME_BASE = 42 # :nodoc:
83
+ FUNCTION_GET_TIME_BASE = 43 # :nodoc:
84
+ FUNCTION_GET_ALL_DATA = 44 # :nodoc:
85
+ FUNCTION_SET_ALL_DATA_PERIOD = 45 # :nodoc:
86
+ FUNCTION_GET_ALL_DATA_PERIOD = 46 # :nodoc:
87
+ FUNCTION_GET_SEND_TIMEOUT_COUNT = 233 # :nodoc:
88
+ FUNCTION_ENABLE_STATUS_LED = 238 # :nodoc:
89
+ FUNCTION_DISABLE_STATUS_LED = 239 # :nodoc:
90
+ FUNCTION_IS_STATUS_LED_ENABLED = 240 # :nodoc:
91
+ FUNCTION_GET_PROTOCOL1_BRICKLET_NAME = 241 # :nodoc:
92
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
93
+ FUNCTION_RESET = 243 # :nodoc:
94
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
95
+
96
+ STEP_RESOLUTION_1 = 8 # :nodoc:
97
+ STEP_RESOLUTION_2 = 7 # :nodoc:
98
+ STEP_RESOLUTION_4 = 6 # :nodoc:
99
+ STEP_RESOLUTION_8 = 5 # :nodoc:
100
+ STEP_RESOLUTION_16 = 4 # :nodoc:
101
+ STEP_RESOLUTION_32 = 3 # :nodoc:
102
+ STEP_RESOLUTION_64 = 2 # :nodoc:
103
+ STEP_RESOLUTION_128 = 1 # :nodoc:
104
+ STEP_RESOLUTION_256 = 0 # :nodoc:
105
+ CHOPPER_MODE_SPREAD_CYCLE = 0 # :nodoc:
106
+ CHOPPER_MODE_FAST_DECAY = 1 # :nodoc:
107
+ FREEWHEEL_MODE_NORMAL = 0 # :nodoc:
108
+ FREEWHEEL_MODE_FREEWHEELING = 1 # :nodoc:
109
+ FREEWHEEL_MODE_COIL_SHORT_LS = 2 # :nodoc:
110
+ FREEWHEEL_MODE_COIL_SHORT_HS = 3 # :nodoc:
111
+ CURRENT_UP_STEP_INCREMENT_1 = 0 # :nodoc:
112
+ CURRENT_UP_STEP_INCREMENT_2 = 1 # :nodoc:
113
+ CURRENT_UP_STEP_INCREMENT_4 = 2 # :nodoc:
114
+ CURRENT_UP_STEP_INCREMENT_8 = 3 # :nodoc:
115
+ CURRENT_DOWN_STEP_DECREMENT_1 = 0 # :nodoc:
116
+ CURRENT_DOWN_STEP_DECREMENT_2 = 1 # :nodoc:
117
+ CURRENT_DOWN_STEP_DECREMENT_8 = 2 # :nodoc:
118
+ CURRENT_DOWN_STEP_DECREMENT_32 = 3 # :nodoc:
119
+ MINIMUM_CURRENT_HALF = 0 # :nodoc:
120
+ MINIMUM_CURRENT_QUARTER = 1 # :nodoc:
121
+ STALLGUARD_MODE_STANDARD = 0 # :nodoc:
122
+ STALLGUARD_MODE_FILTERED = 1 # :nodoc:
123
+ OPEN_LOAD_NONE = 0 # :nodoc:
124
+ OPEN_LOAD_PHASE_A = 1 # :nodoc:
125
+ OPEN_LOAD_PHASE_B = 2 # :nodoc:
126
+ OPEN_LOAD_PHASE_AB = 3 # :nodoc:
127
+ SHORT_TO_GROUND_NONE = 0 # :nodoc:
128
+ SHORT_TO_GROUND_PHASE_A = 1 # :nodoc:
129
+ SHORT_TO_GROUND_PHASE_B = 2 # :nodoc:
130
+ SHORT_TO_GROUND_PHASE_AB = 3 # :nodoc:
131
+ OVER_TEMPERATURE_NONE = 0 # :nodoc:
132
+ OVER_TEMPERATURE_WARNING = 1 # :nodoc:
133
+ OVER_TEMPERATURE_LIMIT = 2 # :nodoc:
134
+ STATE_STOP = 1 # :nodoc:
135
+ STATE_ACCELERATION = 2 # :nodoc:
136
+ STATE_RUN = 3 # :nodoc:
137
+ STATE_DEACCELERATION = 4 # :nodoc:
138
+ STATE_DIRECTION_CHANGE_TO_FORWARD = 5 # :nodoc:
139
+ STATE_DIRECTION_CHANGE_TO_BACKWARD = 6 # :nodoc:
140
+ COMMUNICATION_METHOD_NONE = 0 # :nodoc:
141
+ COMMUNICATION_METHOD_USB = 1 # :nodoc:
142
+ COMMUNICATION_METHOD_SPI_STACK = 2 # :nodoc:
143
+ COMMUNICATION_METHOD_CHIBI = 3 # :nodoc:
144
+ COMMUNICATION_METHOD_RS485 = 4 # :nodoc:
145
+ COMMUNICATION_METHOD_WIFI = 5 # :nodoc:
146
+ COMMUNICATION_METHOD_ETHERNET = 6 # :nodoc:
147
+ COMMUNICATION_METHOD_WIFI_V2 = 7 # :nodoc:
148
+
149
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
150
+ # the IP Connection <tt>ipcon</tt>.
151
+ def initialize(uid, ipcon)
152
+ super uid, ipcon
153
+
154
+ @api_version = [2, 0, 0]
155
+
156
+ @response_expected[FUNCTION_SET_MAX_VELOCITY] = RESPONSE_EXPECTED_FALSE
157
+ @response_expected[FUNCTION_GET_MAX_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
158
+ @response_expected[FUNCTION_GET_CURRENT_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
159
+ @response_expected[FUNCTION_SET_SPEED_RAMPING] = RESPONSE_EXPECTED_FALSE
160
+ @response_expected[FUNCTION_GET_SPEED_RAMPING] = RESPONSE_EXPECTED_ALWAYS_TRUE
161
+ @response_expected[FUNCTION_FULL_BRAKE] = RESPONSE_EXPECTED_FALSE
162
+ @response_expected[FUNCTION_SET_CURRENT_POSITION] = RESPONSE_EXPECTED_FALSE
163
+ @response_expected[FUNCTION_GET_CURRENT_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
164
+ @response_expected[FUNCTION_SET_TARGET_POSITION] = RESPONSE_EXPECTED_FALSE
165
+ @response_expected[FUNCTION_GET_TARGET_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
166
+ @response_expected[FUNCTION_SET_STEPS] = RESPONSE_EXPECTED_FALSE
167
+ @response_expected[FUNCTION_GET_STEPS] = RESPONSE_EXPECTED_ALWAYS_TRUE
168
+ @response_expected[FUNCTION_GET_REMAINING_STEPS] = RESPONSE_EXPECTED_ALWAYS_TRUE
169
+ @response_expected[FUNCTION_SET_STEP_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
170
+ @response_expected[FUNCTION_GET_STEP_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
171
+ @response_expected[FUNCTION_DRIVE_FORWARD] = RESPONSE_EXPECTED_FALSE
172
+ @response_expected[FUNCTION_DRIVE_BACKWARD] = RESPONSE_EXPECTED_FALSE
173
+ @response_expected[FUNCTION_STOP] = RESPONSE_EXPECTED_FALSE
174
+ @response_expected[FUNCTION_GET_STACK_INPUT_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
175
+ @response_expected[FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
176
+ @response_expected[FUNCTION_GET_CURRENT_CONSUMPTION] = RESPONSE_EXPECTED_ALWAYS_TRUE
177
+ @response_expected[FUNCTION_SET_MOTOR_CURRENT] = RESPONSE_EXPECTED_FALSE
178
+ @response_expected[FUNCTION_GET_MOTOR_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
179
+ @response_expected[FUNCTION_ENABLE] = RESPONSE_EXPECTED_FALSE
180
+ @response_expected[FUNCTION_DISABLE] = RESPONSE_EXPECTED_FALSE
181
+ @response_expected[FUNCTION_IS_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
182
+ @response_expected[FUNCTION_SET_BASIC_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
183
+ @response_expected[FUNCTION_GET_BASIC_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
184
+ @response_expected[FUNCTION_SET_SPREADCYCLE_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
185
+ @response_expected[FUNCTION_GET_SPREADCYCLE_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
186
+ @response_expected[FUNCTION_SET_STEALTH_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
187
+ @response_expected[FUNCTION_GET_STEALTH_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
188
+ @response_expected[FUNCTION_SET_COOLSTEP_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
189
+ @response_expected[FUNCTION_GET_COOLSTEP_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
190
+ @response_expected[FUNCTION_SET_MISC_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
191
+ @response_expected[FUNCTION_GET_MISC_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
192
+ @response_expected[FUNCTION_GET_DRIVER_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
193
+ @response_expected[FUNCTION_SET_MINIMUM_VOLTAGE] = RESPONSE_EXPECTED_TRUE
194
+ @response_expected[FUNCTION_GET_MINIMUM_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
195
+ @response_expected[CALLBACK_UNDER_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_FALSE
196
+ @response_expected[CALLBACK_POSITION_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
197
+ @response_expected[FUNCTION_SET_TIME_BASE] = RESPONSE_EXPECTED_FALSE
198
+ @response_expected[FUNCTION_GET_TIME_BASE] = RESPONSE_EXPECTED_ALWAYS_TRUE
199
+ @response_expected[FUNCTION_GET_ALL_DATA] = RESPONSE_EXPECTED_ALWAYS_TRUE
200
+ @response_expected[FUNCTION_SET_ALL_DATA_PERIOD] = RESPONSE_EXPECTED_TRUE
201
+ @response_expected[FUNCTION_GET_ALL_DATA_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
202
+ @response_expected[CALLBACK_ALL_DATA] = RESPONSE_EXPECTED_ALWAYS_FALSE
203
+ @response_expected[CALLBACK_NEW_STATE] = RESPONSE_EXPECTED_ALWAYS_FALSE
204
+ @response_expected[FUNCTION_GET_SEND_TIMEOUT_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
205
+ @response_expected[FUNCTION_ENABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE
206
+ @response_expected[FUNCTION_DISABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE
207
+ @response_expected[FUNCTION_IS_STATUS_LED_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
208
+ @response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
209
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
210
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
211
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
212
+
213
+ @callback_formats[CALLBACK_UNDER_VOLTAGE] = 'S'
214
+ @callback_formats[CALLBACK_POSITION_REACHED] = 'l'
215
+ @callback_formats[CALLBACK_ALL_DATA] = 'S l l S S S'
216
+ @callback_formats[CALLBACK_NEW_STATE] = 'C C'
217
+ end
218
+
219
+ # Sets the maximum velocity of the stepper motor in steps per second.
220
+ # This function does *not* start the motor, it merely sets the maximum
221
+ # velocity the stepper motor is accelerated to. To get the motor running use
222
+ # either BrickSilentStepper#set_target_position, BrickSilentStepper#set_steps, BrickSilentStepper#drive_forward or
223
+ # BrickSilentStepper#drive_backward.
224
+ def set_max_velocity(velocity)
225
+ send_request(FUNCTION_SET_MAX_VELOCITY, [velocity], 'S', 0, '')
226
+ end
227
+
228
+ # Returns the velocity as set by BrickSilentStepper#set_max_velocity.
229
+ def get_max_velocity
230
+ send_request(FUNCTION_GET_MAX_VELOCITY, [], '', 2, 'S')
231
+ end
232
+
233
+ # Returns the *current* velocity of the stepper motor in steps per second.
234
+ def get_current_velocity
235
+ send_request(FUNCTION_GET_CURRENT_VELOCITY, [], '', 2, 'S')
236
+ end
237
+
238
+ # Sets the acceleration and deacceleration of the stepper motor. The values
239
+ # are given in *steps/s²*. An acceleration of 1000 means, that
240
+ # every second the velocity is increased by 1000 *steps/s*.
241
+ #
242
+ # For example: If the current velocity is 0 and you want to accelerate to a
243
+ # velocity of 8000 *steps/s* in 10 seconds, you should set an acceleration
244
+ # of 800 *steps/s²*.
245
+ #
246
+ # An acceleration/deacceleration of 0 means instantaneous
247
+ # acceleration/deacceleration (not recommended)
248
+ #
249
+ # The default value is 1000 for both
250
+ def set_speed_ramping(acceleration, deacceleration)
251
+ send_request(FUNCTION_SET_SPEED_RAMPING, [acceleration, deacceleration], 'S S', 0, '')
252
+ end
253
+
254
+ # Returns the acceleration and deacceleration as set by
255
+ # BrickSilentStepper#set_speed_ramping.
256
+ def get_speed_ramping
257
+ send_request(FUNCTION_GET_SPEED_RAMPING, [], '', 4, 'S S')
258
+ end
259
+
260
+ # Executes an active full brake.
261
+ #
262
+ # .. warning::
263
+ # This function is for emergency purposes,
264
+ # where an immediate brake is necessary. Depending on the current velocity and
265
+ # the strength of the motor, a full brake can be quite violent.
266
+ #
267
+ # Call BrickSilentStepper#stop if you just want to stop the motor.
268
+ def full_brake
269
+ send_request(FUNCTION_FULL_BRAKE, [], '', 0, '')
270
+ end
271
+
272
+ # Sets the current steps of the internal step counter. This can be used to
273
+ # set the current position to 0 when some kind of starting position
274
+ # is reached (e.g. when a CNC machine reaches a corner).
275
+ def set_current_position(position)
276
+ send_request(FUNCTION_SET_CURRENT_POSITION, [position], 'l', 0, '')
277
+ end
278
+
279
+ # Returns the current position of the stepper motor in steps. On startup
280
+ # the position is 0. The steps are counted with all possible driving
281
+ # functions (BrickSilentStepper#set_target_position, BrickSilentStepper#set_steps, BrickSilentStepper#drive_forward or
282
+ # BrickSilentStepper#drive_backward). It also is possible to reset the steps to 0 or
283
+ # set them to any other desired value with BrickSilentStepper#set_current_position.
284
+ def get_current_position
285
+ send_request(FUNCTION_GET_CURRENT_POSITION, [], '', 4, 'l')
286
+ end
287
+
288
+ # Sets the target position of the stepper motor in steps. For example,
289
+ # if the current position of the motor is 500 and BrickSilentStepper#set_target_position is
290
+ # called with 1000, the stepper motor will drive 500 steps forward. It will
291
+ # use the velocity, acceleration and deacceleration as set by
292
+ # BrickSilentStepper#set_max_velocity and BrickSilentStepper#set_speed_ramping.
293
+ #
294
+ # A call of BrickSilentStepper#set_target_position with the parameter *x* is equivalent to
295
+ # a call of BrickSilentStepper#set_steps with the parameter
296
+ # (*x* - BrickSilentStepper#get_current_position).
297
+ def set_target_position(position)
298
+ send_request(FUNCTION_SET_TARGET_POSITION, [position], 'l', 0, '')
299
+ end
300
+
301
+ # Returns the last target position as set by BrickSilentStepper#set_target_position.
302
+ def get_target_position
303
+ send_request(FUNCTION_GET_TARGET_POSITION, [], '', 4, 'l')
304
+ end
305
+
306
+ # Sets the number of steps the stepper motor should run. Positive values
307
+ # will drive the motor forward and negative values backward.
308
+ # The velocity, acceleration and deacceleration as set by
309
+ # BrickSilentStepper#set_max_velocity and BrickSilentStepper#set_speed_ramping will be used.
310
+ def set_steps(steps)
311
+ send_request(FUNCTION_SET_STEPS, [steps], 'l', 0, '')
312
+ end
313
+
314
+ # Returns the last steps as set by BrickSilentStepper#set_steps.
315
+ def get_steps
316
+ send_request(FUNCTION_GET_STEPS, [], '', 4, 'l')
317
+ end
318
+
319
+ # Returns the remaining steps of the last call of BrickSilentStepper#set_steps.
320
+ # For example, if BrickSilentStepper#set_steps is called with 2000 and
321
+ # BrickSilentStepper#get_remaining_steps is called after the motor has run for 500 steps,
322
+ # it will return 1500.
323
+ def get_remaining_steps
324
+ send_request(FUNCTION_GET_REMAINING_STEPS, [], '', 4, 'l')
325
+ end
326
+
327
+ # Sets the step resolution from full-step up to 1/256-step.
328
+ #
329
+ # If interpolation is turned on, the Silent Stepper Brick will always interpolate
330
+ # your step inputs as 1/256-step. If you use full-step mode with interpolation, each
331
+ # step will generate 256 1/256 steps.
332
+ #
333
+ # For maximum torque use full-step without interpolation. For maximum resolution use
334
+ # 1/256-step. Turn interpolation on to make the Stepper driving less noisy.
335
+ #
336
+ # If you often change the speed with high acceleration you should turn the
337
+ # interpolation off.
338
+ #
339
+ # The default is 1/256-step with interpolation on.
340
+ def set_step_configuration(step_resolution, interpolation)
341
+ send_request(FUNCTION_SET_STEP_CONFIGURATION, [step_resolution, interpolation], 'C ?', 0, '')
342
+ end
343
+
344
+ # Returns the step mode as set by BrickSilentStepper#set_step_configuration.
345
+ def get_step_configuration
346
+ send_request(FUNCTION_GET_STEP_CONFIGURATION, [], '', 2, 'C ?')
347
+ end
348
+
349
+ # Drives the stepper motor forward until BrickSilentStepper#drive_backward or
350
+ # BrickSilentStepper#stop is called. The velocity, acceleration and deacceleration as
351
+ # set by BrickSilentStepper#set_max_velocity and BrickSilentStepper#set_speed_ramping will be used.
352
+ def drive_forward
353
+ send_request(FUNCTION_DRIVE_FORWARD, [], '', 0, '')
354
+ end
355
+
356
+ # Drives the stepper motor backward until BrickSilentStepper#drive_forward or
357
+ # BrickSilentStepper#stop is triggered. The velocity, acceleration and deacceleration as
358
+ # set by BrickSilentStepper#set_max_velocity and BrickSilentStepper#set_speed_ramping will be used.
359
+ def drive_backward
360
+ send_request(FUNCTION_DRIVE_BACKWARD, [], '', 0, '')
361
+ end
362
+
363
+ # Stops the stepper motor with the deacceleration as set by
364
+ # BrickSilentStepper#set_speed_ramping.
365
+ def stop
366
+ send_request(FUNCTION_STOP, [], '', 0, '')
367
+ end
368
+
369
+ # Returns the stack input voltage in mV. The stack input voltage is the
370
+ # voltage that is supplied via the stack, i.e. it is given by a
371
+ # Step-Down or Step-Up Power Supply.
372
+ def get_stack_input_voltage
373
+ send_request(FUNCTION_GET_STACK_INPUT_VOLTAGE, [], '', 2, 'S')
374
+ end
375
+
376
+ # Returns the external input voltage in mV. The external input voltage is
377
+ # given via the black power input connector on the Slient Stepper Brick.
378
+ #
379
+ # If there is an external input voltage and a stack input voltage, the motor
380
+ # will be driven by the external input voltage. If there is only a stack
381
+ # voltage present, the motor will be driven by this voltage.
382
+ #
383
+ # .. warning::
384
+ # This means, if you have a high stack voltage and a low external voltage,
385
+ # the motor will be driven with the low external voltage. If you then remove
386
+ # the external connection, it will immediately be driven by the high
387
+ # stack voltage
388
+ def get_external_input_voltage
389
+ send_request(FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE, [], '', 2, 'S')
390
+ end
391
+
392
+ # Returns the current consumption of the motor in mA.
393
+ def get_current_consumption
394
+ send_request(FUNCTION_GET_CURRENT_CONSUMPTION, [], '', 2, 'S')
395
+ end
396
+
397
+ # Sets the current in mA with which the motor will be driven.
398
+ # The minimum value is 360mA, the maximum value 1640mA and the
399
+ # default value is 800mA.
400
+ #
401
+ # .. warning::
402
+ # Do not set this value above the specifications of your stepper motor.
403
+ # Otherwise it may damage your motor.
404
+ def set_motor_current(current)
405
+ send_request(FUNCTION_SET_MOTOR_CURRENT, [current], 'S', 0, '')
406
+ end
407
+
408
+ # Returns the current as set by BrickSilentStepper#set_motor_current.
409
+ def get_motor_current
410
+ send_request(FUNCTION_GET_MOTOR_CURRENT, [], '', 2, 'S')
411
+ end
412
+
413
+ # Enables the driver chip. The driver parameters can be configured (maximum velocity,
414
+ # acceleration, etc) before it is enabled.
415
+ def enable
416
+ send_request(FUNCTION_ENABLE, [], '', 0, '')
417
+ end
418
+
419
+ # Disables the driver chip. The configurations are kept (maximum velocity,
420
+ # acceleration, etc) but the motor is not driven until it is enabled again.
421
+ def disable
422
+ send_request(FUNCTION_DISABLE, [], '', 0, '')
423
+ end
424
+
425
+ # Returns *true* if the driver chip is enabled, *false* otherwise.
426
+ def is_enabled
427
+ send_request(FUNCTION_IS_ENABLED, [], '', 1, '?')
428
+ end
429
+
430
+ # Sets the basic configuration parameters for the different modes (Stealth, Coolstep, Classic).
431
+ #
432
+ # * Standstill Current: This value can be used to lower the current during stand still. This might
433
+ # be reasonable to reduce the heating of the motor and the Brick. When the motor is in standstill
434
+ # the configured motor phase current will be driven until the configured
435
+ # Power Down Time is elapsed. After that the phase current will be reduced to the standstill
436
+ # current. The elapsed time for this reduction can be configured with the Standstill Delay Time.
437
+ # The unit is in mA and the maximum allowed value is the configured maximum motor current
438
+ # (see BrickSilentStepper#set_motor_current).
439
+ #
440
+ # * Motor Run Current: The value sets the motor current when the motor is running.
441
+ # Use a value of at least one half of the global maximum motor current for a good
442
+ # microstep performance. The unit is in mA and the maximum allowed value is the current
443
+ # motor current. The API maps the entered value to 1/32 ... 32/32 of the maximum
444
+ # motor current. This value should be used to change the motor current during motor movement,
445
+ # whereas the global maximum motor current should not be changed while the motor is moving
446
+ # (see BrickSilentStepper#set_motor_current).
447
+ #
448
+ # * Standstill Delay Time: Controls the duration for motor power down after a motion
449
+ # as soon as standstill is detected and the Power Down Time is expired. A high Standstill Delay
450
+ # Time results in a smooth transition that avoids motor jerk during power down.
451
+ # The value range is 0 to 307ms
452
+ #
453
+ # * Power Down Time: Sets the delay time after a stand still.
454
+ # The value range is 0 to 5222ms.
455
+ #
456
+ # * Stealth Threshold: Sets the upper threshold for Stealth mode in steps/s. The value range is
457
+ # 0-65536 steps/s. If the velocity of the motor goes above this value, Stealth mode is turned
458
+ # off. Otherwise it is turned on. In Stealth mode the torque declines with high speed.
459
+ #
460
+ # * Coolstep Threshold: Sets the lower threshold for Coolstep mode in steps/s. The value range is
461
+ # 0-65536 steps/s. The Coolstep Threshold needs to be above the Stealth Threshold.
462
+ #
463
+ # * Classic Threshold: Sets the lower threshold for classic mode. The value range is
464
+ # 0-65536 steps/s. In classic mode the stepper becomes more noisy, but the torque is maximized.
465
+ #
466
+ # * High Velocity Shopper Mode: If High Velocity Shopper Mode is enabled, the stepper control
467
+ # is optimized to run the stepper motors at high velocities.
468
+ #
469
+ # If you want to use all three thresholds make sure that
470
+ # 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
+ 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
+ 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 ?', 0, '')
484
+ end
485
+
486
+ # Returns the configuration as set by BrickSilentStepper#set_basic_configuration.
487
+ def get_basic_configuration
488
+ send_request(FUNCTION_GET_BASIC_CONFIGURATION, [], '', 15, 'S S S S S S S ?')
489
+ end
490
+
491
+ # Note: If you don't know what any of this means you can very likely keep all of
492
+ # the values as default!
493
+ #
494
+ # Sets the Spreadcycle configuration parameters. Spreadcycle is a chopper algorithm which actively
495
+ # controls the motor current flow. More information can be found in the TMC2130 datasheet on page
496
+ # 47 (7 spreadCycle and Classic Chopper).
497
+ #
498
+ # * Slow Decay Duration: Controls duration of off time setting of slow decay phase. The value
499
+ # range is 0-15. 0 = driver disabled, all bridges off. Use 1 only with Comparator Blank time >= 2.
500
+ #
501
+ # * Enable Random Slow Decay: Set to false to fix chopper off time as set by Slow Decay Duration.
502
+ # If you set it to true, Decay Duration is randomly modulated.
503
+ #
504
+ # * Fast Decay Duration: Sets the fast decay duration. The value range is 0-15. This parameters is
505
+ # only used if the Chopper Mode is set to Fast Decay.
506
+ #
507
+ # * Hysteresis Start Value: Sets the hysteresis start value. The value range is 0-7. This parameter is
508
+ # only used if the Chopper Mode is set to Spread Cycle.
509
+ #
510
+ # * Hysteresis End Value: Sets the hysteresis end value. The value range is -3 to 12. This parameter is
511
+ # only used if the Chopper Mode is set to Spread Cycle.
512
+ #
513
+ # * Sine Wave Offset: Sets the sine wave offset. The value range is -3 to 12. This parameters is
514
+ # only used if the Chopper Mode is set to Fast Decay. 1/512 of the value becomes added to the absolute
515
+ # value of the sine wave.
516
+ #
517
+ # * Chopper Mode: 0 = Spread Cycle, 1 = Fast Decay.
518
+ #
519
+ # * Comparator Blank Time: Sets the blank time of the comparator. Available values are
520
+ #
521
+ # * 0 = 16 clocks,
522
+ # * 1 = 24 clocks,
523
+ # * 2 = 36 clocks and
524
+ # * 3 = 54 clocks.
525
+ #
526
+ # A value of 1 or 2 is recommended for most applications.
527
+ #
528
+ # * Fast Decay Without Comparator: If set to true the current comparator usage for termination of the
529
+ # 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
+ 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
+ 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 ?', 0, '')
544
+ end
545
+
546
+ # Returns the configuration as set by BrickSilentStepper#set_basic_configuration.
547
+ def get_spreadcycle_configuration
548
+ send_request(FUNCTION_GET_SPREADCYCLE_CONFIGURATION, [], '', 9, 'C ? C C c c C C ?')
549
+ end
550
+
551
+ # Note: If you don't know what any of this means you can very likely keep all of
552
+ # the values as default!
553
+ #
554
+ # Sets the configuration relevant for Stealth mode.
555
+ #
556
+ # * Enable Stealth: If set to true the stealth mode is enabled, if set to false the
557
+ # stealth mode is disabled, even if the speed is below the threshold set in BrickSilentStepper#set_basic_configuration.
558
+ #
559
+ # * 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. The value range is 0-255.
561
+ #
562
+ # * Gradient: If autoscale is disabled, the PWM gradient is scaled by this value. If autoscale is enabled,
563
+ # 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. The value range is 0-255.
565
+ #
566
+ # * Enable Autoscale: If set to true, automatic current control is used. Otherwise the user defined
567
+ # amplitude and gradient are used.
568
+ #
569
+ # * Force Symmetric: If true, A symmetric PWM cycle is enforced. Otherwise the PWM value may change within each
570
+ # PWM cycle.
571
+ #
572
+ # * Freewheel Mode: The freewheel mode defines the behavior in stand still if the Standstill Current
573
+ # (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
+ def set_stealth_configuration(enable_stealth, amplitude, gradient, enable_autoscale, force_symmetric, freewheel_mode)
584
+ send_request(FUNCTION_SET_STEALTH_CONFIGURATION, [enable_stealth, amplitude, gradient, enable_autoscale, force_symmetric, freewheel_mode], '? C C ? ? C', 0, '')
585
+ end
586
+
587
+ # Returns the configuration as set by BrickSilentStepper#set_stealth_configuration.
588
+ def get_stealth_configuration
589
+ send_request(FUNCTION_GET_STEALTH_CONFIGURATION, [], '', 6, '? C C ? ? C')
590
+ end
591
+
592
+ # Note: If you don't know what any of this means you can very likely keep all of
593
+ # the values as default!
594
+ #
595
+ # Sets the configuration relevant for Coolstep.
596
+ #
597
+ # * Minimum Stallguard Value: If the Stallguard result falls below this value*32, the motor current
598
+ # is increased to reduce motor load angle. The value range is 0-15. A value of 0 turns Coolstep off.
599
+ #
600
+ # * Maximum Stallguard Value: If the Stallguard result goes above
601
+ # (Min Stallguard Value + Max Stallguard Value + 1) * 32, the motor current is decreased to save
602
+ # energy.
603
+ #
604
+ # * Current Up Step Width: Sets the up step increment per Stallguard value. The value range is 0-3,
605
+ # corresponding to the increments 1, 2, 4 and 8.
606
+ #
607
+ # * Current Down Step Width: Sets the down step decrement per Stallguard value. The value range is 0-3,
608
+ # corresponding to the decrements 1, 2, 8 and 16.
609
+ #
610
+ # * Minimum Current: Sets the minimum current for Coolstep current control. You can choose between
611
+ # half and quarter of the run current.
612
+ #
613
+ # * Stallguard Threshold Value: Sets the level for stall output (see BrickSilentStepper#get_driver_status). The value
614
+ # range is -64 to +63. A lower value gives a higher sensitivity. You have to find a suitable value for your
615
+ # motor by trial and error, 0 works for most motors.
616
+ #
617
+ # * Stallguard Mode: Set to 0 for standard resolution or 1 for filtered mode. In filtered mode the Stallguard
618
+ # 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
+ 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
+ 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', 0, '')
631
+ end
632
+
633
+ # Returns the configuration as set by BrickSilentStepper#set_coolstep_configuration.
634
+ def get_coolstep_configuration
635
+ send_request(FUNCTION_GET_COOLSTEP_CONFIGURATION, [], '', 7, 'C C C C C c C')
636
+ end
637
+
638
+ # Note: If you don't know what any of this means you can very likely keep all of
639
+ # the values as default!
640
+ #
641
+ # Sets miscellaneous configuration parameters.
642
+ #
643
+ # * Disable Short To Ground Protection: Set to false to enable short to ground protection, otherwise
644
+ # it is disabled.
645
+ #
646
+ # * Synchronize Phase Frequency: With this parameter you can synchronize the chopper for both phases
647
+ # of a two phase motor to avoid the occurrence of a beat. The value range is 0-15. If set to 0,
648
+ # the synchronization is turned off. Otherwise the synchronization is done through the formula
649
+ # f_sync = f_clk/(value*64). In Classic Mode the synchronization is automatically switched off.
650
+ # 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
+ def set_misc_configuration(disable_short_to_ground_protection, synchronize_phase_frequency)
657
+ send_request(FUNCTION_SET_MISC_CONFIGURATION, [disable_short_to_ground_protection, synchronize_phase_frequency], '? C', 0, '')
658
+ end
659
+
660
+ # Returns the configuration as set by BrickSilentStepper#set_misc_configuration.
661
+ def get_misc_configuration
662
+ send_request(FUNCTION_GET_MISC_CONFIGURATION, [], '', 2, '? C')
663
+ end
664
+
665
+ # Returns the current driver status.
666
+ #
667
+ # * Open Load: Indicates if an open load is present on phase A, B or both. This could mean that there is a problem
668
+ # with the wiring of the motor. False detection can occur in fast motion as well as during stand still.
669
+ #
670
+ # * Short To Ground: Indicates if a short to ground is present on phase A, B or both. If this is detected the driver
671
+ # automatically becomes disabled and stays disabled until it is enabled again manually.
672
+ #
673
+ # * Over Temperature: The over temperature indicator switches to "Warning" if the driver IC warms up. The warning flag
674
+ # is expected during long duration stepper uses. If the temperature limit is reached the indicator switches
675
+ # to "Limit". In this case the driver becomes disabled until it cools down again.
676
+ #
677
+ # * Motor Stalled: Is true if a motor stall was detected.
678
+ #
679
+ # * Actual Motor Current: Indicates the actual current control scaling as used in Coolstep mode.
680
+ #
681
+ # * Stallguard Result: Indicates the load of the motor. A lower value signals a higher load. Per trial and error
682
+ # you can find out which value corresponds to a suitable torque for the velocity used in your application.
683
+ # After that you can use this threshold value to find out if a motor stall becomes probable and react on it (e.g.
684
+ # decrease velocity).
685
+ # During stand still this value can not be used for stall detection, it shows the chopper on-time for motor coil A.
686
+ #
687
+ # * Stealth Voltage Amplitude: Shows the actual PWM scaling. In Stealth mode it can be used to detect motor load and
688
+ # stall if autoscale is enabled (see BrickSilentStepper#set_stealth_configuration).
689
+ def get_driver_status
690
+ send_request(FUNCTION_GET_DRIVER_STATUS, [], '', 8, 'C C C ? C ? C C')
691
+ end
692
+
693
+ # Sets the minimum voltage in mV, below which the CALLBACK_UNDER_VOLTAGE callback
694
+ # is triggered. The minimum possible value that works with the Slient Stepper
695
+ # Brick is 8V.
696
+ # You can use this function to detect the discharge of a battery that is used
697
+ # to drive the stepper motor. If you have a fixed power supply, you likely do
698
+ # not need this functionality.
699
+ #
700
+ # The default value is 8V.
701
+ def set_minimum_voltage(voltage)
702
+ send_request(FUNCTION_SET_MINIMUM_VOLTAGE, [voltage], 'S', 0, '')
703
+ end
704
+
705
+ # Returns the minimum voltage as set by BrickSilentStepper#set_minimum_voltage.
706
+ def get_minimum_voltage
707
+ send_request(FUNCTION_GET_MINIMUM_VOLTAGE, [], '', 2, 'S')
708
+ end
709
+
710
+ # Sets the time base of the velocity and the acceleration of the Silent Stepper
711
+ # Brick (in seconds).
712
+ #
713
+ # For example, if you want to make one step every 1.5 seconds, you can set
714
+ # the time base to 15 and the velocity to 10. Now the velocity is
715
+ # 10steps/15s = 1steps/1.5s.
716
+ #
717
+ # The default value is 1.
718
+ def set_time_base(time_base)
719
+ send_request(FUNCTION_SET_TIME_BASE, [time_base], 'L', 0, '')
720
+ end
721
+
722
+ # Returns the time base as set by BrickSilentStepper#set_time_base.
723
+ def get_time_base
724
+ send_request(FUNCTION_GET_TIME_BASE, [], '', 4, 'L')
725
+ end
726
+
727
+ # Returns the following parameters: The current velocity,
728
+ # the current position, the remaining steps, the stack voltage, the external
729
+ # voltage and the current consumption of the stepper motor.
730
+ #
731
+ # There is also a callback for this function, see CALLBACK_ALL_DATA callback.
732
+ def get_all_data
733
+ send_request(FUNCTION_GET_ALL_DATA, [], '', 16, 'S l l S S S')
734
+ end
735
+
736
+ # Sets the period in ms with which the CALLBACK_ALL_DATA callback is triggered
737
+ # periodically. A value of 0 turns the callback off.
738
+ def set_all_data_period(period)
739
+ send_request(FUNCTION_SET_ALL_DATA_PERIOD, [period], 'L', 0, '')
740
+ end
741
+
742
+ # Returns the period as set by BrickSilentStepper#set_all_data_period.
743
+ def get_all_data_period
744
+ send_request(FUNCTION_GET_ALL_DATA_PERIOD, [], '', 4, 'L')
745
+ end
746
+
747
+ # Returns the timeout count for the different communication methods.
748
+ #
749
+ # The methods 0-2 are available for all Bricks, 3-7 only for Master Bricks.
750
+ #
751
+ # This function is mostly used for debugging during development, in normal operation
752
+ # the counters should nearly always stay at 0.
753
+ def get_send_timeout_count(communication_method)
754
+ send_request(FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 4, 'L')
755
+ end
756
+
757
+ # Enables the status LED.
758
+ #
759
+ # The status LED is the blue LED next to the USB connector. If enabled is is
760
+ # on and it flickers if data is transfered. If disabled it is always off.
761
+ #
762
+ # The default state is enabled.
763
+ def enable_status_led
764
+ send_request(FUNCTION_ENABLE_STATUS_LED, [], '', 0, '')
765
+ end
766
+
767
+ # Disables the status LED.
768
+ #
769
+ # The status LED is the blue LED next to the USB connector. If enabled is is
770
+ # on and it flickers if data is transfered. If disabled it is always off.
771
+ #
772
+ # The default state is enabled.
773
+ def disable_status_led
774
+ send_request(FUNCTION_DISABLE_STATUS_LED, [], '', 0, '')
775
+ end
776
+
777
+ # Returns *true* if the status LED is enabled, *false* otherwise.
778
+ def is_status_led_enabled
779
+ send_request(FUNCTION_IS_STATUS_LED_ENABLED, [], '', 1, '?')
780
+ end
781
+
782
+ # Returns the firmware and protocol version and the name of the Bricklet for a
783
+ # given port.
784
+ #
785
+ # This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet
786
+ # plugins.
787
+ def get_protocol1_bricklet_name(port)
788
+ send_request(FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 44, 'C C3 Z40')
789
+ end
790
+
791
+ # Returns the temperature in °C/10 as measured inside the microcontroller. The
792
+ # value returned is not the ambient temperature!
793
+ #
794
+ # The temperature is only proportional to the real temperature and it has an
795
+ # accuracy of +-15%. Practically it is only useful as an indicator for
796
+ # temperature changes.
797
+ def get_chip_temperature
798
+ send_request(FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's')
799
+ end
800
+
801
+ # Calling this function will reset the Brick. Calling this function
802
+ # on a Brick inside of a stack will reset the whole stack.
803
+ #
804
+ # After a reset you have to create new device objects,
805
+ # calling functions on the existing ones will result in
806
+ # undefined behavior!
807
+ def reset
808
+ send_request(FUNCTION_RESET, [], '', 0, '')
809
+ end
810
+
811
+ # Returns the UID, the UID where the Brick is connected to,
812
+ # the position, the hardware and firmware version as well as the
813
+ # device identifier.
814
+ #
815
+ # The position can be '0'-'8' (stack position).
816
+ #
817
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
818
+ # |device_identifier_constant|
819
+ def get_identity
820
+ send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
821
+ end
822
+
823
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
824
+ def register_callback(id, &block)
825
+ callback = block
826
+ @registered_callbacks[id] = callback
827
+ end
828
+ end
829
+ end