Motoron Motor Controller library for Arduino
|
#include <Motoron.h>
Public Member Functions | |
MotoronI2C (uint8_t address=16) | |
void | setBus (TwoWire *bus) |
TwoWire * | getBus () |
void | setAddress (uint8_t address) |
uint8_t | getAddress () |
uint8_t | getLastError () |
void | getFirmwareVersion (uint16_t *productId, uint16_t *firmwareVersion) |
void | setProtocolOptions (uint8_t options) |
void | setProtocolOptionsLocally (uint8_t options) |
uint8_t | getProtocolOptionsLocally () |
void | enableCrc () |
void | disableCrc () |
void | enableCrcForCommands () |
void | disableCrcForCommands () |
void | enableCrcForResponses () |
void | disableCrcForResponses () |
void | enableI2cGeneralCall () |
void | disableI2cGeneralCall () |
void | readEeprom (uint8_t offset, uint8_t length, uint8_t *buffer) |
uint8_t | readEepromDeviceNumber () |
void | writeEeprom (uint8_t offset, uint8_t value) |
void | writeEeprom16 (uint8_t offset, uint16_t value) |
void | writeEepromDeviceNumber (uint16_t number) |
void | writeEepromAlternativeDeviceNumber (uint16_t number) |
void | writeEepromDisableAlternativeDeviceNumber () |
void | writeEepromCommunicationOptions (uint8_t options) |
void | writeEepromBaudRate (uint32_t baud) |
void | writeEepromResponseDelay (uint8_t delay) |
void | reinitialize () |
void | reset () |
void | getVariables (uint8_t motor, uint8_t offset, uint8_t length, uint8_t *buffer) |
uint8_t | getVar8 (uint8_t motor, uint8_t offset) |
uint16_t | getVar16 (uint8_t motor, uint8_t offset) |
uint16_t | getStatusFlags () |
bool | getProtocolErrorFlag () |
bool | getCrcErrorFlag () |
bool | getCommandTimeoutLatchedFlag () |
bool | getMotorFaultLatchedFlag () |
bool | getNoPowerLatchedFlag () |
bool | getUARTErrorFlag () |
bool | getResetFlag () |
bool | getMotorFaultingFlag () |
bool | getNoPowerFlag () |
bool | getErrorActiveFlag () |
bool | getMotorOutputEnabledFlag () |
bool | getMotorDrivingFlag () |
uint8_t | getUARTFaults () |
uint16_t | getVinVoltage () |
uint32_t | getVinVoltageMv (uint16_t referenceMv, MotoronVinSenseType type=MotoronVinSenseType::Motoron256) |
uint16_t | getCommandTimeoutMilliseconds () |
uint8_t | getErrorResponse () |
uint16_t | getErrorMask () |
uint8_t | getJumperState () |
int16_t | getTargetSpeed (uint8_t motor) |
uint16_t | getTargetBrakeAmount (uint8_t motor) |
int16_t | getCurrentSpeed (uint8_t motor) |
int16_t | getBufferedSpeed (uint8_t motor) |
uint8_t | getPwmMode (uint8_t motor) |
uint16_t | getMaxAccelerationForward (uint8_t motor) |
uint16_t | getMaxAccelerationReverse (uint8_t motor) |
uint16_t | getMaxDecelerationForward (uint8_t motor) |
uint16_t | getMaxDecelerationReverse (uint8_t motor) |
uint16_t | getStartingSpeedForward (uint8_t motor) |
uint16_t | getStartingSpeedReverse (uint8_t motor) |
uint8_t | getDirectionChangeDelayForward (uint8_t motor) |
uint8_t | getDirectionChangeDelayReverse (uint8_t motor) |
uint16_t | getCurrentLimit (uint8_t motor) |
MotoronCurrentSenseReading | getCurrentSenseReading (uint8_t motor) |
MotoronCurrentSenseReading | getCurrentSenseRawAndSpeed (uint8_t motor) |
MotoronCurrentSenseReading | getCurrentSenseProcessedAndSpeed (uint8_t motor) |
uint16_t | getCurrentSenseRaw (uint8_t motor) |
uint16_t | getCurrentSenseProcessed (uint8_t motor) |
uint8_t | getCurrentSenseOffset (uint8_t motor) |
uint16_t | getCurrentSenseMinimumDivisor (uint8_t motor) |
void | setVariable (uint8_t motor, uint8_t offset, uint16_t value) |
void | setCommandTimeoutMilliseconds (uint16_t ms) |
void | setErrorResponse (uint8_t response) |
void | setErrorMask (uint16_t mask) |
void | disableCommandTimeout () |
void | clearUARTFaults (uint8_t flags) |
void | setPwmMode (uint8_t motor, uint8_t mode) |
void | setMaxAccelerationForward (uint8_t motor, uint16_t accel) |
void | setMaxAccelerationReverse (uint8_t motor, uint16_t accel) |
void | setMaxAcceleration (uint8_t motor, uint16_t accel) |
void | setMaxDecelerationForward (uint8_t motor, uint16_t decel) |
void | setMaxDecelerationReverse (uint8_t motor, uint16_t decel) |
void | setMaxDeceleration (uint8_t motor, uint16_t decel) |
void | setStartingSpeedForward (uint8_t motor, uint16_t speed) |
void | setStartingSpeedReverse (uint8_t motor, uint16_t speed) |
void | setStartingSpeed (uint8_t motor, uint16_t speed) |
void | setDirectionChangeDelayForward (uint8_t motor, uint8_t duration) |
void | setDirectionChangeDelayReverse (uint8_t motor, uint8_t duration) |
void | setDirectionChangeDelay (uint8_t motor, uint8_t duration) |
void | setCurrentLimit (uint8_t motor, uint16_t limit) |
void | setCurrentSenseOffset (uint8_t motor, uint8_t offset) |
void | setCurrentSenseMinimumDivisor (uint8_t motor, uint16_t speed) |
void | coastNow () |
void | clearMotorFault (uint8_t flags=0) |
void | clearMotorFaultUnconditional () |
void | clearLatchedStatusFlags (uint16_t flags) |
void | clearResetFlag () |
void | setLatchedStatusFlags (uint16_t flags) |
void | setSpeed (uint8_t motor, int16_t speed) |
void | setSpeedNow (uint8_t motor, int16_t speed) |
void | setBufferedSpeed (uint8_t motor, int16_t speed) |
void | setAllSpeeds (int16_t speed1, int16_t speed2, int16_t speed3) |
void | setAllSpeeds (int16_t speed1, int16_t speed2) |
void | setAllSpeeds (int16_t speed1) |
void | setAllSpeedsNow (int16_t speed1, int16_t speed2, int16_t speed3) |
void | setAllSpeedsNow (int16_t speed1, int16_t speed2) |
void | setAllSpeedsNow (int16_t speed1) |
void | setAllBufferedSpeeds (int16_t speed1, int16_t speed2, int16_t speed3) |
void | setAllBufferedSpeeds (int16_t speed1, int16_t speed2) |
void | setAllBufferedSpeeds (int16_t speed1) |
void | setAllSpeedsUsingBuffers () |
void | setAllSpeedsNowUsingBuffers () |
void | setBraking (uint8_t motor, uint16_t amount) |
void | setBrakingNow (uint8_t motor, uint16_t amount) |
void | resetCommandTimeout () |
Static Public Member Functions | |
static uint8_t | calculateCrc (uint8_t length, const uint8_t *buffer, uint8_t init=0) |
static uint16_t | calculateCurrentLimit (uint32_t milliamps, MotoronCurrentSenseType type, uint16_t referenceMv, uint16_t offset) |
static constexpr uint16_t | currentSenseUnitsMilliamps (MotoronCurrentSenseType type, uint16_t referenceMv) |
Protected Member Functions | |
void | sendCommand (uint8_t length, const uint8_t *cmd) |
void | sendCommandAndReadResponse (uint8_t cmdLength, const uint8_t *cmd, uint8_t responseLength, uint8_t *response) |
Protected Attributes | |
uint8_t | lastError |
uint8_t | protocolOptions |
Represents an I2C connection to a Motoron Motor Controller.
|
inline |
Creates a new MotoronI2C object to communicate with the Motoron over I2C.
The address
parameter specifies the 7-bit I2C address to use, and it must match the address that the Motoron is configured to use.
|
inlinestaticinherited |
|
inlinestaticinherited |
Calculates a current limit value that can be passed to the Motoron using setCurrentLimit().
milliamps | The desired current limit, in units of mA. |
type | Specifies what type of Motoron you are using. |
referenceMv | The reference voltage (IOREF), in millivolts. For example, use 3300 for a 3.3 V system or 5000 for a 5 V system. |
offset | The offset of the raw current sense signal for the Motoron channel. This is the same measurement that you would put into the Motoron's "Current sense offset" variable using setCurrentSenseOffset(), so see the documentation of that function for more info. The offset is typically 10 for 5 V systems and 15 for 3.3 V systems, (50*1024/referenceMv) but it can vary widely. |
|
inlineinherited |
Clears the specified flags in getStatusFlags().
For each bit in the flags argument that is 1, this command clears the corresponding bit in the "Status flags" variable, setting it to 0.
For more information, see the "Clear latched status flags" command in the Motoron user's guide.
|
inlineinherited |
Sends a "Clear motor fault" command to the Motoron.
If any of the Motoron's motors chips are currently experiencing a fault (error), or bit 0 of the flags argument is 1, this command makes the Motoron attempt to recover from the faults.
For more information, see the "Clear motor fault" command in the Motoron user's guide.
|
inlineinherited |
Sends a "Clear motor fault" command to the Motoron with the "unconditional" flag set, so the Motoron will attempt to recover from any motor faults even if no fault is currently occurring.
This is a more robust version of clearMotorFault().
|
inlineinherited |
Clears the Motoron's reset flag.
The reset flag is a latched status flag in getStatusFlags() that is particularly important to clear: it gets set to 1 after the Motoron powers on or experiences a reset, and it is considered to be an error by default, so it prevents the motors from running. Therefore, it is necessary to call this function (or clearLatchedStatusFlags()) to clear the Reset flag before you can get the motors running. We recommend that immediately after you clear the reset flag. you should configure the Motoron's motor settings and error response settings. That way, if the Motoron experiences an unexpected reset while your system is running, it will stop running its motors and it will not start them again until all the important settings have been configured.
|
inlineinherited |
Sends a "Set variable" command that clears the specified flags in getUARTFaults().
For each bit in the flags argument that is 1, this command clears the corresponding bit in the "UART faults" variable, setting it to 0.
For more information, see the "UART faults" variable in the Motoron user's guide.
|
inlineinherited |
|
inlinestaticconstexprinherited |
Calculates the units for the Motoron's current sense reading returned by getCurrentSenseProcessed(), in milliamps.
To convert a reading from getCurrentSenseProcessed() to milliamps multiply it by the value returned from this function using 32-bit multiplication. For example:
uint32_t ma = (uint32_t)processed * units;
type | Specifies what type of Motoron you are using. |
referenceMv | The reference voltage (IOREF), in millivolts. For example, use 3300 for a 3.3 V system or 5000 for a 5 V system. |
|
inlineinherited |
This disables the Motoron's command timeout feature by resetting the the "Error mask" variable to its default value but with the command timeout bit cleared.
By default, the Motoron's command timeout will occur if no valid commands are received in 1500 milliseconds, and the command timeout is treated as an error, so the motors will shut down. You can use this function if you want to disable that feature.
Note that this function overrides any previous values you set in the "Error mask" variable, so if you are using setErrorMask() in your program to configure which status flags are treated as errors, you do not need to use this function and you probably should not use this function.
|
inlineinherited |
Disables CRC for commands and responses. See setProtocolOptions().
|
inlineinherited |
Disables CRC for commands. See setProtocolOptions().
|
inlineinherited |
Disables CRC for responses. See setProtocolOptions().
|
inlineinherited |
Disables the I2C general call address. See setProtocolOptions().
|
inlineinherited |
Enables CRC for commands and responses. See setProtocolOptions().
|
inlineinherited |
Enables CRC for commands. See setProtocolOptions().
|
inlineinherited |
Enables CRC for responses. See setProtocolOptions().
|
inlineinherited |
Enables the I2C general call address. See setProtocolOptions().
|
inline |
|
inlineinherited |
Reads the buffered speed of the specified motor.
For more information, see the "Buffered speed" variable in the Motoron user's guide.
|
inline |
|
inlineinherited |
Returns the "Command timeout latched" bit from getStatusFlags().
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
Reads the "Command timeout" variable and converts it to milliseconds.
For more information, see the "Command timeout" variable in the Motoron user's guide.
|
inlineinherited |
Returns the "CRC error" bit from getStatusFlags().
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
Reads the current limit for the specified motor.
This only works for the high-power Motorons.
For more information, see the "Current limit" variable in the Motoron user's guide.
|
inlineinherited |
Reads the current sense minimum divisor setting and returns it as a speed between 0 and 800.
This only works for the high-power Motorons.
For more information, see the "Current sense minimum divisor" variable in the Motoron user's guide.
|
inlineinherited |
Reads the current sense offset setting.
This only works for the high-power Motorons.
For more information, see the "Current sense offset" variable in the Motoron user's guide.
|
inlineinherited |
Reads the processed current sense reading for the specified motor.
This only works for the high-power Motorons.
The units of this reading depend on the logic voltage of the Motoron and on the specific model of Motoron that you have, and you can use MotoronI2C::currentSenseUnitsMilliamps() to calculate the units.
The accuracy of this reading can be improved by measuring the current sense offset and setting it with setCurrentSenseOffset(). See the "Current sense processed" variable in the Motoron user's guide for or the CurrentSenseCalibrate example for more information.
Note that this reading will be 0xFFFF if an overflow happens during the calculation due to very high current.
|
inlineinherited |
This is like getCurrentSenseReading() but it only reads the processed current sense measurement and the speed.
The 'raw' member of the returned structure will be 0.
This only works for the high-power Motorons.
|
inlineinherited |
Reads the raw current sense measurement for the specified motor.
This only works for the high-power Motorons.
For more information, see the "Current sense raw" variable in the Motoron user's guide.
|
inlineinherited |
This is like getCurrentSenseReading() but it only reads the raw current sense measurement and the speed.
The 'processed' member of the returned structure will be 0.
This only works for the high-power Motorons.
|
inlineinherited |
Reads all the results from the last current sense measurement for the specified motor.
This function reads the "Current sense raw", "Current sense speed", and "Current sense processed" variables from the Motoron using a single command, so the values returned are all guaranteed to be part of the same measurement.
This only works for the high-power Motorons.
|
inlineinherited |
Reads the current speed of the specified motor, which is the speed that the Motoron is currently trying to apply to the motor.
For more information, see the "Target speed" variable in the Motoron user's guide.
|
inlineinherited |
Reads the direction change delay for the specified motor in the forward direction.
For more information, see the "Direction change delay forward" variable in the Motoron user's guide.
|
inlineinherited |
Reads the direction change delay for the specified motor in the reverse direction.
For more information, see the "Direction change delay reverse" variable in the Motoron user's guide.
|
inlineinherited |
Returns the "Error active" bit from getStatusFlags().
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
Reads the "Error mask" variable, which defines which status flags are considered to be errors.
For more information, see the "Error mask" variable in the Motoron user's guide.
|
inlineinherited |
Reads the "Error response" variable, which defines how the Motoron will stop its motors when an error is happening.
For more information, see the "Error response" variable in the Motoron user's guide.
|
inlineinherited |
Sends the "Get firmware version" command to get the device's firmware product ID and firmware version numbers.
For more information, see the "Get firmware version" command in the Motoron user's guide.
productId | An optional pointer used to return the product ID. Can be NULL. |
firmwareVersion | An optional pointer used to return the firmware version. Can be NULL. |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Reads the maximum acceleration of the specified motor for the forward direction.
For more information, see the "Max acceleration forward" variable in the Motoron user's guide.
|
inlineinherited |
Reads the maximum acceleration of the specified motor for the reverse direction.
For more information, see the "Max acceleration reverse" variable in the Motoron user's guide.
|
inlineinherited |
Reads the maximum deceleration of the specified motor for the forward direction.
For more information, see the "Max deceleration forward" variable in the Motoron user's guide.
|
inlineinherited |
Reads the maximum deceleration of the specified motor for the reverse direction.
For more information, see the "Max deceleration reverse" variable in the Motoron user's guide.
|
inlineinherited |
Returns the "Motor driving" bit from getStatusFlags().
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
Returns the "Motor faulting" bit from getStatusFlags().
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
Returns the "Motor fault latched" bit from getStatusFlags().
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
Returns the "Motor output enabled" bit from getStatusFlags().
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
Returns the "No power" bit from getStatusFlags().
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
Returns the "No power latched" bit from getStatusFlags().
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
Returns the "Protocol error" bit from getStatusFlags().
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
Get the protocol options that this object is currently configured to use.
|
inlineinherited |
Reads the PWM mode of the specified motor.
For more information, see the "PWM mode" variable in the Motoron user's guide.
|
inlineinherited |
Returns the "Reset" bit from getStatusFlags().
This bit is set to 1 when the Motoron powers on, its processor is reset (e.g. by reset()), or it receives a reinitialize() command. It can be cleared using clearResetFlag() or clearLatchedStatusFlags().
By default, the Motoron is configured to treat this bit as an error, so you will need to clear it before you can turn on the motors.
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
Reads the starting speed for the specified motor in the forward direction.
For more information, see the "Starting speed forward" variable in the Motoron user's guide.
|
inlineinherited |
Reads the starting speed for the specified motor in the reverse direction.
For more information, see the "Starting speed reverse" variable in the Motoron user's guide.
|
inlineinherited |
Reads the "Status flags" variable from the Motoron.
The bits in this variable are defined by the MOTORON_STATUS_FLAG_* macros:
Here is some example code that uses C++ bitwise operators to check whether there is currently a motor fault or a lack of power:
This library has helper methods that make it easier if you just want to read a single bit:
The clearLatchedStatusFlags() method sets the specified set of latched status flags to 0. The reinitialize() and reset() commands reset the latched status flags to their default values.
For more information, see the "Status flags" variable in the Motoron user's guide.
|
inlineinherited |
|
inlineinherited |
Reads the target speed of the specified motor, which is the speed at which the motor has been commanded to move.
For more information, see the "Target speed" variable in the Motoron user's guide.
|
inlineinherited |
Returns the "UART error" bit from getStatusFlags().
This bit is only relevant for the Motoron controllers with a UART serial interface.
For more information, see the "Status flags" variable in the Motoron user's guide.
If this flag is set, you might consider calling getUARTFaults() to get details about what error happened.
|
inlineinherited |
Returns the "UART faults" variable.
Every time the Motoron sets the "UART error" bit in the status flags register (see getUARTErrorFlag()) it also sets one of the bits in this variable to indicate the cause of the error.
The bits in this variable are defined by the MOTORON_UART_FAULT_* macros:
This function is only useful for Motorons with a UART serial interface.
For more information, see the "UART faults" variable in the Motoron user's guide.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Reads information from the Motoron using a "Get variables" command.
This library has helper methods to read every variable, but this method is useful if you want to get the raw bytes, or if you want to read multiple consecutive variables at the same time for efficiency.
motor | 0 to read general variables, or a motor number to read motor-specific variables. |
offset | The location of the first byte to read. |
length | How many bytes to read. |
buffer | A pointer to an array to store the bytes read from the controller. |
|
inlineinherited |
Reads voltage on the Motoron's VIN pin, in raw device units.
For more information, see the "VIN voltage" variable in the Motoron user's guide.
|
inlineinherited |
Reads the voltage on the Motoron's VIN pin and converts it to millivolts.
For more information, see the "VIN voltage" variable in the Motoron user's guide.
referenceMv | The reference voltage (IOREF), in millivolts. For example, use 3300 for a 3.3 V system or 5000 for a 5 V system. |
type | Specifies what type of Motoron you are using. |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Sends a "Reset" command to the Motoron, which does a full hardware reset.
This command is equivalent to briefly driving the Motoron's RST pin low. The Motoron's RST is briefly driven low by the Motoron itself as a result of this command.
After running this command, we recommend waiting for at least 5 milliseconds before you try to communicate with the Motoron.
|
inlineinherited |
Resets the command timeout.
This prevents the command timeout status flags from getting set for some time. (The command timeout is also reset by every other Motoron command, as long as its parameters are valid.)
For more information, see the "Reset command timeout" command in the Motoron user's guide.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inline |
|
inlineinherited |
An overload of setAllBufferedSpeeds() for 1-channel Motorons.
|
inlineinherited |
An overload of setAllBufferedSpeeds() for 2-channel Motorons.
|
inlineinherited |
Sets the buffered speeds of all the motors.
The number of speed arguments you provide to this function must be equal to the number of motor channels your Motoron has, or else this command might not work.
This command does not immediately cause any change to the motors: it stores speed for each motor in the Motoron so they can be used by later commands.
This is equivalent to calling setBufferedSpeed() once for each motor, but it is more efficient because all of the speeds are sent in the same command.
For more information, see the "Set all speeds" command in the Motoron user's guide.
|
inlineinherited |
An overload of setAllSpeeds() for single-channel Motorons.
|
inlineinherited |
An overload of setAllSpeeds() for 2-channel Motorons.
|
inlineinherited |
Sets the target speeds of all the motors at the same time.
The number of speed arguments you provide to this function must be equal to the number of motor channels your Motoron has, or else this command might not work.
This is equivalent to calling setSpeed() once for each motor, but it is more efficient because all of the speeds are sent in the same command.
For more information, see the "Set all speeds" command in the Motoron user's guide.
|
inlineinherited |
An overload of setAllSpeedsNow() for single-channel Motorons.
|
inlineinherited |
An overload of setAllSpeedsNow() for 2-channel Motorons.
|
inlineinherited |
Sets the target and current speeds of all the motors at the same time.
The number of speed arguments you provide to this function must be equal to the number of motor channels your Motoron has, or else this command might not work.
This is equivalent to calling setSpeedNow() once for each motor, but it is more efficient because all of the speeds are sent in the same command.
For more information, see the "Set all speeds" command in the Motoron user's guide.
|
inlineinherited |
Sets each motor's target speed and current speed equal to the buffered speed.
This command is the same as setAllSpeedsNow() except that the speeds are provided ahead of time using setBufferedSpeed() or setAllBufferedSpeeds().
|
inlineinherited |
Sets each motor's target speed equal to the buffered speed.
This command is the same as setAllSpeeds() except that the speeds are provided ahead of time using setBufferedSpeed() or setAllBufferedSpeeds().
|
inlineinherited |
Commands the motor to brake, coast, or something in between.
Sending this command causes the motor to decelerate to speed 0 obeying any relevant deceleration limits. Once the current speed reaches 0, the motor will attempt to brake or coast as specified by this command, but due to hardware limitations it might not be able to.
The motor number parameter should be between 1 and the number of motors supported by the Motoron.
The amount parameter gets stored in the "Target brake amount" variable for the motor and should be between 0 (coasting) and 800 (braking). Values above 800 will be clipped to 800 by the Motoron firmware.
See the "Set braking" command in the Motoron user's guide for more information.
|
inlineinherited |
Commands the motor to brake, coast, or something in between.
Sending this command causes the motor's current speed to change to 0. The motor will attempt to brake or coast as specified by this command, but due to hardware limitations it might not be able to.
The motor number parameter should be between 1 and the number of motors supported by the Motoron.
The amount parameter gets stored in the "Target brake amount" variable for the motor and should be between 0 (coasting) and 800 (braking). Values above 800 will be clipped to 800 by the Motoron firmware.
See the "Set braking" command in the Motoron user's guide for more information.
|
inlineinherited |
Sets the buffered speed of the specified motor.
This command does not immediately cause any change to the motor: it stores a speed for the specified motor in the Motoron so it can be used by later commands.
For single-channel Motorons, it is better to use setAllBufferedSpeeds() instead of this, since it sends one fewer byte.
For more information, see the "Set speed" command in the Motoron user's guide.
|
inline |
Configures this object to use the specified I2C bus. The default bus is Wire, which is typically the first or only I2C bus on an Arduino. To use Wire1 instead, you can write:
bus | A pointer to a TwoWire object representing the I2C bus to use. |
|
inlineinherited |
Sets the command timeout period, in milliseconds.
For more information, see the "Command timeout" variable in the Motoron user's guide.
|
inlineinherited |
Sets the current limit for the specified motor.
This only works for the high-power Motorons.
The units of the current limit depend on the type of Motoron you have and the logic voltage of your system. See the "Current limit" variable in the Motoron user's guide for more information, or see MotoronI2C::calculateCurrentLimit().
|
inlineinherited |
Sets the current sense minimum divisor setting for the specified motor, given a speed between 0 and 800.
This is one of the settings that determines how current sense readings are processed.
If you do not care about measuring motor current, you do not need to set this variable.
For more information, see the "Current sense minimum divisor" variable in the Motoron user's guide.
This only works for the high-power Motorons.
|
inlineinherited |
Sets the current sense offset setting for the specified motor.
This is one of the settings that determines how current sense readings are processed. It is supposed to be the value returned by getCurrentSenseRaw() when Motor power is supplied to the Motoron and it is driving its motor outputs at speed 0.
The CurrentSenseCalibrate example shows how to measure the current sense offsets and load them onto the Motoron using this function.
If you do not care about measuring motor current, you do not need to set this variable.
For more information, see the "Current sense offset" variable in the Motoron user's guide.
This only works for the high-power Motorons.
|
inlineinherited |
Sets the direction change delay of the specified motor (both directions), in units of 10 ms.
If this function succeeds, it is equivalent to calling setDirectionChangeDelayForward() and setDirectionChangeDelayReverse().
|
inlineinherited |
Sets the direction change delay of the specified motor for the forward direction, in units of 10 ms.
For more information, see the "Direction change delay forward" variable in the Motoron user's guide.
|
inlineinherited |
Sets the direction change delay of the specified motor for the reverse direction, in units of 10 ms.
For more information, see the "Direction change delay reverse" variable in the Motoron user's guide.
|
inlineinherited |
Sets the "Error mask" variable, which defines which status flags are considered to be errors.
For more information, see the "Error mask" variable in the Motoron user's guide.
|
inlineinherited |
Sets the error response, which defines how the Motoron will stop its motors when an error is happening.
The response parameter should be one of:
For more information, see the "Error response" variable in the Motoron user's guide.
|
inlineinherited |
Sets the specified flags in getStatusFlags().
For each bit in the flags argument that is 1, this command sets the corresponding bit in the "Status flags" variable to 1.
For more information, see the "Set latched status flags" command in the Motoron user's guide.
|
inlineinherited |
Sets the maximum acceleration of the specified motor (both directions).
If this function succeeds, it is equivalent to calling setMaxAccelerationForward() and setMaxAccelerationReverse().
|
inlineinherited |
Sets the maximum acceleration of the specified motor for the forward direction.
For more information, see the "Max acceleration forward" variable in the Motoron user's guide.
|
inlineinherited |
Sets the maximum acceleration of the specified motor for the reverse direction.
For more information, see the "Max acceleration reverse" variable in the Motoron user's guide.
|
inlineinherited |
Sets the maximum deceleration of the specified motor (both directions).
If this function succeeds, it is equivalent to calling setMaxDecelerationForward() and setMaxDecelerationReverse().
|
inlineinherited |
Sets the maximum deceleration of the specified motor for the forward direction.
For more information, see the "Max deceleration forward" variable in the Motoron user's guide.
|
inlineinherited |
Sets the maximum deceleration of the specified motor for the reverse direction.
For more information, see the "Max deceleration reverse" variable in the Motoron user's guide.
|
inlineinherited |
Sends the "Set protocol options" command to the device to specify options related to how the device processes commands and sends responses. The options are also saved in this object and are used later when sending other commands or reading responses.
When CRC for commands is enabled, this library generates the CRC byte and appends it to the end of each command it sends. The Motoron checks it to help ensure the command was received correctly.
When CRC for responses is enabled, this library reads the CRC byte sent by the Motoron in its repsonses and makes sure it is correct. If the response CRC byte is incorrect, getLastError() will return a non-zero error code after the command has been run.
When the I2C general call address is enabled, the Motoron receives commands sent to address 0 in addition to its usual I2C address. The general call address is write-only; reading bytes from it is not supported.
By default (in this libary and the Motoron itself), CRC for commands and responses is enabled, and the I2C general call address is enabled.
This method always sends its command with a CRC byte, so it will work even if CRC was previously disabled but has been re-enabled on the device (e.g. due to a reset).
The options
argument should be 0 or a combination of the following expressions made using the bitwise or operator (|):
For more information, see the "Set protocol optons" command in the Motoron user's guide.
|
inlineinherited |
Sets the protocol options for this object, without sending a command to the Motoron.
If the options you specify here do not match the actual configuration of the Motoron, future communication could fail.
Most users should use setProtocolOptions() instead of this.
|
inlineinherited |
Sets the PWM mode for the specified motor.
The mode parameter should be one of the following:
For more information, see the "PWM mode" variable in the Motoron user's guide.
|
inlineinherited |
Sets the target speed of the specified motor.
The current speed will start moving to the specified target speed, obeying any acceleration and deceleration limits.
The motor number should be between 1 and the number of motors supported by the Motoron.
The speed should be between -800 and 800. Values outside that range will be clipped to -800 or 800 by the Motoron firmware.
For single-channel Motorons, it is better to use setAllSpeeds() instead of this, since it sends one fewer byte.
For more information, see the "Set speed" command in the Motoron user's guide.
|
inlineinherited |
Sets the target and current speed of the specified motor, ignoring any acceleration and deceleration limits.
For single-channel Motorons, it is better to use setAllSpeedsNow() instead of this, since it sends one fewer byte.
For more information, see the "Set speed" command in the Motoron user's guide.
|
inlineinherited |
Sets the starting speed of the specified motor (both directions).
If this function succeeds, it is equivalent to calling setStartingSpeedForward() and setStartingSpeedReverse().
|
inlineinherited |
Sets the starting speed of the specified motor for the forward direction.
For more information, see the "Starting speed forward" variable in the Motoron user's guide.
|
inlineinherited |
Sets the starting speed of the specified motor for the reverse direction.
For more information, see the "Starting speed reverse" variable in the Motoron user's guide.
|
inlineinherited |
Configures the Motoron using a "Set variable" command.
This library has helper methods to set every variable, so you should not need to call this function directly.
motor | 0 to set a general variable, or a motor number to set motor-specific variables. |
offset | The address of the variable to set (only certain offsets are allowed). |
value | The value to set the variable to. |
|
inlineinherited |
Writes a value to one byte in the Motoron's EEPROM memory.
This command only has an effect if JMP1 is shorted to GND.
Warning: Be careful not to write to the EEPROM in a fast loop. The EEPROM memory of the Motoron's microcontroller is only rated for 100,000 erase/write cycles.
For more information, see the "Write EEPROM" command in the Motoron user's guide.
|
inlineinherited |
Writes a 2-byte value in the Motoron's EEPROM memory.
This command only has an effect if JMP1 is shorted to GND.
Warning: Be careful not to write to the EEPROM in a fast loop. The EEPROM memory of the Motoron's microcontroller is only rated for 100,000 erase/write cycles.
|
inlineinherited |
Writes to the alternative device number stored in EEPROM, changing it to the specified value.
This function is only useful for Motorons with a UART serial interface, and only has an effect if JMP1 is shorted to GND.
Warning: Be careful not to write to the EEPROM in a fast loop. The EEPROM memory of the Motoron's microcontroller is only rated for 100,000 erase/write cycles.
|
inlineinherited |
Writes to the baud rate stored in EEPROM, changing it to the specified value.
This function is only useful for Motorons with a UART serial interface, and only has an effect if JMP1 is shorted to GND.
Warning: Be careful not to write to the EEPROM in a fast loop. The EEPROM memory of the Motoron's microcontroller is only rated for 100,000 erase/write cycles.
|
inlineinherited |
Writes to the communication options byte stored in EEPROM, changing it to the specified value.
The bits in this byte are defined by the MOTORON_COMMUNICATION_OPTION_* macros.
This function is only useful for Motorons with a UART serial interface, and only has an effect if JMP1 is shorted to GND.
Warning: Be careful not to write to the EEPROM in a fast loop. The EEPROM memory of the Motoron's microcontroller is only rated for 100,000 erase/write cycles.
|
inlineinherited |
Writes to the device number stored in EEPROM, changing it to the specified value.
This command only has an effect if JMP1 is shorted to GND.
Warning: Be careful not to write to the EEPROM in a fast loop. The EEPROM memory of the Motoron's microcontroller is only rated for 100,000 erase/write cycles.
|
inlineinherited |
Writes to EEPROM to disable the alternative device number.
This function is only useful for Motorons with a UART serial interface, and only has an effect if JMP1 is shorted to GND.
Warning: Be careful not to write to the EEPROM in a fast loop. The EEPROM memory of the Motoron's microcontroller is only rated for 100,000 erase/write cycles.
|
inlineinherited |
Writes to the response delay setting stored in EEPROM, changing it to the specified value, in units of microseconds.
This function is only useful for Motorons with a UART serial interface, and only has an effect if JMP1 is shorted to GND.
Warning: Be careful not to write to the EEPROM in a fast loop. The EEPROM memory of the Motoron's microcontroller is only rated for 100,000 erase/write cycles.
|
protectedinherited |
|
protectedinherited |