DMC60C API
This is the C/C++ API for the DMC60C.
DMC60LowLevel Class Reference

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 doesn’t 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 that’s connected to the expansion header. The DMC60’s 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 encoder’s current position is greater than or equal to the specified soft forward limit threshold and the soft forward limit is enabled, then the DMC60’s 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 DMC60’s MCU and is continuously updated by the pulse train applied to QEA and QEB inputs of the expansion header. At power on the encoder’s position is initialized to zero. This may not correspond with the zero point that’s 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 encoder’s 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 DMC60’s 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 DMC60’s MCU and is continuously updated by the pulse train applied to QEA and QEB inputs of the expansion header. At power on the encoder’s position is initialized to zero. This may not correspond with the zero point that’s 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 encoder’s 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 DMC60’s 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...
 

Detailed Description

Low Level DMC60C Interface.

This class contains all of the low level functions used to communicate with the DMC60C.

Constructor & Destructor Documentation

◆ DMC60LowLevel()

DMC60LowLevel ( int  value = 0,
int  verbose = 0,
constructortype  type = constructortype::useDeviceNumber 
)

Creates a DMC60LowLevel object.

Parameters
valueThe deviceNumber of the DMC60C Motor. If type == useSessionID, this is the session ID of the device
verboseA flag to enable verbose feedback.
typeIf useDeviceNumber, value represents the deviceNumber of the DMC60C to connect to. If useSessionID, value represents the session ID of the DMC60C to connect to.

Member Function Documentation

◆ setDeviceNumber()

DMC_Code setDeviceNumber ( uint16_t  newdevnum)

Sets the deviceNumber of the DMC60C.

Parameters
newdevnumThe desired device number (0-64).
Returns
DMC_Code Status code.

◆ getDeviceNumber()

uint8_t getDeviceNumber ( )

Gets the deviceNumber of the DMC60C.

Returns
Device number of DMC60C.

◆ setDeviceName()

DMC_Code setDeviceName ( char *  szDevName,
uint16_t  cbName 
)

Sets the deviceName of the DMC60C.

Parameters
szDevNameCharacter pointer to desired name.
cbNameByte count of name.
Returns
Status code.

◆ getDeviceName()

void getDeviceName ( char *  szNameBuf)

Gets the device name of the DMC60C.

Parameters
szNameBufBuffer to store the name in.

◆ getFWVerBoot()

uint16_t getFWVerBoot ( )

Gets the bootloader firmware of the DMC60C.

Returns
Firmware version of bootloader.

◆ getFWVerApp()

uint16_t getFWVerApp ( )

Gets the application firmware of the DMC60C.

Returns
Firmware version of application.

◆ getImgType()

uint8_t getImgType ( )

Returns the currently running image type (bootloader, application, or aux bootloader).

Returns
0 = App, 1 = Bootloader, 2 = Aux Bootloader.

◆ getSessId()

uint16_t getSessId ( )

Returns the session ID assigned to the DMC60C.

Returns
Session ID.

◆ fetchFWVer()

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.

Returns
Firmware version of application.

◆ softReset()

DMC_Code softReset ( )

Returns the session ID assigned to the DMC60C.

Returns
Status Code.

◆ flashLEDs()

DMC_Code flashLEDs ( )

Flashes the LEDs on the DMC60C in a rainbow pattern for 5 seconds.

Returns
Status Code.

◆ configPID_RampRate()

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 doesn’t 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.

Parameters
slotPID slot to configure.
rampDesired ramp rate.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getPID_RampRate()

DMC_Code getPID_RampRate ( uint8_t  slot,
uint32_t *  ramp,
int  tmsWait 
)

Gets the ramp rate value stored in the specified PID slot.

Parameters
slotPID slot to configure.
rampBuffer to store ramp rate.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configPID_FwdMaxDuty()

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.

Parameters
slotPID slot to configure.
valueMax forward duty cycle (0-32767).
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getPID_FwdMaxDuty()

DMC_Code getPID_FwdMaxDuty ( uint8_t  slot,
int *  value,
int  tmsWait 
)

Gets the forward max duty cycle stored in the specified PID slot.

Parameters
slotPID slot to read from.
valueBuffer to store the ramp rate value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configPID_RevMaxDuty()

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.

