This is the description of the TCP/IP protocol for the Servo Bricklet 2.0. General information and technical specifications for the Servo Bricklet 2.0 are summarized in its hardware description.
A general description of the TCP/IP protocol structure can be found here.
Every function of the Servo Brick API that has a servo_channel parameter can
address a servo with the servo channel (0 to 9). If it is a setter function then
multiple servos can be addressed at once with a bitmask for the
servos, if the highest bit is set. For example: 1
will address servo 1,
(1 << 1) | (1 << 5) | (1 << 15)
will address servos 1 and 5.
This allows to set configurations to several
servos with one function call. It is guaranteed that the changes will take
effect in the same PWM period for all servos you specified in the bitmask.
BrickletServoV2.
get_status
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the status information of the Servo Bricklet 2.0.
The status includes
Please note that the position and the velocity is a snapshot of the current position and velocity of the servo in motion.
BrickletServoV2.
set_enable
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Enables a servo channel (0 to 9). If a servo is enabled, the configured position, velocity, acceleration, etc. are applied immediately.
BrickletServoV2.
get_enabled
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns true if the specified servo channel is enabled, false otherwise.
BrickletServoV2.
set_position
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the position in °/100 for the specified servo channel.
The default range of the position is -9000 to 9000, but it can be specified
according to your servo with 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
set_degree
.
BrickletServoV2.
get_position
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the position of the specified servo channel as set by set_position
.
BrickletServoV2.
get_current_position
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the current position of the specified servo channel. This may not be the
value of set_position
if the servo is currently approaching a
position goal.
BrickletServoV2.
get_current_velocity
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the current velocity of the specified servo channel. This may not be the
velocity specified by set_motion_configuration
. if the servo is
currently approaching a velocity goal.
BrickletServoV2.
set_motion_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the maximum velocity of the specified servo channel in °/100s as well as the acceleration and deceleration in °/100s²
With a velocity of 0 °/100s the position will be set immediately (no velocity).
With an acc-/deceleration of 0 °/100s² the velocity will be set immediately (no acc-/deceleration).
BrickletServoV2.
get_motion_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the motion configuration as set by set_motion_configuration
.
BrickletServoV2.
set_pulse_width
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the minimum and maximum pulse width of the specified servo channel in µs.
Usually, servos are controlled with a PWM, whereby the length of the pulse controls the position of the servo. Every servo has different minimum and maximum pulse widths, these can be specified with this function.
If you have a datasheet for your servo that specifies the minimum and maximum pulse width, you should set the values accordingly. If your servo comes without any datasheet you have to find the values via trial and error.
Both values have a range from 1 to 65535 (unsigned 16-bit integer). The minimum must be smaller than the maximum.
The default values are 1000µs (1ms) and 2000µs (2ms) for minimum and maximum pulse width.
BrickletServoV2.
get_pulse_width
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the minimum and maximum pulse width for the specified servo channel as set by
set_pulse_width
.
BrickletServoV2.
set_degree
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the minimum and maximum degree for the specified servo channel (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 set_position
with 0 will result in a pulse width of 1500µs
(-90° = 1000µs, 90° = 2000µs, etc.).
Possible usage:
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².set_position
now controls the rpm.Both values have a possible range from -32767 to 32767 (signed 16-bit integer). The minimum must be smaller than the maximum.
The default values are -9000 and 9000 for the minimum and maximum degree.
BrickletServoV2.
get_degree
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the minimum and maximum degree for the specified servo channel as set by
set_degree
.
BrickletServoV2.
set_period
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the period of the specified servo channel in µs.
Usually, servos are controlled with a PWM. Different servos expect PWMs with different periods. Most servos run well with a period of about 20ms.
If your servo comes with a datasheet that specifies a period, you should set it accordingly. If you don't have a datasheet and you have no idea what the correct period is, the default value (19.5ms) will most likely work fine.
The minimum possible period is 1µs and the maximum is 1000000µs.
The default value is 19.5ms (19500µs).
BrickletServoV2.
get_period
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the period for the specified servo channel as set by set_period
.
BrickletServoV2.
get_servo_current
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the current consumption of the specified servo channel in mA.
BrickletServoV2.
set_servo_current_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the averaging duration of the current measurement for the specified servo channel in ms.
BrickletServoV2.
get_servo_current_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the servo current configuration for the specified servo channel as set
by set_servo_current_configuration
.
BrickletServoV2.
set_input_voltage_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the averaging duration of the input voltage measurement for the specified servo channel in ms.
BrickletServoV2.
get_input_voltage_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the input voltage configuration as set by set_input_voltage_configuration
.
BrickletServoV2.
get_overall_current
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the current consumption of all servos together in mA.
BrickletServoV2.
get_input_voltage
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the input voltage in mV. The input voltage is given via the black power input connector on the Servo Brick.
BrickletServoV2.
set_current_calibration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets an offset value (in mA) for each channel.
Note: On delivery the Servo Bricklet 2.0 is already calibrated.
BrickletServoV2.
get_current_calibration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the current calibration as set by set_current_calibration
.
BrickletServoV2.
get_spitfp_error_count
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the error count for the communication between Brick and Bricklet.
The errors are divided into
The errors counts are for errors that occur on the Bricklet side. All Bricks have a similar function that returns the errors on the Brick side.
BrickletServoV2.
set_status_led_config
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the status LED configuration. By default the LED shows communication traffic between Brick and Bricklet, it flickers once for every 10 received data packets.
You can also turn the LED permanently on/off or show a heartbeat.
If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
The following meanings are defined for the elements of this function:
For config:
BrickletServoV2.
get_status_led_config
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the configuration as set by set_status_led_config
The following meanings are defined for the elements of this function:
For config:
BrickletServoV2.
get_chip_temperature
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
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 bad accuracy. Practically it is only useful as an indicator for temperature changes.
BrickletServoV2.
reset
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Calling this function will reset the Bricklet. All configurations will be lost.
After a reset you have to create new device objects, calling functions on the existing ones will result in undefined behavior!
BrickletServoV2.
get_identity
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an Isolator Bricklet is always at position 'z'.
The device identifier numbers can be found here.
BrickletServoV2.
set_position_reached_callback_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Enable/Disable CALLBACK_POSITION_REACHED
callback.
BrickletServoV2.
get_position_reached_callback_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the callback configuration as set by
set_position_reached_callback_configuration
.
BrickletServoV2.
CALLBACK_POSITION_REACHED
¶Function ID: |
|
---|---|
Response: |
|
This callback is triggered when a position set by 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 response values are the servo and the position that is reached.
You can enable this callback with set_position_reached_callback_configuration
.
Note
Since we can't get any feedback from the servo, this only works if the
velocity (see set_motion_configuration
) 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.
Internal functions are used for maintenance tasks such as flashing a new firmware of changing the UID of a Bricklet. These task should be performed using Brick Viewer instead of using the internal functions directly.
BrickletServoV2.
set_bootloader_mode
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the bootloader mode and returns the status after the requested mode change was instigated.
You can change from bootloader mode to firmware mode and vice versa. A change from bootloader mode to firmware mode will only take place if the entry function, device identifier and CRC are present and correct.
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
The following meanings are defined for the elements of this function:
For mode:
For status:
BrickletServoV2.
get_bootloader_mode
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the current bootloader mode, see set_bootloader_mode
.
The following meanings are defined for the elements of this function:
For mode:
BrickletServoV2.
set_write_firmware_pointer
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the firmware pointer for write_firmware
. The pointer has
to be increased by chunks of size 64. The data is written to flash
every 4 chunks (which equals to one page of size 256).
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
BrickletServoV2.
write_firmware
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Writes 64 Bytes of firmware at the position as written by
set_write_firmware_pointer
before. The firmware is written
to flash every 4 chunks.
You can only write firmware in bootloader mode.
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
BrickletServoV2.
write_uid
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Writes a new UID into flash. If you want to set a new UID you have to decode the Base58 encoded UID string into an integer first.
We recommend that you use Brick Viewer to change the UID.
BrickletServoV2.
read_uid
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the current UID as an integer. Encode as Base58 to get the usual string version.