Jrk G2 library for Arduino
|
#include <JrkG2.h>
Public Member Functions | |
uint8_t | getLastError () |
Motor control commands | |
void | setTarget (uint16_t target) |
void | setTargetLowResRev (uint8_t target) |
void | setTargetLowResFwd (uint8_t target) |
void | forceDutyCycleTarget (int16_t dutyCycle) |
void | forceDutyCycle (int16_t dutyCycle) |
void | stopMotor () |
Variable reading commands | |
uint16_t | getInput () |
uint16_t | getTarget () |
uint16_t | getFeedback () |
uint16_t | getScaledFeedback () |
int16_t | getIntegral () |
int16_t | getDutyCycleTarget () |
int16_t | getDutyCycle () |
uint8_t | getCurrentLowRes () |
bool | getPIDPeriodExceeded () |
uint16_t | getPIDPeriodCount () |
uint16_t | getErrorFlagsHalting () |
uint16_t | getErrorFlagsOccurred () |
JrkG2ForceMode | getForceMode () |
uint16_t | getVinVoltage () |
uint16_t | getCurrent () |
JrkG2Reset | getDeviceReset () |
uint32_t | getUpTime () |
uint16_t | getRCPulseWidth () |
uint16_t | getFBTReading () |
uint16_t | getAnalogReading (JrkG2Pin pin) |
bool | getDigitalReading (JrkG2Pin pin) |
uint16_t | getRawCurrent () |
uint16_t | getEncodedHardCurrentLimit () |
int16_t | getLastDutyCycle () |
uint8_t | getCurrentChoppingConsecutiveCount () |
uint8_t | getCurrentChoppingOccurrenceCount () |
RAM settings commands | |
void | setResetIntegral (bool reset) |
bool | getResetIntegral () |
void | setCoastWhenOff (bool coast) |
bool | getCoastWhenOff () |
void | setProportionalCoefficient (uint16_t multiplier, uint8_t exponent) |
uint16_t | getProportionalMultiplier () |
uint8_t | getProportionalExponent () |
void | setIntegralCoefficient (uint16_t multiplier, uint8_t exponent) |
uint16_t | getIntegralMultiplier () |
uint8_t | getIntegralExponent () |
void | setDerivativeCoefficient (uint16_t multiplier, uint8_t exponent) |
uint16_t | getDerivativeMultiplier () |
uint8_t | getDerivativeExponent () |
void | setPIDPeriod (uint16_t period) |
uint16_t | getPIDPeriod () |
void | setIntegralLimit (uint16_t limit) |
uint16_t | getIntegralLimit () |
void | setMaxDutyCycleWhileFeedbackOutOfRange (uint16_t duty) |
uint16_t | getMaxDutyCycleWhileFeedbackOutOfRange () |
void | setMaxAccelerationForward (uint16_t accel) |
uint16_t | getMaxAccelerationForward () |
void | setMaxAccelerationReverse (uint16_t accel) |
uint16_t | getMaxAccelerationReverse () |
void | setMaxAcceleration (uint16_t accel) |
void | setMaxDecelerationForward (uint16_t decel) |
uint16_t | getMaxDecelerationForward () |
void | setMaxDecelerationReverse (uint16_t decel) |
uint16_t | getMaxDecelerationReverse () |
void | setMaxDeceleration (uint16_t decel) |
void | setMaxDutyCycleForward (uint16_t duty) |
uint16_t | getMaxDutyCycleForward () |
void | setMaxDutyCycleReverse (uint16_t duty) |
uint16_t | getMaxDutyCycleReverse () |
void | setMaxDutyCycle (uint16_t duty) |
void | setEncodedHardCurrentLimitForward (uint16_t encoded_limit) |
uint16_t | getEncodedHardCurrentLimitForward () |
void | setEncodedHardCurrentLimitReverse (uint16_t encoded_limit) |
uint16_t | getEncodedHardCurrentLimitReverse () |
void | setEncodedHardCurrentLimit (uint16_t encoded_limit) |
void | setBrakeDurationForward (uint8_t duration) |
uint8_t | getBrakeDurationForward () |
void | setBrakeDurationReverse (uint8_t duration) |
uint8_t | getBrakeDurationReverse () |
void | setBrakeDuration (uint8_t duration) |
void | setSoftCurrentLimitForward (uint16_t current) |
uint16_t | getSoftCurrentLimitForward () |
void | setSoftCurrentLimitReverse (uint16_t current) |
uint16_t | getSoftCurrentLimitReverse () |
void | setSoftCurrentLimit (uint16_t current) |
Low-level settings and variables commands | |
void | getEEPROMSettings (uint8_t offset, uint8_t length, uint8_t *buffer) |
void | getRAMSettings (uint8_t offset, uint8_t length, uint8_t *buffer) |
void | setRAMSettings (uint8_t offset, uint8_t length, uint8_t *buffer) |
void | getVariables (uint8_t offset, uint8_t length, uint8_t *buffer) |
Protected Attributes | |
uint8_t | _lastError = 0 |
This is a base class used to represent a connection to a Jrk G2. This class provides high-level functions for sending commands to the Jrk and reading data from it.
See the subclasses of this class, JrkG2Serial and JrkG2I2C.
|
inline |
Forces the duty cycle of the Jrk to a value in the range -600 to +600.
The jrk will ignore the results of the usual algorithm for choosing the duty cycle, and instead set it to be equal to the value specified by this command, ignoring all motor limits except the maximum duty cycle parameters, and ignoring the 'Input invalid', 'Input disconnect', and 'Feedback disconnect' errors. This command will have an immediate effect, regardless of the PID period. The jrk will set its 'Integral' variable to 0 while in this mode.
This is useful if the jrk is configured to use feedback but you want to take control of the motor for some time, without respecting most motor limits.
Example usage:
This function sends a "Force duty cycle" command to the Jrk G2, which clears the "Awaiting command" error bit.
To get out of this mode, use setTarget(), setTargetLowResFwd(), setTargetLowResRev(), forceDutyCycleTarget(), or stopMotor().
See also getForceMode().
|
inline |
Forces the duty cycle target of the Jrk to a value in the range -600 to +600.
The Jrk will ignore the results of the usual algorithm for choosing the duty cycle target, and instead set it to be equal to the target specified by this command. The Jrk will set its 'Integral' variable to 0 while in this mode.
This is useful if the Jrk is configured to use feedback but you want to take control of the motor for some time, while still respecting errors and motor limits as usual.
Example usage:
This function sends a "Force duty cycle target" command to the Jrk G2, which clears the "Awaiting command" error bit.
To get out of this mode, use setTarget(), setTargetLowResFwd(), setTargetLowResRev(), forceDutyCycle(), or stopMotor().
See also getForceMode().
|
inline |
Gets the analog reading from the specified pin.
The reading is left-justified, so 0xFFFE represents a voltage equal to the Jrk's 5V pin (approximately 4.8 V).
Returns JrkG2InputNull if the analog reading is disabled or not ready or the pin is invalid.
Example usage:
|
inline |
Gets the brake duration when switching from forward to reverse from the Jrk's RAM settings, in units of 5 ms.
See also setBrakeDurationForward().
|
inline |
Gets the brake duration when switching from reverse to forward from the Jrk's RAM settings, in units of 5 ms.
See also setBrakeDurationReverse().
|
inline |
Gets the "Coast when off" setting from the Jrk's RAM settings.
See also setCoastWhenOff().
|
inline |
|
inline |
Gets the number of consecutive PID periods during which current chopping due to the hard current limit has been active.
See also getCurrentChoppingOccurrenceCount().
|
inline |
Gets and clears the "Current chopping occurrence count" variable, which is the number of PID periods during which current chopping due to the hard current limit has been active, since the last time the variable was cleared.
This command is only valid for the Jrk G2 18v19, 24v13, 18v27, and 24v21. The Jrk G2 21v3 cannot sense when current chopping occurs so this command will always return 0.
See also getCurrentChoppingConsecutiveCount().
|
inline |
Gets the most-significant 8 bits of the "Current" variable.
The Jrk G2 supports this command mainly to be compatible with older Jrk models. In new applications, we recommend using getCurrent(), which provides a higher-resolution measurement.
|
inline |
Gets the exponent part of the derivative coefficient from the Jrk's RAM settings.
See also getDerivativeMultiplier() and setDerivativeCoefficient().
|
inline |
Gets the multiplier part of the derivative coefficient from the Jrk's RAM settings.
See also getDerivativeExponent() and setDerivativeCoefficient().
|
inline |
|
inline |
Gets a digital reading from the specified pin.
A return value of 0 means low while 1 means high. In most cases, pins configured as analog inputs cannot be read as digital inputs, so their values will be 0. See getAnalogReading() for those pins.
Example usage:
|
inline |
Gets the duty cycle variable.
The duty cycle variable is the duty cycle at which the jrk is currently driving the motor. A value of -600 means full speed reverse, while a value of 600 means full speed forward. A value of 0 means stopped (braking or coasting). The duty cycle could be different from the duty cycle target because it normally takes into account the Jrk's configurable motor limits and errors. The duty cycle can be overridden with forceDutyCycle().
See also getLastDutyCycle(), getDutyCycleTarget(), and forceDutyCycle().
|
inline |
Gets the duty cycle target variable.
In general, this is the duty cycle that the Jrk is trying to achieve. A value of -600 or less means full speed reverse, while a value of 600 or more means full speed forward. A value of 0 means stopped (braking or coasting). In no feedback mode (open-loop speed control mode), the duty cycle target is normally the target minus 2048. In other feedback modes, the duty cycle target is normally the sum of the proportional, integral, and derivative terms of the PID algorithm. In any mode, the duty cycle target can be overridden with forceDutyCycleTarget().
If an error is stopping the motor, the duty cycle target variable will not be directly affected, but the duty cycle variable will change/decelerate to zero.
See also getDutyCycle(), getLastDutyCycle(), and forceDutyCycleTarget().
|
inline |
Gets a contiguous block of settings from the Jrk G2's EEPROM.
The maximum length that can be fetched is 15 bytes.
Example usage:
For information on how the settings are encoded, see the Jrk G2 user's guide.
|
inline |
Gets the encoded value representing the hardware current limit the jrk is currently using.
This command is only valid for the Jrk G2 18v19, 24v13, 18v27, and 24v21. The Jrk G2 21v3 does not have a configurable hard current limit.
See also setEncodedHardCurrentLimit(), getCurrent().
|
inline |
Gets the encoded hard current limit for driving in the forward direction from the Jrk's RAM settings.
This command is only valid for the Jrk G2 18v19, 24v13, 18v27, and 24v21. The Jrk G2 21v3 does not have a configurable hard current limit.
See also setEncodedHardCurrentLimitForward().
|
inline |
Gets the encoded hard current limit for driving in the reverse direction from the Jrk's RAM settings.
This command is only valid for the Jrk G2 18v19, 24v13, 18v27, and 24v21. The Jrk G2 21v3 does not have a configurable hard current limit.
See also setEncodedHardCurrentLimitReverse().
|
inline |
Gets the errors that are currently stopping the motor and clears any latched errors that are enabled. Calling this function is equivalent to reading the "Currently stopping motor?" column in the Errors tab of the configuration utility, and then clicking the "Clear Errors" button.
Each bit in the returned register represents a different error. The bits are defined in the JrkG2Error enum.
Example usage:
It is possible to read this variable without clearing the bits in it using a getVariables().
See also getErrorFlagsOccurred().
|
inline |
Gets the errors that have occurred since the last time this function was called. Unlike getErrorFlagsHalting(), calling this function has no effect on the motor.
Note that the Jrk G2 Control Center constantly clears the bits in this register, so if you are running the Jrk G2 Control Center then you will not be able to reliably detect errors with this function.
Each bit in the returned register represents a different error. The bits are defined in the JrkG2Error enum.
Example usage:
It is possible to read this variable without clearing the bits in it using getVariables().
See also getErrorFlagsHalting().
|
inline |
Gets the raw pulse rate or pulse width measured on the Jrk's FBT (tachometer feedback) pin.
In pulse counting mode, this will be the number of pulses on the FBT pin seen in the last N PID periods, where N is the "Pulse samples" setting.
In pulse timing mode, this will be a measurement of the width of pulses on the FBT pin. This measurement is affected by several configurable settings.
Example usage:
|
inline |
Gets the feedback variable.
The feedback variable is a raw, unscaled feedback value, representing a measurement taken by the Jrk of the output of the system. In analog feedback mode, the feedback is a measurement of the voltage on the FBA pin, where 0 is 0 V and 4092 is a voltage equal to the Jrk's 5V pin (approximately 4.8 V). In frequency feedback mode, the feedback is 2048 plus or minus a measurement of the frequency of pulses on the FBT pin. In feedback mode none (open-loop speed control mode), the feedback is always zero.
See also getScaledFeedback().
|
inline |
Returns an indication of whether the Jrk's duty cycle target or duty cycle are being overridden with a forced value.
Example usage:
See also forceDutyCycleTarget() and forceDutyCycle().
|
inline |
Gets the input variable.
The input variable is a raw, unscaled value representing a measurement taken by the Jrk of the input to the system. In serial input mode, the input is equal to the target, which can be set to any value from 0 to 4095 using serial commands. In analog input mode, the input is a measurement of the voltage on the SDA pin, where 0 is 0 V and 4092 is a voltage equal to the Jrk's 5V pin (approximately 4.8 V). In RC input mode, the input is the duration of the last RC pulse measured, in units of 2/3 us.
See the Jrk G2 user's guide for more information about input modes.
See also getTarget() and setTarget().
|
inline |
Gets the integral variable.
In general, every PID period, the error (scaled feedback minus target) is added to the integral (also known as error sum). There are several settings to configure the behavior of this variable, and it is used in the PID calculation.
|
inline |
Gets the exponent part of the integral coefficient from the Jrk's RAM settings.
See also getIntegralMultiplier() and setIntegralCoefficient().
|
inline |
Gets the integral limit from the Jrk's RAM settings.
See also setIntegralLimit().
|
inline |
Gets the multiplier part of the integral coefficient from the Jrk's RAM settings.
See also getIntegralExponent() and setIntegralCoefficient().
|
inline |
Gets the duty cycle the Jrk drove the motor with in the last PID period.
This can be useful for converting the getRawCurrent() reading into milliamps.
See also getDutyCycle(), getDutyCycleTarget(), and getCurrent().
|
inline |
|
inline |
Gets the maximum acceleration in the forward direction from the Jrk's RAM settings.
See also setMaxAccelerationForward().
|
inline |
Gets the maximum acceleration in the reverse direction from the Jrk's RAM settings.
See also setMaxAccelerationReverse().
|
inline |
Gets the maximum deceleration in the forward direction from the Jrk's RAM settings.
See also setMaxDecelerationForward().
|
inline |
Gets the maximum deceleration in the reverse direction from the Jrk's RAM settings.
See also setMaxDecelerationReverse().
|
inline |
Gets the maximum duty cycle in the forward direction from the Jrk's RAM settings.
See also setMaxDutyCycleForward().
|
inline |
Gets the maximum duty cycle in the reverse direction from the Jrk's RAM settings.
See also setMaxDutyCycleReverse().
|
inline |
Gets the maximum duty cycle while feedback is out of range from the Jrk's RAM settings.
See also setMaxDutyCycleWhileFeedbackOutOfRange().
|
inline |
Gets the PID period from the Jrk's RAM settings, in milliseconds.
See also setPIDPeriod().
|
inline |
|
inline |
Returns true if the Jrk's most recent PID cycle took more time than the configured PID period. This indicates that the Jrk does not have time to perform all of its tasks at the desired rate. Most often, this is caused by the configured number of analog samples for input, feedback, or current sensing being too high for the configured PID period.
|
inline |
Gets the exponent part of the proportional coefficient from the Jrk's RAM settings.
See also getProportionalMultiplier() and setProportionalCoefficient().
|
inline |
Gets the multiplier part of the proportional coefficient from the Jrk's RAM settings.
See also getProportionalExponent() and setProportionalCoefficient().
|
inline |
Gets a contiguous block of settings from the Jrk G2's RAM.
The maximum length that can be fetched is 15 bytes.
Example usage:
Note that this library has several functions for reading and writing specific RAM settings, and they are easier to use than this function.
For information on how the settings are encoded, see the Jrk G2 user's guide.
|
inline |
Gets the Jrk's raw measurement of the current running through the motor.
This is an analog voltage reading from the Jrk's current sense pin. The units of the reading depend on what hard current limit is being used (getEncodedHardCurrentLimit()).
See also getCurrent().
|
inline |
Gets the raw RC pulse width measured on the Jrk's RC input, in units of twelfths of a microsecond.
Returns 0 if the RC input is missing or invalid.
Example usage:
|
inline |
Gets the "Reset integral" setting from the Jrk's RAM settings.
See also setResetIntegral().
|
inline |
Gets the scaled feedback variable.
The scaled feedback is calculated from the feedback using the Jrk's configurable feedback scaling settings.
See also getFeedback().
|
inline |
Gets the soft current limit when driving in the forward direction from the Jrk's RAM settings, in units of mA.
See also setSoftCurrentLimitForward().
|
inline |
Gets the soft current limit when driving in the reverse direction from the Jrk's RAM settings, in units of mA.
See also setSoftCurrentLimitReverse().
|
inline |
Gets the target variable.
In serial input mode, the target is set directly with serial commands. In the other input modes, the target is computed by scaling the input, using the configurable input scaling settings.
See also setTarget() and getInput().
|
inline |
|
inline |
Gets a contiguous block of variables from the Jrk G2.
Note that this library has convenient functions for reading every variable provided by the Jrk. The main reason to use this function is if you want to read multiple variables at once for extra efficiency or to ensure that the variables are in a consistent state.
The maximum length that can be fetched is 15 bytes.
Example usage:
For information on how the variables are encoded, see the Jrk G2 user's guide.
|
inline |
|
inline |
Sets the brake duration for both directions in the Jrk's RAM settings, in units of 5 ms.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also setBrakeDurationForward(), setBrakeDurationReverse().
|
inline |
Sets the brake duration when switching from forward to reverse in the Jrk's RAM settings, in units of 5 ms.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getBrakeDurationForward() and setBrakeDurationReverse().
|
inline |
Sets the brake duration when switching from reverse to forward in the Jrk's RAM settings, in units of 5 ms.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getBrakeDurationReverse() and setBrakeDurationForward().
|
inline |
Sets or clears the "Coast when off" setting in the Jrk's RAM settings.
By default, the Jrk drives both motor outputs low when the motor is stopped (duty cycle is zero), causing it to brake. If enabled, this setting causes it to instead tri-state both outputs, making the motor coast.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getCoastWhenOff().
|
inline |
Sets the derivative coefficient in the Jrk's RAM settings.
This coefficient is used in the Jrk's PID algorithm. The coefficient takes the form:
multiplier / (2 ^ exponent)
The multiplier can range from 0 to 1023, and the exponent can range from 0 to 18.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getDerivativeMultiplier() and getDerivativeExponent(), as well as setProportionalCoefficient() and setIntegralCoefficient().
|
inline |
Sets the encoded hard current limit for both directions in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
This command is only valid for the Jrk G2 18v19, 24v13, 18v27, and 24v21. The Jrk G2 21v3 does not have a configurable hard current limit.
See also setEncodedHardCurrentLimitForward(), setEncodedHardCurrentLimitReverse(), getEncodedHardCurrentLimit(), and setSoftCurrentLimit().
|
inline |
Sets the encoded hard current limit for driving in the forward direction in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
This command is only valid for the Jrk G2 18v19, 24v13, 18v27, and 24v21. The Jrk G2 21v3 does not have a configurable hard current limit.
See also getEncodedHardCurrentLimitForward() and setEncodedHardCurrentLimitReverse().
|
inline |
Sets the encoded hard current limit for driving in the reverse direction in the Jrk's RAM settings
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
This command is only valid for the Jrk G2 18v19, 24v13, 18v27, and 24v21. The Jrk G2 21v3 does not have a configurable hard current limit.
See also getEncodedHardCurrentLimitReverse() and setEncodedHardCurrentLimitForward().
|
inline |
Sets the integral coefficient in the Jrk's RAM settings.
This coefficient is used in the Jrk's PID algorithm. The coefficient takes the form:
multiplier / (2 ^ exponent)
The multiplier can range from 0 to 1023, and the exponent can range from 0 to 18.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getIntegralMultiplier() and getIntegralExponent(), as well as setProportionalCoefficient() and setDerivativeCoefficient().
|
inline |
Sets the integral limit in the Jrk's RAM settings.
The PID algorithm prevents the absolute value of the integral variable (also known as error sum) from exceeding this limit. This can help limit integral wind-up. The limit can range from 0 to 32767.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getIntegralLimit().
|
inline |
Sets the maximum acceleration in both directions in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also setMaxAccelerationForward(), setMaxAccelerationReverse(), setMaxDeceleration().
|
inline |
Sets the maximum acceleration in the forward direction in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getMaxAccelerationForward(), setMaxAccelerationReverse(), setMaxAcceleration(), and setMaxDecelerationForward().
|
inline |
Sets the maximum acceleration in the reverse direction in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getMaxAccelerationReverse(), setMaxAccelerationForward(), setMaxAcceleration(), and setMaxDecelerationReverse().
|
inline |
Sets the maximum deceleration in both directions in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also setMaxDecelerationForward(), setMaxDecelerationReverse(), setMaxAcceleration().
|
inline |
Sets the maximum deceleration in the forward direction in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getMaxDecelerationForward(), setMaxDecelerationReverse(), setMaxDeceleration(), and setMaxAccelerationForward().
|
inline |
Sets the maximum deceleration in the reverse direction in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getMaxDecelerationReverse(), setMaxDecelerationForward(), setMaxDeceleration(), and setMaxAccelerationReverse().
|
inline |
Sets the maximum duty cycle for both directions in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also setMaxDutyCycleForward(), setMaxDutyCycleReverse().
|
inline |
Sets the maximum duty cycle in the forward direction in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getMaxDutyCycleForward(), setMaxDutyCycleReverse().
|
inline |
Sets the maximum duty cycle in the reverse direction in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getMaxDutyCycleReverse(), setMaxDutyCycleForard().
|
inline |
Sets the maximum duty cycle while feedback is out of range in the Jrk's RAM settings.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getMaxDutyCycleWhileFeedbackOutOfRange().
|
inline |
Sets the PID period in the Jrk's RAM settings.
This is the rate at which the Jrk runs through all of its calculations, in milliseconds. Note that a higher PID period will result in a more slowly changing integral and a higher derivative, so the two corresponding PID coefficients might need to be adjusted whenever the PID period is changed.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getPIDPeriod().
|
inline |
Sets the proportional coefficient in the Jrk's RAM settings.
This coefficient is used in the Jrk's PID algorithm. The coefficient takes the form:
multiplier / (2 ^ exponent)
The multiplier can range from 0 to 1023, and the exponent can range from 0 to 18.
Example usage:
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getProportionalMultiplier() and getProportionalExponent(), as well as setIntegralCoefficient() and setDerivativeCoefficient().
|
inline |
Sets a contiguous block of settings in the Jrk G2's RAM.
The maximum length that can be written in a single command is 7 bytes over Serial, 13 bytes over I2C.
Example usage:
Note that this library has several functions for reading and writing specific RAM settings, and they are easier to use than this function.
For information on how the settings are encoded, see the Jrk G2 user's guide.
|
inline |
Sets or clears the "Reset integral" setting in the Jrk's RAM settings.
If this setting is set to true, the PID algorithm will reset the integral variable (also known as error sum) when the absolute value of the proportional term exceeds 600.
When enabled, this can help limit integral wind-up, or the uncontrolled growth of the integral when the feedback system is temporarily unable to keep the error small. This might happen, for example, when the target is changing quickly.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getResetIntegral().
|
inline |
Sets the soft current limit for driving in both directions in the Jrk's RAM settings, in units of mA.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also setSoftCurrentLimitForward() and setSoftCurrentLimitReverse(), setEncodedHardCurrentLimit().
|
inline |
Sets the soft current limit when driving in the forward direction in the Jrk's RAM settings, in units of mA.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getSoftCurrentLimitForward() and setSoftCurrentLimitReverse().
|
inline |
Sets the soft current limit when driving in the reverse direction in the Jrk's RAM settings, in units of mA.
You would normally configure this setting ahead of time using the Jrk G2 Configuration Utility, but this function allows you to change it temporarily on the fly.
See also getSoftCurrentLimitReverse() and setSoftCurrentLimitForward().
|
inline |
Sets the target of the Jrk to a value in the range 0 to 4095.
The target can represent a target duty cycle, speed, or position depending on the feedback mode.
Example usage:
This functions sends a "Set target" command to the jrk, which clears the "Awaiting command" error bit and (if the input mode is serial) will set the jrk's input and target variables.
See also setTargetLowResRev(), setTargetLowResFwd(), getTarget(), forceDutyCycleTarget(), forceDutyCycle().
|
inline |
Sets the target of the Jrk based on a value in the range 0 to 127 that maps to a 12-bit target of 2048 or greater.
If the feedback mode is Analog or Tachometer, then the formula is Target = 2048 + 16 * value.
If the feedback mode is None (speed control mode), then the formula is Target = 2048 + (600 / 127) * value. This means that a value of 127 will set the duty cycle target to full-speed reverse (-600), while a value of zero will make the motor stop.
Example usage:
This function sends a "Set target low resolution forward" command to the Jrk G2, which clears the "Awaiting command" error bit and (if the input mode is serial) will set the jrk's input and target variables.
See also setTargetLowResRev(), setTarget(), and getTarget().
|
inline |
Sets the target of the Jrk based on a value in the range 0 to 127.
If the value is zero, then this command is equivalent to the "Stop motor" command. Otherwise, the value maps to a 12-bit target less than 2048.
If the feedback mode is Analog or Tachometer, then the formula is Target = 2048 - 16 * value.
If the feedback mode is None (speed control mode), then the formula is Target = 2048 - (600 / 127) * value. This means that a value of 127 will set the duty cycle target to full-speed reverse (-600).
Example usage:
This function sends a "Set target low resolution reverse" command to the Jrk G2, which clears the "Awaiting command" error bit and (if the input mode is serial) will set the jrk's input and target variables.
See also setTargetLowResFwd(), setTarget(), getTarget(), and stopMotor().
|
inline |
Turns the motor off.
This function sends a "Stop motor" command to the Jrk, which sets the "Awaiting command" error bit. The Jrk will respect the configured deceleration limit while decelerating to a duty cycle of 0, unless the "Awaiting command" error has been configured as a hard error. Once the duty cycle reaches zero, the Jrk will either brake or coast.
Example usage:
|
protected |