Parameters
slotPID slot to configure.
valueMax reverse duty cycle (-32768 to 0).
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getPID_RevMaxDuty()

DMC_Code getPID_RevMaxDuty ( uint8_t  slot,
int *  value,
int  tmsWait 
)

Gets the reverse max duty cycle stored in the specified PID slot.

Parameters
slotPID slot to read from.
valueBuffer to store the ramp rate value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configPID_FwdNominal()

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.

Parameters
slotPID slot to configure.
valueClosed loop nominal duty cycle (0 to 32767).
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getPID_FwdNominal()

DMC_Code getPID_FwdNominal ( uint8_t  slot,
int *  value,
int  tmsWait 
)

Gets the forward nominal duty cycle stored in the specified PID slot.

Parameters
slotPID slot to read from.
valueBuffer to store the forward nominal duty cycle value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configPID_RevNominal()

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.

Parameters
slotPID slot to configure.
valueClosed loop nominal duty cycle (-32768 to 0).
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getPID_RevNominal()

DMC_Code getPID_RevNominal ( uint8_t  slot,
int *  value,
int  tmsWait 
)

Gets the reverse nominal duty cycle stored in the specified PID slot.

Parameters
slotPID slot to read from.
valueBuffer to store the reverse nominal duty cycle value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configPID_kP()

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.

Parameters
slotPID slot to configure.
valueP gain value to assign.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ get_kP()

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.

Parameters
slotPID slot to read.
valuePointer to store value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configPID_kI()

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.

Parameters
slotPID slot to configure.
valueI gain value to assign.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ get_kI()

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.

Parameters
slotPID slot to read.
valuePointer to store value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configPID_kD()

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.

Parameters
slotPID slot to configure.
valueD gain value to assign.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ get_kD()

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.

Parameters
slotPID slot to read.
valuePointer to store value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configPID_kF()

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.

Parameters
slotPID slot to configure.
valueF gain value to assign.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ get_kF()

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.

Parameters
slotPID slot to read.
valuePointer to store value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configPID_IZone()

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.

Parameters
slotPID slot to configure.
valueIzone value to assign.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ get_IZone()

DMC_Code get_IZone ( uint8_t  slot,
unsigned int *  value,
int  tmsWait 
)

Gets the current Izone value stored in the specified PID slot.

Parameters
slotPID slot to configure.
valueBuffer to store Izone value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configPID_AllowableError()

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.

Parameters
slotPID slot to configure.
valueAllowable closed loop error.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getPID_AllowableError()

DMC_Code getPID_AllowableError ( uint8_t  slot,
uint32_t *  value,
int  tmsWait 
)

Gets the allowable error value stored in the specified PID slot.

Parameters
slotPID slot to configure.
valueBuffer to store the allowable error value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configForwardLimitSwitchEnable()

DMC_Code configForwardLimitSwitchEnable ( bool  enable,
int  tmsWait 
)

Sets whether or not the forward limit switch is enabled or not.

Parameters
enableTrue if enabled, false if not.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getForwardLimitSwitchEnable()

DMC_Code getForwardLimitSwitchEnable ( bool *  enable,
int  tmsWait 
)

Gets whether or not the forward limit switch is enabled or not.

Parameters
enablePointer to store the enabled value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configForwardLimitSwitchType()

DMC_Code configForwardLimitSwitchType ( bool  normallyClosed,
int  tmsWait 
)

Sets the switch type of the forward limit switch.

Parameters
normallyClosedFalse if the switch is normally opened, true if normally closed.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getForwardLimitSwitchType()

DMC_Code getForwardLimitSwitchType ( bool *  normallyClosed,
int  tmsWait 
)

Gets the switch type of the forward limit switch.

Parameters
normallyClosedPointer to store the switch type value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configReverseLimitSwitchEnable()

DMC_Code configReverseLimitSwitchEnable ( bool  enable,
int  tmsWait 
)

Sets whether or not the reverse limit switch is enabled or not.

Parameters
enableTrue if enabled, false if not.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getReverseLimitSwitchEnable()

DMC_Code getReverseLimitSwitchEnable ( bool *  enable,
int  tmsWait 
)

Gets whether or not the reverse limit switch is enabled or not.

Parameters
enablePointer to store the enabled value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configReverseLimitSwitchType()

