tinkerforge 2.1.24 → 2.1.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +156 -75
  3. data/lib/tinkerforge/brick_hat.rb +69 -31
  4. data/lib/tinkerforge/brick_hat_zero.rb +55 -23
  5. data/lib/tinkerforge/brick_imu.rb +185 -78
  6. data/lib/tinkerforge/brick_imu_v2.rb +209 -106
  7. data/lib/tinkerforge/brick_master.rb +491 -183
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +186 -102
  10. data/lib/tinkerforge/brick_silent_stepper.rb +247 -167
  11. data/lib/tinkerforge/brick_stepper.rb +211 -99
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +57 -23
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +104 -54
  14. data/lib/tinkerforge/bricklet_air_quality.rb +116 -59
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +50 -21
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +44 -24
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +65 -27
  18. data/lib/tinkerforge/bricklet_analog_in.rb +62 -25
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +56 -23
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +66 -25
  21. data/lib/tinkerforge/bricklet_analog_out.rb +22 -9
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +19 -8
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +53 -20
  24. data/lib/tinkerforge/bricklet_barometer.rb +100 -27
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +98 -37
  26. data/lib/tinkerforge/bricklet_can.rb +83 -19
  27. data/lib/tinkerforge/bricklet_can_v2.rb +171 -38
  28. data/lib/tinkerforge/bricklet_co2.rb +33 -14
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +97 -38
  30. data/lib/tinkerforge/bricklet_color.rb +68 -27
  31. data/lib/tinkerforge/bricklet_color_v2.rb +86 -33
  32. data/lib/tinkerforge/bricklet_compass.rb +77 -30
  33. data/lib/tinkerforge/bricklet_current12.rb +57 -24
  34. data/lib/tinkerforge/bricklet_current25.rb +57 -24
  35. data/lib/tinkerforge/bricklet_dc_v2.rb +521 -0
  36. data/lib/tinkerforge/bricklet_distance_ir.rb +56 -23
  37. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +82 -31
  38. data/lib/tinkerforge/bricklet_distance_us.rb +39 -16
  39. data/lib/tinkerforge/bricklet_distance_us_v2.rb +66 -25
  40. data/lib/tinkerforge/bricklet_dmx.rb +87 -34
  41. data/lib/tinkerforge/bricklet_dual_button.rb +23 -10
  42. data/lib/tinkerforge/bricklet_dual_button_v2.rb +63 -24
  43. data/lib/tinkerforge/bricklet_dual_relay.rb +26 -11
  44. data/lib/tinkerforge/bricklet_dust_detector.rb +39 -16
  45. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +87 -32
  46. data/lib/tinkerforge/bricklet_energy_monitor.rb +72 -27
  47. data/lib/tinkerforge/bricklet_gps.rb +63 -26
  48. data/lib/tinkerforge/bricklet_gps_v2.rb +116 -47
  49. data/lib/tinkerforge/bricklet_hall_effect.rb +42 -23
  50. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +70 -27
  51. data/lib/tinkerforge/bricklet_humidity.rb +50 -21
  52. data/lib/tinkerforge/bricklet_humidity_v2.rb +82 -31
  53. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  54. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +37 -14
  55. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +80 -29
  56. data/lib/tinkerforge/bricklet_industrial_counter.rb +100 -39
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +44 -17
  58. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +76 -29
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +35 -14
  60. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +72 -27
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +39 -16
  62. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -30
  63. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +48 -19
  65. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +137 -31
  66. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +60 -23
  67. data/lib/tinkerforge/bricklet_industrial_ptc.rb +475 -0
  68. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +35 -14
  69. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +66 -25
  70. data/lib/tinkerforge/bricklet_io16.rb +54 -21
  71. data/lib/tinkerforge/bricklet_io16_v2.rb +89 -34
  72. data/lib/tinkerforge/bricklet_io4.rb +54 -23
  73. data/lib/tinkerforge/bricklet_io4_v2.rb +95 -36
  74. data/lib/tinkerforge/bricklet_isolator.rb +72 -29
  75. data/lib/tinkerforge/bricklet_joystick.rb +58 -25
  76. data/lib/tinkerforge/bricklet_joystick_v2.rb +67 -26
  77. data/lib/tinkerforge/bricklet_laser_range_finder.rb +81 -32
  78. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +95 -36
  79. data/lib/tinkerforge/bricklet_lcd_128x64.rb +191 -70
  80. data/lib/tinkerforge/bricklet_lcd_16x2.rb +44 -18
  81. data/lib/tinkerforge/bricklet_lcd_20x4.rb +57 -23
  82. data/lib/tinkerforge/bricklet_led_strip.rb +59 -22
  83. data/lib/tinkerforge/bricklet_led_strip_v2.rb +90 -46
  84. data/lib/tinkerforge/bricklet_line.rb +33 -14
  85. data/lib/tinkerforge/bricklet_linear_poti.rb +50 -21
  86. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +54 -21
  87. data/lib/tinkerforge/bricklet_load_cell.rb +60 -23
  88. data/lib/tinkerforge/bricklet_load_cell_v2.rb +79 -30
  89. data/lib/tinkerforge/bricklet_moisture.rb +39 -16
  90. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  91. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +61 -27
  92. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +70 -27
  93. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -13
  94. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +75 -28
  95. data/lib/tinkerforge/bricklet_nfc.rb +126 -62
  96. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  97. data/lib/tinkerforge/bricklet_oled_128x64.rb +28 -11
  98. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +65 -24
  99. data/lib/tinkerforge/bricklet_oled_64x48.rb +28 -11
  100. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  101. data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -28
  102. data/lib/tinkerforge/bricklet_particulate_matter.rb +74 -30
  103. data/lib/tinkerforge/bricklet_performance_dc.rb +682 -0
  104. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +18 -9
  105. data/lib/tinkerforge/bricklet_piezo_speaker.rb +21 -10
  106. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +79 -42
  107. data/lib/tinkerforge/bricklet_ptc.rb +73 -42
  108. data/lib/tinkerforge/bricklet_ptc_v2.rb +94 -48
  109. data/lib/tinkerforge/bricklet_real_time_clock.rb +44 -33
  110. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +77 -44
  111. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  112. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  113. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  114. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  115. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  116. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  117. data/lib/tinkerforge/bricklet_rotary_encoder.rb +38 -19
  118. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +59 -24
  119. data/lib/tinkerforge/bricklet_rotary_poti.rb +52 -28
  120. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +56 -23
  121. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  122. data/lib/tinkerforge/bricklet_rs232_v2.rb +117 -44
  123. data/lib/tinkerforge/bricklet_rs485.rb +222 -95
  124. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  125. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +74 -35
  126. data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
  127. data/lib/tinkerforge/bricklet_silent_stepper_v2.rb +1024 -0
  128. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  129. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  130. data/lib/tinkerforge/bricklet_sound_intensity.rb +34 -18
  131. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +71 -31
  132. data/lib/tinkerforge/bricklet_temperature.rb +39 -16
  133. data/lib/tinkerforge/bricklet_temperature_ir.rb +56 -23
  134. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +70 -27
  135. data/lib/tinkerforge/bricklet_temperature_v2.rb +60 -25
  136. data/lib/tinkerforge/bricklet_thermal_imaging.rb +104 -44
  137. data/lib/tinkerforge/bricklet_thermocouple.rb +44 -24
  138. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +64 -27
  139. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  140. data/lib/tinkerforge/bricklet_uv_light.rb +35 -18
  141. data/lib/tinkerforge/bricklet_uv_light_v2.rb +84 -37
  142. data/lib/tinkerforge/bricklet_voltage.rb +51 -28
  143. data/lib/tinkerforge/bricklet_voltage_current.rb +90 -73
  144. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +89 -68
  145. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +79 -30
  146. data/lib/tinkerforge/device_display_names.rb +170 -0
  147. data/lib/tinkerforge/ip_connection.rb +153 -33
  148. data/lib/tinkerforge/version.rb +1 -1
  149. metadata +11 -3
