This is the description of the TCP/IP protocol for the Performance DC Bricklet. General information and technical specifications for the Performance DC Bricklet are summarized in its hardware description.
A general description of the TCP/IP protocol structure can be found here.
BrickletPerformanceDC.
set_enabled
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Enables/Disables the driver chip. The driver parameters can be configured (velocity, acceleration, etc) before it is enabled.
BrickletPerformanceDC.
get_enabled
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns true if the driver chip is enabled, false otherwise.
BrickletPerformanceDC.
set_velocity
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the velocity of the motor. Whereas -32767 is full speed backward,
0 is stop and 32767 is full speed forward. Depending on the
acceleration (see set_motion
), the motor is not immediately
brought to the velocity but smoothly accelerated.
The velocity describes the duty cycle of the PWM with which the motor is
controlled, e.g. a velocity of 3277 sets a PWM with a 10% duty cycle.
You can not only control the duty cycle of the PWM but also the frequency,
see set_pwm_frequency
.
BrickletPerformanceDC.
get_velocity
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the velocity as set by set_velocity
.
BrickletPerformanceDC.
get_current_velocity
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the current velocity of the motor. This value is different
from get_velocity
whenever the motor is currently accelerating
to a goal set by set_velocity
.
BrickletPerformanceDC.
set_motion
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the acceleration and deceleration of the motor. It is given in velocity/s. An acceleration of 10000 means, that every second the velocity is increased by 10000 (or about 30% duty cycle).
For example: If the current velocity is 0 and you want to accelerate to a velocity of 16000 (about 50% duty cycle) in 10 seconds, you should set an acceleration of 1600.
If acceleration and deceleration is set to 0, there is no speed ramping, i.e. a new velocity is immediately given to the motor.
BrickletPerformanceDC.
get_motion
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the acceleration/deceleration as set by set_motion
.
BrickletPerformanceDC.
full_brake
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Executes an active full brake.
Warning
This function is for emergency purposes, where an immediate brake is necessary. Depending on the current velocity and the strength of the motor, a full brake can be quite violent.
Call set_velocity
with 0 if you just want to stop the motor.
BrickletPerformanceDC.
get_pwm_frequency
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the PWM frequency as set by set_pwm_frequency
.
BrickletPerformanceDC.
get_power_statistics
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns input voltage, current usage and temperature of the driver.
BrickletPerformanceDC.
set_thermal_shutdown
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets a temperature threshold that is used for thermal shutdown.
Additionally to this user defined threshold the driver chip will shut down at a temperature of 150°C.
If a thermal shutdown is triggered the driver is disabled and has to be
explicitly re-enabled with set_enabled
.
BrickletPerformanceDC.
get_thermal_shutdown
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the thermal shutdown temperature as set by set_thermal_shutdown
.
BrickletPerformanceDC.
set_gpio_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the GPIO configuration for the given channel.
You can configure a debounce and the deceleration that is used if the action is
configured as normal stop
. See set_gpio_action
.
BrickletPerformanceDC.
get_gpio_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the GPIO configuration for a channel as set by set_gpio_configuration
.
BrickletPerformanceDC.
set_gpio_action
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the GPIO action for the given channel.
The action can be a normal stop, a full brake or a callback. Each for a rising edge or falling edge. The actions are a bitmask they can be used at the same time. You can for example trigger a full brake and a callback at the same time or for rising and falling edge.
The deceleration speed for the normal stop can be configured with
set_gpio_configuration
.
The following meanings are defined for the elements of this function:
For action:
BrickletPerformanceDC.
get_gpio_action
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the GPIO action for a channel as set by set_gpio_action
.
The following meanings are defined for the elements of this function:
For action:
BrickletPerformanceDC.
get_gpio_state
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the GPIO state for both channels. True if the state is high
and
false if the state is low
.
BrickletPerformanceDC.
set_drive_mode
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the drive mode. Possible modes are:
These modes are different kinds of motor controls.
In Drive/Brake mode, the motor is always either driving or braking. There is no freewheeling. Advantages are: A more linear correlation between PWM and velocity, more exact accelerations and the possibility to drive with slower velocities.
In Drive/Coast mode, the motor is always either driving or freewheeling. Advantages are: Less current consumption and less demands on the motor and driver chip.
The following meanings are defined for the elements of this function:
For mode:
BrickletPerformanceDC.
get_drive_mode
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the drive mode, as set by set_drive_mode
.
The following meanings are defined for the elements of this function:
For mode:
BrickletPerformanceDC.
set_pwm_frequency
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Sets the frequency of the PWM with which the motor is driven. Often a high frequency is less noisy and the motor runs smoother. However, with a low frequency there are less switches and therefore fewer switching losses. Also with most motors lower frequencies enable higher torque.
If you have no idea what all this means, just ignore this function and use the default frequency, it will very likely work fine.
BrickletPerformanceDC.
set_error_led_config
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Configures the error LED to be either turned off, turned on, blink in heartbeat mode or show an error.
If the LED is configured to show errors it has three different states:
The following meanings are defined for the elements of this function:
For config:
BrickletPerformanceDC.
get_error_led_config
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the LED configuration as set by set_error_led_config
The following meanings are defined for the elements of this function:
For config:
BrickletPerformanceDC.
set_cw_led_config
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Configures the CW LED to be either turned off, turned on, blink in heartbeat mode or if the motor turn clockwise.
The following meanings are defined for the elements of this function:
For config:
BrickletPerformanceDC.
get_cw_led_config
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the LED configuration as set by set_cw_led_config
The following meanings are defined for the elements of this function:
For config:
BrickletPerformanceDC.
set_ccw_led_config
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Configures the CCW LED to be either turned off, turned on, blink in heartbeat mode or if the motor turn counter-clockwise.
The following meanings are defined for the elements of this function:
For config:
BrickletPerformanceDC.
get_ccw_led_config
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the LED configuration as set by set_ccw_led_config
The following meanings are defined for the elements of this function:
For config:
BrickletPerformanceDC.
set_gpio_led_config
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Configures the GPIO LED to be either turned off, turned on, blink in heartbeat mode or the GPIO state.
The GPIO LED can be configured for both channels.
The following meanings are defined for the elements of this function:
For config:
BrickletPerformanceDC.
get_gpio_led_config
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the LED configuration as set by set_gpio_led_config
The following meanings are defined for the elements of this function:
For config:
BrickletPerformanceDC.
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.
BrickletPerformanceDC.
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:
BrickletPerformanceDC.
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:
BrickletPerformanceDC.
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.
BrickletPerformanceDC.
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!
BrickletPerformanceDC.
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.
BrickletPerformanceDC.
set_emergency_shutdown_callback_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Enable/Disable CALLBACK_EMERGENCY_SHUTDOWN
callback.
BrickletPerformanceDC.
get_emergency_shutdown_callback_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the callback configuration as set by
set_emergency_shutdown_callback_configuration
.
BrickletPerformanceDC.
set_velocity_reached_callback_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Enable/Disable CALLBACK_VELOCITY_REACHED
callback.
BrickletPerformanceDC.
get_velocity_reached_callback_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the callback configuration as set by
set_velocity_reached_callback_configuration
.
BrickletPerformanceDC.
set_current_velocity_callback_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
The period is the period with which the CALLBACK_CURRENT_VELOCITY
callback is triggered periodically. A value of 0 turns the callback off.
If the value has to change-parameter is set to true, the callback is only triggered after the value has changed. If the value didn't change within the period, the callback is triggered immediately on change.
If it is set to false, the callback is continuously triggered with the period, independent of the value.
BrickletPerformanceDC.
get_current_velocity_callback_configuration
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the callback configuration as set by
set_current_velocity_callback_configuration
.
BrickletPerformanceDC.
CALLBACK_EMERGENCY_SHUTDOWN
¶Function ID: |
|
---|---|
Response: |
|
This callback is triggered if either the current consumption
is too high or the temperature of the driver chip is too high
(above 150°C) or the user defined thermal shutdown is triggered (see set_thermal_shutdown
).
n case of a voltage below 6V (input voltage) this
callback is triggered as well.
If this callback is triggered, the driver chip gets disabled at the same time.
That means, set_enabled
has to be called to drive the motor again.
BrickletPerformanceDC.
CALLBACK_VELOCITY_REACHED
¶Function ID: |
|
---|---|
Response: |
|
This callback is triggered whenever a set velocity is reached. For example:
If a velocity of 0 is present, acceleration is set to 5000 and velocity
to 10000, the CALLBACK_VELOCITY_REACHED
callback will be triggered after about
2 seconds, when the set velocity is actually reached.
Note
Since we can't get any feedback from the DC motor, this only works if the
acceleration (see set_motion
) is set smaller or equal to the
maximum acceleration of the motor. Otherwise the motor will lag behind the
control value and the callback will be triggered too early.
BrickletPerformanceDC.
CALLBACK_CURRENT_VELOCITY
¶Function ID: |
|
---|---|
Response: |
|
This callback is triggered with the period that is set by
set_current_velocity_callback_configuration
. The response value is the current
velocity used by the motor.
The CALLBACK_CURRENT_VELOCITY
callback is only triggered after the set period
if there is a change in the velocity.
BrickletPerformanceDC.
CALLBACK_GPIO_STATE
¶Function ID: |
|
---|---|
Response: |
|
This callback is triggered by GPIO changes if it is activated through set_gpio_action
.
New in version 2.0.1 (Plugin).
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.
BrickletPerformanceDC.
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:
BrickletPerformanceDC.
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:
BrickletPerformanceDC.
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.
BrickletPerformanceDC.
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.
BrickletPerformanceDC.
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.
BrickletPerformanceDC.
read_uid
¶Function ID: |
|
---|---|
Request: |
|
Response: |
|
Returns the current UID as an integer. Encode as Base58 to get the usual string version.