DMC60C API
This is the C/C++ API for the DMC60C.
|
Low Level DMC60C Interface. More...
Public Member Functions | |
DMC60LowLevel (int value=0, int verbose=0, constructortype type=constructortype::useDeviceNumber) | |
Creates a DMC60LowLevel object. More... | |
DMC_Code | setDeviceNumber (uint16_t newdevnum) |
Sets the deviceNumber of the DMC60C. More... | |
uint8_t | getDeviceNumber () |
Gets the deviceNumber of the DMC60C. More... | |
DMC_Code | setDeviceName (char *szDevName, uint16_t cbName) |
Sets the deviceName of the DMC60C. More... | |
void | getDeviceName (char *szNameBuf) |
Gets the device name of the DMC60C. More... | |
uint16_t | getFWVerBoot () |
Gets the bootloader firmware of the DMC60C. More... | |
uint16_t | getFWVerApp () |
Gets the application firmware of the DMC60C. More... | |
uint8_t | getImgType () |
Returns the currently running image type (bootloader, application, or aux bootloader). More... | |
uint16_t | getSessId () |
Returns the session ID assigned to the DMC60C. More... | |
DMC_Code | fetchFWVer () |
Retrieves the device's firmware version information. This includes application firmware revision, bootloader firmware revision, and the time of firmware image that is currently running. This information is stored in the private member DMCInfo, and can be read with the get commands. More... | |
DMC_Code | softReset () |
Returns the session ID assigned to the DMC60C. More... | |
DMC_Code | flashLEDs () |
Flashes the LEDs on the DMC60C in a rainbow pattern for 5 seconds. More... | |
void | setPIDSlot (uint8_t slotNum) |
Sets the active PID slot used by the DMC60C. | |
DMC_Code | configPID_RampRate (uint8_t slot, uint32_t ramp, int tmsWait) |
Configure the closed loop ramp rate used by the specified closed loop profile slot. The closed loop ramp rate specifies the maximum number of throttle units the output can change by each time the control loop executes in closed loop control mode (Velocity, Position, or Current). For example, If the closed loop ramp rate is set to 1000 and the PID update function determines that the throttle should be increased by 5000 units then the immediate throttle increase will be limited to 1000 units. If the next PID Update doesnt change the target throttle output value, the throttle will be increased by another 1000 units the next time the control loop executes. This process will continue until the target throttle is reached or a new throttle value is calculated. The control loop executes once every 500 µs. Therefore, specifying a closed loop ramp rate of 16 would result in it taking approximately 1.02 seconds to go from 0% throttle (0) to 100% throttle (32767). Specifying a value of 0 for the closed loop ramp rate disables throttling and allows the output to be immediately set to the target value. This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | getPID_RampRate (uint8_t slot, uint32_t *ramp, int tmsWait) |
Gets the ramp rate value stored in the specified PID slot. More... | |
DMC_Code | configPID_FwdMaxDuty (uint8_t slot, int value, int tmsWait) |
Configure the closed loop control maximum forward duty cycle used by the specified motor control profile slot. The maximum forward duty cycle is the largest positive duty cycle that may be applied to the output when motor control profile slot 0 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). The value specified for this parameter should be restricted to be within the range of 0 to 32767. This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | getPID_FwdMaxDuty (uint8_t slot, int *value, int tmsWait) |
Gets the forward max duty cycle stored in the specified PID slot. More... | |
DMC_Code | configPID_RevMaxDuty (uint8_t slot, int value, int tmsWait) |
Configure the closed loop control maximum reverse duty cycle used by the specified motor control profile slot. The maximum reverse duty cycle is the largest negative duty cycle that may be applied to the output when motor control profile slot 0 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). The value specified for this parameter should be restricted to be within the range of -32768 to 0. This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | getPID_RevMaxDuty (uint8_t slot, int *value, int tmsWait) |
Gets the reverse max duty cycle stored in the specified PID slot. More... | |
DMC_Code | configPID_FwdNominal (uint8_t slot, int value, int tmsWait) |
Configure the closed loop control nominal forward duty cycle used by the specified motor control profile slot. The nominal forward duty cycle is the smallest positive duty cycle that may be applied to the output when the closed loop error exceeds the allowable closed loop error specified for the selected motor profile slot. The closed loop nominal forward duty cycle is only utilized when the control frame specifies one of the closed loop control modes (Velocity, Position, or Current). The value specified for this parameter should be restricted to be within the range of 0 to 32767. This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | getPID_FwdNominal (uint8_t slot, int *value, int tmsWait) |
Gets the forward nominal duty cycle stored in the specified PID slot. More... | |
DMC_Code | configPID_RevNominal (uint8_t slot, int value, int tmsWait) |
Configure the closed loop control nominal reverse duty cycle used by the specified motor control profile slot. The nominal reverse duty cycle is the smallest negative duty cycle that may be applied to the output when the closed loop error exceeds the allowable closed loop error specified for the selected motor profile slot. The closed loop nominal reverse duty cycle is only utilized when the control frame specifies one of the closed loop control modes (Velocity, Position, or Current). The value specified for this parameter should be restricted to be within the range of -32768 to 0. This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | getPID_RevNominal (uint8_t slot, int *value, int tmsWait) |
Gets the reverse nominal duty cycle stored in the specified PID slot. More... | |
DMC_Code | configPID_kP (uint8_t slot, float value, int tmsWait) |
Configure the proportional gain constant used by the specified motor control profile slot. This constant is used during closed loop control to calculate a proportional increase or decrease in the throttle (duty cycle) due to the measured closed loop error. This parameter will be utilized for PID calculations when motor control profile slot 1 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | get_kP (uint8_t slot, float *value, int tmsWait) |
Reads the P gain value of the specified slot and stores the value into a pointer. More... | |
DMC_Code | configPID_kI (uint8_t slot, float value, int tmsWait) |
Configure the integral gain constant used by the specified motor control profile slot. This constant is used during closed loop control to calculate an integral increase or decrease in the throttle (duty cycle) due to the measured closed loop error. This parameter will be utilized for PID calculations when motor control profile slot 1 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | get_kI (uint8_t slot, float *value, int tmsWait) |
Reads the I gain value of the specified slot and stores the value into a pointer. More... | |
DMC_Code | configPID_kD (uint8_t slot, float value, int tmsWait) |
Configure the derivative gain constant used by the specified motor control profile slot. This constant is used during closed loop control to calculate the derivative increase or decrease in the throttle (duty cycle) due to the measured closed loop error. This parameter will be utilized for PID calculations when motor control profile slot 1 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | get_kD (uint8_t slot, float *value, int tmsWait) |
Reads the D gain value of the specified slot and stores the value into a pointer. More... | |
DMC_Code | configPID_kF (uint8_t slot, float value, int tmsWait) |
Configure the feed-forward gain constant used by the specified motor control profile slot. This constant is used during closed loop control to calculate the number of throttle units to contribute to the duty cycle as the proportion of the setpoint (target Velocity, Position, or Current) independent of the error. For example, if the target current is 20.0 amps and you want to apply 50% throttle for this setpoint then the feed forward gain would be set to (0.50×32767)/20.0=819.175. Convert this to fixed-point by multiplying by 65536. This results in a value of 0x03332CCC (hex), which is what should be sent to the DMC60 in the value field of the PARAMSET packet. The feed-forward term can be excluded from the PID calculations by specifying a value of 0 for the gain. This parameter will be utilized for PID calculations when motor control profile slot 1 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | get_kF (uint8_t slot, float *value, int tmsWait) |
Reads the F gain value of the specified slot and stores the value into a pointer. More... | |
DMC_Code | configPID_IZone (uint8_t slot, unsigned int value, int tmsWait) |
Configure the integral accumulator limit used by motor control profile slot 0. The integral accumulator limit, or I-zone, is used to limit how large the integral accumulator can grow during closed loop control. The value sent to the DMC60 is converted to a 32-bit signed integer and used to set the positive and negative bounds of the integral accumulator. If the integral accumulator exceeds these bounds while PID calculations are performed, then the accumulator will be capped to value or -value. This provides a mechanism for combating integral windup. Setting a value of 0 will disable the limit and allow the integral accumulator to grow without bounds. This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | get_IZone (uint8_t slot, unsigned int *value, int tmsWait) |
Gets the current Izone value stored in the specified PID slot. More... | |
DMC_Code | configPID_AllowableError (uint8_t slot, uint32_t value, int tmsWait) |
Configure the allowable closed loop error used by the specified motor control profile slot. The allowable closed loop error specifies the minimum error required for the PID controller to calculate a non-zero contribution to the output throttle (duty cycle) based on the P, I, and D terms. If the allowable error is set to a non-zero value and the measured error is less than the allowable error then the P, I, and D terms will contribute 0 throttle units to the output throttle calculation and the integral accumulator will be cleared. If the allowable error is set to 0 or the measured error exceeds the allowable error then P, I, and D terms are included in the output throttle calculation. The feed-forward gain constant, or F term, is included in the output throttle calculation regardless of the allowable error setting. This parameter will be utilized for PID calculations when motor control profile slot 1 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | getPID_AllowableError (uint8_t slot, uint32_t *value, int tmsWait) |
Gets the allowable error value stored in the specified PID slot. More... | |
DMC_Code | configForwardLimitSwitchEnable (bool enable, int tmsWait) |
Sets whether or not the forward limit switch is enabled or not. More... | |
DMC_Code | getForwardLimitSwitchEnable (bool *enable, int tmsWait) |
Gets whether or not the forward limit switch is enabled or not. More... | |
DMC_Code | configForwardLimitSwitchType (bool normallyClosed, int tmsWait) |
Sets the switch type of the forward limit switch. More... | |
DMC_Code | getForwardLimitSwitchType (bool *normallyClosed, int tmsWait) |
Gets the switch type of the forward limit switch. More... | |
DMC_Code | configReverseLimitSwitchEnable (bool enable, int tmsWait) |
Sets whether or not the reverse limit switch is enabled or not. More... | |
DMC_Code | getReverseLimitSwitchEnable (bool *enable, int tmsWait) |
Gets whether or not the reverse limit switch is enabled or not. More... | |
DMC_Code | configReverseLimitSwitchType (bool normallyClosed, int tmsWait) |
Sets the switch type of the reverse limit switch. More... | |
DMC_Code | getReverseLimitSwitchType (bool *normallyClosed, int tmsWait) |
Gets the switch type of the reverse limit switch. More... | |
DMC_Code | configSoftFwdThreshold (bool enable, int limit, int tmsWait) |
Configure the soft forward limit threshold. The soft forward limit threshold specifies the maximum position that the encoder can read in the forward direction. The units are native to the encoder thats connected to the expansion header. The DMC60s control loop runs every 500us. Each time it executes the current position of the encoder is read and compared to the soft forward limit threshold. If the encoders current position is greater than or equal to the specified soft forward limit threshold and the soft forward limit is enabled, then the DMC60s output will be prevented from applying a positive voltage to the load. Both positive and negative soft limit thresholds are valid. This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | getSoftFwdThreshold (bool *enable, int *limit, int tmsWait) |
Gets the current soft forward threshold value. More... | |
DMC_Code | configSoftRevThreshold (bool enable, int limit, int tmsWait) |
Configure the reverse limit switch type. The reverse limit switch be configured as a normally closed switch by setting the value field to a 1 or a normally open switch by setting the value field to a 0. The DMC60 uses internal (weak) pull-ups to pull the reverse limit switch pin to 3.3V. When configured as a normally closed switch the DMC60 will prevent the output from applying a negative voltage to the load when the limit switch opens, causing the DMC60 to detect a logic 1 on the REVLIM pin. When configured as a normally open switch the DMC60 will prevent the output from applying a negative voltage to the load when the limit switch closes, causing the DMC60 to detect a logic 0 on the REVLIM pin. This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | getSoftRevThreshold (bool *enable, int *limit, int tmsWait) |
Gets the current soft reverse threshold value. More... | |
DMC_Code | configAnalogStatusFramePeriod (uint32_t periodMs, int tmsWait) |
Configure the rate at which the DMC60 transmits Analog Input, Current, Temperature, and Battery Voltage Status Frames. These status frames are formatted as STSANALOG packets and are described in the Periodic Status Messages section. The frame rate can be set to any value between 1 millisecond and 30000 milliseconds. Power cycling the DMC60 will result in the device reverting to the default frame rate, which is 100 milliseconds. More... | |
DMC_Code | getAnalogStatusFramePeriod (uint32_t *periodMs, int tmsWait) |
Gets the current analog status frame period. More... | |
DMC_Code | configEncoderStatusFramePeriod (uint32_t periodMs, int tmsWait) |
Configure the rate at which the DMC60 transmits Quadrature Encoder Status Frames. These status frames are formatted as STSENCODER packets and are described in the Periodic Status Messages section. The frame rate can be set to any value between 1 millisecond and 30000 milliseconds. Power cycling the DMC60 will result in the device reverting to the default frame rate, which is 100 milliseconds. More... | |
DMC_Code | getEncoderStatusFramePeriod (uint32_t *periodMs, int tmsWait) |
Get the current encoder status frame period. More... | |
DMC_Code | configGeneralStatusFramePeriod (uint32_t periodMs, int tmsWait) |
Configure the rate at which the DMC60 transmits General Status Frames. These status frames are formatted as STSGENERAL packets and are described in the Periodic Status Messages section. The frame rate can be set to any value between 1 millisecond and 30000 milliseconds. Power cycling the DMC60 will result in the device reverting to the default frame rate, which is 10 milliseconds. More... | |
DMC_Code | getGeneralStatusFramePeriod (uint32_t *periodMs, int tmsWait) |
Get the current general status frame period. More... | |
DMC_Code | setEncoderPosition (int position, int tmsWait) |
Configure the encoder position. The encoder position is maintained by the QEI module of the DMC60s MCU and is continuously updated by the pulse train applied to QEA and QEB inputs of the expansion header. At power on the encoders position is initialized to zero. This may not correspond with the zero point thats defined in the end user application, and as such, it may be necessary to set the encoder to a specific position or reset it to 0 after performing a homing sequence. The encoders position is used for closed loop position control and for determining whether the forward soft limit or reverse soft limit have been hit. The encoder position should only be configured while the DMC60s output is disabled. More... | |
DMC_Code | getEncoderPosition (int *position, int tmsWait) |
Configure the encoder position. The encoder position is maintained by the QEI module of the DMC60s MCU and is continuously updated by the pulse train applied to QEA and QEB inputs of the expansion header. At power on the encoders position is initialized to zero. This may not correspond with the zero point thats defined in the end user application, and as such, it may be necessary to set the encoder to a specific position or reset it to 0 after performing a homing sequence. The encoders position is used for closed loop position control and for determining whether the forward soft limit or reverse soft limit have been hit. The encoder position should only be configured while the DMC60s output is disabled. More... | |
DMC_Code | setClearPositionOnIndex (bool enable, int tmsWait) |
Sets whether or not the index pin will cause the position count to reset. More... | |
DMC_Code | getClearPositionOnIndex (bool *enable, int tmsWait) |
Gets whether or not the index pin will cause the position count to reset. More... | |
DMC_Code | setClearPositionOnFwdLimit (bool enable, int tmsWait) |
Sets whether or not the forward limit switch pin will cause the position count to reset. More... | |
DMC_Code | getClearPositionOnFwdLimit (bool *enable, int tmsWait) |
Gets whether or not the fwd limit switch pin will cause the position count to reset. More... | |
DMC_Code | setClearPositionOnRevLimit (bool enable, int tmsWait) |
Sets whether or not the reverse limit switch pin will cause the position count to reset. More... | |
DMC_Code | getClearPositionOnRevLimit (bool *enable, int tmsWait) |
Gets whether or not the reverse limit switch pin will cause the position count to reset. More... | |
DMC_Code | setIndexActiveEdge (bool edge, int tmsWait) |
Sets the active edge of the index pin. More... | |
DMC_Code | getIndexActiveEdge (bool *edge, int tmsWait) |
Gets the active edge of the index pin. More... | |
DMC_Code | resetStickyFaults (int tmsWait) |
Resets the counts stored in the sticky faults. More... | |
DMC_Code | resetOverTempStickyFaults (int tmsWait) |
Resets the overtemp sticky fault count. More... | |
DMC_Code | resetOverCurrentStickyFaults (int tmsWait) |
Resets the overcurrent sticky fault count. More... | |
DMC_Code | resetUnderVoltageStickyFaults (int tmsWait) |
Resets the undervoltage sticky fault count. More... | |
DMC_Code | resetGateDriverStickyFaults (int tmsWait) |
Resets the gate driver sticky fault count. More... | |
DMC_Code | resetCommStickyFaults (int tmsWait) |
Resets the comm sticky fault count. More... | |
DMC_Code | getActiveFaults (uint32_t *value, int tmsWait) |
Retrieves the active fault bit field from the motor controller. More... | |
DMC_Code | getStickyFaults (uint32_t *value, int tmsWait) |
Retrieves the sticky fault bit field from the motor controller. More... | |
DMC_Code | getOverTempStickyFaultCount (uint32_t *value, int tmsWait) |
Retrieves the number of over temp sticky faults. More... | |
DMC_Code | getOverCurrentStickyFaultCount (uint32_t *value, int tmsWait) |
Retrieves the number of over current sticky faults. More... | |
DMC_Code | getUnderVoltageStickyFaultCount (uint32_t *value, int tmsWait) |
Retrieves the number of under voltage sticky faults. More... | |
DMC_Code | getGateDriverStickyFaultCount (uint32_t *value, int tmsWait) |
Retrieves the number of gate driver sticky faults. More... | |
DMC_Code | getCommStickyFaultCount (uint32_t *value, int tmsWait) |
Retrieves the number of comm sticky faults. More... | |
void | setOverrideBC (bool enable, bool brakecoast) |
Sets the brake/coast mode override. More... | |
void | setReverse (bool reverse) |
Sets the reverse bit in control0 frame. This causes the motor controller to reverse drive of the motor. More... | |
void | setLimitSwitchOverride (bool enable, bool forwardSwitchEnable, bool reverseSwitchEnable) |
Sets the override bits in the control frame. This overrides the limit switch parameters to allow enabling and disabling the limit switches realtime,. More... | |
void | setReverseFeedbackSensor (bool reverse) |
Sets the reverse bit in control0 frame. This causes the motor controller to reverse drive of the motor. More... | |
void | setRampRate (unsigned short rampRate) |
Sets the open loop ramp rate that is sent within each control0 frame. More... | |
void | sendControl () |
Resends the control0 frame. If it has not been sent before, it will start sending the default _control0 frame at 100ms. | |
void | sendControl (ControlMode Mode, double trgt) |
Sends the control0 frame with the specified parameters at a specified period. This is the main control of the DMC60C. This frame must be sent every 104ms or the DMC60C will go into standby mode. More... | |
void | sendControl (ControlMode Mode, double trgt, uint16_t ramp, uint32_t periodMs) |
Sends the control0 frame with the specified parameters at a specified period. This is the main control of the DMC60C. This frame must be sent every 104ms or the DMC60C will go into standby mode. More... | |
DMC_Code | getAnalogStatus (STSANALOG *stsAnalogOut) |
Retrieves the latest STSANALOG frame from the DMC60C. More... | |
DMC_Code | getEncoderStatus (STSENCODER *stsEncoderOut) |
Retrieves the latest STSENCODER frame from the DMC60C. More... | |
DMC_Code | getGeneralStatus (STSGENERAL *stsGeneralOut) |
Retrieves the latest STSGENERAL frame from the DMC60C. More... | |
void | SetControlMode (ControlMode Mode) |
Sets the ControlMode in the control0 frame. The frame must be resent with sendControl() to have any effect, although this is not recommended in most cases. More... | |
ControlMode | GetControlMode () const |
Returns the current controlMode in the control0 frame. More... | |
DMC_Code | setContinuousCurrentLimit (double currentAmps) |
Sets the continuous current limit. This applies only if current limiting is enabled. The continuous current limit is the maximum current that can be drawn by the DMC60C AFTER the peak current limit has been hit for the peak current duration. If the continuous current limit is greater than or equal to the peak current limit, then the DMC60C will begin limiting the current immediately after the continuous current limit is exceeded. More... | |
DMC_Code | getContinuousCurrentLimit (double *currentAmps) |
Gets the continuous current limit. More... | |
DMC_Code | setPeakCurrentLimit (double currentAmps) |
Sets the peak current limit. This only applies if current limiting is enabled. The peak current is the max current that can be applied to the motor at any given time. This limit can be applied for up to [peak current duration] milliseconds. Afterwards the continuous current limit will be applied. If the peak current limit is set to a value lower than the continuous current limit, the DMC60C will apply the continuous current limit immediately after it detects that the continuous current limit has been exceeded. More... | |
DMC_Code | getPeakCurrentLimit (double *currentAmps) |
Gets the peak current limit. More... | |
DMC_Code | setPeakCurrentDuration (int durationMs) |
Sets the peak current duration. This only applies if current limiting is enabled. The peak current duration is the maximum amount of time the peak current can be applied to the motor. After this duration, the continuous current limit will be applied. If the duration is set to 0, the DMC60C will begin applying the continuous current limit immediately after the peak current limit has been exceeded. More... | |
DMC_Code | getPeakCurrentDuration (int *durationMs) |
Gets the peak current duration. More... | |
DMC_Code | enableCurrentLimit (bool enabled) |
Enables or disables current limiting mode. More... | |
DMC_Code | isCurrentLimitEnabled (bool *enabled) |
Returns whether or not the current limit is enabled. More... | |
DMC_Code | setCurrentLimitPGain (double P) |
DMC_Code | getCurrentLimitPGain (double *P) |
DMC_Code | setCurrentLimitIGain (double I) |
DMC_Code | getCurrentLimitIGain (double *I) |
DMC_Code | setCurrentLimitDGain (double D) |
DMC_Code | getCurrentLimitDGain (double *D) |
DMC_Code | setCurrentLimitFGain (double F) |
DMC_Code | getCurrentLimitFGain (double *F) |
DMC_Code | setCurrentLimitIZone (double I) |
DMC_Code | getCurrentLimitIZone (double *I) |
DMC_Code | setADCMultiplier (float value, int tmsWait) |
Configure the constant used by the DMC60 to convert ADC measurements into an associated load current in amps. The DMC60 uses a combination of a current sense resistor, bidirectional current sense amplifier with a 50V/V gain, and a 3.3V reference to measure load currents. The current sense amplifier is biased at 1.65V, which means a load current of 0 amps will result in the current sense amplifier outputting 1.65V. At power on the DMC60 performs a calibration procedure to determine the ADC sample value (smpZeroCurrent) corresponding to no current flow between the M+ and M- terminals. When current flows from the M+ terminal to the M- terminal the current sense amplifier outputs a voltage between 1.65V and 3.3V, which corresponds to positive current flow. When current flows from the M- terminal to the M+ terminal the current sense amplifier outputs a voltage between 1.65V and 0V, corresponding to negative current flow. The DMC60 uses an internal 12-bit ADC to convert this voltage into digitized value every 500 microseconds. The digitized value is then converted into a signed 16.6 fixed point current measurement (in Amps) using the following formula: crntLoad=(smpAdc-smpZeroCurrent)×mplrAdcCurrent. The multiplier (mplrAdcCurrent) that corresponds to a given sense resistance (resCrntSns, in ohms) can be calculated using the following formula: mplrAdcCurrent=(vref/4096×1/(resCrntSns×50))×65536. For example, if the sense resistor has a nominal value of 500 µohms then the mplrAdcCurrent=(3.3/4096×1/(0.0005×50))×65536=2112 or 0x00000840 in hexadecimal. The DMC60 comes pre-programmed with a multiplier that corresponds to the expected sense resistance (approximately 510 µohms) so it should not be necessary to configure the multiplier. However, if current measurements appear to be off then paramAdcCurrentMultiplier can be used to adjust the multiplier used. This parameter is stored in nonvolatile memory and is preserved across power cycles. More... | |
DMC_Code | getADCMultiplier (float *value, int tmsWait) |
Gets the currently stored value for. More... | |
DMC_Code | enterBootloader () |
Sends the DMC60C into bootloader mode. More... | |
Low Level DMC60C Interface.
This class contains all of the low level functions used to communicate with the DMC60C.
DMC60LowLevel | ( | int | value = 0 , |
int | verbose = 0 , |
||
constructortype | type = constructortype::useDeviceNumber |
||
) |
Creates a DMC60LowLevel object.
value | The deviceNumber of the DMC60C Motor. If type == useSessionID, this is the session ID of the device |
verbose | A flag to enable verbose feedback. |
type | If useDeviceNumber, value represents the deviceNumber of the DMC60C to connect to. If useSessionID, value represents the session ID of the DMC60C to connect to. |
DMC_Code setDeviceNumber | ( | uint16_t | newdevnum | ) |
Sets the deviceNumber of the DMC60C.
newdevnum | The desired device number (0-64). |
uint8_t getDeviceNumber | ( | ) |
Gets the deviceNumber of the DMC60C.
DMC_Code setDeviceName | ( | char * | szDevName, |
uint16_t | cbName | ||
) |
Sets the deviceName of the DMC60C.
szDevName | Character pointer to desired name. |
cbName | Byte count of name. |
void getDeviceName | ( | char * | szNameBuf | ) |
Gets the device name of the DMC60C.
szNameBuf | Buffer to store the name in. |
uint16_t getFWVerBoot | ( | ) |
Gets the bootloader firmware of the DMC60C.
uint16_t getFWVerApp | ( | ) |
Gets the application firmware of the DMC60C.
uint8_t getImgType | ( | ) |
Returns the currently running image type (bootloader, application, or aux bootloader).
uint16_t getSessId | ( | ) |
Returns the session ID assigned to the DMC60C.
DMC_Code fetchFWVer | ( | ) |
Retrieves the device's firmware version information. This includes application firmware revision, bootloader firmware revision, and the time of firmware image that is currently running. This information is stored in the private member DMCInfo, and can be read with the get commands.
DMC_Code softReset | ( | ) |
Returns the session ID assigned to the DMC60C.
DMC_Code flashLEDs | ( | ) |
Flashes the LEDs on the DMC60C in a rainbow pattern for 5 seconds.
DMC_Code configPID_RampRate | ( | uint8_t | slot, |
uint32_t | ramp, | ||
int | tmsWait | ||
) |
Configure the closed loop ramp rate used by the specified closed loop profile slot. The closed loop ramp rate specifies the maximum number of throttle units the output can change by each time the control loop executes in closed loop control mode (Velocity, Position, or Current). For example, If the closed loop ramp rate is set to 1000 and the PID update function determines that the throttle should be increased by 5000 units then the immediate throttle increase will be limited to 1000 units. If the next PID Update doesnt change the target throttle output value, the throttle will be increased by another 1000 units the next time the control loop executes. This process will continue until the target throttle is reached or a new throttle value is calculated. The control loop executes once every 500 µs. Therefore, specifying a closed loop ramp rate of 16 would result in it taking approximately 1.02 seconds to go from 0% throttle (0) to 100% throttle (32767). Specifying a value of 0 for the closed loop ramp rate disables throttling and allows the output to be immediately set to the target value. This parameter is stored in nonvolatile memory and is preserved across power cycles.
slot | PID slot to configure. |
ramp | Desired ramp rate. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getPID_RampRate | ( | uint8_t | slot, |
uint32_t * | ramp, | ||
int | tmsWait | ||
) |
Gets the ramp rate value stored in the specified PID slot.
slot | PID slot to configure. |
ramp | Buffer to store ramp rate. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configPID_FwdMaxDuty | ( | uint8_t | slot, |
int | value, | ||
int | tmsWait | ||
) |
Configure the closed loop control maximum forward duty cycle used by the specified motor control profile slot. The maximum forward duty cycle is the largest positive duty cycle that may be applied to the output when motor control profile slot 0 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). The value specified for this parameter should be restricted to be within the range of 0 to 32767. This parameter is stored in nonvolatile memory and is preserved across power cycles.
slot | PID slot to configure. |
value | Max forward duty cycle (0-32767). |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getPID_FwdMaxDuty | ( | uint8_t | slot, |
int * | value, | ||
int | tmsWait | ||
) |
Gets the forward max duty cycle stored in the specified PID slot.
slot | PID slot to read from. |
value | Buffer to store the ramp rate value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configPID_RevMaxDuty | ( | uint8_t | slot, |
int | value, | ||
int | tmsWait | ||
) |
Configure the closed loop control maximum reverse duty cycle used by the specified motor control profile slot. The maximum reverse duty cycle is the largest negative duty cycle that may be applied to the output when motor control profile slot 0 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). The value specified for this parameter should be restricted to be within the range of -32768 to 0. This parameter is stored in nonvolatile memory and is preserved across power cycles.
slot | PID slot to configure. |
value | Max reverse duty cycle (-32768 to 0). |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getPID_RevMaxDuty | ( | uint8_t | slot, |
int * | value, | ||
int | tmsWait | ||
) |
Gets the reverse max duty cycle stored in the specified PID slot.
slot | PID slot to read from. |
value | Buffer to store the ramp rate value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configPID_FwdNominal | ( | uint8_t | slot, |
int | value, | ||
int | tmsWait | ||
) |
Configure the closed loop control nominal forward duty cycle used by the specified motor control profile slot. The nominal forward duty cycle is the smallest positive duty cycle that may be applied to the output when the closed loop error exceeds the allowable closed loop error specified for the selected motor profile slot. The closed loop nominal forward duty cycle is only utilized when the control frame specifies one of the closed loop control modes (Velocity, Position, or Current). The value specified for this parameter should be restricted to be within the range of 0 to 32767. This parameter is stored in nonvolatile memory and is preserved across power cycles.
slot | PID slot to configure. |
value | Closed loop nominal duty cycle (0 to 32767). |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getPID_FwdNominal | ( | uint8_t | slot, |
int * | value, | ||
int | tmsWait | ||
) |
Gets the forward nominal duty cycle stored in the specified PID slot.
slot | PID slot to read from. |
value | Buffer to store the forward nominal duty cycle value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configPID_RevNominal | ( | uint8_t | slot, |
int | value, | ||
int | tmsWait | ||
) |
Configure the closed loop control nominal reverse duty cycle used by the specified motor control profile slot. The nominal reverse duty cycle is the smallest negative duty cycle that may be applied to the output when the closed loop error exceeds the allowable closed loop error specified for the selected motor profile slot. The closed loop nominal reverse duty cycle is only utilized when the control frame specifies one of the closed loop control modes (Velocity, Position, or Current). The value specified for this parameter should be restricted to be within the range of -32768 to 0. This parameter is stored in nonvolatile memory and is preserved across power cycles.
slot | PID slot to configure. |
value | Closed loop nominal duty cycle (-32768 to 0). |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getPID_RevNominal | ( | uint8_t | slot, |
int * | value, | ||
int | tmsWait | ||
) |
Gets the reverse nominal duty cycle stored in the specified PID slot.
slot | PID slot to read from. |
value | Buffer to store the reverse nominal duty cycle value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configPID_kP | ( | uint8_t | slot, |
float | value, | ||
int | tmsWait | ||
) |
Configure the proportional gain constant used by the specified motor control profile slot. This constant is used during closed loop control to calculate a proportional increase or decrease in the throttle (duty cycle) due to the measured closed loop error. This parameter will be utilized for PID calculations when motor control profile slot 1 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). This parameter is stored in nonvolatile memory and is preserved across power cycles.
slot | PID slot to configure. |
value | P gain value to assign. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code get_kP | ( | uint8_t | slot, |
float * | value, | ||
int | tmsWait | ||
) |
Reads the P gain value of the specified slot and stores the value into a pointer.
slot | PID slot to read. |
value | Pointer to store value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configPID_kI | ( | uint8_t | slot, |
float | value, | ||
int | tmsWait | ||
) |
Configure the integral gain constant used by the specified motor control profile slot. This constant is used during closed loop control to calculate an integral increase or decrease in the throttle (duty cycle) due to the measured closed loop error. This parameter will be utilized for PID calculations when motor control profile slot 1 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). This parameter is stored in nonvolatile memory and is preserved across power cycles.
slot | PID slot to configure. |
value | I gain value to assign. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code get_kI | ( | uint8_t | slot, |
float * | value, | ||
int | tmsWait | ||
) |
Reads the I gain value of the specified slot and stores the value into a pointer.
slot | PID slot to read. |
value | Pointer to store value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configPID_kD | ( | uint8_t | slot, |
float | value, | ||
int | tmsWait | ||
) |
Configure the derivative gain constant used by the specified motor control profile slot. This constant is used during closed loop control to calculate the derivative increase or decrease in the throttle (duty cycle) due to the measured closed loop error. This parameter will be utilized for PID calculations when motor control profile slot 1 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). This parameter is stored in nonvolatile memory and is preserved across power cycles.
slot | PID slot to configure. |
value | D gain value to assign. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code get_kD | ( | uint8_t | slot, |
float * | value, | ||
int | tmsWait | ||
) |
Reads the D gain value of the specified slot and stores the value into a pointer.
slot | PID slot to read. |
value | Pointer to store value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configPID_kF | ( | uint8_t | slot, |
float | value, | ||
int | tmsWait | ||
) |
Configure the feed-forward gain constant used by the specified motor control profile slot. This constant is used during closed loop control to calculate the number of throttle units to contribute to the duty cycle as the proportion of the setpoint (target Velocity, Position, or Current) independent of the error. For example, if the target current is 20.0 amps and you want to apply 50% throttle for this setpoint then the feed forward gain would be set to (0.50×32767)/20.0=819.175. Convert this to fixed-point by multiplying by 65536. This results in a value of 0x03332CCC (hex), which is what should be sent to the DMC60 in the value field of the PARAMSET packet. The feed-forward term can be excluded from the PID calculations by specifying a value of 0 for the gain. This parameter will be utilized for PID calculations when motor control profile slot 1 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). This parameter is stored in nonvolatile memory and is preserved across power cycles.
slot | PID slot to configure. |
value | F gain value to assign. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code get_kF | ( | uint8_t | slot, |
float * | value, | ||
int | tmsWait | ||
) |
Reads the F gain value of the specified slot and stores the value into a pointer.
slot | PID slot to read. |
value | Pointer to store value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configPID_IZone | ( | uint8_t | slot, |
unsigned int | value, | ||
int | tmsWait | ||
) |
Configure the integral accumulator limit used by motor control profile slot 0. The integral accumulator limit, or I-zone, is used to limit how large the integral accumulator can grow during closed loop control. The value sent to the DMC60 is converted to a 32-bit signed integer and used to set the positive and negative bounds of the integral accumulator. If the integral accumulator exceeds these bounds while PID calculations are performed, then the accumulator will be capped to value or -value. This provides a mechanism for combating integral windup. Setting a value of 0 will disable the limit and allow the integral accumulator to grow without bounds. This parameter is stored in nonvolatile memory and is preserved across power cycles.
slot | PID slot to configure. |
value | Izone value to assign. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code get_IZone | ( | uint8_t | slot, |
unsigned int * | value, | ||
int | tmsWait | ||
) |
Gets the current Izone value stored in the specified PID slot.
slot | PID slot to configure. |
value | Buffer to store Izone value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configPID_AllowableError | ( | uint8_t | slot, |
uint32_t | value, | ||
int | tmsWait | ||
) |
Configure the allowable closed loop error used by the specified motor control profile slot. The allowable closed loop error specifies the minimum error required for the PID controller to calculate a non-zero contribution to the output throttle (duty cycle) based on the P, I, and D terms. If the allowable error is set to a non-zero value and the measured error is less than the allowable error then the P, I, and D terms will contribute 0 throttle units to the output throttle calculation and the integral accumulator will be cleared. If the allowable error is set to 0 or the measured error exceeds the allowable error then P, I, and D terms are included in the output throttle calculation. The feed-forward gain constant, or F term, is included in the output throttle calculation regardless of the allowable error setting. This parameter will be utilized for PID calculations when motor control profile slot 1 is specified in a control frame that specifies one of the closed loop control modes (Velocity, Position, or Current). This parameter is stored in nonvolatile memory and is preserved across power cycles.
slot | PID slot to configure. |
value | Allowable closed loop error. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getPID_AllowableError | ( | uint8_t | slot, |
uint32_t * | value, | ||
int | tmsWait | ||
) |
Gets the allowable error value stored in the specified PID slot.
slot | PID slot to configure. |
value | Buffer to store the allowable error value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configForwardLimitSwitchEnable | ( | bool | enable, |
int | tmsWait | ||
) |
Sets whether or not the forward limit switch is enabled or not.
enable | True if enabled, false if not. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getForwardLimitSwitchEnable | ( | bool * | enable, |
int | tmsWait | ||
) |
Gets whether or not the forward limit switch is enabled or not.
enable | Pointer to store the enabled value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configForwardLimitSwitchType | ( | bool | normallyClosed, |
int | tmsWait | ||
) |
Sets the switch type of the forward limit switch.
normallyClosed | False if the switch is normally opened, true if normally closed. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getForwardLimitSwitchType | ( | bool * | normallyClosed, |
int | tmsWait | ||
) |
Gets the switch type of the forward limit switch.
normallyClosed | Pointer to store the switch type value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configReverseLimitSwitchEnable | ( | bool | enable, |
int | tmsWait | ||
) |
Sets whether or not the reverse limit switch is enabled or not.
enable | True if enabled, false if not. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getReverseLimitSwitchEnable | ( | bool * | enable, |
int | tmsWait | ||
) |
Gets whether or not the reverse limit switch is enabled or not.
enable | Pointer to store the enabled value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configReverseLimitSwitchType | ( | bool | normallyClosed, |
int | tmsWait | ||
) |
Sets the switch type of the reverse limit switch.
normallyClosed | False if the switch is normally opened, true if normally closed. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getReverseLimitSwitchType | ( | bool * | normallyClosed, |
int | tmsWait | ||
) |
Gets the switch type of the reverse limit switch.
normallyClosed | Pointer to store the switch type value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configSoftFwdThreshold | ( | bool | enable, |
int | limit, | ||
int | tmsWait | ||
) |
Configure the soft forward limit threshold. The soft forward limit threshold specifies the maximum position that the encoder can read in the forward direction. The units are native to the encoder thats connected to the expansion header. The DMC60s control loop runs every 500us. Each time it executes the current position of the encoder is read and compared to the soft forward limit threshold. If the encoders current position is greater than or equal to the specified soft forward limit threshold and the soft forward limit is enabled, then the DMC60s output will be prevented from applying a positive voltage to the load. Both positive and negative soft limit thresholds are valid. This parameter is stored in nonvolatile memory and is preserved across power cycles.
enable | Enables or disables the forward soft limit. |
limit | Soft forward limit threshold. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getSoftFwdThreshold | ( | bool * | enable, |
int * | limit, | ||
int | tmsWait | ||
) |
Gets the current soft forward threshold value.
enable | Buffer to store the enabled bit. |
limit | Buffer to store the limit value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configSoftRevThreshold | ( | bool | enable, |
int | limit, | ||
int | tmsWait | ||
) |
Configure the reverse limit switch type. The reverse limit switch be configured as a normally closed switch by setting the value field to a 1 or a normally open switch by setting the value field to a 0. The DMC60 uses internal (weak) pull-ups to pull the reverse limit switch pin to 3.3V. When configured as a normally closed switch the DMC60 will prevent the output from applying a negative voltage to the load when the limit switch opens, causing the DMC60 to detect a logic 1 on the REVLIM pin. When configured as a normally open switch the DMC60 will prevent the output from applying a negative voltage to the load when the limit switch closes, causing the DMC60 to detect a logic 0 on the REVLIM pin. This parameter is stored in nonvolatile memory and is preserved across power cycles.
enable | Enables or disables the reverse soft limit. |
limit | Soft reverse limit threshold. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getSoftRevThreshold | ( | bool * | enable, |
int * | limit, | ||
int | tmsWait | ||
) |
Gets the current soft reverse threshold value.
enable | Buffer to store the enabled bit. |
limit | Buffer to store the limit value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configAnalogStatusFramePeriod | ( | uint32_t | periodMs, |
int | tmsWait | ||
) |
Configure the rate at which the DMC60 transmits Analog Input, Current, Temperature, and Battery Voltage Status Frames. These status frames are formatted as STSANALOG packets and are described in the Periodic Status Messages section. The frame rate can be set to any value between 1 millisecond and 30000 milliseconds. Power cycling the DMC60 will result in the device reverting to the default frame rate, which is 100 milliseconds.
periodMs | Frame period in milliseconds. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getAnalogStatusFramePeriod | ( | uint32_t * | periodMs, |
int | tmsWait | ||
) |
Gets the current analog status frame period.
periodMs | Buffer to store the period. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configEncoderStatusFramePeriod | ( | uint32_t | periodMs, |
int | tmsWait | ||
) |
Configure the rate at which the DMC60 transmits Quadrature Encoder Status Frames. These status frames are formatted as STSENCODER packets and are described in the Periodic Status Messages section. The frame rate can be set to any value between 1 millisecond and 30000 milliseconds. Power cycling the DMC60 will result in the device reverting to the default frame rate, which is 100 milliseconds.
periodMs | Frame period in milliseconds. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getEncoderStatusFramePeriod | ( | uint32_t * | periodMs, |
int | tmsWait | ||
) |
Get the current encoder status frame period.
periodMs | Buffer to store the period. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code configGeneralStatusFramePeriod | ( | uint32_t | periodMs, |
int | tmsWait | ||
) |
Configure the rate at which the DMC60 transmits General Status Frames. These status frames are formatted as STSGENERAL packets and are described in the Periodic Status Messages section. The frame rate can be set to any value between 1 millisecond and 30000 milliseconds. Power cycling the DMC60 will result in the device reverting to the default frame rate, which is 10 milliseconds.
periodMs | Frame period in milliseconds. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getGeneralStatusFramePeriod | ( | uint32_t * | periodMs, |
int | tmsWait | ||
) |
Get the current general status frame period.
periodMs | Buffer to store the period. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code setEncoderPosition | ( | int | position, |
int | tmsWait | ||
) |
Configure the encoder position. The encoder position is maintained by the QEI module of the DMC60s MCU and is continuously updated by the pulse train applied to QEA and QEB inputs of the expansion header. At power on the encoders position is initialized to zero. This may not correspond with the zero point thats defined in the end user application, and as such, it may be necessary to set the encoder to a specific position or reset it to 0 after performing a homing sequence. The encoders position is used for closed loop position control and for determining whether the forward soft limit or reverse soft limit have been hit. The encoder position should only be configured while the DMC60s output is disabled.
position | 32 bit signed encoder position. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getEncoderPosition | ( | int * | position, |
int | tmsWait | ||
) |
Configure the encoder position. The encoder position is maintained by the QEI module of the DMC60s MCU and is continuously updated by the pulse train applied to QEA and QEB inputs of the expansion header. At power on the encoders position is initialized to zero. This may not correspond with the zero point thats defined in the end user application, and as such, it may be necessary to set the encoder to a specific position or reset it to 0 after performing a homing sequence. The encoders position is used for closed loop position control and for determining whether the forward soft limit or reverse soft limit have been hit. The encoder position should only be configured while the DMC60s output is disabled.
*position | Integer to store position. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code setClearPositionOnIndex | ( | bool | enable, |
int | tmsWait | ||
) |
Sets whether or not the index pin will cause the position count to reset.
enable | True to enable position count reset on active edge of index. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getClearPositionOnIndex | ( | bool * | enable, |
int | tmsWait | ||
) |
Gets whether or not the index pin will cause the position count to reset.
enable | Buffer to store the result. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code setClearPositionOnFwdLimit | ( | bool | enable, |
int | tmsWait | ||
) |
Sets whether or not the forward limit switch pin will cause the position count to reset.
enable | True to enable position count reset on active edge of fwd limit switch. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getClearPositionOnFwdLimit | ( | bool * | enable, |
int | tmsWait | ||
) |
Gets whether or not the fwd limit switch pin will cause the position count to reset.
enable | Buffer to store the result. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code setClearPositionOnRevLimit | ( | bool | enable, |
int | tmsWait | ||
) |
Sets whether or not the reverse limit switch pin will cause the position count to reset.
enable | True to enable position count reset on active edge of rev limit switch. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getClearPositionOnRevLimit | ( | bool * | enable, |
int | tmsWait | ||
) |
Gets whether or not the reverse limit switch pin will cause the position count to reset.
enable | Buffer to store the result. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code setIndexActiveEdge | ( | bool | edge, |
int | tmsWait | ||
) |
Sets the active edge of the index pin.
edge | True for rising edge, false for falling edge. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getIndexActiveEdge | ( | bool * | edge, |
int | tmsWait | ||
) |
Gets the active edge of the index pin.
edge | Buffer to store the result. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code resetStickyFaults | ( | int | tmsWait | ) |
Resets the counts stored in the sticky faults.
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code resetOverTempStickyFaults | ( | int | tmsWait | ) |
Resets the overtemp sticky fault count.
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code resetOverCurrentStickyFaults | ( | int | tmsWait | ) |
Resets the overcurrent sticky fault count.
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code resetUnderVoltageStickyFaults | ( | int | tmsWait | ) |
Resets the undervoltage sticky fault count.
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code resetGateDriverStickyFaults | ( | int | tmsWait | ) |
Resets the gate driver sticky fault count.
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code resetCommStickyFaults | ( | int | tmsWait | ) |
Resets the comm sticky fault count.
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getActiveFaults | ( | uint32_t * | value, |
int | tmsWait | ||
) |
Retrieves the active fault bit field from the motor controller.
value | Buffer to store the active faults into. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getStickyFaults | ( | uint32_t * | value, |
int | tmsWait | ||
) |
Retrieves the sticky fault bit field from the motor controller.
value | Buffer to store the sticky faults into. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getOverTempStickyFaultCount | ( | uint32_t * | value, |
int | tmsWait | ||
) |
Retrieves the number of over temp sticky faults.
value | Buffer to store the number into. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getOverCurrentStickyFaultCount | ( | uint32_t * | value, |
int | tmsWait | ||
) |
Retrieves the number of over current sticky faults.
value | Buffer to store the number into. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getUnderVoltageStickyFaultCount | ( | uint32_t * | value, |
int | tmsWait | ||
) |
Retrieves the number of under voltage sticky faults.
value | Buffer to store the number into. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getGateDriverStickyFaultCount | ( | uint32_t * | value, |
int | tmsWait | ||
) |
Retrieves the number of gate driver sticky faults.
value | Buffer to store the number into. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getCommStickyFaultCount | ( | uint32_t * | value, |
int | tmsWait | ||
) |
Retrieves the number of comm sticky faults.
value | Buffer to store the number into. |
tmsWait | Max time in milliseconds to wait for a response. |
void setOverrideBC | ( | bool | enable, |
bool | brakecoast | ||
) |
Sets the brake/coast mode override.
enable | Enable the override. |
brakecoast | 0: Coast when neutral throttle is applied 1: Brake when neutral throttle is applied. |
void setReverse | ( | bool | reverse | ) |
Sets the reverse bit in control0 frame. This causes the motor controller to reverse drive of the motor.
reverse | true = Reversed, false = Not reversed. |
void setLimitSwitchOverride | ( | bool | enable, |
bool | forwardSwitchEnable, | ||
bool | reverseSwitchEnable | ||
) |
Sets the override bits in the control frame. This overrides the limit switch parameters to allow enabling and disabling the limit switches realtime,.
enable | Enables the override. |
forwardSwitchEnable | True = Enable forward limit switch when override is enabled. False = Disable forward limit switch when override is enabled. |
reverseSwitchEnable | True = Enable reverse limit switch when override is enabled. False = Disable reverse limit switch when override is enabled. |
void setReverseFeedbackSensor | ( | bool | reverse | ) |
Sets the reverse bit in control0 frame. This causes the motor controller to reverse drive of the motor.
reverse | true = Reversed, false = Not reversed. |
void setRampRate | ( | unsigned short | rampRate | ) |
Sets the open loop ramp rate that is sent within each control0 frame.
rampRate | The open loop ramp rate. The lower it is, the slower it will ramp. |
void sendControl | ( | ControlMode | Mode, |
double | trgt | ||
) |
Sends the control0 frame with the specified parameters at a specified period. This is the main control of the DMC60C. This frame must be sent every 104ms or the DMC60C will go into standby mode.
Mode | The control mode. |
trgt | The target setpoint of the specified control mode. |
void sendControl | ( | ControlMode | Mode, |
double | trgt, | ||
uint16_t | ramp, | ||
uint32_t | periodMs | ||
) |
Sends the control0 frame with the specified parameters at a specified period. This is the main control of the DMC60C. This frame must be sent every 104ms or the DMC60C will go into standby mode.
Mode | The control mode. |
trgt | The target setpoint of the specified control mode. |
ramp | The open loop ramp rate (not applicable in closed loop mode). |
periodMs | The period to send the control0 frame at. |
DMC_Code getAnalogStatus | ( | STSANALOG * | stsAnalogOut | ) |
Retrieves the latest STSANALOG frame from the DMC60C.
stsAnalogOut | Pointer to STSANALOG buffer to store data into. |
DMC_Code getEncoderStatus | ( | STSENCODER * | stsEncoderOut | ) |
Retrieves the latest STSENCODER frame from the DMC60C.
stsEncoderOut | Pointer to STSENCODER buffer to store data into. |
DMC_Code getGeneralStatus | ( | STSGENERAL * | stsGeneralOut | ) |
Retrieves the latest STSGENERAL frame from the DMC60C.
stsGeneralOut | Pointer to STSGENERAL buffer to store data into. |
void SetControlMode | ( | ControlMode | Mode | ) |
Sets the ControlMode in the control0 frame. The frame must be resent with sendControl() to have any effect, although this is not recommended in most cases.
Mode | Control mode to set to. |
ControlMode GetControlMode | ( | ) | const |
Returns the current controlMode in the control0 frame.
DMC_Code setContinuousCurrentLimit | ( | double | currentAmps | ) |
Sets the continuous current limit. This applies only if current limiting is enabled. The continuous current limit is the maximum current that can be drawn by the DMC60C AFTER the peak current limit has been hit for the peak current duration. If the continuous current limit is greater than or equal to the peak current limit, then the DMC60C will begin limiting the current immediately after the continuous current limit is exceeded.
currentAmps | The continuous current limit to set in amps. |
DMC_Code getContinuousCurrentLimit | ( | double * | currentAmps | ) |
Gets the continuous current limit.
currentAmps | Buffer to store the value. |
DMC_Code setPeakCurrentLimit | ( | double | currentAmps | ) |
Sets the peak current limit. This only applies if current limiting is enabled. The peak current is the max current that can be applied to the motor at any given time. This limit can be applied for up to [peak current duration] milliseconds. Afterwards the continuous current limit will be applied. If the peak current limit is set to a value lower than the continuous current limit, the DMC60C will apply the continuous current limit immediately after it detects that the continuous current limit has been exceeded.
currentAmps | The peak current limit to set in amps. |
DMC_Code getPeakCurrentLimit | ( | double * | currentAmps | ) |
Gets the peak current limit.
currentAmps | Buffer to store the value. |
DMC_Code setPeakCurrentDuration | ( | int | durationMs | ) |
Sets the peak current duration. This only applies if current limiting is enabled. The peak current duration is the maximum amount of time the peak current can be applied to the motor. After this duration, the continuous current limit will be applied. If the duration is set to 0, the DMC60C will begin applying the continuous current limit immediately after the peak current limit has been exceeded.
durationMs | The peak current duration in milliseconds. |
DMC_Code getPeakCurrentDuration | ( | int * | durationMs | ) |
Gets the peak current duration.
durationMs | Buffer to store the value. |
DMC_Code enableCurrentLimit | ( | bool | enabled | ) |
Enables or disables current limiting mode.
enabled | If true, enabled current limiting. If false, disables current limiting. |
DMC_Code isCurrentLimitEnabled | ( | bool * | enabled | ) |
Returns whether or not the current limit is enabled.
enabled | Buffer to store the result. |
DMC_Code setADCMultiplier | ( | float | value, |
int | tmsWait | ||
) |
Configure the constant used by the DMC60 to convert ADC measurements into an associated load current in amps. The DMC60 uses a combination of a current sense resistor, bidirectional current sense amplifier with a 50V/V gain, and a 3.3V reference to measure load currents. The current sense amplifier is biased at 1.65V, which means a load current of 0 amps will result in the current sense amplifier outputting 1.65V. At power on the DMC60 performs a calibration procedure to determine the ADC sample value (smpZeroCurrent) corresponding to no current flow between the M+ and M- terminals. When current flows from the M+ terminal to the M- terminal the current sense amplifier outputs a voltage between 1.65V and 3.3V, which corresponds to positive current flow. When current flows from the M- terminal to the M+ terminal the current sense amplifier outputs a voltage between 1.65V and 0V, corresponding to negative current flow. The DMC60 uses an internal 12-bit ADC to convert this voltage into digitized value every 500 microseconds. The digitized value is then converted into a signed 16.6 fixed point current measurement (in Amps) using the following formula: crntLoad=(smpAdc-smpZeroCurrent)×mplrAdcCurrent. The multiplier (mplrAdcCurrent) that corresponds to a given sense resistance (resCrntSns, in ohms) can be calculated using the following formula: mplrAdcCurrent=(vref/4096×1/(resCrntSns×50))×65536. For example, if the sense resistor has a nominal value of 500 µohms then the mplrAdcCurrent=(3.3/4096×1/(0.0005×50))×65536=2112 or 0x00000840 in hexadecimal. The DMC60 comes pre-programmed with a multiplier that corresponds to the expected sense resistance (approximately 510 µohms) so it should not be necessary to configure the multiplier. However, if current measurements appear to be off then paramAdcCurrentMultiplier can be used to adjust the multiplier used. This parameter is stored in nonvolatile memory and is preserved across power cycles.
value | Signed 16.16 value to set the ADC Multiplier to |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code getADCMultiplier | ( | float * | value, |
int | tmsWait | ||
) |
Gets the currently stored value for.
value | Buffer to store the value. |
tmsWait | Max time in milliseconds to wait for a response. |
DMC_Code enterBootloader | ( | ) |
Sends the DMC60C into bootloader mode.