DMC_Code configReverseLimitSwitchType ( bool  normallyClosed,
int  tmsWait 
)

Sets the switch type of the reverse limit switch.

Parameters
normallyClosedFalse if the switch is normally opened, true if normally closed.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getReverseLimitSwitchType()

DMC_Code getReverseLimitSwitchType ( bool *  normallyClosed,
int  tmsWait 
)

Gets the switch type of the reverse limit switch.

Parameters
normallyClosedPointer to store the switch type value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configSoftFwdThreshold()

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 that’s connected to the expansion header. The DMC60’s 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 encoder’s current position is greater than or equal to the specified soft forward limit threshold and the soft forward limit is enabled, then the DMC60’s 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.

Parameters
enableEnables or disables the forward soft limit.
limitSoft forward limit threshold.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getSoftFwdThreshold()

DMC_Code getSoftFwdThreshold ( bool *  enable,
int *  limit,
int  tmsWait 
)

Gets the current soft forward threshold value.

Parameters
enableBuffer to store the enabled bit.
limitBuffer to store the limit value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configSoftRevThreshold()

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.

Parameters
enableEnables or disables the reverse soft limit.
limitSoft reverse limit threshold.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getSoftRevThreshold()

DMC_Code getSoftRevThreshold ( bool *  enable,
int *  limit,
int  tmsWait 
)

Gets the current soft reverse threshold value.

Parameters
enableBuffer to store the enabled bit.
limitBuffer to store the limit value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configAnalogStatusFramePeriod()

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.

Parameters
periodMsFrame period in milliseconds.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getAnalogStatusFramePeriod()

DMC_Code getAnalogStatusFramePeriod ( uint32_t *  periodMs,
int  tmsWait 
)

Gets the current analog status frame period.

Parameters
periodMsBuffer to store the period.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configEncoderStatusFramePeriod()

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.

Parameters
periodMsFrame period in milliseconds.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getEncoderStatusFramePeriod()

DMC_Code getEncoderStatusFramePeriod ( uint32_t *  periodMs,
int  tmsWait 
)

Get the current encoder status frame period.

Parameters
periodMsBuffer to store the period.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ configGeneralStatusFramePeriod()

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.

Parameters
periodMsFrame period in milliseconds.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getGeneralStatusFramePeriod()

DMC_Code getGeneralStatusFramePeriod ( uint32_t *  periodMs,
int  tmsWait 
)

Get the current general status frame period.

Parameters
periodMsBuffer to store the period.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ setEncoderPosition()

DMC_Code setEncoderPosition ( int  position,
int  tmsWait 
)

Configure the encoder position. The encoder position is maintained by the QEI module of the DMC60’s MCU and is continuously updated by the pulse train applied to QEA and QEB inputs of the expansion header. At power on the encoder’s position is initialized to zero. This may not correspond with the zero point that’s 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 encoder’s 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 DMC60’s output is disabled.

Parameters
position32 bit signed encoder position.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getEncoderPosition()

DMC_Code getEncoderPosition ( int *  position,
int  tmsWait 
)

Configure the encoder position. The encoder position is maintained by the QEI module of the DMC60’s MCU and is continuously updated by the pulse train applied to QEA and QEB inputs of the expansion header. At power on the encoder’s position is initialized to zero. This may not correspond with the zero point that’s 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 encoder’s 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 DMC60’s output is disabled.

Parameters
*positionInteger to store position.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ setClearPositionOnIndex()

DMC_Code setClearPositionOnIndex ( bool  enable,
int  tmsWait 
)

Sets whether or not the index pin will cause the position count to reset.

Parameters
enableTrue to enable position count reset on active edge of index.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getClearPositionOnIndex()

DMC_Code getClearPositionOnIndex ( bool *  enable,
int  tmsWait 
)

Gets whether or not the index pin will cause the position count to reset.

Parameters
enableBuffer to store the result.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ setClearPositionOnFwdLimit()

DMC_Code setClearPositionOnFwdLimit ( bool  enable,
int  tmsWait 
)

Sets whether or not the forward limit switch pin will cause the position count to reset.

Parameters
enableTrue to enable position count reset on active edge of fwd limit switch.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getClearPositionOnFwdLimit()

DMC_Code getClearPositionOnFwdLimit ( bool *  enable,
int  tmsWait 
)