@@ -0,0 +1,1024 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2021-05-06. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.29 #
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
+ require_relative './ip_connection'
13
+
14
+ module Tinkerforge
15
+ # Silently drives one bipolar stepper motor with up to 46V and 1.6A per phase
16
+ class BrickletSilentStepperV2 < Device
17
+ DEVICE_IDENTIFIER = 2166 # :nodoc:
18
+ DEVICE_DISPLAY_NAME = 'Silent Stepper Bricklet 2.0' # :nodoc:
19
+
20
+ # This callback is triggered when the input voltage drops below the value set by
21
+ # BrickletSilentStepperV2#set_minimum_voltage. The parameter is the current voltage.
22
+ CALLBACK_UNDER_VOLTAGE = 41
23
+
24
+ # This callback is triggered when a position set by BrickletSilentStepperV2#set_steps or
25
+ # BrickletSilentStepperV2#set_target_position is reached.
26
+ #
27
+ # .. note::
28
+ # Since we can't get any feedback from the stepper motor, this only works if the
29
+ # acceleration (see BrickletSilentStepperV2#set_speed_ramping) is set smaller or equal to the
30
+ # maximum acceleration of the motor. Otherwise the motor will lag behind the
31
+ # control value and the callback will be triggered too early.
32
+ CALLBACK_POSITION_REACHED = 42
33
+
34
+ # This callback is triggered periodically with the period that is set by
35
+ # BrickletSilentStepperV2#set_all_callback_configuration. The parameters are: the current velocity,
36
+ # the current position, the remaining steps, the stack voltage, the external
37
+ # voltage and the current consumption of the stepper motor.
38
+ CALLBACK_ALL_DATA = 53
39
+
40
+ # This callback is triggered whenever the Silent Stepper Bricklet 2.0 enters a new state.
41
+ # It returns the new state as well as the previous state.
42
+ CALLBACK_NEW_STATE = 54
43
+
44
+ # This callback is triggered by GPIO changes if it is activated through BrickletSilentStepperV2#set_gpio_action.
45
+ CALLBACK_GPIO_STATE = 55
46
+
47
+ FUNCTION_SET_MAX_VELOCITY = 1 # :nodoc:
48
+ FUNCTION_GET_MAX_VELOCITY = 2 # :nodoc:
49
+ FUNCTION_GET_CURRENT_VELOCITY = 3 # :nodoc:
50
+ FUNCTION_SET_SPEED_RAMPING = 4 # :nodoc:
51
+ FUNCTION_GET_SPEED_RAMPING = 5 # :nodoc:
52
+ FUNCTION_FULL_BRAKE = 6 # :nodoc:
53
+ FUNCTION_SET_CURRENT_POSITION = 7 # :nodoc:
54
+ FUNCTION_GET_CURRENT_POSITION = 8 # :nodoc:
55
+ FUNCTION_SET_TARGET_POSITION = 9 # :nodoc:
56
+ FUNCTION_GET_TARGET_POSITION = 10 # :nodoc:
57
+ FUNCTION_SET_STEPS = 11 # :nodoc:
58
+ FUNCTION_GET_STEPS = 12 # :nodoc:
59
+ FUNCTION_GET_REMAINING_STEPS = 13 # :nodoc:
60
+ FUNCTION_SET_STEP_CONFIGURATION = 14 # :nodoc:
61
+ FUNCTION_GET_STEP_CONFIGURATION = 15 # :nodoc:
62
+ FUNCTION_DRIVE_FORWARD = 16 # :nodoc:
63
+ FUNCTION_DRIVE_BACKWARD = 17 # :nodoc:
64
+ FUNCTION_STOP = 18 # :nodoc:
65
+ FUNCTION_GET_INPUT_VOLTAGE = 19 # :nodoc:
66
+ FUNCTION_SET_MOTOR_CURRENT = 22 # :nodoc:
67
+ FUNCTION_GET_MOTOR_CURRENT = 23 # :nodoc:
68
+ FUNCTION_SET_ENABLED = 24 # :nodoc:
69
+ FUNCTION_GET_ENABLED = 25 # :nodoc:
70
+ FUNCTION_SET_BASIC_CONFIGURATION = 26 # :nodoc:
71
+ FUNCTION_GET_BASIC_CONFIGURATION = 27 # :nodoc:
72
+ FUNCTION_SET_SPREADCYCLE_CONFIGURATION = 28 # :nodoc:
73
+ FUNCTION_GET_SPREADCYCLE_CONFIGURATION = 29 # :nodoc:
74
+ FUNCTION_SET_STEALTH_CONFIGURATION = 30 # :nodoc:
75
+ FUNCTION_GET_STEALTH_CONFIGURATION = 31 # :nodoc:
76
+ FUNCTION_SET_COOLSTEP_CONFIGURATION = 32 # :nodoc:
77
+ FUNCTION_GET_COOLSTEP_CONFIGURATION = 33 # :nodoc:
78
+ FUNCTION_SET_MISC_CONFIGURATION = 34 # :nodoc:
79
+ FUNCTION_GET_MISC_CONFIGURATION = 35 # :nodoc:
80
+ FUNCTION_SET_ERROR_LED_CONFIG = 36 # :nodoc:
81
+ FUNCTION_GET_ERROR_LED_CONFIG = 37 # :nodoc:
82
+ FUNCTION_GET_DRIVER_STATUS = 38 # :nodoc:
83
+ FUNCTION_SET_MINIMUM_VOLTAGE = 39 # :nodoc:
84
+ FUNCTION_GET_MINIMUM_VOLTAGE = 40 # :nodoc:
85
+ FUNCTION_SET_TIME_BASE = 43 # :nodoc:
86
+ FUNCTION_GET_TIME_BASE = 44 # :nodoc:
87
+ FUNCTION_GET_ALL_DATA = 45 # :nodoc:
88
+ FUNCTION_SET_ALL_CALLBACK_CONFIGURATION = 46 # :nodoc:
89
+ FUNCTION_GET_ALL_DATA_CALLBACK_CONFIGURATON = 47 # :nodoc:
90
+ FUNCTION_SET_GPIO_CONFIGURATION = 48 # :nodoc:
91
+ FUNCTION_GET_GPIO_CONFIGURATION = 49 # :nodoc:
92
+ FUNCTION_SET_GPIO_ACTION = 50 # :nodoc:
93
+ FUNCTION_GET_GPIO_ACTION = 51 # :nodoc:
94
+ FUNCTION_GET_GPIO_STATE = 52 # :nodoc:
95
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
96
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
97
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
98
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
99
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
100
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
101
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
102
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
103
+ FUNCTION_RESET = 243 # :nodoc:
104
+ FUNCTION_WRITE_UID = 248 # :nodoc:
105
+ FUNCTION_READ_UID = 249 # :nodoc:
106
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
107
+
108
+ STEP_RESOLUTION_1 = 8 # :nodoc:
109
+ STEP_RESOLUTION_2 = 7 # :nodoc:
110
+ STEP_RESOLUTION_4 = 6 # :nodoc:
111
+ STEP_RESOLUTION_8 = 5 # :nodoc:
112
+ STEP_RESOLUTION_16 = 4 # :nodoc:
113
+ STEP_RESOLUTION_32 = 3 # :nodoc:
114
+ STEP_RESOLUTION_64 = 2 # :nodoc:
115
+ STEP_RESOLUTION_128 = 1 # :nodoc:
116
+ STEP_RESOLUTION_256 = 0 # :nodoc:
117
+ CHOPPER_MODE_SPREAD_CYCLE = 0 # :nodoc:
118
+ CHOPPER_MODE_FAST_DECAY = 1 # :nodoc:
119
+ FREEWHEEL_MODE_NORMAL = 0 # :nodoc:
120
+ FREEWHEEL_MODE_FREEWHEELING = 1 # :nodoc:
121
+ FREEWHEEL_MODE_COIL_SHORT_LS = 2 # :nodoc:
122
+ FREEWHEEL_MODE_COIL_SHORT_HS = 3 # :nodoc:
123
+ CURRENT_UP_STEP_INCREMENT_1 = 0 # :nodoc:
124
+ CURRENT_UP_STEP_INCREMENT_2 = 1 # :nodoc:
125
+ CURRENT_UP_STEP_INCREMENT_4 = 2 # :nodoc:
126
+ CURRENT_UP_STEP_INCREMENT_8 = 3 # :nodoc:
127
+ CURRENT_DOWN_STEP_DECREMENT_1 = 0 # :nodoc:
128
+ CURRENT_DOWN_STEP_DECREMENT_2 = 1 # :nodoc:
129
+ CURRENT_DOWN_STEP_DECREMENT_8 = 2 # :nodoc:
130
+ CURRENT_DOWN_STEP_DECREMENT_32 = 3 # :nodoc:
131
+ MINIMUM_CURRENT_HALF = 0 # :nodoc:
132
+ MINIMUM_CURRENT_QUARTER = 1 # :nodoc:
133
+ STALLGUARD_MODE_STANDARD = 0 # :nodoc:
134
+ STALLGUARD_MODE_FILTERED = 1 # :nodoc:
135
+ OPEN_LOAD_NONE = 0 # :nodoc:
136
+ OPEN_LOAD_PHASE_A = 1 # :nodoc:
137
+ OPEN_LOAD_PHASE_B = 2 # :nodoc:
138
+ OPEN_LOAD_PHASE_AB = 3 # :nodoc:
139
+ SHORT_TO_GROUND_NONE = 0 # :nodoc:
140
+ SHORT_TO_GROUND_PHASE_A = 1 # :nodoc:
141
+ SHORT_TO_GROUND_PHASE_B = 2 # :nodoc:
142
+ SHORT_TO_GROUND_PHASE_AB = 3 # :nodoc:
143
+ OVER_TEMPERATURE_NONE = 0 # :nodoc:
144
+ OVER_TEMPERATURE_WARNING = 1 # :nodoc:
145
+ OVER_TEMPERATURE_LIMIT = 2 # :nodoc:
146
+ STATE_STOP = 1 # :nodoc:
147
+ STATE_ACCELERATION = 2 # :nodoc:
148
+ STATE_RUN = 3 # :nodoc:
149
+ STATE_DEACCELERATION = 4 # :nodoc:
150
+ STATE_DIRECTION_CHANGE_TO_FORWARD = 5 # :nodoc:
151
+ STATE_DIRECTION_CHANGE_TO_BACKWARD = 6 # :nodoc:
152
+ GPIO_ACTION_NONE = 0 # :nodoc:
153
+ GPIO_ACTION_NORMAL_STOP_RISING_EDGE = 1 # :nodoc:
154
+ GPIO_ACTION_NORMAL_STOP_FALLING_EDGE = 2 # :nodoc:
155
+ GPIO_ACTION_FULL_BRAKE_RISING_EDGE = 4 # :nodoc:
156
+ GPIO_ACTION_FULL_BRAKE_FALLING_EDGE = 8 # :nodoc:
157
+ GPIO_ACTION_CALLBACK_RISING_EDGE = 16 # :nodoc:
158
+ GPIO_ACTION_CALLBACK_FALLING_EDGE = 32 # :nodoc:
159
+ ERROR_LED_CONFIG_OFF = 0 # :nodoc:
160
+ ERROR_LED_CONFIG_ON = 1 # :nodoc:
161
+ ERROR_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
162
+ ERROR_LED_CONFIG_SHOW_ERROR = 3 # :nodoc:
163
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
164
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
165
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
166
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
167
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
168
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
169
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
170
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
171
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
172
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
173
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
174
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
175
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
176
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
177
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
178
+
179
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
180
+ # the IP Connection <tt>ipcon</tt>.
181
+ def initialize(uid, ipcon)
182
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
183
+
184
+ @api_version = [2, 0, 0]
185
+
186
+ @response_expected[FUNCTION_SET_MAX_VELOCITY] = RESPONSE_EXPECTED_FALSE
187
+ @response_expected[FUNCTION_GET_MAX_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
188
+ @response_expected[FUNCTION_GET_CURRENT_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
189
+ @response_expected[FUNCTION_SET_SPEED_RAMPING] = RESPONSE_EXPECTED_FALSE
190
+ @response_expected[FUNCTION_GET_SPEED_RAMPING] = RESPONSE_EXPECTED_ALWAYS_TRUE
191
+ @response_expected[FUNCTION_FULL_BRAKE] = RESPONSE_EXPECTED_FALSE
192
+ @response_expected[FUNCTION_SET_CURRENT_POSITION] = RESPONSE_EXPECTED_FALSE
193
+ @response_expected[FUNCTION_GET_CURRENT_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
194
+ @response_expected[FUNCTION_SET_TARGET_POSITION] = RESPONSE_EXPECTED_FALSE
195
+ @response_expected[FUNCTION_GET_TARGET_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
196
+ @response_expected[FUNCTION_SET_STEPS] = RESPONSE_EXPECTED_FALSE
197
+ @response_expected[FUNCTION_GET_STEPS] = RESPONSE_EXPECTED_ALWAYS_TRUE
198
+ @response_expected[FUNCTION_GET_REMAINING_STEPS] = RESPONSE_EXPECTED_ALWAYS_TRUE
199
+ @response_expected[FUNCTION_SET_STEP_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
200
+ @response_expected[FUNCTION_GET_STEP_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
201
+ @response_expected[FUNCTION_DRIVE_FORWARD] = RESPONSE_EXPECTED_FALSE
202
+ @response_expected[FUNCTION_DRIVE_BACKWARD] = RESPONSE_EXPECTED_FALSE
203
+ @response_expected[FUNCTION_STOP] = RESPONSE_EXPECTED_FALSE
204
+ @response_expected[FUNCTION_GET_INPUT_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
205
+ @response_expected[FUNCTION_SET_MOTOR_CURRENT] = RESPONSE_EXPECTED_FALSE
206
+ @response_expected[FUNCTION_GET_MOTOR_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
207
+ @response_expected[FUNCTION_SET_ENABLED] = RESPONSE_EXPECTED_FALSE
208
+ @response_expected[FUNCTION_GET_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
209
+ @response_expected[FUNCTION_SET_BASIC_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
210
+ @response_expected[FUNCTION_GET_BASIC_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
211
+ @response_expected[FUNCTION_SET_SPREADCYCLE_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
212
+ @response_expected[FUNCTION_GET_SPREADCYCLE_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
213
+ @response_expected[FUNCTION_SET_STEALTH_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
214
+ @response_expected[FUNCTION_GET_STEALTH_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
215
+ @response_expected[FUNCTION_SET_COOLSTEP_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
216
+ @response_expected[FUNCTION_GET_COOLSTEP_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
217
+ @response_expected[FUNCTION_SET_MISC_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
218
+ @response_expected[FUNCTION_GET_MISC_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
219
+ @response_expected[FUNCTION_SET_ERROR_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
220
+ @response_expected[FUNCTION_GET_ERROR_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
221
+ @response_expected[FUNCTION_GET_DRIVER_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
222
+ @response_expected[FUNCTION_SET_MINIMUM_VOLTAGE] = RESPONSE_EXPECTED_TRUE
223
+ @response_expected[FUNCTION_GET_MINIMUM_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
224
+ @response_expected[FUNCTION_SET_TIME_BASE] = RESPONSE_EXPECTED_FALSE
225
+ @response_expected[FUNCTION_GET_TIME_BASE] = RESPONSE_EXPECTED_ALWAYS_TRUE
226
+ @response_expected[FUNCTION_GET_ALL_DATA] = RESPONSE_EXPECTED_ALWAYS_TRUE
227
+ @response_expected[FUNCTION_SET_ALL_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
228
+ @response_expected[FUNCTION_GET_ALL_DATA_CALLBACK_CONFIGURATON] = RESPONSE_EXPECTED_ALWAYS_TRUE
229
+ @response_expected[FUNCTION_SET_GPIO_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
230
+ @response_expected[FUNCTION_GET_GPIO_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
231
+ @response_expected[FUNCTION_SET_GPIO_ACTION] = RESPONSE_EXPECTED_FALSE
232
+ @response_expected[FUNCTION_GET_GPIO_ACTION] = RESPONSE_EXPECTED_ALWAYS_TRUE
233
+ @response_expected[FUNCTION_GET_GPIO_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
234
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
235
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
236
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
237
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
238
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
239
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
240
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
241
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
242
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
243
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
244
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
245
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
246
+
247
+ @callback_formats[CALLBACK_UNDER_VOLTAGE] = [10, 'S']
248
+ @callback_formats[CALLBACK_POSITION_REACHED] = [12, 'l']
249
+ @callback_formats[CALLBACK_ALL_DATA] = [22, 'S l l S S']
250
+ @callback_formats[CALLBACK_NEW_STATE] = [10, 'C C']
251
+ @callback_formats[CALLBACK_GPIO_STATE] = [9, '?2']
252
+
253
+ @ipcon.add_device self
254
+ end
255
+
256
+ # Sets the maximum velocity of the stepper motor.
257
+ # This function does *not* start the motor, it merely sets the maximum
258
+ # velocity the stepper motor is accelerated to. To get the motor running use
259
+ # either BrickletSilentStepperV2#set_target_position, BrickletSilentStepperV2#set_steps, BrickletSilentStepperV2#drive_forward or
260
+ # BrickletSilentStepperV2#drive_backward.
261
+ def set_max_velocity(velocity)
262
+ check_validity
263
+
264
+ send_request FUNCTION_SET_MAX_VELOCITY, [velocity], 'S', 8, ''
265
+ end
266
+
267
+ # Returns the velocity as set by BrickletSilentStepperV2#set_max_velocity.
268
+ def get_max_velocity
269
+ check_validity
270
+
271
+ send_request FUNCTION_GET_MAX_VELOCITY, [], '', 10, 'S'
272
+ end
273
+
274
+ # Returns the *current* velocity of the stepper motor.
275
+ def get_current_velocity
276
+ check_validity
277
+
278
+ send_request FUNCTION_GET_CURRENT_VELOCITY, [], '', 10, 'S'
279
+ end
280
+
281
+ # Sets the acceleration and deacceleration of the stepper motor.
282
+ # An acceleration of 1000 means, that
283
+ # every second the velocity is increased by 1000 *steps/s*.
284
+ #
285
+ # For example: If the current velocity is 0 and you want to accelerate to a
286
+ # velocity of 8000 *steps/s* in 10 seconds, you should set an acceleration
287
+ # of 800 *steps/s²*.
288
+ #
289
+ # An acceleration/deacceleration of 0 means instantaneous
290
+ # acceleration/deacceleration (not recommended)
291
+ def set_speed_ramping(acceleration, deacceleration)
292
+ check_validity
293
+
294
+ send_request FUNCTION_SET_SPEED_RAMPING, [acceleration, deacceleration], 'S S', 8, ''
295
+ end
296
+
297
+ # Returns the acceleration and deacceleration as set by
298
+ # BrickletSilentStepperV2#set_speed_ramping.
299
+ def get_speed_ramping
300
+ check_validity
301
+
302
+ send_request FUNCTION_GET_SPEED_RAMPING, [], '', 12, 'S S'
303
+ end
304
+
305
+ # Executes an active full brake.
306
+ #
307
+ # .. warning::
308
+ # This function is for emergency purposes,
309
+ # where an immediate brake is necessary. Depending on the current velocity and
310
+ # the strength of the motor, a full brake can be quite violent.
311
+ #
312
+ # Call BrickletSilentStepperV2#stop if you just want to stop the motor.
313
+ def full_brake
314
+ check_validity
315
+
316
+ send_request FUNCTION_FULL_BRAKE, [], '', 8, ''
317
+ end
318
+
319
+ # Sets the current steps of the internal step counter. This can be used to
320
+ # set the current position to 0 when some kind of starting position
321
+ # is reached (e.g. when a CNC machine reaches a corner).
322
+ def set_current_position(position)
323
+ check_validity
324
+
325
+ send_request FUNCTION_SET_CURRENT_POSITION, [position], 'l', 8, ''
326
+ end
327
+
328
+ # Returns the current position of the stepper motor in steps. On startup
329
+ # the position is 0. The steps are counted with all possible driving
330
+ # functions (BrickletSilentStepperV2#set_target_position, BrickletSilentStepperV2#set_steps, BrickletSilentStepperV2#drive_forward or
331
+ # BrickletSilentStepperV2#drive_backward). It also is possible to reset the steps to 0 or
332
+ # set them to any other desired value with BrickletSilentStepperV2#set_current_position.
333
+ def get_current_position
334
+ check_validity
335
+
336
+ send_request FUNCTION_GET_CURRENT_POSITION, [], '', 12, 'l'
337
+ end
338
+
339
+ # Sets the target position of the stepper motor in steps. For example,
340
+ # if the current position of the motor is 500 and BrickletSilentStepperV2#set_target_position is
341
+ # called with 1000, the stepper motor will drive 500 steps forward. It will
342
+ # use the velocity, acceleration and deacceleration as set by
343
+ # BrickletSilentStepperV2#set_max_velocity and BrickletSilentStepperV2#set_speed_ramping.
344
+ #
345
+ # A call of BrickletSilentStepperV2#set_target_position with the parameter *x* is equivalent to
346
+ # a call of BrickletSilentStepperV2#set_steps with the parameter
347
+ # (*x* - BrickletSilentStepperV2#get_current_position).
348
+ def set_target_position(position)
349
+ check_validity
350
+
351
+ send_request FUNCTION_SET_TARGET_POSITION, [position], 'l', 8, ''
352
+ end
353
+
354
+ # Returns the last target position as set by BrickletSilentStepperV2#set_target_position.
355
+ def get_target_position
356
+ check_validity
357
+
358
+ send_request FUNCTION_GET_TARGET_POSITION, [], '', 12, 'l'
359
+ end
360
+
361
+ # Sets the number of steps the stepper motor should run. Positive values
362
+ # will drive the motor forward and negative values backward.
363
+ # The velocity, acceleration and deacceleration as set by
364
+ # BrickletSilentStepperV2#set_max_velocity and BrickletSilentStepperV2#set_speed_ramping will be used.
365
+ def set_steps(steps)
366
+ check_validity
367
+
368
+ send_request FUNCTION_SET_STEPS, [steps], 'l', 8, ''
369
+ end
370
+
371
+ # Returns the last steps as set by BrickletSilentStepperV2#set_steps.
372
+ def get_steps
373
+ check_validity
374
+
375
+ send_request FUNCTION_GET_STEPS, [], '', 12, 'l'
376
+ end
377
+
378
+ # Returns the remaining steps of the last call of BrickletSilentStepperV2#set_steps.
379
+ # For example, if BrickletSilentStepperV2#set_steps is called with 2000 and
380
+ # BrickletSilentStepperV2#get_remaining_steps is called after the motor has run for 500 steps,
381
+ # it will return 1500.
382
+ def get_remaining_steps
383
+ check_validity
384
+
385
+ send_request FUNCTION_GET_REMAINING_STEPS, [], '', 12, 'l'
386
+ end
387
+
388
+ # Sets the step resolution from full-step up to 1/256-step.
389
+ #
390
+ # If interpolation is turned on, the Silent Stepper Bricklet 2.0 will always interpolate
391
+ # your step inputs as 1/256-step. If you use full-step mode with interpolation, each
392
+ # step will generate 256 1/256 steps.
393
+ #
394
+ # For maximum torque use full-step without interpolation. For maximum resolution use
395
+ # 1/256-step. Turn interpolation on to make the Stepper driving less noisy.
396
+ #
397
+ # If you often change the speed with high acceleration you should turn the
398
+ # interpolation off.
399
+ def set_step_configuration(step_resolution, interpolation)
400
+ check_validity
401
+
402
+ send_request FUNCTION_SET_STEP_CONFIGURATION, [step_resolution, interpolation], 'C ?', 8, ''
403
+ end
404
+
405
+ # Returns the step mode as set by BrickletSilentStepperV2#set_step_configuration.
406
+ def get_step_configuration
407
+ check_validity
408
+
409
+ send_request FUNCTION_GET_STEP_CONFIGURATION, [], '', 10, 'C ?'
410
+ end
411
+
412
+ # Drives the stepper motor forward until BrickletSilentStepperV2#drive_backward or
413
+ # BrickletSilentStepperV2#stop is called. The velocity, acceleration and deacceleration as
414
+ # set by BrickletSilentStepperV2#set_max_velocity and BrickletSilentStepperV2#set_speed_ramping will be used.
415
+ def drive_forward
416
+ check_validity
417
+
418
+ send_request FUNCTION_DRIVE_FORWARD, [], '', 8, ''
419
+ end
420
+
421
+ # Drives the stepper motor backward until BrickletSilentStepperV2#drive_forward or
422
+ # BrickletSilentStepperV2#stop is triggered. The velocity, acceleration and deacceleration as
423
+ # set by BrickletSilentStepperV2#set_max_velocity and BrickletSilentStepperV2#set_speed_ramping will be used.
424
+ def drive_backward
425
+ check_validity
426
+
427
+ send_request FUNCTION_DRIVE_BACKWARD, [], '', 8, ''
428
+ end
429
+
430
+ # Stops the stepper motor with the deacceleration as set by
431
+ # BrickletSilentStepperV2#set_speed_ramping.
432
+ def stop
433
+ check_validity
434
+
435
+ send_request FUNCTION_STOP, [], '', 8, ''
436
+ end
437
+
438
+ # Returns the external input voltage. The external input voltage is
439
+ # given via the black power input connector on the Silent Stepper Bricklet 2.0.
440
+ #
441
+ # If there is an external input voltage and a stack input voltage, the motor
442
+ # will be driven by the external input voltage. If there is only a stack
443
+ # voltage present, the motor will be driven by this voltage.
444
+ #
445
+ # .. warning::
446
+ # This means, if you have a high stack voltage and a low external voltage,
447
+ # the motor will be driven with the low external voltage. If you then remove
448
+ # the external connection, it will immediately be driven by the high
449
+ # stack voltage
450
+ def get_input_voltage
451
+ check_validity
452
+
453
+ send_request FUNCTION_GET_INPUT_VOLTAGE, [], '', 10, 'S'
454
+ end
455
+
456
+ # Sets the current with which the motor will be driven.
457
+ #
458
+ # .. warning::
459
+ # Do not set this value above the specifications of your stepper motor.
460
+ # Otherwise it may damage your motor.
461
+ def set_motor_current(current)
462
+ check_validity
463
+
464
+ send_request FUNCTION_SET_MOTOR_CURRENT, [current], 'S', 8, ''
465
+ end
466
+
467
+ # Returns the current as set by BrickletSilentStepperV2#set_motor_current.
468
+ def get_motor_current
469
+ check_validity
470
+
471
+ send_request FUNCTION_GET_MOTOR_CURRENT, [], '', 10, 'S'
472
+ end
473
+
474
+ # Enables/Disables the driver chip. The driver parameters can be configured (maximum velocity,
475
+ # acceleration, etc) before it is enabled.
476
+ #
477
+ # .. warning::
478
+ # Disabling the driver chip while the motor is still turning can damage the
479
+ # driver chip. The motor should be stopped calling BrickletSilentStepperV2#stop function
480
+ # before disabling the motor power. The BrickletSilentStepperV2#stop function will **not**
481
+ # wait until the motor is actually stopped. You have to explicitly wait for the
482
+ # appropriate time after calling the BrickletSilentStepperV2#stop function before calling
483
+ # the BrickletSilentStepperV2#set_enabled with false function.
484
+ def set_enabled(enabled)
485
+ check_validity
486
+
487
+ send_request FUNCTION_SET_ENABLED, [enabled], '?', 8, ''
488
+ end
489
+
490
+ # Returns *true* if the stepper driver is enabled, *false* otherwise.
491
+ def get_enabled
492
+ check_validity
493
+
494
+ send_request FUNCTION_GET_ENABLED, [], '', 9, '?'
495
+ end
496
+
497
+ # Sets the basic configuration parameters for the different modes (Stealth, Coolstep, Classic).
498
+ #
499
+ # * Standstill Current: This value can be used to lower the current during stand still. This might
500
+ # be reasonable to reduce the heating of the motor and the Bricklet 2.0. When the motor is in standstill
501
+ # the configured motor phase current will be driven until the configured
502
+ # Power Down Time is elapsed. After that the phase current will be reduced to the standstill
503
+ # current. The elapsed time for this reduction can be configured with the Standstill Delay Time.
504
+ # The maximum allowed value is the configured maximum motor current
505
+ # (see BrickletSilentStepperV2#set_motor_current).
506
+ #
507
+ # * Motor Run Current: The value sets the motor current when the motor is running.
508
+ # Use a value of at least one half of the global maximum motor current for a good
509
+ # microstep performance. The maximum allowed value is the current
510
+ # motor current. The API maps the entered value to 1/32 ... 32/32 of the maximum
511
+ # motor current. This value should be used to change the motor current during motor movement,
512
+ # whereas the global maximum motor current should not be changed while the motor is moving
513
+ # (see BrickletSilentStepperV2#set_motor_current).
514
+ #
515
+ # * Standstill Delay Time: Controls the duration for motor power down after a motion
516
+ # as soon as standstill is detected and the Power Down Time is expired. A high Standstill Delay
517
+ # Time results in a smooth transition that avoids motor jerk during power down.
518
+ #
519
+ # * Power Down Time: Sets the delay time after a stand still.
520
+ #
521
+ # * Stealth Threshold: Sets the upper threshold for Stealth mode.
522
+ # If the velocity of the motor goes above this value, Stealth mode is turned
523
+ # off. Otherwise it is turned on. In Stealth mode the torque declines with high speed.
524
+ #
525
+ # * Coolstep Threshold: Sets the lower threshold for Coolstep mode.
526
+ # The Coolstep Threshold needs to be above the Stealth Threshold.
527
+ #
528
+ # * Classic Threshold: Sets the lower threshold for classic mode.
529
+ # In classic mode the stepper becomes more noisy, but the torque is maximized.
530
+ #
531
+ # * High Velocity Chopper Mode: If High Velocity Chopper Mode is enabled, the stepper control
532
+ # is optimized to run the stepper motors at high velocities.
533
+ #
534
+ # If you want to use all three thresholds make sure that
535
+ # Stealth Threshold < Coolstep Threshold < Classic Threshold.
536
+ 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)
537
+ check_validity
538
+
539
+ 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, ''
540
+ end
541
+
542
+ # Returns the configuration as set by BrickletSilentStepperV2#set_basic_configuration.
543
+ def get_basic_configuration
544
+ check_validity
545
+
546
+ send_request FUNCTION_GET_BASIC_CONFIGURATION, [], '', 23, 'S S S S S S S ?'
547
+ end
548
+
549
+ # Note: If you don't know what any of this means you can very likely keep all of
550
+ # the values as default!
551
+ #
552
+ # Sets the Spreadcycle configuration parameters. Spreadcycle is a chopper algorithm which actively
553
+ # controls the motor current flow. More information can be found in the TMC2130 datasheet on page
554
+ # 47 (7 spreadCycle and Classic Chopper).
555
+ #
556
+ # * Slow Decay Duration: Controls duration of off time setting of slow decay phase.
557
+ # 0 = driver disabled, all bridges off. Use 1 only with Comparator Blank time >= 2.
558
+ #
559
+ # * Enable Random Slow Decay: Set to false to fix chopper off time as set by Slow Decay Duration.
560
+ # If you set it to true, Decay Duration is randomly modulated.
561
+ #
562
+ # * Fast Decay Duration: Sets the fast decay duration. This parameters is
563
+ # only used if the Chopper Mode is set to Fast Decay.
564
+ #
565
+ # * Hysteresis Start Value: Sets the hysteresis start value. This parameter is
566
+ # only used if the Chopper Mode is set to Spread Cycle.
567
+ #
568
+ # * Hysteresis End Value: Sets the hysteresis end value. This parameter is
569
+ # only used if the Chopper Mode is set to Spread Cycle.
570
+ #
571
+ # * Sine Wave Offset: Sets the sine wave offset. This parameters is
572
+ # only used if the Chopper Mode is set to Fast Decay. 1/512 of the value becomes added to the absolute
573
+ # value of the sine wave.
574
+ #
575
+ # * Chopper Mode: 0 = Spread Cycle, 1 = Fast Decay.
576
+ #
577
+ # * Comparator Blank Time: Sets the blank time of the comparator. Available values are
578
+ #
579
+ # * 0 = 16 clocks,
580
+ # * 1 = 24 clocks,
581
+ # * 2 = 36 clocks and
582
+ # * 3 = 54 clocks.
583
+ #
584
+ # A value of 1 or 2 is recommended for most applications.
585
+ #
586
+ # * Fast Decay Without Comparator: If set to true the current comparator usage for termination of the
587
+ # fast decay cycle is disabled.
588
+ 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)
589
+ check_validity
590
+
591
+ 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, ''
592
+ end
593
+
594
+ # Returns the configuration as set by BrickletSilentStepperV2#set_basic_configuration.
595
+ def get_spreadcycle_configuration
596
+ check_validity
597
+
598
+ send_request FUNCTION_GET_SPREADCYCLE_CONFIGURATION, [], '', 17, 'C ? C C c c C C ?'
599
+ end
600
+
601
+ # Note: If you don't know what any of this means you can very likely keep all of
602
+ # the values as default!
603
+ #
604
+ # Sets the configuration relevant for Stealth mode.
605
+ #
606
+ # * Enable Stealth: If set to true the stealth mode is enabled, if set to false the
607
+ # stealth mode is disabled, even if the speed is below the threshold set in BrickletSilentStepperV2#set_basic_configuration.
608
+ #
609
+ # * Amplitude: If autoscale is disabled, the PWM amplitude is scaled by this value. If autoscale is enabled,
610
+ # this value defines the maximum PWM amplitude change per half wave.
611
+ #
612
+ # * Gradient: If autoscale is disabled, the PWM gradient is scaled by this value. If autoscale is enabled,
613
+ # this value defines the maximum PWM gradient. With autoscale a value above 64 is recommended,
614
+ # otherwise the regulation might not be able to measure the current.
615
+ #
616
+ # * Enable Autoscale: If set to true, automatic current control is used. Otherwise the user defined
617
+ # amplitude and gradient are used.
618
+ #
619
+ # * Force Symmetric: If true, A symmetric PWM cycle is enforced. Otherwise the PWM value may change within each
620
+ # PWM cycle.
621
+ #
622
+ # * Freewheel Mode: The freewheel mode defines the behavior in stand still if the Standstill Current
623
+ # (see BrickletSilentStepperV2#set_basic_configuration) is set to 0.
624
+ def set_stealth_configuration(enable_stealth, amplitude, gradient, enable_autoscale, force_symmetric, freewheel_mode)
625
+ check_validity
626
+
627
+ send_request FUNCTION_SET_STEALTH_CONFIGURATION, [enable_stealth, amplitude, gradient, enable_autoscale, force_symmetric, freewheel_mode], '? C C ? ? C', 8, ''
628
+ end
629
+
630
+ # Returns the configuration as set by BrickletSilentStepperV2#set_stealth_configuration.
631
+ def get_stealth_configuration
632
+ check_validity
633
+
634
+ send_request FUNCTION_GET_STEALTH_CONFIGURATION, [], '', 14, '? C C ? ? C'
635
+ end
636
+
637
+ # Note: If you don't know what any of this means you can very likely keep all of
638
+ # the values as default!
639
+ #
640
+ # Sets the configuration relevant for Coolstep.
641
+ #
642
+ # * Minimum Stallguard Value: If the Stallguard result falls below this value*32, the motor current
643
+ # is increased to reduce motor load angle. A value of 0 turns Coolstep off.
644
+ #
645
+ # * Maximum Stallguard Value: If the Stallguard result goes above
646
+ # (Min Stallguard Value + Max Stallguard Value + 1) * 32, the motor current is decreased to save
647
+ # energy.
648
+ #
649
+ # * Current Up Step Width: Sets the up step increment per Stallguard value. The value range is 0-3,
650
+ # corresponding to the increments 1, 2, 4 and 8.
651
+ #
652
+ # * Current Down Step Width: Sets the down step decrement per Stallguard value. The value range is 0-3,
653
+ # corresponding to the decrements 1, 2, 8 and 16.
654
+ #
655
+ # * Minimum Current: Sets the minimum current for Coolstep current control. You can choose between
656
+ # half and quarter of the run current.
657
+ #
658
+ # * Stallguard Threshold Value: Sets the level for stall output (see BrickletSilentStepperV2#get_driver_status).
659
+ # A lower value gives a higher sensitivity. You have to find a suitable value for your
660
+ # motor by trial and error, 0 works for most motors.
661
+ #
662
+ # * Stallguard Mode: Set to 0 for standard resolution or 1 for filtered mode. In filtered mode the Stallguard
663
+ # signal will be updated every four full-steps.
664
+ 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)
665
+ check_validity
666
+
667
+ 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, ''
668
+ end
669
+
670
+ # Returns the configuration as set by BrickletSilentStepperV2#set_coolstep_configuration.
671
+ def get_coolstep_configuration
672
+ check_validity
673
+
674
+ send_request FUNCTION_GET_COOLSTEP_CONFIGURATION, [], '', 15, 'C C C C C c C'
675
+ end
676
+
677
+ # Note: If you don't know what any of this means you can very likely keep all of
678
+ # the values as default!
679
+ #
680
+ # Sets miscellaneous configuration parameters.
681
+ #
682
+ # * Disable Short To Ground Protection: Set to false to enable short to ground protection, otherwise
683
+ # it is disabled.
684
+ #
685
+ # * Synchronize Phase Frequency: With this parameter you can synchronize the chopper for both phases
686
+ # of a two phase motor to avoid the occurrence of a beat. The value range is 0-15. If set to 0,
687
+ # the synchronization is turned off. Otherwise the synchronization is done through the formula
688
+ # f_sync = f_clk/(value*64). In Classic Mode the synchronization is automatically switched off.
689
+ # f_clk is 12.8MHz.
690
+ def set_misc_configuration(disable_short_to_ground_protection, synchronize_phase_frequency)
691
+ check_validity
692
+
693
+ send_request FUNCTION_SET_MISC_CONFIGURATION, [disable_short_to_ground_protection, synchronize_phase_frequency], '? C', 8, ''
694
+ end
695
+
696
+ # Returns the configuration as set by BrickletSilentStepperV2#set_misc_configuration.
697
+ def get_misc_configuration
698
+ check_validity
699
+
700
+ send_request FUNCTION_GET_MISC_CONFIGURATION, [], '', 10, '? C'
701
+ end
702
+
703
+ # Configures the error LED to be either turned off, turned on, blink in
704
+ # heartbeat mode or show an error.
705
+ #
706
+ # If the LED is configured to show errors it has three different states:
707
+ #
708
+ # * Off: No error present.
709
+ # * 250ms interval blink: Overtemperature warning.
710
+ # * 1s interval blink: Input voltage too small.
711
+ # * full red: motor disabled because of short to ground in phase a or b or because of overtemperature.
712
+ def set_error_led_config(config)
713
+ check_validity
714
+
715
+ send_request FUNCTION_SET_ERROR_LED_CONFIG, [config], 'C', 8, ''
716
+ end
717
+
718
+ # Returns the LED configuration as set by BrickletSilentStepperV2#set_error_led_config
719
+ def get_error_led_config
720
+ check_validity
721
+
722
+ send_request FUNCTION_GET_ERROR_LED_CONFIG, [], '', 9, 'C'
723
+ end
724
+
725
+ # Returns the current driver status.
726
+ #
727
+ # * Open Load: Indicates if an open load is present on phase A, B or both. This could mean that there is a problem
728
+ # with the wiring of the motor. False detection can occur in fast motion as well as during stand still.
729
+ #
730
+ # * Short To Ground: Indicates if a short to ground is present on phase A, B or both. If this is detected the driver
731
+ # automatically becomes disabled and stays disabled until it is enabled again manually.
732
+ #
733
+ # * Over Temperature: The over temperature indicator switches to "Warning" if the driver IC warms up. The warning flag
734
+ # is expected during long duration stepper uses. If the temperature limit is reached the indicator switches
735
+ # to "Limit". In this case the driver becomes disabled until it cools down again.
736
+ #
737
+ # * Motor Stalled: Is true if a motor stall was detected.
738
+ #
739
+ # * Actual Motor Current: Indicates the actual current control scaling as used in Coolstep mode.
740
+ # It represents a multiplier of 1/32 to 32/32 of the
741
+ # ``Motor Run Current`` as set by BrickletSilentStepperV2#set_basic_configuration. Example: If a ``Motor Run Current``
742
+ # of 1000mA was set and the returned value is 15, the ``Actual Motor Current`` is 16/32*1000mA = 500mA.
743
+ #
744
+ # * Stallguard Result: Indicates the load of the motor. A lower value signals a higher load. Per trial and error
745
+ # you can find out which value corresponds to a suitable torque for the velocity used in your application.
746
+ # After that you can use this threshold value to find out if a motor stall becomes probable and react on it (e.g.
747
+ # decrease velocity).
748
+ # During stand still this value can not be used for stall detection, it shows the chopper on-time for motor coil A.
749
+ #
750
+ # * Stealth Voltage Amplitude: Shows the actual PWM scaling. In Stealth mode it can be used to detect motor load and
751
+ # stall if autoscale is enabled (see BrickletSilentStepperV2#set_stealth_configuration).
752
+ def get_driver_status
753
+ check_validity
754
+
755
+ send_request FUNCTION_GET_DRIVER_STATUS, [], '', 16, 'C C C ? C ? C C'
756
+ end
757
+
758
+ # Sets the minimum voltage, below which the CALLBACK_UNDER_VOLTAGE callback
759
+ # is triggered. The minimum possible value that works with the Silent Stepper
760
+ # Bricklet 2.0 is 8V.
761
+ # You can use this function to detect the discharge of a battery that is used
762
+ # to drive the stepper motor. If you have a fixed power supply, you likely do
763
+ # not need this functionality.
764
+ def set_minimum_voltage(voltage)
765
+ check_validity
766
+
767
+ send_request FUNCTION_SET_MINIMUM_VOLTAGE, [voltage], 'S', 8, ''
768
+ end
769
+
770
+ # Returns the minimum voltage as set by BrickletSilentStepperV2#set_minimum_voltage.
771
+ def get_minimum_voltage
772
+ check_validity
773
+
774
+ send_request FUNCTION_GET_MINIMUM_VOLTAGE, [], '', 10, 'S'
775
+ end
776
+
777
+ # Sets the time base of the velocity and the acceleration of the Silent Stepper
778
+ # Bricklet 2.0.
779
+ #
780
+ # For example, if you want to make one step every 1.5 seconds, you can set
781
+ # the time base to 15 and the velocity to 10. Now the velocity is
782
+ # 10steps/15s = 1steps/1.5s.
783
+ def set_time_base(time_base)
784
+ check_validity
785
+
786
+ send_request FUNCTION_SET_TIME_BASE, [time_base], 'L', 8, ''
787
+ end
788
+
789
+ # Returns the time base as set by BrickletSilentStepperV2#set_time_base.
790
+ def get_time_base
791
+ check_validity
792
+
793
+ send_request FUNCTION_GET_TIME_BASE, [], '', 12, 'L'
794
+ end
795
+
796
+ # Returns the following parameters: The current velocity,
797
+ # the current position, the remaining steps, the stack voltage, the external
798
+ # voltage and the current consumption of the stepper motor.
799
+ #
800
+ # The current consumption is calculated by multiplying the ``Actual Motor Current``
801
+ # value (see BrickletSilentStepperV2#set_basic_configuration) with the ``Motor Run Current``
802
+ # (see BrickletSilentStepperV2#get_driver_status). This is an internal calculation of the
803
+ # driver, not an independent external measurement.
804
+ #
805
+ # The current consumption calculation was broken up to firmware 2.0.1, it is fixed
806
+ # since firmware 2.0.2.
807
+ #
808
+ # There is also a callback for this function, see CALLBACK_ALL_DATA callback.
809
+ def get_all_data
810
+ check_validity
811
+
812
+ send_request FUNCTION_GET_ALL_DATA, [], '', 22, 'S l l S S'
813
+ end
814
+
815
+ # Sets the period with which the CALLBACK_ALL_DATA callback is triggered
816
+ # periodically. A value of 0 turns the callback off.
817
+ def set_all_callback_configuration(period)
818
+ check_validity
819
+
820
+ send_request FUNCTION_SET_ALL_CALLBACK_CONFIGURATION, [period], 'L', 8, ''
821
+ end
822
+
823
+ # Returns the period as set by BrickletSilentStepperV2#set_all_callback_configuration.
824
+ def get_all_data_callback_configuraton
825
+ check_validity
826
+
827
+ send_request FUNCTION_GET_ALL_DATA_CALLBACK_CONFIGURATON, [], '', 12, 'L'
828
+ end
829
+
830
+ # Sets the GPIO configuration for the given channel.
831
+ # You can configure a debounce and the deceleration that is used if the action is
832
+ # configured as ``normal stop``. See BrickletSilentStepperV2#set_gpio_action.
833
+ def set_gpio_configuration(channel, debounce, stop_deceleration)
834
+ check_validity
835
+
836
+ send_request FUNCTION_SET_GPIO_CONFIGURATION, [channel, debounce, stop_deceleration], 'C S S', 8, ''
837
+ end
838
+
839
+ # Returns the GPIO configuration for a channel as set by BrickletSilentStepperV2#set_gpio_configuration.
840
+ def get_gpio_configuration(channel)
841
+ check_validity
842
+
843
+ send_request FUNCTION_GET_GPIO_CONFIGURATION, [channel], 'C', 12, 'S S'
844
+ end
845
+
846
+ # Sets the GPIO action for the given channel.
847
+ #
848
+ # The action can be a normal stop, a full brake or a callback. Each for a rising
849
+ # edge or falling edge. The actions are a bitmask they can be used at the same time.
850
+ # You can for example trigger a full brake and a callback at the same time or for
851
+ # rising and falling edge.
852
+ #
853
+ # The deceleration speed for the normal stop can be configured with
854
+ # BrickletSilentStepperV2#set_gpio_configuration.
855
+ def set_gpio_action(channel, action)
856
+ check_validity
857
+
858
+ send_request FUNCTION_SET_GPIO_ACTION, [channel, action], 'C L', 8, ''
859
+ end
860
+
861
+ # Returns the GPIO action for a channel as set by BrickletSilentStepperV2#set_gpio_action.
862
+ def get_gpio_action(channel)
863
+ check_validity
864
+
865
+ send_request FUNCTION_GET_GPIO_ACTION, [channel], 'C', 12, 'L'
866
+ end
867
+
868
+ # Returns the GPIO state for both channels. True if the state is ``high`` and
869
+ # false if the state is ``low``.
870
+ def get_gpio_state
871
+ check_validity
872
+
873
+ send_request FUNCTION_GET_GPIO_STATE, [], '', 9, '?2'
874
+ end
875
+
876
+ # Returns the error count for the communication between Brick and Bricklet.
877
+ #
878
+ # The errors are divided into
879
+ #
880
+ # * ACK checksum errors,
881
+ # * message checksum errors,
882
+ # * framing errors and
883
+ # * overflow errors.
884
+ #
885
+ # The errors counts are for errors that occur on the Bricklet side. All
886
+ # Bricks have a similar function that returns the errors on the Brick side.
887
+ def get_spitfp_error_count
888
+ check_validity
889
+
890
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
891
+ end
892
+
893
+ # Sets the bootloader mode and returns the status after the requested
894
+ # mode change was instigated.
895
+ #
896
+ # You can change from bootloader mode to firmware mode and vice versa. A change
897
+ # from bootloader mode to firmware mode will only take place if the entry function,
898
+ # device identifier and CRC are present and correct.
899
+ #
900
+ # This function is used by Brick Viewer during flashing. It should not be
901
+ # necessary to call it in a normal user program.
902
+ def set_bootloader_mode(mode)
903
+ check_validity
904
+
905
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
906
+ end
907
+
908
+ # Returns the current bootloader mode, see BrickletSilentStepperV2#set_bootloader_mode.
909
+ def get_bootloader_mode
910
+ check_validity
911
+
912
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
913
+ end
914
+
915
+ # Sets the firmware pointer for BrickletSilentStepperV2#write_firmware. The pointer has
916
+ # to be increased by chunks of size 64. The data is written to flash
917
+ # every 4 chunks (which equals to one page of size 256).
918
+ #
919
+ # This function is used by Brick Viewer during flashing. It should not be
920
+ # necessary to call it in a normal user program.
921
+ def set_write_firmware_pointer(pointer)
922
+ check_validity
923
+
924
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
925
+ end
926
+
927
+ # Writes 64 Bytes of firmware at the position as written by
928
+ # BrickletSilentStepperV2#set_write_firmware_pointer before. The firmware is written
929
+ # to flash every 4 chunks.
930
+ #
931
+ # You can only write firmware in bootloader mode.
932
+ #
933
+ # This function is used by Brick Viewer during flashing. It should not be
934
+ # necessary to call it in a normal user program.
935
+ def write_firmware(data)
936
+ check_validity
937
+
938
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
939
+ end
940
+
941
+ # Sets the status LED configuration. By default the LED shows
942
+ # communication traffic between Brick and Bricklet, it flickers once
943
+ # for every 10 received data packets.
944
+ #
945
+ # You can also turn the LED permanently on/off or show a heartbeat.
946
+ #
947
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
948
+ def set_status_led_config(config)
949
+ check_validity
950
+
951
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
952
+ end
953
+
954
+ # Returns the configuration as set by BrickletSilentStepperV2#set_status_led_config
955
+ def get_status_led_config
956
+ check_validity
957
+
958
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
959
+ end
960
+
961
+ # Returns the temperature as measured inside the microcontroller. The
962
+ # value returned is not the ambient temperature!
963
+ #
964
+ # The temperature is only proportional to the real temperature and it has bad
965
+ # accuracy. Practically it is only useful as an indicator for
966
+ # temperature changes.
967
+ def get_chip_temperature
968
+ check_validity
969
+
970
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
971
+ end
972
+
973
+ # Calling this function will reset the Bricklet. All configurations
974
+ # will be lost.
975
+ #
976
+ # After a reset you have to create new device objects,
977
+ # calling functions on the existing ones will result in
978
+ # undefined behavior!
979
+ def reset
980
+ check_validity
981
+
982
+ send_request FUNCTION_RESET, [], '', 8, ''
983
+ end
984
+
985
+ # Writes a new UID into flash. If you want to set a new UID
986
+ # you have to decode the Base58 encoded UID string into an
987
+ # integer first.
988
+ #
989
+ # We recommend that you use Brick Viewer to change the UID.
990
+ def write_uid(uid)
991
+ check_validity
992
+
993
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
994
+ end
995
+
996
+ # Returns the current UID as an integer. Encode as
997
+ # Base58 to get the usual string version.
998
+ def read_uid
999
+ check_validity
1000
+
1001
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
1002
+ end
1003
+
1004
+ # Returns the UID, the UID where the Bricklet is connected to,
1005
+ # the position, the hardware and firmware version as well as the
1006
+ # device identifier.
1007
+ #
1008
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
1009
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
1010
+ # position 'z'.
1011
+ #
1012
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
1013
+ # |device_identifier_constant|
1014
+ def get_identity
1015
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
1016
+ end
1017
+
1018
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
1019
+ def register_callback(id, &block)
1020
+ callback = block
1021
+ @registered_callbacks[id] = callback
1022
+ end
1023
+ end
1024
+ end