public class BrickDC extends Device
Modifier and Type | Class and Description |
---|---|
static interface |
BrickDC.CurrentVelocityListener
This listener is triggered with the period that is set by
setCurrentVelocityPeriod(int) . |
static interface |
BrickDC.EmergencyShutdownListener
This listener is triggered if either the current consumption
is too high (above 5A) or the temperature of the driver chip is too high
(above 175°C).
|
class |
BrickDC.Protocol1BrickletName |
class |
BrickDC.SPITFPBaudrateConfig |
class |
BrickDC.SPITFPErrorCount |
static interface |
BrickDC.UnderVoltageListener
This listener is triggered when the input voltage drops below the value set by
setMinimumVoltage(int) . |
static interface |
BrickDC.VelocityReachedListener
This listener is triggered whenever a set velocity is reached.
|
Device.Identity
Constructor and Description |
---|
BrickDC(String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and Description |
---|---|
void |
addCurrentVelocityListener(BrickDC.CurrentVelocityListener listener)
Adds a CurrentVelocity listener.
|
void |
addEmergencyShutdownListener(BrickDC.EmergencyShutdownListener listener)
Adds a EmergencyShutdown listener.
|
void |
addUnderVoltageListener(BrickDC.UnderVoltageListener listener)
Adds a UnderVoltage listener.
|
void |
addVelocityReachedListener(BrickDC.VelocityReachedListener listener)
Adds a VelocityReached listener.
|
void |
disable()
Disables the driver chip.
|
void |
disableStatusLED()
Disables the status LED.
|
void |
enable()
Enables the driver chip.
|
void |
enableStatusLED()
Enables the status LED.
|
void |
fullBrake()
Executes an active full brake.
|
int |
getAcceleration()
Returns the acceleration as set by
setAcceleration(int) . |
short |
getChipTemperature()
Returns the temperature as measured inside the microcontroller.
|
int |
getCurrentConsumption()
Returns the current consumption of the motor.
|
short |
getCurrentVelocity()
Returns the *current* velocity of the motor.
|
int |
getCurrentVelocityPeriod()
Returns the period as set by
setCurrentVelocityPeriod(int) . |
short |
getDriveMode()
Returns the drive mode, as set by
setDriveMode(short) . |
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 |
getMinimumVoltage()
Returns the minimum voltage as set by
setMinimumVoltage(int) |
BrickDC.Protocol1BrickletName |
getProtocol1BrickletName(char port)
Returns the firmware and protocol version and the name of the Bricklet for a
given port.
|
int |
getPWMFrequency()
Returns the PWM frequency as set by
setPWMFrequency(int) . |
long |
getSendTimeoutCount(short communicationMethod)
Returns the timeout count for the different communication methods.
|
long |
getSPITFPBaudrate(char brickletPort)
Returns the baudrate for a given Bricklet port, see
setSPITFPBaudrate(char, long) . |
BrickDC.SPITFPBaudrateConfig |
getSPITFPBaudrateConfig()
Returns the baudrate config, see
setSPITFPBaudrateConfig(boolean, long) . |
BrickDC.SPITFPErrorCount |
getSPITFPErrorCount(char brickletPort)
Returns the error count for the communication between Brick and Bricklet.
|
int |
getStackInputVoltage()
Returns the stack input voltage.
|
short |
getVelocity()
Returns the velocity as set by
setVelocity(short) . |
boolean |
isEnabled()
Returns *true* if the driver chip is enabled, *false* otherwise.
|
boolean |
isStatusLEDEnabled()
Returns *true* if the status LED is enabled, *false* otherwise.
|
short[] |
readBrickletPlugin(char port,
short offset)
Reads 32 bytes of firmware from the bricklet attached at the given port.
|
void |
removeCurrentVelocityListener(BrickDC.CurrentVelocityListener listener)
Removes a CurrentVelocity listener.
|
void |
removeEmergencyShutdownListener(BrickDC.EmergencyShutdownListener listener)
Removes a EmergencyShutdown listener.
|
void |
removeUnderVoltageListener(BrickDC.UnderVoltageListener listener)
Removes a UnderVoltage listener.
|
void |
removeVelocityReachedListener(BrickDC.VelocityReachedListener listener)
Removes a VelocityReached listener.
|
void |
reset()
Calling this function will reset the Brick.
|
void |
setAcceleration(int acceleration)
Sets the acceleration of the motor.
|
void |
setCurrentVelocityPeriod(int period)
Sets a period with which the
BrickDC.CurrentVelocityListener listener is triggered. |
void |
setDriveMode(short mode)
Sets the drive mode.
|
void |
setMinimumVoltage(int voltage)
Sets the minimum voltage, below which the
BrickDC.UnderVoltageListener listener
is triggered. |
void |
setPWMFrequency(int frequency)
Sets the frequency of the PWM with which the motor is driven.
|
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 |
setVelocity(short velocity)
Sets the velocity of the motor.
|
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_VELOCITY
public static final byte FUNCTION_GET_VELOCITY
public static final byte FUNCTION_GET_CURRENT_VELOCITY
public static final byte FUNCTION_SET_ACCELERATION
public static final byte FUNCTION_GET_ACCELERATION
public static final byte FUNCTION_SET_PWM_FREQUENCY
public static final byte FUNCTION_GET_PWM_FREQUENCY
public static final byte FUNCTION_FULL_BRAKE
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_ENABLE
public static final byte FUNCTION_DISABLE
public static final byte FUNCTION_IS_ENABLED
public static final byte FUNCTION_SET_MINIMUM_VOLTAGE
public static final byte FUNCTION_GET_MINIMUM_VOLTAGE
public static final byte FUNCTION_SET_DRIVE_MODE
public static final byte FUNCTION_GET_DRIVE_MODE
public static final byte FUNCTION_SET_CURRENT_VELOCITY_PERIOD
public static final byte FUNCTION_GET_CURRENT_VELOCITY_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 DRIVE_MODE_DRIVE_BRAKE
public static final short DRIVE_MODE_DRIVE_COAST
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 BrickDC(String uid, IPConnection ipcon)
public void setVelocity(short velocity) throws TinkerforgeException
setAcceleration(int)
), 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 setPWMFrequency(int)
.TinkerforgeException
public short getVelocity() throws TinkerforgeException
setVelocity(short)
.TinkerforgeException
public short getCurrentVelocity() throws TinkerforgeException
getVelocity()
whenever the motor is currently accelerating
to a goal set by setVelocity(short)
.TinkerforgeException
public void setAcceleration(int acceleration) throws TinkerforgeException
TinkerforgeException
public int getAcceleration() throws TinkerforgeException
setAcceleration(int)
.TinkerforgeException
public void setPWMFrequency(int frequency) throws TinkerforgeException
TinkerforgeException
public int getPWMFrequency() throws TinkerforgeException
setPWMFrequency(int)
.TinkerforgeException
public void fullBrake() throws TinkerforgeException
setVelocity(short)
with 0 if you just want to stop the motor.TinkerforgeException
public int getStackInputVoltage() throws TinkerforgeException
TinkerforgeException
public int getExternalInputVoltage() throws TinkerforgeException
TinkerforgeException
public int getCurrentConsumption() throws TinkerforgeException
TinkerforgeException
public void enable() throws TinkerforgeException
TinkerforgeException
public void disable() throws TinkerforgeException
setVelocity(short)
with 0
before disabling the motor power. The setVelocity(short)
function will **not**
wait until the motor is actually stopped. You have to explicitly wait for the
appropriate time after calling the setVelocity(short)
function before calling
the disable()
function.TinkerforgeException
public boolean isEnabled() throws TinkerforgeException
TinkerforgeException
public void setMinimumVoltage(int voltage) throws TinkerforgeException
BrickDC.UnderVoltageListener
listener
is triggered. The minimum possible value that works with the DC Brick is 6V.
You can use this function to detect the discharge of a battery that is used
to drive the 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 setDriveMode(short mode) throws TinkerforgeException
TinkerforgeException
public short getDriveMode() throws TinkerforgeException
setDriveMode(short)
.TinkerforgeException
public void setCurrentVelocityPeriod(int period) throws TinkerforgeException
BrickDC.CurrentVelocityListener
listener is triggered.
A period of 0 turns the listener off.TinkerforgeException
public int getCurrentVelocityPeriod() throws TinkerforgeException
setCurrentVelocityPeriod(int)
.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.5$nbsp;(Firmware)TinkerforgeException
public BrickDC.SPITFPBaudrateConfig getSPITFPBaudrateConfig() throws TinkerforgeException
setSPITFPBaudrateConfig(boolean, long)
.
.. versionadded:: 2.3.5$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 BrickDC.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 BrickDC.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(BrickDC.UnderVoltageListener listener)
public void removeUnderVoltageListener(BrickDC.UnderVoltageListener listener)
public void addEmergencyShutdownListener(BrickDC.EmergencyShutdownListener listener)
public void removeEmergencyShutdownListener(BrickDC.EmergencyShutdownListener listener)
public void addVelocityReachedListener(BrickDC.VelocityReachedListener listener)
public void removeVelocityReachedListener(BrickDC.VelocityReachedListener listener)
public void addCurrentVelocityListener(BrickDC.CurrentVelocityListener listener)
public void removeCurrentVelocityListener(BrickDC.CurrentVelocityListener listener)
Copyright © 2022 Tinkerforge GmbH. All rights reserved.