Gets whether or not the fwd limit switch pin will cause the position count to reset.

Parameters
enableBuffer to store the result.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ setClearPositionOnRevLimit()

DMC_Code setClearPositionOnRevLimit ( bool  enable,
int  tmsWait 
)

Sets whether or not the reverse limit switch pin will cause the position count to reset.

Parameters
enableTrue to enable position count reset on active edge of rev limit switch.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getClearPositionOnRevLimit()

DMC_Code getClearPositionOnRevLimit ( bool *  enable,
int  tmsWait 
)

Gets whether or not the reverse limit switch pin will cause the position count to reset.

Parameters
enableBuffer to store the result.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ setIndexActiveEdge()

DMC_Code setIndexActiveEdge ( bool  edge,
int  tmsWait 
)

Sets the active edge of the index pin.

Parameters
edgeTrue for rising edge, false for falling edge.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getIndexActiveEdge()

DMC_Code getIndexActiveEdge ( bool *  edge,
int  tmsWait 
)

Gets the active edge of the index pin.

Parameters
edgeBuffer to store the result.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ resetStickyFaults()

DMC_Code resetStickyFaults ( int  tmsWait)

Resets the counts stored in the sticky faults.

Parameters
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ resetOverTempStickyFaults()

DMC_Code resetOverTempStickyFaults ( int  tmsWait)

Resets the overtemp sticky fault count.

Parameters
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ resetOverCurrentStickyFaults()

DMC_Code resetOverCurrentStickyFaults ( int  tmsWait)

Resets the overcurrent sticky fault count.

Parameters
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ resetUnderVoltageStickyFaults()

DMC_Code resetUnderVoltageStickyFaults ( int  tmsWait)

Resets the undervoltage sticky fault count.

Parameters
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ resetGateDriverStickyFaults()

DMC_Code resetGateDriverStickyFaults ( int  tmsWait)

Resets the gate driver sticky fault count.

Parameters
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ resetCommStickyFaults()

DMC_Code resetCommStickyFaults ( int  tmsWait)

Resets the comm sticky fault count.

Parameters
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getActiveFaults()

DMC_Code getActiveFaults ( uint32_t *  value,
int  tmsWait 
)

Retrieves the active fault bit field from the motor controller.

Parameters
valueBuffer to store the active faults into.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getStickyFaults()

DMC_Code getStickyFaults ( uint32_t *  value,
int  tmsWait 
)

Retrieves the sticky fault bit field from the motor controller.

Parameters
valueBuffer to store the sticky faults into.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getOverTempStickyFaultCount()

DMC_Code getOverTempStickyFaultCount ( uint32_t *  value,
int  tmsWait 
)

Retrieves the number of over temp sticky faults.

Parameters
valueBuffer to store the number into.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getOverCurrentStickyFaultCount()

DMC_Code getOverCurrentStickyFaultCount ( uint32_t *  value,
int  tmsWait 
)

Retrieves the number of over current sticky faults.

Parameters
valueBuffer to store the number into.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getUnderVoltageStickyFaultCount()

DMC_Code getUnderVoltageStickyFaultCount ( uint32_t *  value,
int  tmsWait 
)

Retrieves the number of under voltage sticky faults.

Parameters
valueBuffer to store the number into.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getGateDriverStickyFaultCount()

DMC_Code getGateDriverStickyFaultCount ( uint32_t *  value,
int  tmsWait 
)

Retrieves the number of gate driver sticky faults.

Parameters
valueBuffer to store the number into.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getCommStickyFaultCount()

DMC_Code getCommStickyFaultCount ( uint32_t *  value,
int  tmsWait 
)

Retrieves the number of comm sticky faults.

Parameters
valueBuffer to store the number into.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ setOverrideBC()

void setOverrideBC ( bool  enable,
bool  brakecoast 
)

Sets the brake/coast mode override.

Parameters
enableEnable the override.
brakecoast0: Coast when neutral throttle is applied 1: Brake when neutral throttle is applied.

◆ setReverse()

void setReverse ( bool  reverse)

Sets the reverse bit in control0 frame. This causes the motor controller to reverse drive of the motor.

Parameters
reversetrue = Reversed, false = Not reversed.

◆ setLimitSwitchOverride()

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,.

