class Tinkerforge::BrickServo
Drives up to 7 RC Servos with up to 3A
Constants
- CALLBACK_POSITION_REACHED
This callback is triggered when a position set by
BrickServo#set_position
is reached. If the new position matches the current position then the callback is not triggered, because the servo didn't move. The parameters are the servo and the position that is reached.You can enable this callback with
BrickServo#enable_position_reached_callback
.- .. note
-
Since we can't get any feedback from the servo, this only works if the velocity (see
BrickServo#set_velocity
) is set smaller or equal to the maximum velocity of the servo. Otherwise the servo will lag behind the control value and the callback will be triggered too early.
- CALLBACK_UNDER_VOLTAGE
This callback is triggered when the input voltage drops below the value set by
BrickServo#set_minimum_voltage
. The parameter is the current voltage.- CALLBACK_VELOCITY_REACHED
This callback is triggered when a velocity set by
BrickServo#set_velocity
is reached. The parameters are the servo and the velocity that is reached.You can enable this callback with
BrickServo#enable_velocity_reached_callback
.- .. note
-
Since we can't get any feedback from the servo, this only works if the acceleration (see
BrickServo#set_acceleration
) is set smaller or equal to the maximum acceleration of the servo. Otherwise the servo will lag behind the control value and the callback will be triggered too early.
Public Class Methods
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
# File lib/tinkerforge/brick_servo.rb, line 107 def initialize(uid, ipcon) super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME @api_version = [2, 0, 4] @response_expected[FUNCTION_ENABLE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_DISABLE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_IS_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_POSITION] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_CURRENT_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_VELOCITY] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_CURRENT_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_ACCELERATION] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_ACCELERATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_OUTPUT_VOLTAGE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_OUTPUT_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_PULSE_WIDTH] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_PULSE_WIDTH] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_DEGREE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_DEGREE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_PERIOD] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_SERVO_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_OVERALL_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_STACK_INPUT_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_MINIMUM_VOLTAGE] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_MINIMUM_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_ENABLE_POSITION_REACHED_CALLBACK] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_DISABLE_POSITION_REACHED_CALLBACK] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_IS_POSITION_REACHED_CALLBACK_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_ENABLE_VELOCITY_REACHED_CALLBACK] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_DISABLE_VELOCITY_REACHED_CALLBACK] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_IS_VELOCITY_REACHED_CALLBACK_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_SPITFP_BAUDRATE_CONFIG] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_SPITFP_BAUDRATE_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_SEND_TIMEOUT_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_SPITFP_BAUDRATE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_SPITFP_BAUDRATE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_ENABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_DISABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_IS_STATUS_LED_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_WRITE_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_READ_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE @callback_formats[CALLBACK_UNDER_VOLTAGE] = [10, 'S'] @callback_formats[CALLBACK_POSITION_REACHED] = [11, 'C s'] @callback_formats[CALLBACK_VELOCITY_REACHED] = [11, 'C s'] @ipcon.add_device self end
Public Instance Methods
Disables a servo (0 to 6). Disabled servos are not driven at all, i.e. a disabled servo will not hold its position if a load is applied.
# File lib/tinkerforge/brick_servo.rb, line 176 def disable(servo_num) check_validity send_request FUNCTION_DISABLE, [servo_num], 'C', 8, '' end
Disables the CALLBACK_POSITION_REACHED
callback.
- .. versionadded
-
2.0.1$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 448 def disable_position_reached_callback check_validity send_request FUNCTION_DISABLE_POSITION_REACHED_CALLBACK, [], '', 8, '' end
Disables the status LED.
The status LED is the blue LED next to the USB connector. If enabled is is on and it flickers if data is transfered. If disabled it is always off.
The default state is enabled.
- .. versionadded
-
2.3.1$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 614 def disable_status_led check_validity send_request FUNCTION_DISABLE_STATUS_LED, [], '', 8, '' end
Disables the CALLBACK_VELOCITY_REACHED
callback.
Default is disabled.
- .. versionadded
-
2.0.1$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 479 def disable_velocity_reached_callback check_validity send_request FUNCTION_DISABLE_VELOCITY_REACHED_CALLBACK, [], '', 8, '' end
Enables a servo (0 to 6). If a servo is enabled, the configured position, velocity, acceleration, etc. are applied immediately.
# File lib/tinkerforge/brick_servo.rb, line 168 def enable(servo_num) check_validity send_request FUNCTION_ENABLE, [servo_num], 'C', 8, '' end
Enables the CALLBACK_POSITION_REACHED
callback.
Default is disabled.
- .. versionadded
-
2.0.1$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 439 def enable_position_reached_callback check_validity send_request FUNCTION_ENABLE_POSITION_REACHED_CALLBACK, [], '', 8, '' end
Enables the status LED.
The status LED is the blue LED next to the USB connector. If enabled is is on and it flickers if data is transfered. If disabled it is always off.
The default state is enabled.
- .. versionadded
-
2.3.1$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 600 def enable_status_led check_validity send_request FUNCTION_ENABLE_STATUS_LED, [], '', 8, '' end
Enables the CALLBACK_VELOCITY_REACHED
callback.
Default is disabled.
- .. versionadded
-
2.0.1$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 468 def enable_velocity_reached_callback check_validity send_request FUNCTION_ENABLE_VELOCITY_REACHED_CALLBACK, [], '', 8, '' end
Returns the acceleration for the specified servo as set by BrickServo#set_acceleration
.
# File lib/tinkerforge/brick_servo.rb, line 258 def get_acceleration(servo_num) check_validity send_request FUNCTION_GET_ACCELERATION, [servo_num], 'C', 10, 'S' end
Returns the temperature as measured inside the microcontroller. The value returned is not the ambient temperature!
The temperature is only proportional to the real temperature and it has an accuracy of ±15%. Practically it is only useful as an indicator for temperature changes.
# File lib/tinkerforge/brick_servo.rb, line 646 def get_chip_temperature check_validity send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's' end
Returns the current position of the specified servo. This may not be the value of BrickServo#set_position
if the servo is currently approaching a position goal.
# File lib/tinkerforge/brick_servo.rb, line 213 def get_current_position(servo_num) check_validity send_request FUNCTION_GET_CURRENT_POSITION, [servo_num], 'C', 10, 's' end
Returns the current velocity of the specified servo. This may not be the value of BrickServo#set_velocity
if the servo is currently approaching a velocity goal.
# File lib/tinkerforge/brick_servo.rb, line 240 def get_current_velocity(servo_num) check_validity send_request FUNCTION_GET_CURRENT_VELOCITY, [servo_num], 'C', 10, 'S' end
Returns the minimum and maximum degree for the specified servo as set by BrickServo#set_degree
.
# File lib/tinkerforge/brick_servo.rb, line 345 def get_degree(servo_num) check_validity send_request FUNCTION_GET_DEGREE, [servo_num], 'C', 12, 's s' end
Returns the external input voltage. The external input voltage is given via the black power input connector on the Servo Brick.
If there is an external input voltage and a stack input voltage, the motors will be driven by the external input voltage. If there is only a stack voltage present, the motors will be driven by this voltage.
- .. warning
-
This means, if you have a high stack voltage and a low external voltage, the motors will be driven with the low external voltage. If you then remove the external connection, it will immediately be driven by the high stack voltage
# File lib/tinkerforge/brick_servo.rb, line 410 def get_external_input_voltage check_validity send_request FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE, [], '', 10, 'S' end
Returns the UID, the UID where the Brick is connected to, the position, the hardware and firmware version as well as the device identifier.
The position is the position in the stack from '0' (bottom) to '8' (top).
The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|
# File lib/tinkerforge/brick_servo.rb, line 694 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end
Returns the minimum voltage as set by BrickServo#set_minimum_voltage
# File lib/tinkerforge/brick_servo.rb, line 428 def get_minimum_voltage check_validity send_request FUNCTION_GET_MINIMUM_VOLTAGE, [], '', 10, 'S' end
Returns the output voltage as specified by BrickServo#set_output_voltage
.
# File lib/tinkerforge/brick_servo.rb, line 277 def get_output_voltage check_validity send_request FUNCTION_GET_OUTPUT_VOLTAGE, [], '', 10, 'S' end
Returns the current consumption of all servos together.
# File lib/tinkerforge/brick_servo.rb, line 383 def get_overall_current check_validity send_request FUNCTION_GET_OVERALL_CURRENT, [], '', 10, 'S' end
Returns the period for the specified servo as set by BrickServo#set_period
.
# File lib/tinkerforge/brick_servo.rb, line 369 def get_period(servo_num) check_validity send_request FUNCTION_GET_PERIOD, [servo_num], 'C', 10, 'S' end
Returns the position of the specified servo as set by BrickServo#set_position
.
# File lib/tinkerforge/brick_servo.rb, line 204 def get_position(servo_num) check_validity send_request FUNCTION_GET_POSITION, [servo_num], 'C', 10, 's' end
Returns the firmware and protocol version and the name of the Bricklet for a given port.
This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet plugins.
# File lib/tinkerforge/brick_servo.rb, line 634 def get_protocol1_bricklet_name(port) check_validity send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 52, 'C C3 Z40' end
Returns the minimum and maximum pulse width for the specified servo as set by BrickServo#set_pulse_width
.
# File lib/tinkerforge/brick_servo.rb, line 304 def get_pulse_width(servo_num) check_validity send_request FUNCTION_GET_PULSE_WIDTH, [servo_num], 'C', 12, 'S S' end
Returns the timeout count for the different communication methods.
The methods 0-2 are available for all Bricks, 3-7 only for Master Bricks.
This function is mostly used for debugging during development, in normal operation the counters should nearly always stay at 0.
- .. versionadded
-
2.3.2$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 537 def get_send_timeout_count(communication_method) check_validity send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 12, 'L' end
Returns the current consumption of the specified servo.
# File lib/tinkerforge/brick_servo.rb, line 376 def get_servo_current(servo_num) check_validity send_request FUNCTION_GET_SERVO_CURRENT, [servo_num], 'C', 10, 'S' end
Returns the baudrate for a given Bricklet port, see BrickServo#set_spitfp_baudrate
.
- .. versionadded
-
2.3.2$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 567 def get_spitfp_baudrate(bricklet_port) check_validity send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 12, 'L' end
Returns the baudrate config, see BrickServo#set_spitfp_baudrate_config
.
- .. versionadded
-
2.3.4$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 523 def get_spitfp_baudrate_config check_validity send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 13, '? L' end
Returns the error count for the communication between Brick and Bricklet.
The errors are divided into
-
ACK checksum errors,
-
message checksum errors,
-
framing errors and
-
overflow errors.
The errors counts are for errors that occur on the Brick side. All Bricklets have a similar function that returns the errors on the Bricklet side.
- .. versionadded
-
2.3.2$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 586 def get_spitfp_error_count(bricklet_port) check_validity send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 24, 'L L L L' end
Returns the stack input voltage. The stack input voltage is the voltage that is supplied via the stack, i.e. it is given by a Step-Down or Step-Up Power Supply.
# File lib/tinkerforge/brick_servo.rb, line 392 def get_stack_input_voltage check_validity send_request FUNCTION_GET_STACK_INPUT_VOLTAGE, [], '', 10, 'S' end
Returns the velocity of the specified servo as set by BrickServo#set_velocity
.
# File lib/tinkerforge/brick_servo.rb, line 231 def get_velocity(servo_num) check_validity send_request FUNCTION_GET_VELOCITY, [servo_num], 'C', 10, 'S' end
Returns true if the specified servo is enabled, false otherwise.
# File lib/tinkerforge/brick_servo.rb, line 183 def is_enabled(servo_num) check_validity send_request FUNCTION_IS_ENABLED, [servo_num], 'C', 9, '?' end
Returns true if CALLBACK_POSITION_REACHED
callback is enabled, false otherwise.
- .. versionadded
-
2.0.1$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 457 def is_position_reached_callback_enabled check_validity send_request FUNCTION_IS_POSITION_REACHED_CALLBACK_ENABLED, [], '', 9, '?' end
Returns true if the status LED is enabled, false otherwise.
- .. versionadded
-
2.3.1$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 623 def is_status_led_enabled check_validity send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 9, '?' end
Returns true if CALLBACK_VELOCITY_REACHED
callback is enabled, false otherwise.
- .. versionadded
-
2.0.1$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 488 def is_velocity_reached_callback_enabled check_validity send_request FUNCTION_IS_VELOCITY_REACHED_CALLBACK_ENABLED, [], '', 9, '?' end
Reads 32 bytes of firmware from the bricklet attached at the given port. The bytes are read starting at the position offset * 32.
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
# File lib/tinkerforge/brick_servo.rb, line 680 def read_bricklet_plugin(port, offset) check_validity send_request FUNCTION_READ_BRICKLET_PLUGIN, [port, offset], 'k C', 40, 'C32' end
Registers a callback with ID id
to the block block
.
# File lib/tinkerforge/brick_servo.rb, line 699 def register_callback(id, &block) callback = block @registered_callbacks[id] = callback end
Calling this function will reset the Brick. Calling this function on a Brick inside of a stack will reset the whole stack.
After a reset you have to create new device objects, calling functions on the existing ones will result in undefined behavior!
# File lib/tinkerforge/brick_servo.rb, line 658 def reset check_validity send_request FUNCTION_RESET, [], '', 8, '' end
Sets the acceleration of the specified servo.
The minimum acceleration is 1 and the maximum acceleration is 65535. With a value of 65535 the velocity will be set immediately (no acceleration).
# File lib/tinkerforge/brick_servo.rb, line 250 def set_acceleration(servo_num, acceleration) check_validity send_request FUNCTION_SET_ACCELERATION, [servo_num, acceleration], 'C S', 8, '' end
Sets the minimum and maximum degree for the specified servo (by default given as °/100).
This only specifies the abstract values between which the minimum and maximum pulse width is scaled. For example: If you specify a pulse width of 1000µs to 2000µs and a degree range of -90° to 90°, a call of BrickServo#set_position
with 0 will result in a pulse width of 1500µs (-90° = 1000µs, 90° = 2000µs, etc.).
Possible usage:
-
The datasheet of your servo specifies a range of 200° with the middle position at 110°. In this case you can set the minimum to -9000 and the maximum to 11000.
-
You measure a range of 220° on your servo and you don't have or need a middle position. In this case you can set the minimum to 0 and the maximum to 22000.
-
You have a linear servo with a drive length of 20cm, In this case you could set the minimum to 0 and the maximum to 20000. Now you can set the Position with
BrickServo#set_position
with a resolution of cm/100. Also the velocity will have a resolution of cm/100s and the acceleration will have a resolution of cm/100s². -
You don't care about units and just want the highest possible resolution. In this case you should set the minimum to -32767 and the maximum to 32767.
-
You have a brushless motor with a maximum speed of 10000 rpm and want to control it with a RC brushless motor controller. In this case you can set the minimum to 0 and the maximum to 10000.
BrickServo#set_position
now controls the rpm.
The minimum must be smaller than the maximum.
# File lib/tinkerforge/brick_servo.rb, line 337 def set_degree(servo_num, min, max) check_validity send_request FUNCTION_SET_DEGREE, [servo_num, min, max], 'C s s', 8, '' end
Sets the minimum voltage, below which the CALLBACK_UNDER_VOLTAGE
callback is triggered. The minimum possible value that works with the Servo Brick is 5V. You can use this function to detect the discharge of a battery that is used to drive the stepper motor. If you have a fixed power supply, you likely do not need this functionality.
# File lib/tinkerforge/brick_servo.rb, line 421 def set_minimum_voltage(voltage) check_validity send_request FUNCTION_SET_MINIMUM_VOLTAGE, [voltage], 'S', 8, '' end
Sets the output voltages with which the servos are driven.
- .. note
-
We recommend that you set this value to the maximum voltage that is specified for your servo, most servos achieve their maximum force only with high voltages.
# File lib/tinkerforge/brick_servo.rb, line 270 def set_output_voltage(voltage) check_validity send_request FUNCTION_SET_OUTPUT_VOLTAGE, [voltage], 'S', 8, '' end
Sets the period of the specified servo.
Usually, servos are controlled with a `PWM <
# File lib/tinkerforge/brick_servo.rb, line 362
def set_period(servo_num, period)
check_validity
send_request FUNCTION_SET_PERIOD, [servo_num, period], 'C S', 8, ''
end
Sets the position for the specified servo.
The default range of the position is -9000 to 9000, but it can be specified according to your servo with BrickServo#set_degree
.
If you want to control a linear servo or RC brushless motor controller or similar with the Servo Brick, you can also define lengths or speeds with BrickServo#set_degree
.
# File lib/tinkerforge/brick_servo.rb, line 197 def set_position(servo_num, position) check_validity send_request FUNCTION_SET_POSITION, [servo_num, position], 'C s', 8, '' end
Sets the minimum and maximum pulse width of the specified servo.
Usually, servos are controlled with a `PWM <
# File lib/tinkerforge/brick_servo.rb, line 296
def set_pulse_width(servo_num, min, max)
check_validity
send_request FUNCTION_SET_PULSE_WIDTH, [servo_num, min, max], 'C S S', 8, ''
end
Sets the baudrate for a specific Bricklet port.
If you want to increase the throughput of Bricklets you can increase the baudrate. If you get a high error count because of high interference (see BrickServo#get_spitfp_error_count
) you can decrease the baudrate.
If the dynamic baudrate feature is enabled, the baudrate set by this function corresponds to the maximum baudrate (see BrickServo#set_spitfp_baudrate_config
).
Regulatory testing is done with the default baudrate. If CE compatibility or similar is necessary in your applications we recommend to not change the baudrate.
- .. versionadded
-
2.3.2$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 558 def set_spitfp_baudrate(bricklet_port, baudrate) check_validity send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 8, '' end
The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is enabled, the Brick will try to adapt the baudrate for the communication between Bricks and Bricklets according to the amount of data that is transferred.
The baudrate will be increased exponentially if lots of data is sent/received and decreased linearly if little data is sent/received.
This lowers the baudrate in applications where little data is transferred (e.g. a weather station) and increases the robustness. If there is lots of data to transfer (e.g. Thermal Imaging Bricklet) it automatically increases the baudrate as needed.
In cases where some data has to transferred as fast as possible every few seconds (e.g. RS485 Bricklet with a high baudrate but small payload) you may want to turn the dynamic baudrate off to get the highest possible performance.
The maximum value of the baudrate can be set per port with the function BrickServo#set_spitfp_baudrate
. If the dynamic baudrate is disabled, the baudrate as set by BrickServo#set_spitfp_baudrate
will be used statically.
- .. versionadded
-
2.3.4$nbsp;(Firmware)
# File lib/tinkerforge/brick_servo.rb, line 514 def set_spitfp_baudrate_config(enable_dynamic_baudrate, minimum_dynamic_baudrate) check_validity send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 8, '' end
Sets the maximum velocity of the specified servo. The velocity is accelerated according to the value set by BrickServo#set_acceleration
.
The minimum velocity is 0 (no movement) and the maximum velocity is 65535. With a value of 65535 the position will be set immediately (no velocity).
# File lib/tinkerforge/brick_servo.rb, line 224 def set_velocity(servo_num, velocity) check_validity send_request FUNCTION_SET_VELOCITY, [servo_num, velocity], 'C S', 8, '' end
Writes 32 bytes of firmware to the bricklet attached at the given port. The bytes are written to the position offset * 32.
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
# File lib/tinkerforge/brick_servo.rb, line 669 def write_bricklet_plugin(port, offset, chunk) check_validity send_request FUNCTION_WRITE_BRICKLET_PLUGIN, [port, offset, chunk], 'k C C32', 8, '' end