Documentation ¶
Overview ¶
Drives one brushed DC motor with up to 36V and 10A.
See also the documentation here: https://www.tinkerforge.com/en/doc/Software/Bricklets/PerformanceDC_Bricklet_Go.html.
Index ¶
- Constants
- type BootloaderMode
- type BootloaderStatus
- type CCWLEDConfig
- type CWLEDConfig
- type DriveMode
- type ErrorLEDConfig
- type Function
- type GPIOAction
- type GPIOLEDConfig
- type PerformanceDCBricklet
- func (device *PerformanceDCBricklet) DeregisterCurrentVelocityCallback(registrationId uint64)
- func (device *PerformanceDCBricklet) DeregisterEmergencyShutdownCallback(registrationId uint64)
- func (device *PerformanceDCBricklet) DeregisterGPIOStateCallback(registrationId uint64)
- func (device *PerformanceDCBricklet) DeregisterVelocityReachedCallback(registrationId uint64)
- func (device *PerformanceDCBricklet) FullBrake() (err error)
- func (device *PerformanceDCBricklet) GetAPIVersion() [3]uint8
- func (device *PerformanceDCBricklet) GetBootloaderMode() (mode BootloaderMode, err error)
- func (device *PerformanceDCBricklet) GetCCWLEDConfig() (config CCWLEDConfig, err error)
- func (device *PerformanceDCBricklet) GetCWLEDConfig() (config CWLEDConfig, err error)
- func (device *PerformanceDCBricklet) GetChipTemperature() (temperature int16, err error)
- func (device *PerformanceDCBricklet) GetCurrentVelocity() (velocity int16, err error)
- func (device *PerformanceDCBricklet) GetCurrentVelocityCallbackConfiguration() (period uint32, valueHasToChange bool, err error)
- func (device *PerformanceDCBricklet) GetDriveMode() (mode DriveMode, err error)
- func (device *PerformanceDCBricklet) GetEmergencyShutdownCallbackConfiguration() (enabled bool, err error)
- func (device *PerformanceDCBricklet) GetEnabled() (enabled bool, err error)
- func (device *PerformanceDCBricklet) GetErrorLEDConfig() (config ErrorLEDConfig, err error)
- func (device *PerformanceDCBricklet) GetGPIOAction(channel uint8) (action GPIOAction, err error)
- func (device *PerformanceDCBricklet) GetGPIOConfiguration(channel uint8) (debounce uint16, stopDeceleration uint16, err error)
- func (device *PerformanceDCBricklet) GetGPIOLEDConfig(channel uint8) (config GPIOLEDConfig, err error)
- func (device *PerformanceDCBricklet) GetGPIOState() (gpioState [2]bool, err error)
- func (device *PerformanceDCBricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, ...)
- func (device *PerformanceDCBricklet) GetMotion() (acceleration uint16, deceleration uint16, err error)
- func (device *PerformanceDCBricklet) GetPWMFrequency() (frequency uint16, err error)
- func (device *PerformanceDCBricklet) GetPowerStatistics() (voltage uint16, current uint16, temperature int16, err error)
- func (device *PerformanceDCBricklet) GetResponseExpected(functionID Function) (bool, error)
- func (device *PerformanceDCBricklet) GetSPITFPErrorCount() (errorCountAckChecksum uint32, errorCountMessageChecksum uint32, ...)
- func (device *PerformanceDCBricklet) GetStatusLEDConfig() (config StatusLEDConfig, err error)
- func (device *PerformanceDCBricklet) GetThermalShutdown() (temperature uint8, err error)
- func (device *PerformanceDCBricklet) GetVelocity() (velocity int16, err error)
- func (device *PerformanceDCBricklet) GetVelocityReachedCallbackConfiguration() (enabled bool, err error)
- func (device *PerformanceDCBricklet) ReadUID() (uid uint32, err error)
- func (device *PerformanceDCBricklet) RegisterCurrentVelocityCallback(fn func(int16)) uint64
- func (device *PerformanceDCBricklet) RegisterEmergencyShutdownCallback(fn func()) uint64
- func (device *PerformanceDCBricklet) RegisterGPIOStateCallback(fn func([2]bool)) uint64
- func (device *PerformanceDCBricklet) RegisterVelocityReachedCallback(fn func(int16)) uint64
- func (device *PerformanceDCBricklet) Reset() (err error)
- func (device *PerformanceDCBricklet) SetBootloaderMode(mode BootloaderMode) (status BootloaderStatus, err error)
- func (device *PerformanceDCBricklet) SetCCWLEDConfig(config CCWLEDConfig) (err error)
- func (device *PerformanceDCBricklet) SetCWLEDConfig(config CWLEDConfig) (err error)
- func (device *PerformanceDCBricklet) SetCurrentVelocityCallbackConfiguration(period uint32, valueHasToChange bool) (err error)
- func (device *PerformanceDCBricklet) SetDriveMode(mode DriveMode) (err error)
- func (device *PerformanceDCBricklet) SetEmergencyShutdownCallbackConfiguration(enabled bool) (err error)
- func (device *PerformanceDCBricklet) SetEnabled(enabled bool) (err error)
- func (device *PerformanceDCBricklet) SetErrorLEDConfig(config ErrorLEDConfig) (err error)
- func (device *PerformanceDCBricklet) SetGPIOAction(channel uint8, action GPIOAction) (err error)
- func (device *PerformanceDCBricklet) SetGPIOConfiguration(channel uint8, debounce uint16, stopDeceleration uint16) (err error)
- func (device *PerformanceDCBricklet) SetGPIOLEDConfig(channel uint8, config GPIOLEDConfig) (err error)
- func (device *PerformanceDCBricklet) SetMotion(acceleration uint16, deceleration uint16) (err error)
- func (device *PerformanceDCBricklet) SetPWMFrequency(frequency uint16) (err error)
- func (device *PerformanceDCBricklet) SetResponseExpected(functionID Function, responseExpected bool) error
- func (device *PerformanceDCBricklet) SetResponseExpectedAll(responseExpected bool)
- func (device *PerformanceDCBricklet) SetStatusLEDConfig(config StatusLEDConfig) (err error)
- func (device *PerformanceDCBricklet) SetThermalShutdown(temperature uint8) (err error)
- func (device *PerformanceDCBricklet) SetVelocity(velocity int16) (err error)
- func (device *PerformanceDCBricklet) SetVelocityReachedCallbackConfiguration(enabled bool) (err error)
- func (device *PerformanceDCBricklet) SetWriteFirmwarePointer(pointer uint32) (err error)
- func (device *PerformanceDCBricklet) WriteFirmware(data [64]uint8) (status uint8, err error)
- func (device *PerformanceDCBricklet) WriteUID(uid uint32) (err error)
- type StatusLEDConfig
Constants ¶
const DeviceDisplayName = "Performance DC Bricklet"
const DeviceIdentifier = 2156
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BootloaderMode ¶
type BootloaderMode = uint8
const ( BootloaderModeBootloader BootloaderMode = 0 BootloaderModeFirmware BootloaderMode = 1 BootloaderModeBootloaderWaitForReboot BootloaderMode = 2 BootloaderModeFirmwareWaitForReboot BootloaderMode = 3 BootloaderModeFirmwareWaitForEraseAndReboot BootloaderMode = 4 )
type BootloaderStatus ¶
type BootloaderStatus = uint8
const ( BootloaderStatusOK BootloaderStatus = 0 BootloaderStatusInvalidMode BootloaderStatus = 1 BootloaderStatusNoChange BootloaderStatus = 2 BootloaderStatusEntryFunctionNotPresent BootloaderStatus = 3 BootloaderStatusDeviceIdentifierIncorrect BootloaderStatus = 4 BootloaderStatusCRCMismatch BootloaderStatus = 5 )
type CCWLEDConfig ¶
type CCWLEDConfig = uint8
const ( CCWLEDConfigOff CCWLEDConfig = 0 CCWLEDConfigOn CCWLEDConfig = 1 CCWLEDConfigShowHeartbeat CCWLEDConfig = 2 CCWLEDConfigShowCCWAsForward CCWLEDConfig = 3 CCWLEDConfigShowCCWAsBackward CCWLEDConfig = 4 )
type CWLEDConfig ¶
type CWLEDConfig = uint8
const ( CWLEDConfigOff CWLEDConfig = 0 CWLEDConfigOn CWLEDConfig = 1 CWLEDConfigShowHeartbeat CWLEDConfig = 2 CWLEDConfigShowCWAsForward CWLEDConfig = 3 CWLEDConfigShowCWAsBackward CWLEDConfig = 4 )
type ErrorLEDConfig ¶
type ErrorLEDConfig = uint8
const ( ErrorLEDConfigOff ErrorLEDConfig = 0 ErrorLEDConfigOn ErrorLEDConfig = 1 ErrorLEDConfigShowHeartbeat ErrorLEDConfig = 2 ErrorLEDConfigShowError ErrorLEDConfig = 3 )
type Function ¶
type Function = uint8
const ( FunctionSetEnabled Function = 1 FunctionGetEnabled Function = 2 FunctionSetVelocity Function = 3 FunctionGetVelocity Function = 4 FunctionGetCurrentVelocity Function = 5 FunctionSetMotion Function = 6 FunctionGetMotion Function = 7 FunctionFullBrake Function = 8 FunctionSetDriveMode Function = 9 FunctionGetDriveMode Function = 10 FunctionSetPWMFrequency Function = 11 FunctionGetPWMFrequency Function = 12 FunctionGetPowerStatistics Function = 13 FunctionSetThermalShutdown Function = 14 FunctionGetThermalShutdown Function = 15 FunctionSetGPIOConfiguration Function = 16 FunctionGetGPIOConfiguration Function = 17 FunctionSetGPIOAction Function = 18 FunctionGetGPIOAction Function = 19 FunctionGetGPIOState Function = 20 FunctionSetErrorLEDConfig Function = 21 FunctionGetErrorLEDConfig Function = 22 FunctionSetCWLEDConfig Function = 23 FunctionGetCWLEDConfig Function = 24 FunctionSetCCWLEDConfig Function = 25 FunctionGetCCWLEDConfig Function = 26 FunctionSetGPIOLEDConfig Function = 27 FunctionGetGPIOLEDConfig Function = 28 FunctionSetEmergencyShutdownCallbackConfiguration Function = 29 FunctionGetEmergencyShutdownCallbackConfiguration Function = 30 FunctionSetVelocityReachedCallbackConfiguration Function = 31 FunctionGetVelocityReachedCallbackConfiguration Function = 32 FunctionSetCurrentVelocityCallbackConfiguration Function = 33 FunctionGetCurrentVelocityCallbackConfiguration Function = 34 FunctionGetSPITFPErrorCount Function = 234 FunctionSetBootloaderMode Function = 235 FunctionGetBootloaderMode Function = 236 FunctionSetWriteFirmwarePointer Function = 237 FunctionWriteFirmware Function = 238 FunctionSetStatusLEDConfig Function = 239 FunctionGetStatusLEDConfig Function = 240 FunctionGetChipTemperature Function = 242 FunctionReset Function = 243 FunctionWriteUID Function = 248 FunctionReadUID Function = 249 FunctionGetIdentity Function = 255 FunctionCallbackEmergencyShutdown Function = 35 FunctionCallbackVelocityReached Function = 36 FunctionCallbackCurrentVelocity Function = 37 FunctionCallbackGPIOState Function = 38 )
type GPIOAction ¶
type GPIOAction = uint32
const ( GPIOActionNone GPIOAction = 0 GPIOActionNormalStopRisingEdge GPIOAction = 1 GPIOActionNormalStopFallingEdge GPIOAction = 2 GPIOActionFullBrakeRisingEdge GPIOAction = 4 GPIOActionFullBrakeFallingEdge GPIOAction = 8 GPIOActionCallbackRisingEdge GPIOAction = 16 GPIOActionCallbackFallingEdge GPIOAction = 32 )
type GPIOLEDConfig ¶
type GPIOLEDConfig = uint8
const ( GPIOLEDConfigOff GPIOLEDConfig = 0 GPIOLEDConfigOn GPIOLEDConfig = 1 GPIOLEDConfigShowHeartbeat GPIOLEDConfig = 2 GPIOLEDConfigShowGPIOActiveHigh GPIOLEDConfig = 3 GPIOLEDConfigShowGPIOActiveLow GPIOLEDConfig = 4 )
type PerformanceDCBricklet ¶
type PerformanceDCBricklet struct {
// contains filtered or unexported fields
}
func New ¶
func New(uid string, ipcon *ipconnection.IPConnection) (PerformanceDCBricklet, error)
Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ipcon` is connected.
func (*PerformanceDCBricklet) DeregisterCurrentVelocityCallback ¶
func (device *PerformanceDCBricklet) DeregisterCurrentVelocityCallback(registrationId uint64)
Remove a registered Current Velocity callback.
func (*PerformanceDCBricklet) DeregisterEmergencyShutdownCallback ¶
func (device *PerformanceDCBricklet) DeregisterEmergencyShutdownCallback(registrationId uint64)
Remove a registered Emergency Shutdown callback.
func (*PerformanceDCBricklet) DeregisterGPIOStateCallback ¶
func (device *PerformanceDCBricklet) DeregisterGPIOStateCallback(registrationId uint64)
Remove a registered GPIO State callback.
func (*PerformanceDCBricklet) DeregisterVelocityReachedCallback ¶
func (device *PerformanceDCBricklet) DeregisterVelocityReachedCallback(registrationId uint64)
Remove a registered Velocity Reached callback.
func (*PerformanceDCBricklet) FullBrake ¶
func (device *PerformanceDCBricklet) FullBrake() (err error)
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 SetVelocity with 0 if you just want to stop the motor.
func (*PerformanceDCBricklet) GetAPIVersion ¶
func (device *PerformanceDCBricklet) GetAPIVersion() [3]uint8
Returns the version of the API definition (major, minor, revision) implemented by this API bindings. This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
func (*PerformanceDCBricklet) GetBootloaderMode ¶
func (device *PerformanceDCBricklet) GetBootloaderMode() (mode BootloaderMode, err error)
Returns the current bootloader mode, see SetBootloaderMode.
Associated constants:
- BootloaderModeBootloader
- BootloaderModeFirmware
- BootloaderModeBootloaderWaitForReboot
- BootloaderModeFirmwareWaitForReboot
- BootloaderModeFirmwareWaitForEraseAndReboot
func (*PerformanceDCBricklet) GetCCWLEDConfig ¶
func (device *PerformanceDCBricklet) GetCCWLEDConfig() (config CCWLEDConfig, err error)
Returns the LED configuration as set by SetCCWLEDConfig
Associated constants:
- CCWLEDConfigOff
- CCWLEDConfigOn
- CCWLEDConfigShowHeartbeat
- CCWLEDConfigShowCCWAsForward
- CCWLEDConfigShowCCWAsBackward
func (*PerformanceDCBricklet) GetCWLEDConfig ¶
func (device *PerformanceDCBricklet) GetCWLEDConfig() (config CWLEDConfig, err error)
Returns the LED configuration as set by SetCWLEDConfig
Associated constants:
- CWLEDConfigOff
- CWLEDConfigOn
- CWLEDConfigShowHeartbeat
- CWLEDConfigShowCWAsForward
- CWLEDConfigShowCWAsBackward
func (*PerformanceDCBricklet) GetChipTemperature ¶
func (device *PerformanceDCBricklet) GetChipTemperature() (temperature int16, err error)
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.
func (*PerformanceDCBricklet) GetCurrentVelocity ¶
func (device *PerformanceDCBricklet) GetCurrentVelocity() (velocity int16, err error)
Returns the *current* velocity of the motor. This value is different from GetVelocity whenever the motor is currently accelerating to a goal set by SetVelocity.
func (*PerformanceDCBricklet) GetCurrentVelocityCallbackConfiguration ¶
func (device *PerformanceDCBricklet) GetCurrentVelocityCallbackConfiguration() (period uint32, valueHasToChange bool, err error)
Returns the callback configuration as set by SetCurrentVelocityCallbackConfiguration.
func (*PerformanceDCBricklet) GetDriveMode ¶
func (device *PerformanceDCBricklet) GetDriveMode() (mode DriveMode, err error)
Returns the drive mode, as set by SetDriveMode.
Associated constants:
- DriveModeDriveBrake
- DriveModeDriveCoast
func (*PerformanceDCBricklet) GetEmergencyShutdownCallbackConfiguration ¶
func (device *PerformanceDCBricklet) GetEmergencyShutdownCallbackConfiguration() (enabled bool, err error)
Returns the callback configuration as set by SetEmergencyShutdownCallbackConfiguration.
func (*PerformanceDCBricklet) GetEnabled ¶
func (device *PerformanceDCBricklet) GetEnabled() (enabled bool, err error)
Returns *true* if the driver chip is enabled, *false* otherwise.
func (*PerformanceDCBricklet) GetErrorLEDConfig ¶
func (device *PerformanceDCBricklet) GetErrorLEDConfig() (config ErrorLEDConfig, err error)
Returns the LED configuration as set by SetErrorLEDConfig
Associated constants:
- ErrorLEDConfigOff
- ErrorLEDConfigOn
- ErrorLEDConfigShowHeartbeat
- ErrorLEDConfigShowError
func (*PerformanceDCBricklet) GetGPIOAction ¶
func (device *PerformanceDCBricklet) GetGPIOAction(channel uint8) (action GPIOAction, err error)
Returns the GPIO action for a channel as set by SetGPIOAction.
Associated constants:
- GPIOActionNone
- GPIOActionNormalStopRisingEdge
- GPIOActionNormalStopFallingEdge
- GPIOActionFullBrakeRisingEdge
- GPIOActionFullBrakeFallingEdge
- GPIOActionCallbackRisingEdge
- GPIOActionCallbackFallingEdge
func (*PerformanceDCBricklet) GetGPIOConfiguration ¶
func (device *PerformanceDCBricklet) GetGPIOConfiguration(channel uint8) (debounce uint16, stopDeceleration uint16, err error)
Returns the GPIO configuration for a channel as set by SetGPIOConfiguration.
func (*PerformanceDCBricklet) GetGPIOLEDConfig ¶
func (device *PerformanceDCBricklet) GetGPIOLEDConfig(channel uint8) (config GPIOLEDConfig, err error)
Returns the LED configuration as set by SetGPIOLEDConfig
Associated constants:
- GPIOLEDConfigOff
- GPIOLEDConfigOn
- GPIOLEDConfigShowHeartbeat
- GPIOLEDConfigShowGPIOActiveHigh
- GPIOLEDConfigShowGPIOActiveLow
func (*PerformanceDCBricklet) GetGPIOState ¶
func (device *PerformanceDCBricklet) GetGPIOState() (gpioState [2]bool, err error)
Returns the GPIO state for both channels. True if the state is “high“ and false if the state is “low“.
func (*PerformanceDCBricklet) GetIdentity ¶
func (device *PerformanceDCBricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, firmwareVersion [3]uint8, deviceIdentifier uint16, err error)
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 <isolator_bricklet>` is always at position 'z'.
The device identifier numbers can be found `here <device_identifier>`. |device_identifier_constant|
func (*PerformanceDCBricklet) GetMotion ¶
func (device *PerformanceDCBricklet) GetMotion() (acceleration uint16, deceleration uint16, err error)
Returns the acceleration/deceleration as set by SetMotion.
func (*PerformanceDCBricklet) GetPWMFrequency ¶
func (device *PerformanceDCBricklet) GetPWMFrequency() (frequency uint16, err error)
Returns the PWM frequency as set by SetPWMFrequency.
func (*PerformanceDCBricklet) GetPowerStatistics ¶
func (device *PerformanceDCBricklet) GetPowerStatistics() (voltage uint16, current uint16, temperature int16, err error)
Returns input voltage, current usage and temperature of the driver.
func (*PerformanceDCBricklet) GetResponseExpected ¶
func (device *PerformanceDCBricklet) GetResponseExpected(functionID Function) (bool, error)
Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.
For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled by SetResponseExpected. For setter functions it is disabled by default and can be enabled.
Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.
See SetResponseExpected for the list of function ID constants available for this function.
func (*PerformanceDCBricklet) GetSPITFPErrorCount ¶
func (device *PerformanceDCBricklet) GetSPITFPErrorCount() (errorCountAckChecksum uint32, errorCountMessageChecksum uint32, errorCountFrame uint32, errorCountOverflow uint32, err error)
Returns the error count for the communication between Brick and Bricklet.
The errors are divided into ¶
* ACK checksum errors, * message checksum errors, * framing errors and * overflow errors.
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.
func (*PerformanceDCBricklet) GetStatusLEDConfig ¶
func (device *PerformanceDCBricklet) GetStatusLEDConfig() (config StatusLEDConfig, err error)
Returns the configuration as set by SetStatusLEDConfig
Associated constants:
- StatusLEDConfigOff
- StatusLEDConfigOn
- StatusLEDConfigShowHeartbeat
- StatusLEDConfigShowStatus
func (*PerformanceDCBricklet) GetThermalShutdown ¶
func (device *PerformanceDCBricklet) GetThermalShutdown() (temperature uint8, err error)
Returns the thermal shutdown temperature as set by SetThermalShutdown.
func (*PerformanceDCBricklet) GetVelocity ¶
func (device *PerformanceDCBricklet) GetVelocity() (velocity int16, err error)
Returns the velocity as set by SetVelocity.
func (*PerformanceDCBricklet) GetVelocityReachedCallbackConfiguration ¶
func (device *PerformanceDCBricklet) GetVelocityReachedCallbackConfiguration() (enabled bool, err error)
Returns the callback configuration as set by SetVelocityReachedCallbackConfiguration.
func (*PerformanceDCBricklet) ReadUID ¶
func (device *PerformanceDCBricklet) ReadUID() (uid uint32, err error)
Returns the current UID as an integer. Encode as Base58 to get the usual string version.
func (*PerformanceDCBricklet) RegisterCurrentVelocityCallback ¶
func (device *PerformanceDCBricklet) RegisterCurrentVelocityCallback(fn func(int16)) uint64
This callback is triggered with the period that is set by SetCurrentVelocityCallbackConfiguration. The parameter is the *current* velocity used by the motor.
The RegisterCurrentVelocityCallback callback is only triggered after the set period if there is a change in the velocity.
func (*PerformanceDCBricklet) RegisterEmergencyShutdownCallback ¶
func (device *PerformanceDCBricklet) RegisterEmergencyShutdownCallback(fn func()) uint64
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 SetThermalShutdown). 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, SetEnabled has to be called to drive the motor again.
func (*PerformanceDCBricklet) RegisterGPIOStateCallback ¶
func (device *PerformanceDCBricklet) RegisterGPIOStateCallback(fn func([2]bool)) uint64
This callback is triggered by GPIO changes if it is activated through SetGPIOAction.
.. versionadded:: 2.0.1$nbsp;(Plugin)
func (*PerformanceDCBricklet) RegisterVelocityReachedCallback ¶
func (device *PerformanceDCBricklet) RegisterVelocityReachedCallback(fn func(int16)) uint64
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 RegisterVelocityReachedCallback 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 SetMotion) 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.
func (*PerformanceDCBricklet) Reset ¶
func (device *PerformanceDCBricklet) Reset() (err error)
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!
func (*PerformanceDCBricklet) SetBootloaderMode ¶
func (device *PerformanceDCBricklet) SetBootloaderMode(mode BootloaderMode) (status BootloaderStatus, err error)
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.
Associated constants:
- BootloaderModeBootloader
- BootloaderModeFirmware
- BootloaderModeBootloaderWaitForReboot
- BootloaderModeFirmwareWaitForReboot
- BootloaderModeFirmwareWaitForEraseAndReboot
- BootloaderStatusOK
- BootloaderStatusInvalidMode
- BootloaderStatusNoChange
- BootloaderStatusEntryFunctionNotPresent
- BootloaderStatusDeviceIdentifierIncorrect
- BootloaderStatusCRCMismatch
func (*PerformanceDCBricklet) SetCCWLEDConfig ¶
func (device *PerformanceDCBricklet) SetCCWLEDConfig(config CCWLEDConfig) (err error)
Configures the CCW LED to be either turned off, turned on, blink in heartbeat mode or if the motor turn counter-clockwise.
Associated constants:
- CCWLEDConfigOff
- CCWLEDConfigOn
- CCWLEDConfigShowHeartbeat
- CCWLEDConfigShowCCWAsForward
- CCWLEDConfigShowCCWAsBackward
func (*PerformanceDCBricklet) SetCWLEDConfig ¶
func (device *PerformanceDCBricklet) SetCWLEDConfig(config CWLEDConfig) (err error)
Configures the CW LED to be either turned off, turned on, blink in heartbeat mode or if the motor turn clockwise.
Associated constants:
- CWLEDConfigOff
- CWLEDConfigOn
- CWLEDConfigShowHeartbeat
- CWLEDConfigShowCWAsForward
- CWLEDConfigShowCWAsBackward
func (*PerformanceDCBricklet) SetCurrentVelocityCallbackConfiguration ¶
func (device *PerformanceDCBricklet) SetCurrentVelocityCallbackConfiguration(period uint32, valueHasToChange bool) (err error)
The period is the period with which the RegisterCurrentVelocityCallback 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.
func (*PerformanceDCBricklet) SetDriveMode ¶
func (device *PerformanceDCBricklet) SetDriveMode(mode DriveMode) (err error)
Sets the drive mode. Possible modes are:
* 0 = Drive/Brake * 1 = Drive/Coast
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.
Associated constants:
- DriveModeDriveBrake
- DriveModeDriveCoast
func (*PerformanceDCBricklet) SetEmergencyShutdownCallbackConfiguration ¶
func (device *PerformanceDCBricklet) SetEmergencyShutdownCallbackConfiguration(enabled bool) (err error)
Enable/Disable RegisterEmergencyShutdownCallback callback.
func (*PerformanceDCBricklet) SetEnabled ¶
func (device *PerformanceDCBricklet) SetEnabled(enabled bool) (err error)
Enables/Disables the driver chip. The driver parameters can be configured (velocity, acceleration, etc) before it is enabled.
func (*PerformanceDCBricklet) SetErrorLEDConfig ¶
func (device *PerformanceDCBricklet) SetErrorLEDConfig(config ErrorLEDConfig) (err error)
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:
* Off: No error present. * 1s interval blinking: Input voltage too low (below 6V). * 250ms interval blinking: Overtemperature or overcurrent.
Associated constants:
- ErrorLEDConfigOff
- ErrorLEDConfigOn
- ErrorLEDConfigShowHeartbeat
- ErrorLEDConfigShowError
func (*PerformanceDCBricklet) SetGPIOAction ¶
func (device *PerformanceDCBricklet) SetGPIOAction(channel uint8, action GPIOAction) (err error)
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 SetGPIOConfiguration.
Associated constants:
- GPIOActionNone
- GPIOActionNormalStopRisingEdge
- GPIOActionNormalStopFallingEdge
- GPIOActionFullBrakeRisingEdge
- GPIOActionFullBrakeFallingEdge
- GPIOActionCallbackRisingEdge
- GPIOActionCallbackFallingEdge
func (*PerformanceDCBricklet) SetGPIOConfiguration ¶
func (device *PerformanceDCBricklet) SetGPIOConfiguration(channel uint8, debounce uint16, stopDeceleration uint16) (err error)
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 SetGPIOAction.
func (*PerformanceDCBricklet) SetGPIOLEDConfig ¶
func (device *PerformanceDCBricklet) SetGPIOLEDConfig(channel uint8, config GPIOLEDConfig) (err error)
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.
Associated constants:
- GPIOLEDConfigOff
- GPIOLEDConfigOn
- GPIOLEDConfigShowHeartbeat
- GPIOLEDConfigShowGPIOActiveHigh
- GPIOLEDConfigShowGPIOActiveLow
func (*PerformanceDCBricklet) SetMotion ¶
func (device *PerformanceDCBricklet) SetMotion(acceleration uint16, deceleration uint16) (err error)
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.
func (*PerformanceDCBricklet) SetPWMFrequency ¶
func (device *PerformanceDCBricklet) SetPWMFrequency(frequency uint16) (err error)
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.
func (*PerformanceDCBricklet) SetResponseExpected ¶
func (device *PerformanceDCBricklet) SetResponseExpected(functionID Function, responseExpected bool) error
Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.
Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.
func (*PerformanceDCBricklet) SetResponseExpectedAll ¶
func (device *PerformanceDCBricklet) SetResponseExpectedAll(responseExpected bool)
Changes the response expected flag for all setter and callback configuration functions of this device at once.
func (*PerformanceDCBricklet) SetStatusLEDConfig ¶
func (device *PerformanceDCBricklet) SetStatusLEDConfig(config StatusLEDConfig) (err error)
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.
Associated constants:
- StatusLEDConfigOff
- StatusLEDConfigOn
- StatusLEDConfigShowHeartbeat
- StatusLEDConfigShowStatus
func (*PerformanceDCBricklet) SetThermalShutdown ¶
func (device *PerformanceDCBricklet) SetThermalShutdown(temperature uint8) (err error)
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 SetEnabled.
func (*PerformanceDCBricklet) SetVelocity ¶
func (device *PerformanceDCBricklet) SetVelocity(velocity int16) (err error)
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 SetMotion), 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.
func (*PerformanceDCBricklet) SetVelocityReachedCallbackConfiguration ¶
func (device *PerformanceDCBricklet) SetVelocityReachedCallbackConfiguration(enabled bool) (err error)
Enable/Disable RegisterVelocityReachedCallback callback.
func (*PerformanceDCBricklet) SetWriteFirmwarePointer ¶
func (device *PerformanceDCBricklet) SetWriteFirmwarePointer(pointer uint32) (err error)
Sets the firmware pointer for WriteFirmware. 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.
func (*PerformanceDCBricklet) WriteFirmware ¶
func (device *PerformanceDCBricklet) WriteFirmware(data [64]uint8) (status uint8, err error)
Writes 64 Bytes of firmware at the position as written by SetWriteFirmwarePointer 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.
func (*PerformanceDCBricklet) WriteUID ¶
func (device *PerformanceDCBricklet) WriteUID(uid uint32) (err error)
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.
type StatusLEDConfig ¶
type StatusLEDConfig = uint8
const ( StatusLEDConfigOff StatusLEDConfig = 0 StatusLEDConfigOn StatusLEDConfig = 1 StatusLEDConfigShowHeartbeat StatusLEDConfig = 2 StatusLEDConfigShowStatus StatusLEDConfig = 3 )