Parameters
enableEnables the override.
forwardSwitchEnableTrue = Enable forward limit switch when override is enabled. False = Disable forward limit switch when override is enabled.
reverseSwitchEnableTrue = Enable reverse limit switch when override is enabled. False = Disable reverse limit switch when override is enabled.

◆ setReverseFeedbackSensor()

void setReverseFeedbackSensor ( bool  reverse)

Sets the reverse bit in control0 frame. This causes the motor controller to reverse drive of the motor.

Parameters
reversetrue = Reversed, false = Not reversed.

◆ setRampRate()

void setRampRate ( unsigned short  rampRate)

Sets the open loop ramp rate that is sent within each control0 frame.

Parameters
rampRateThe open loop ramp rate. The lower it is, the slower it will ramp.

◆ sendControl() [1/2]

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.

Parameters
ModeThe control mode.
trgtThe target setpoint of the specified control mode.

◆ sendControl() [2/2]

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.

Parameters
ModeThe control mode.
trgtThe target setpoint of the specified control mode.
rampThe open loop ramp rate (not applicable in closed loop mode).
periodMsThe period to send the control0 frame at.

◆ getAnalogStatus()

DMC_Code getAnalogStatus ( STSANALOG *  stsAnalogOut)

Retrieves the latest STSANALOG frame from the DMC60C.

Parameters
stsAnalogOutPointer to STSANALOG buffer to store data into.
Returns
Status code.

◆ getEncoderStatus()

DMC_Code getEncoderStatus ( STSENCODER *  stsEncoderOut)

Retrieves the latest STSENCODER frame from the DMC60C.

Parameters
stsEncoderOutPointer to STSENCODER buffer to store data into.
Returns
Status code.

◆ getGeneralStatus()

DMC_Code getGeneralStatus ( STSGENERAL *  stsGeneralOut)

Retrieves the latest STSGENERAL frame from the DMC60C.

Parameters
stsGeneralOutPointer to STSGENERAL buffer to store data into.
Returns
Status code.

◆ SetControlMode()

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.

Parameters
ModeControl mode to set to.

◆ GetControlMode()

ControlMode GetControlMode ( ) const

Returns the current controlMode in the control0 frame.

Returns
The current control mode.

◆ setContinuousCurrentLimit()

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.

Parameters
currentAmpsThe continuous current limit to set in amps.
Returns
DMC_Code Status code.

◆ getContinuousCurrentLimit()

DMC_Code getContinuousCurrentLimit ( double *  currentAmps)

Gets the continuous current limit.

Parameters
currentAmpsBuffer to store the value.
Returns
DMC_Code Status code.

◆ setPeakCurrentLimit()

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.

Parameters
currentAmpsThe peak current limit to set in amps.
Returns
DMC_Code Status code.

◆ getPeakCurrentLimit()

DMC_Code getPeakCurrentLimit ( double *  currentAmps)

Gets the peak current limit.

Parameters
currentAmpsBuffer to store the value.
Returns
DMC_Code Status code.

◆ setPeakCurrentDuration()

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.

Parameters
durationMsThe peak current duration in milliseconds.
Returns
DMC_Code Status code.

◆ getPeakCurrentDuration()

DMC_Code getPeakCurrentDuration ( int *  durationMs)

Gets the peak current duration.

Parameters
durationMsBuffer to store the value.
Returns
DMC_Code Status code.

◆ enableCurrentLimit()

DMC_Code enableCurrentLimit ( bool  enabled)

Enables or disables current limiting mode.

Parameters
enabledIf true, enabled current limiting. If false, disables current limiting.
Returns
DMC_Code Status code.

◆ isCurrentLimitEnabled()

DMC_Code isCurrentLimitEnabled ( bool *  enabled)

Returns whether or not the current limit is enabled.

Parameters
enabledBuffer to store the result.
Returns
DMC_Code Status code.

◆ setADCMultiplier()

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.

Parameters
valueSigned 16.16 value to set the ADC Multiplier to
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ getADCMultiplier()

DMC_Code getADCMultiplier ( float *  value,
int  tmsWait 
)

Gets the currently stored value for.

Parameters
valueBuffer to store the value.
tmsWaitMax time in milliseconds to wait for a response.
Returns
Status code.

◆ enterBootloader()

DMC_Code enterBootloader ( )

Sends the DMC60C into bootloader mode.

Returns
Status code.