public class BrickStepper extends Device
Modifier and Type | Class and Description |
---|---|
class |
BrickStepper.AllData |
static interface |
BrickStepper.AllDataListener
This listener is triggered periodically with the period that is set by
setAllDataPeriod(long) . |
static interface |
BrickStepper.NewStateListener
This listener is triggered whenever the Stepper Brick enters a new state.
|
static interface |
BrickStepper.PositionReachedListener
This listener is triggered when a position set by
setSteps(int) or
setTargetPosition(int) is reached. |
class |
BrickStepper.Protocol1BrickletName |
class |
BrickStepper.SpeedRamping |
class |
BrickStepper.SPITFPBaudrateConfig |
class |
BrickStepper.SPITFPErrorCount |
static interface |
BrickStepper.UnderVoltageListener
This listener is triggered when the input voltage drops below the value set by
setMinimumVoltage(int) . |
Device.Identity
Constructor and Description |
---|
BrickStepper(String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and Description |
---|---|
void |
addAllDataListener(BrickStepper.AllDataListener listener)
Adds a AllData listener.
|
void |
addNewStateListener(BrickStepper.NewStateListener listener)
Adds a NewState listener.
|
void |
addPositionReachedListener(BrickStepper.PositionReachedListener listener)
Adds a PositionReached listener.
|
void |
addUnderVoltageListener(BrickStepper.UnderVoltageListener listener)
Adds a UnderVoltage listener.
|
void |
disable()
Disables the driver chip.
|
void |
disableStatusLED()
Disables the status LED.
|
void |
driveBackward()
Drives the stepper motor backward until
driveForward() or
stop() is triggered. |
void |
driveForward()
Drives the stepper motor forward until
driveBackward() or
stop() is called. |
void |
enable()
Enables the driver chip.
|
void |
enableStatusLED()
Enables the status LED.
|
void |
fullBrake()
Executes an active full brake.
|
BrickStepper.AllData |
getAllData()
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.
|
long |
getAllDataPeriod()
Returns the period as set by
setAllDataPeriod(long) . |
short |
getChipTemperature()
Returns the temperature as measured inside the microcontroller.
|
int |
getCurrentConsumption()
Returns the current consumption of the motor.
|
int |
getCurrentPosition()
Returns the current position of the stepper motor in steps.
|
int |
getCurrentVelocity()
Returns the *current* velocity of the stepper motor.
|
int |
getDecay()
Returns the decay mode as set by
setDecay(int) . |
int |
getExternalInputVoltage()
Returns the external input voltage.
|
Device.Identity |
getIdentity()
Returns the UID, the UID where the Brick is connected to,
the position, the hardware and firmware version as well as the
device identifier.
|
int |
getMaxVelocity()
Returns the velocity as set by
setMaxVelocity(int) . |
int |
getMinimumVoltage()
Returns the minimum voltage as set by
setMinimumVoltage(int) . |
int |
getMotorCurrent()
Returns the current as set by
setMotorCurrent(int) . |
BrickStepper.Protocol1BrickletName |
getProtocol1BrickletName(char port)
Returns the firmware and protocol version and the name of the Bricklet for a
given port.
|
int |
getRemainingSteps()
Returns the remaining steps of the last call of
setSteps(int) . |
long |
getSendTimeoutCount(short communicationMethod)
Returns the timeout count for the different communication methods.
|
BrickStepper.SpeedRamping |
getSpeedRamping()
Returns the acceleration and deacceleration as set by
setSpeedRamping(int, int) . |
long |
getSPITFPBaudrate(char brickletPort)
Returns the baudrate for a given Bricklet port, see
setSPITFPBaudrate(char, long) . |
BrickStepper.SPITFPBaudrateConfig |
getSPITFPBaudrateConfig()
Returns the baudrate config, see
setSPITFPBaudrateConfig(boolean, long) . |
BrickStepper.SPITFPErrorCount |
getSPITFPErrorCount(char brickletPort)
Returns the error count for the communication between Brick and Bricklet.
|
int |
getStackInputVoltage()
Returns the stack input voltage.
|
short |
getStepMode()
Returns the step mode as set by
setStepMode(short) . |
int |
getSteps()
Returns the last steps as set by
setSteps(int) . |
int |
getTargetPosition()
Returns the last target position as set by
setTargetPosition(int) . |
long |
getTimeBase()
Returns the time base as set by
setTimeBase(long) . |
boolean |
isEnabled()
Returns *true* if the driver chip is enabled, *false* otherwise.
|
boolean |
isStatusLEDEnabled()
Returns *true* if the status LED is enabled, *false* otherwise.
|
boolean |
isSyncRect()
Returns *true* if synchronous rectification is enabled, *false* otherwise.
|
short[] |
readBrickletPlugin(char port,
short offset)
Reads 32 bytes of firmware from the bricklet attached at the given port.
|
void |
removeAllDataListener(BrickStepper.AllDataListener listener)
Removes a AllData listener.
|
void |
removeNewStateListener(BrickStepper.NewStateListener listener)
Removes a NewState listener.
|
void |
removePositionReachedListener(BrickStepper.PositionReachedListener listener)
Removes a PositionReached listener.
|
void |
removeUnderVoltageListener(BrickStepper.UnderVoltageListener listener)
Removes a UnderVoltage listener.
|
void |
reset()
Calling this function will reset the Brick.
|
void |
setAllDataPeriod(long period)
Sets the period with which the
BrickStepper.AllDataListener listener is triggered
periodically. |
void |
setCurrentPosition(int position)
Sets the current steps of the internal step counter.
|
void |
setDecay(int decay)
Sets the decay mode of the stepper motor.
|
void |
setMaxVelocity(int velocity)
Sets the maximum velocity of the stepper motor.
|
void |
setMinimumVoltage(int voltage)
Sets the minimum voltage, below which the
BrickStepper.UnderVoltageListener listener
is triggered. |
void |
setMotorCurrent(int current)
Sets the current with which the motor will be driven.
|
void |
setSpeedRamping(int acceleration,
int deacceleration)
Sets the acceleration and deacceleration of the stepper motor.
|
void |
setSPITFPBaudrate(char brickletPort,
long baudrate)
Sets the baudrate for a specific Bricklet port.
|
void |
setSPITFPBaudrateConfig(boolean enableDynamicBaudrate,
long minimumDynamicBaudrate)
The SPITF protocol can be used with a dynamic baudrate.
|
void |
setStepMode(short mode)
Sets the step mode of the stepper motor.
|
void |
setSteps(int steps)
Sets the number of steps the stepper motor should run.
|
void |
setSyncRect(boolean syncRect)
Turns synchronous rectification on or off (*true* or *false*).
|
void |
setTargetPosition(int position)
Sets the target position of the stepper motor in steps.
|
void |
setTimeBase(long timeBase)
Sets the time base of the velocity and the acceleration of the stepper brick.
|
void |
stop()
Stops the stepper motor with the deacceleration as set by
setSpeedRamping(int, int) . |
void |
writeBrickletPlugin(char port,
short offset,
short[] chunk)
Writes 32 bytes of firmware to the bricklet attached at the given port.
|
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
public static final int DEVICE_IDENTIFIER
public static final String DEVICE_DISPLAY_NAME
public static final byte FUNCTION_SET_MAX_VELOCITY
public static final byte FUNCTION_GET_MAX_VELOCITY
public static final byte FUNCTION_GET_CURRENT_VELOCITY
public static final byte FUNCTION_SET_SPEED_RAMPING
public static final byte FUNCTION_GET_SPEED_RAMPING
public static final byte FUNCTION_FULL_BRAKE
public static final byte FUNCTION_SET_CURRENT_POSITION
public static final byte FUNCTION_GET_CURRENT_POSITION
public static final byte FUNCTION_SET_TARGET_POSITION
public static final byte FUNCTION_GET_TARGET_POSITION
public static final byte FUNCTION_SET_STEPS
public static final byte FUNCTION_GET_STEPS
public static final byte FUNCTION_GET_REMAINING_STEPS
public static final byte FUNCTION_SET_STEP_MODE
public static final byte FUNCTION_GET_STEP_MODE
public static final byte FUNCTION_DRIVE_FORWARD
public static final byte FUNCTION_DRIVE_BACKWARD
public static final byte FUNCTION_STOP
public static final byte FUNCTION_GET_STACK_INPUT_VOLTAGE
public static final byte FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE
public static final byte FUNCTION_GET_CURRENT_CONSUMPTION
public static final byte FUNCTION_SET_MOTOR_CURRENT
public static final byte FUNCTION_GET_MOTOR_CURRENT
public static final byte FUNCTION_ENABLE
public static final byte FUNCTION_DISABLE
public static final byte FUNCTION_IS_ENABLED
public static final byte FUNCTION_SET_DECAY
public static final byte FUNCTION_GET_DECAY
public static final byte FUNCTION_SET_MINIMUM_VOLTAGE
public static final byte FUNCTION_GET_MINIMUM_VOLTAGE
public static final byte FUNCTION_SET_SYNC_RECT
public static final byte FUNCTION_IS_SYNC_RECT
public static final byte FUNCTION_SET_TIME_BASE
public static final byte FUNCTION_GET_TIME_BASE
public static final byte FUNCTION_GET_ALL_DATA
public static final byte FUNCTION_SET_ALL_DATA_PERIOD
public static final byte FUNCTION_GET_ALL_DATA_PERIOD
public static final byte FUNCTION_SET_SPITFP_BAUDRATE_CONFIG
public static final byte FUNCTION_GET_SPITFP_BAUDRATE_CONFIG
public static final byte FUNCTION_GET_SEND_TIMEOUT_COUNT
public static final byte FUNCTION_SET_SPITFP_BAUDRATE
public static final byte FUNCTION_GET_SPITFP_BAUDRATE
public static final byte FUNCTION_GET_SPITFP_ERROR_COUNT
public static final byte FUNCTION_ENABLE_STATUS_LED
public static final byte FUNCTION_DISABLE_STATUS_LED
public static final byte FUNCTION_IS_STATUS_LED_ENABLED
public static final byte FUNCTION_GET_PROTOCOL1_BRICKLET_NAME
public static final byte FUNCTION_GET_CHIP_TEMPERATURE
public static final byte FUNCTION_RESET
public static final byte FUNCTION_WRITE_BRICKLET_PLUGIN
public static final byte FUNCTION_READ_BRICKLET_PLUGIN
public static final byte FUNCTION_GET_IDENTITY
public static final short STEP_MODE_FULL_STEP
public static final short STEP_MODE_HALF_STEP
public static final short STEP_MODE_QUARTER_STEP
public static final short STEP_MODE_EIGHTH_STEP
public static final short STATE_STOP
public static final short STATE_ACCELERATION
public static final short STATE_RUN
public static final short STATE_DEACCELERATION
public static final short STATE_DIRECTION_CHANGE_TO_FORWARD
public static final short STATE_DIRECTION_CHANGE_TO_BACKWARD
public static final short COMMUNICATION_METHOD_NONE
public static final short COMMUNICATION_METHOD_USB
public static final short COMMUNICATION_METHOD_SPI_STACK
public static final short COMMUNICATION_METHOD_CHIBI
public static final short COMMUNICATION_METHOD_RS485
public static final short COMMUNICATION_METHOD_WIFI
public static final short COMMUNICATION_METHOD_ETHERNET
public static final short COMMUNICATION_METHOD_WIFI_V2
public BrickStepper(String uid, IPConnection ipcon)
public void setMaxVelocity(int velocity) throws TinkerforgeException
setTargetPosition(int)
, setSteps(int)
, driveForward()
or
driveBackward()
.TinkerforgeException
public int getMaxVelocity() throws TinkerforgeException
setMaxVelocity(int)
.TinkerforgeException
public int getCurrentVelocity() throws TinkerforgeException
TinkerforgeException
public void setSpeedRamping(int acceleration, int deacceleration) throws TinkerforgeException
TinkerforgeException
public BrickStepper.SpeedRamping getSpeedRamping() throws TinkerforgeException
setSpeedRamping(int, int)
.TinkerforgeException
public void fullBrake() throws TinkerforgeException
stop()
if you just want to stop the motor.TinkerforgeException
public void setCurrentPosition(int position) throws TinkerforgeException
TinkerforgeException
public int getCurrentPosition() throws TinkerforgeException
setTargetPosition(int)
, setSteps(int)
, driveForward()
or
driveBackward()
). It also is possible to reset the steps to 0 or
set them to any other desired value with setCurrentPosition(int)
.TinkerforgeException
public void setTargetPosition(int position) throws TinkerforgeException
setTargetPosition(int)
is
called with 1000, the stepper motor will drive 500 steps forward. It will
use the velocity, acceleration and deacceleration as set by
setMaxVelocity(int)
and setSpeedRamping(int, int)
.
A call of setTargetPosition(int)
with the parameter *x* is equivalent to
a call of setSteps(int)
with the parameter
(*x* - getCurrentPosition()
).TinkerforgeException
public int getTargetPosition() throws TinkerforgeException
setTargetPosition(int)
.TinkerforgeException
public void setSteps(int steps) throws TinkerforgeException
setMaxVelocity(int)
and setSpeedRamping(int, int)
will be used.TinkerforgeException
public int getSteps() throws TinkerforgeException
setSteps(int)
.TinkerforgeException
public int getRemainingSteps() throws TinkerforgeException
setSteps(int)
.
For example, if setSteps(int)
is called with 2000 and
getRemainingSteps()
is called after the motor has run for 500 steps,
it will return 1500.TinkerforgeException
public void setStepMode(short mode) throws TinkerforgeException
TinkerforgeException
public short getStepMode() throws TinkerforgeException
setStepMode(short)
.TinkerforgeException
public void driveForward() throws TinkerforgeException
driveBackward()
or
stop()
is called. The velocity, acceleration and deacceleration as
set by setMaxVelocity(int)
and setSpeedRamping(int, int)
will be used.TinkerforgeException
public void driveBackward() throws TinkerforgeException
driveForward()
or
stop()
is triggered. The velocity, acceleration and deacceleration as
set by setMaxVelocity(int)
and setSpeedRamping(int, int)
will be used.TinkerforgeException
public void stop() throws TinkerforgeException
setSpeedRamping(int, int)
.TinkerforgeException
public int getStackInputVoltage() throws TinkerforgeException
TinkerforgeException
public int getExternalInputVoltage() throws TinkerforgeException
TinkerforgeException
public int getCurrentConsumption() throws TinkerforgeException
TinkerforgeException
public void setMotorCurrent(int current) throws TinkerforgeException
TinkerforgeException
public int getMotorCurrent() throws TinkerforgeException
setMotorCurrent(int)
.TinkerforgeException
public void enable() throws TinkerforgeException
TinkerforgeException
public void disable() throws TinkerforgeException
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.TinkerforgeException
public boolean isEnabled() throws TinkerforgeException
TinkerforgeException
public void setDecay(int decay) throws TinkerforgeException
setSyncRect(boolean)
).
For a good explanation of the different decay modes see
`this <https://ebldc.com/?p=86/>`__ 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 valueTinkerforgeException
public int getDecay() throws TinkerforgeException
setDecay(int)
.TinkerforgeException
public void setMinimumVoltage(int voltage) throws TinkerforgeException
BrickStepper.UnderVoltageListener
listener
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.TinkerforgeException
public int getMinimumVoltage() throws TinkerforgeException
setMinimumVoltage(int)
.TinkerforgeException
public void setSyncRect(boolean syncRect) throws TinkerforgeException
setDecay(int)
). Without synchronous rectification fast
decay is used.
For an explanation of synchronous rectification see
`here <https://en.wikipedia.org/wiki/Active_rectification>`__.
\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.TinkerforgeException
public boolean isSyncRect() throws TinkerforgeException
TinkerforgeException
public void setTimeBase(long timeBase) throws TinkerforgeException
TinkerforgeException
public long getTimeBase() throws TinkerforgeException
setTimeBase(long)
.TinkerforgeException
public BrickStepper.AllData getAllData() throws TinkerforgeException
BrickStepper.AllDataListener
listener.TinkerforgeException
public void setAllDataPeriod(long period) throws TinkerforgeException
BrickStepper.AllDataListener
listener is triggered
periodically. A value of 0 turns the listener off.TinkerforgeException
public long getAllDataPeriod() throws TinkerforgeException
setAllDataPeriod(long)
.TinkerforgeException
public void setSPITFPBaudrateConfig(boolean enableDynamicBaudrate, long minimumDynamicBaudrate) throws TinkerforgeException
setSPITFPBaudrate(char, long)
. If the dynamic baudrate is disabled, the baudrate
as set by setSPITFPBaudrate(char, long)
will be used statically.
.. versionadded:: 2.3.6$nbsp;(Firmware)TinkerforgeException
public BrickStepper.SPITFPBaudrateConfig getSPITFPBaudrateConfig() throws TinkerforgeException
setSPITFPBaudrateConfig(boolean, long)
.
.. versionadded:: 2.3.6$nbsp;(Firmware)TinkerforgeException
public long getSendTimeoutCount(short communicationMethod) throws TinkerforgeException
TinkerforgeException
public void setSPITFPBaudrate(char brickletPort, long baudrate) throws TinkerforgeException
getSPITFPErrorCount(char)
) you can decrease the
baudrate.
If the dynamic baudrate feature is enabled, the baudrate set by this
function corresponds to the maximum baudrate (see setSPITFPBaudrateConfig(boolean, long)
).
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.3$nbsp;(Firmware)TinkerforgeException
public long getSPITFPBaudrate(char brickletPort) throws TinkerforgeException
setSPITFPBaudrate(char, long)
.
.. versionadded:: 2.3.3$nbsp;(Firmware)TinkerforgeException
public BrickStepper.SPITFPErrorCount getSPITFPErrorCount(char brickletPort) throws TinkerforgeException
TinkerforgeException
public void enableStatusLED() throws TinkerforgeException
TinkerforgeException
public void disableStatusLED() throws TinkerforgeException
TinkerforgeException
public boolean isStatusLEDEnabled() throws TinkerforgeException
TinkerforgeException
public BrickStepper.Protocol1BrickletName getProtocol1BrickletName(char port) throws TinkerforgeException
TinkerforgeException
public short getChipTemperature() throws TinkerforgeException
TinkerforgeException
public void reset() throws TinkerforgeException
TinkerforgeException
public void writeBrickletPlugin(char port, short offset, short[] chunk) throws TinkerforgeException
TinkerforgeException
public short[] readBrickletPlugin(char port, short offset) throws TinkerforgeException
TinkerforgeException
public Device.Identity getIdentity() throws TinkerforgeException
getIdentity
in class Device
TinkerforgeException
public void addUnderVoltageListener(BrickStepper.UnderVoltageListener listener)
public void removeUnderVoltageListener(BrickStepper.UnderVoltageListener listener)
public void addPositionReachedListener(BrickStepper.PositionReachedListener listener)
public void removePositionReachedListener(BrickStepper.PositionReachedListener listener)
public void addAllDataListener(BrickStepper.AllDataListener listener)
public void removeAllDataListener(BrickStepper.AllDataListener listener)
public void addNewStateListener(BrickStepper.NewStateListener listener)
public void removeNewStateListener(BrickStepper.NewStateListener listener)
Copyright © 2022 Tinkerforge GmbH. All rights reserved.