Warning
The openHAB bindings are still in beta, but the development was stopped.
This is the description of the openHAB API bindings for the Stepper Brick. General information and technical specifications for the Stepper Brick are summarized in its hardware description.
An installation guide for the openHAB API bindings is part of their general description.
UID:
- tinkerforge:brickstepper:[UID]
Required firmware version:
- 2.3.6
Firmware update supported:
- no
Channels: Actions:
- SetMaxVelocity
- GetMaxVelocity
- GetCurrentVelocity
- SetSpeedRamping
- GetSpeedRamping
- FullBrake
- SetSteps
- GetSteps
- GetRemainingSteps
- DriveForward
- DriveBackward
- Stop
- SetMotorCurrent
- GetMotorCurrent
- Enable
- Disable
- IsEnabled
- SetCurrentPosition
- GetCurrentPosition
- SetTargetPosition
- GetTargetPosition
- SetStepMode
- GetStepMode
- GetStackInputVoltage
- GetExternalInputVoltage
- GetCurrentConsumption
- SetDecay
- GetDecay
- SetSyncRect
- IsSyncRect
- SetTimeBase
- GetTimeBase
- GetAllData
- GetAllDataPeriod
- GetIdentity
- IsStatusLEDEnabled
- GetChipTemperature
- GetSendTimeoutCount
- GetSPITFPBaudrateConfig
- GetSPITFPErrorCount
- GetSPITFPBaudrate
Parameters:
- All Data Update Interval – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
- Specifies the update interval for all data in milliseconds. A value of 0 disables automatic updates.
- Minimum Voltage – Type: decimal, Default: 8, Unit: V, Min: 0, Max: 65.535
- The minimum voltage in V, below which the Unter Voltage channel is triggered. The minimum possible value that works with the Stepper Brick is 8V. 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. The default value is 8V.
- Status LED Configuration – Type: boolean, Default: true
- 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.
- SPITFP Enable Dynamic Baudrate – Type: boolean, Default: true
- 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. If the dynamic baudrate is disabled, the maximum baudrate will be used statically.
- SPITFP Minimum Dynamic Baudrate – Type: integer, Default: 400000, Min: 400000, Max: 2000000
- See SPITFP Enable Dynamic Baudrate
- (Maximum) SPITFP Baudrate Port A – Type: integer, Default: 1400000, Min: 400000, Max: 2000000
- The baudrate for Bricklet port A. 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 you can decrease the baudrate. If the dynamic baudrate feature is enabled, this is the maximum baudrate. 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.
- (Maximum) SPITFP Baudrate Port B – Type: integer, Default: 1400000, Min: 400000, Max: 2000000
- The baudrate for Bricklet port B. 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 you can decrease the baudrate. If the dynamic baudrate feature is enabled, this is the maximum baudrate. 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.
Velocity
¶The current velocity of the stepper motor in steps per second.
Type:
- Number:Dimensionless
UID:
- tinkerforge:brickstepper:[UID]:BrickStepperCurrentVelocity
Read only:
- Yes
Position
¶The current position of the stepper motor in steps. On startup the position is 0.
Type:
- Number:Dimensionless
UID:
- tinkerforge:brickstepper:[UID]:BrickStepperCurrentPosition
Read only:
- Yes
Remaining Steps
¶The remaining steps of the last call of the setSteps() action.
Type:
- Number:Dimensionless
UID:
- tinkerforge:brickstepper:[UID]:BrickStepperRemainingSteps
Read only:
- Yes
Stack Voltage
¶The stack input voltage in V. 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.
Type:
- Number:ElectricPotential
UID:
- tinkerforge:brickstepper:[UID]:BrickStepperStackVoltage
Read only:
- Yes
Unit:
- Volt
External Voltage
¶The external input voltage in mV. The external input voltage is given via the black power input connector on the Stepper Brick.
If there is an external input voltage and a stack input voltage, the motor will be driven by the external input voltage. If there is only a stack voltage present, the motor will be driven by this voltage.
<b>Warning: This means, if you have a high stack voltage and a low external voltage, the motor 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</b>
Type:
- Number:ElectricPotential
UID:
- tinkerforge:brickstepper:[UID]:BrickStepperExternalVoltage
Read only:
- Yes
Unit:
- Volt
Current Consumption
¶The current consumption of the motor in A.
Type:
- Number:ElectricCurrent
UID:
- tinkerforge:brickstepper:[UID]:BrickStepperCurrentConsumption
Read only:
- Yes
Unit:
- Ampere
State
¶State of the brick:
Type:
- Number
UID:
- tinkerforge:brickstepper:[UID]:BrickStepperState
Read only:
- Yes
Previous State
¶State of the brick:
Type:
- Number
UID:
- tinkerforge:brickstepper:[UID]:BrickStepperPreviousState
Read only:
- Yes
Position Reached
¶This channel is triggered when a position set by the setSteps or setTargetPosition action is reached.
Note
Since we can't get any feedback from the stepper motor, this only works if the acceleration is set smaller or equal to the maximum acceleration of the motor. Otherwise the motor will lag behind the control value and the listener will be triggered too early.
Type:
- Trigger (system.trigger)
UID:
- tinkerforge:brickstepper:[UID]:BrickStepperPositionReached
Read only:
- No
Unter Voltage
¶This channel is triggered when the input voltage drops below the configured minimum voltage.
Type:
- Trigger (system.trigger)
UID:
- tinkerforge:brickstepper:[UID]:BrickStepperUnterVoltage
Read only:
- No
Actions can be used in rules by creating an action object. All actions return a Map<String, Object>. Returned values can be accessed by name, sometimes the type deduction needs some hints, as shown below:
val actions = getActions("tinkerforge", "tinkerforge:brickstepper:[UID]")
val hwVersion = actions.brickStepperGetIdentity().get("hardwareVersion") as short[]
logInfo("Example", "Hardware version: " + hwVersion.get(0) + "." + hwVersion.get(1) + "." + hwVersion.get(2))
brickStepperSetMaxVelocity
(int velocity)¶Parameters: |
|
---|
Sets the maximum velocity of the stepper motor.
This function does not start the motor, it merely sets the maximum
velocity the stepper motor is accelerated to. To get the motor running use
either SetTargetPosition()
, SetSteps()
, DriveForward()
or
DriveBackward()
.
brickStepperGetMaxVelocity
()¶Return Map: |
|
---|
Returns the velocity as set by SetMaxVelocity()
.
brickStepperGetCurrentVelocity
()¶Return Map: |
|
---|
Returns the current velocity of the stepper motor.
brickStepperSetSpeedRamping
(int acceleration, int deacceleration)¶Parameters: |
|
---|
Sets the acceleration and deacceleration of the stepper motor. An acceleration of 1000 means, that every second the velocity is increased by 1000 steps/s.
For example: If the current velocity is 0 and you want to accelerate to a velocity of 8000 steps/s in 10 seconds, you should set an acceleration of 800 steps/s².
An acceleration/deacceleration of 0 means instantaneous acceleration/deacceleration (not recommended)
brickStepperGetSpeedRamping
()¶Return Map: |
|
---|
Returns the acceleration and deacceleration as set by
SetSpeedRamping()
.
brickStepperFullBrake
()¶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 Stop()
if you just want to stop the motor.
brickStepperSetSteps
(int steps)¶Parameters: |
|
---|
Sets the number of steps the stepper motor should run. Positive values
will drive the motor forward and negative values backward.
The velocity, acceleration and deacceleration as set by
SetMaxVelocity()
and SetSpeedRamping()
will be used.
brickStepperGetSteps
()¶Return Map: |
|
---|
Returns the last steps as set by SetSteps()
.
brickStepperGetRemainingSteps
()¶Return Map: |
|
---|
Returns the remaining steps of the last call of SetSteps()
.
For example, if SetSteps()
is called with 2000 and
GetRemainingSteps()
is called after the motor has run for 500 steps,
it will return 1500.
brickStepperDriveForward
()¶Drives the stepper motor forward until DriveBackward()
or
Stop()
is called. The velocity, acceleration and deacceleration as
set by SetMaxVelocity()
and SetSpeedRamping()
will be used.
brickStepperDriveBackward
()¶Drives the stepper motor backward until DriveForward()
or
Stop()
is triggered. The velocity, acceleration and deacceleration as
set by SetMaxVelocity()
and SetSpeedRamping()
will be used.
brickStepperStop
()¶Stops the stepper motor with the deacceleration as set by
SetSpeedRamping()
.
brickStepperSetMotorCurrent
(int current)¶Parameters: |
|
---|
Sets the current with which the motor will be driven.
Warning
Do not set this value above the specifications of your stepper motor. Otherwise it may damage your motor.
brickStepperGetMotorCurrent
()¶Return Map: |
|
---|
Returns the current as set by SetMotorCurrent()
.
brickStepperEnable
()¶Enables the driver chip. The driver parameters can be configured (maximum velocity, acceleration, etc) before it is enabled.
brickStepperDisable
()¶Disables the driver chip. The configurations are kept (maximum velocity, acceleration, etc) but the motor is not driven until it is enabled again.
Warning
Disabling the driver chip while the motor is still turning can damage the
driver chip. The motor should be stopped calling Stop()
function
before disabling the motor power. The Stop()
function will not
wait until the motor is actually stopped. You have to explicitly wait for the
appropriate time after calling the Stop()
function before calling
the Disable()
function.
brickStepperIsEnabled
()¶Return Map: |
|
---|
Returns true if the driver chip is enabled, false otherwise.
brickStepperSetCurrentPosition
(int position)¶Parameters: |
|
---|
Sets the current steps of the internal step counter. This can be used to set the current position to 0 when some kind of starting position is reached (e.g. when a CNC machine reaches a corner).
brickStepperGetCurrentPosition
()¶Return Map: |
|
---|
Returns the current position of the stepper motor in steps. On startup
the position is 0. The steps are counted with all possible driving
functions (SetTargetPosition()
, SetSteps()
, DriveForward()
or
DriveBackward()
). It also is possible to reset the steps to 0 or
set them to any other desired value with SetCurrentPosition()
.
brickStepperSetTargetPosition
(int position)¶Parameters: |
|
---|
Sets the target position of the stepper motor in steps. For example,
if the current position of the motor is 500 and SetTargetPosition()
is
called with 1000, the stepper motor will drive 500 steps forward. It will
use the velocity, acceleration and deacceleration as set by
SetMaxVelocity()
and SetSpeedRamping()
.
A call of SetTargetPosition()
with the parameter x is equivalent to
a call of SetSteps()
with the parameter
(x - GetCurrentPosition()
).
brickStepperGetTargetPosition
()¶Return Map: |
|
---|
Returns the last target position as set by SetTargetPosition()
.
brickStepperSetStepMode
(short mode)¶Parameters: |
|
---|
Sets the step mode of the stepper motor. Possible values are:
A higher value will increase the resolution and decrease the torque of the stepper motor.
The following constants are available for this function:
For mode:
brickStepperGetStepMode
()¶Return Map: |
|
---|
Returns the step mode as set by SetStepMode()
.
The following constants are available for this function:
For mode:
brickStepperGetStackInputVoltage
()¶Return Map: |
|
---|
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.
brickStepperGetExternalInputVoltage
()¶Return Map: |
|
---|
Returns the external input voltage. The external input voltage is given via the black power input connector on the Stepper Brick.
If there is an external input voltage and a stack input voltage, the motor will be driven by the external input voltage. If there is only a stack voltage present, the motor will be driven by this voltage.
Warning
This means, if you have a high stack voltage and a low external voltage, the motor 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
brickStepperGetCurrentConsumption
()¶Return Map: |
|
---|
Returns the current consumption of the motor.
brickStepperSetDecay
(int decay)¶Parameters: |
|
---|
Sets the decay mode of the stepper motor. A value of 0 sets the fast decay mode, a value of 65535 sets the slow decay mode and a value in between sets the mixed decay mode.
Changing the decay mode is only possible if synchronous rectification
is enabled (see SetSyncRect()
).
For a good explanation of the different decay modes see this blog post by Avayan.
A good decay mode is unfortunately different for every motor. The best way to work out a good decay mode for your stepper motor, if you can't measure the current with an oscilloscope, is to listen to the sound of the motor. If the value is too low, you often hear a high pitched sound and if it is too high you can often hear a humming sound.
Generally, fast decay mode (small value) will be noisier but also allow higher motor speeds.
Note
There is unfortunately no formula to calculate a perfect decay mode for a given stepper motor. If you have problems with loud noises or the maximum motor speed is too slow, you should try to tinker with the decay value
brickStepperGetDecay
()¶Return Map: |
|
---|
Returns the decay mode as set by SetDecay()
.
brickStepperSetSyncRect
(boolean syncRect)¶Parameters: |
|
---|
Turns synchronous rectification on or off (true or false).
With synchronous rectification on, the decay can be changed
(see SetDecay()
). Without synchronous rectification fast
decay is used.
For an explanation of synchronous rectification see here.
Warning
If you want to use high speeds (> 10000 steps/s) for a large stepper motor with a large inductivity we strongly suggest that you disable synchronous rectification. Otherwise the Brick may not be able to cope with the load and overheat.
brickStepperIsSyncRect
()¶Return Map: |
|
---|
Returns true if synchronous rectification is enabled, false otherwise.
brickStepperSetTimeBase
(long timeBase)¶Parameters: |
|
---|
Sets the time base of the velocity and the acceleration of the stepper brick.
For example, if you want to make one step every 1.5 seconds, you can set the time base to 15 and the velocity to 10. Now the velocity is 10steps/15s = 1steps/1.5s.
brickStepperGetTimeBase
()¶Return Map: |
|
---|
Returns the time base as set by SetTimeBase()
.
brickStepperGetAllData
()¶Return Map: |
|
---|
Returns the following parameters: The current velocity, the current position, the remaining steps, the stack voltage, the external voltage and the current consumption of the stepper motor.
brickStepperGetIdentity
()¶Return Map: |
|
---|
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 here.
brickStepperIsStatusLEDEnabled
()¶Return Map: |
|
---|
Returns true if the status LED is enabled, false otherwise.
New in version 2.3.1 (Firmware).
brickStepperGetChipTemperature
()¶Return Map: |
|
---|
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.
brickStepperGetSendTimeoutCount
(short communicationMethod)¶Parameters: |
|
---|---|
Return Map: |
|
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.
The following constants are available for this function:
For communicationMethod:
New in version 2.3.4 (Firmware).
brickStepperGetSPITFPBaudrateConfig
()¶Return Map: |
|
---|
Returns the baudrate config, see the thing configuration.
New in version 2.3.6 (Firmware).
brickStepperGetSPITFPErrorCount
(char brickletPort)¶Parameters: |
|
---|---|
Return Map: |
|
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 Brick side. All Bricklets have a similar function that returns the errors on the Bricklet side.
New in version 2.3.3 (Firmware).
brickStepperGetSPITFPBaudrate
(char brickletPort)¶Parameters: |
|
---|---|
Return Map: |
|
Returns the baudrate for a given Bricklet port, see the thing configuration.
New in version 2.3.3 (Firmware).