MSPM0 Sensored Trap Software User’s Guide¶
CCS Project setup¶
Go to Import CCS Projects as shown below.
Click Browse. Navigate to
C:\ti\mspm0_sdk_<SDK_Version>\examples\nortos\[LAUNCHPAD]\motor_control_bldc_sensored_trap_hall
.Click Select Folder. Check the desired hardware board, and click Finish to import the project into your workspace.
Adding Initial Parameters (optional)¶
In the Project Explorer, open the project drop down menu and open “[BOARD_NAME]_gui.h”.
Under “defines” (line 44), change any of the “GUI_INITIAL_xxxx” defines to any pre-defined parameters in “hall_trap.h”, or value inside of the parentheses. The parameters that can be initially defined are below.
Parameter |
Definition |
---|---|
GUI_INITIAL_MOTOR_DIRECTION |
Motor direction (forward or reverse) |
GUI_INITIAL_NSLEEP |
DRV mode (sleep or awake) |
GUI_INITIAL_DRVOFF |
DRV status (ON or OFF) |
GUI_INITIAL_STOPMOTOR |
Motor state (RUN or STOP) |
GUI_INITIAL_CSAGAIN |
DRV CSA gain setting |
GUI_INITIAL_FAULT_RESET |
Fault reset bit status |
GUI_INITIAL_BRAKETYPE |
Motor brake type |
GUI_INITIAL_CSA_REF |
CSA reference source |
GUI_INITIAL_ADC_REF |
ADC reference value, in mV |
GUI_INITIAL_PWM_FREQ |
PWM frequency value, in Hz |
GUI_INITIAL_DEAD_TIME_NS |
Dead time, in ns |
GUI_INITIAL_ACCRATE |
Acceleration rate, in duty cycle per ms |
GUI_INITIAL_PULSE_WIDTH |
PWM duty cycle |
GUI_FAULT_LIMIT |
Fault count limit |
GUI_MAX_PULSEWIDTH |
Maximum PWM duty cycle |
GUI_INITIAL_SHUNT_RES |
Shunt resistance, in milliohms |
GUI_INITIAL_ADCVREF |
ADC voltage reference source |
GUI_INITIAL_ADC_INTVREF |
ADC internal voltage reference source |
GUI_INITIAL_ADC_EXTVREF |
ADC external voltage reference value, in mV |
GUI_MOTOR_NUMBER_OF_POLES |
Number of poles in motor |
GUI_DEFAULT_OVER_VOLTAGE_LIMIT |
Overvoltage limit, in volts |
GUI_DEFAULT_UNDER_VOLTAGE_LIMIT |
Undervoltage limit, in volts |
GUI_DEFAULT_OVER_CURRENT_LIMIT |
Overcurrent limit, in amps |
Starting the Project¶
Connect the hardware and turn on the power supply. There should be no more than 50mA on the power supply.
Click on the Build button. Project should build with no errors.
Click on the Debug button.
Open the Expressions window and add the following global structures and expressions. The expressions below in the guiVar structure control motor system and control parameters.
guiVar |
structure that contains the GUI variables below |
---|---|
motorDirection |
Sets motor direction to forward or reverse |
nsleepSignal |
Sets driver to awake or sleep mode |
stopMotor |
Sets motor to run or stop mode |
motorBraketype |
Sets motor brake type to BRAKE or COAST |
CSAGain |
Sets current sense amplifier (CSA) gain of the driver |
csaRef |
Sets CSA reference in millivolts |
pwmFreq |
Sets PWM frequency in Hz |
deadtime_ns |
Sets dead time in ns |
accRate |
Sets acceleration rate in duty cycle per ms |
pulseWidth |
Sets duty cycle in percent |
adcVref |
Sets ADC voltage reference source as VDDA, internal (1.4 or 2.5V), or external (VREF+ pin) |
adcInternalVRef |
Sets ADC internal voltage reference as 1.4V or 2.5V |
adcExternalVRef |
Sets ADC voltage reference when external VREF is used, in millivolts. Value set should be same as value into VREF+. |
rShunt_mohm |
Shunt resistance of phase(s), in milliohms |
The expressions below in the fault structure control motor system and control parameters.
fault |
structure that contains the fault variables below |
---|---|
Reset |
Resets faults below when written with 1 |
overVoltage |
Set to 1 when bus voltage is higher than guiOverVoltageLimit |
underVoltage |
Set to 1 when bus voltage is lower than guiUnderVoltageLimit |
drvFault |
Set to 1 when driver nFAULT pin is active low |
overCurrent |
Set to 1 when phase current is higher than guiOverCurrentLimit |
ledIndication |
Logical OR of overVoltage, underVoltage, drvFault, and overCurrent flags |
If you wish to monitor the measured bus and phase voltages or currents, or control the current/voltage limits, add the below expressions.
Expression |
Description |
---|---|
moduleVoltage |
Motor supply voltage in IQ(20) format |
moduleCurrent |
Motor supply current in IQ(20) format. For hardware with 1 current shunt only. |
voltagePhaseA |
Phase A voltage in IQ(20) format |
voltagePhaseB |
Phase B voltage in IQ(20) format |
voltagePhaseC |
Phase C voltage in IQ(20) format |
currentPhaseA |
Phase A current in IQ(20) format |
currentPhaseB |
Phase B current in IQ(20) format |
currentPhaseC |
Phase C current in IQ(20) format |
guiOverCurrentLimit |
Sets the overcurrent limit for phases A, B, and C in IQ(20) format |
guiUnderVoltageLimit |
Sets the motor supply and phase A/B/C undervoltage limit for in IQ(20) format |
guiOverVoltageLimit |
Sets the motor supply and phase A/B/C overvoltage limit for in IQ(20) format |
Note: These values above are in IQ20 format. In order to display corrent value, switch them to IQ(20) format in the CCS expressions window as shown below.
For devices with SPI support, you can add the guiSPI structure for SPI Configuration and controlling SPI reads/writes during runtime.
guiSPI |
structure that contains the SPI variables below |
---|---|
writeBitfieldRegFlag |
Writes writeBitfieldRegData to bitfieldRegPosData of writeBitfieldRegAddr when set to 1 |
writeRegFlag |
Writes writeRegData to writeRegData of writeRegAddr when set to 1 |
readRegFlag |
Reads data of readRegAddr and stores into to readRegData when set to 1 |
writeBitfieldRegAddr |
Set to address of a bitfield register write operation |
writeRegAddr |
Set to address of a register write operation |
readRegAddr |
Set to address of a register read operation |
bitfieldRegPosData |
Bitfield position of a bitfield write operation to writeBitfieldRegAddr |
bitfieldRegMaskData |
Mask value of a bitfield write operation to writeBitfieldRegAddr |
writeBitfieldRegData |
Data value of a bitfield write register operation to writeBitfieldRegAddr |
writeRegData |
Data value of a write register operation to writeRegAddr |
readRegData |
Data value read from read operation of readRegAddr |
readAllRegsFlag |
Reads all registers when set to 1 |
The guiRegMap structure shows all of the status and configuration registers in the DRV device during run time. For devices with SPI support only.
guiRegMap structure that contains the DRV83xx register map
Press Play to start the code.
Enable “Continuous Refresh” in the Expressions window.
Running the Project¶
Open guiVar. Set pulseWidth to 20 to spin the motor at 20%. The motor starts spinning.
Set motorDirection = MOTOR_DIR_REVERSE and press Enter. The motor stops spinning in forward direction and starts to spin in the reverse direction.
Set nsleepSignal = DRV83xx_DRV_NSLEEP_SLEEP and press Enter. The driver goes into sleep mode and the motor stops spinning. Set to DRV83xx_DRV_NSLEEP_AWAKE and pulseWidth = 20 to spin the motor again.
Set stopMotor = MOTOR_STATE_STOP and press Enter to stop the motor according to the motorBraketype(MOTOR_BRAKE_TYPE_COAST = coast mode, MOTOR_BRAKE_TYPE_STOP = stop mode).
Change pwmFreq to 10000 to change the PWM frequency to 10kHz. Observe in waveforms.
Change deadtime_ns to 500 to change the MCU deadband to 500 ns. Observe in waveforms.
Change accRate to change the acceleration and deceleration rate of the motor when pulseWidth is modified.
Create an overvoltage fault by increasing the voltage beyond guiOverVoltageLimit. Fault.overVoltage is set to 1, the motor stops spinning, and the LED sets. Reduce the voltage below the limit and set Fault.Reset = 1 to clear the latched fault and start spinning the motor again.
Create an undervoltage fault by decreasing the voltage below guiUnderVoltageLimit. Fault.underVoltage is set to 1, the motor stops spinning, and the LED sets. Increase the voltage above the limit and set Fault.Reset = 1 to clear the latched fault and start spinning the motor again.
If the device has SPI registers, use the guiSPI variables to perform a bitfield write, register write, or register read, or read all operation.
To perform a bitfield write operation:
Select the drop-down register in writeRegAddr
Enter the bitfield position in bitfieldRegPosData
Enter the mask of the setting in that bitfield position in bitfieldRegMaskData (for example, a 3-bit setting has mask 0x7)
Write the bitfield data in writeBitfieldRegData
Set the writeBitfieldRegFlag to 1. It will automatically clear to 0.
To perform a register write operation:
Select the drop-down register in writeRegAddr
Write the data in writeRegData
Set the writeRegFlag to 1. It will automatically clear to 0.
To perform a register read operation:
Select the drop-down register in readRegAddr
Set the readRegFlag to 1. It will automatically clear to 0.
Read the data in readRegData
To perform a read all registers operation:
Set the readAllRegsFlag to 1. It will automatically clear to 0.
View all registers in the guiRegMap structure
API Guide¶
Known Issues¶
Supported Devices¶
DRV8300Dxxx-EVM¶
Supported MSPM0 Launchpads
Links
DRV8311HEVM¶
Supported MSPM0 Launchpads
Links
DRV8316REVM¶
Supported MSPM0 Launchpads
Links
DRV8317HEVM¶
Supported MSPM0 Launchpads
Links
DRV8323RHEVM¶
Supported MSPM0 Launchpads
Links
DRV8328AEVM¶
Supported MSPM0 Launchpads
Links
DRV8329AEVM¶
Supported MSPM0 Launchpads
Links
DRV8329AEVM¶
Supported MSPM0 Launchpads
Links
DRV8353RHEVM¶
Supported MSPM0 Launchpads
Links