Motor Evaluation Kit NEVC-MCTRL-100-t01-1.0.0
Firmware for NEVB-MCTRL-100-01 for trapezoidal control of BLDC motors using Hall-effect sensors
|
These defines can be modified by the user. More...
Macros | |
#define | MOTOR_POLES 8 |
Number of poles in the motor. | |
#define | TIM4_FREQ 20000UL |
Desired Switching Frequency for MOSFET Gate Signals. | |
#define | DEAD_TIME 350UL |
Dead Time Specification. | |
#define | HALL_PULLUP_ENABLE FALSE |
Internal Pull-up Resistor Configuration for Hall Sensor Inputs. | |
#define | EMULATE_HALL FALSE |
Emulate Motor Spinning. | |
#define | TIM3_FREQ 200UL |
Desired Electrical Rotational Frequency for "Emulated" Motor. | |
#define | COMMUTATION_TICKS_STOPPED 6000 |
Commutation Stopped Limit. | |
#define | TURN_OFF_MODE TURN_OFF_MODE_COAST |
Turn Off Mode. | |
#define | CURRENT_GAIN 50 |
Current Gain for Current Measurement. | |
#define | CURRENT_SENSE_RESISTOR 2000 |
Current Sense Resistor Value. | |
#define | CURRENT_WARNING_THRESHOLD 408 |
Current Warning Threshold (Register Value) | |
#define | CURRENT_ERROR_THRESHOLD 816 |
Current Error Threshold (Register Value) | |
#define | CURRENT_FAULT_ENABLE FALSE |
Current Fault Enable. | |
#define | SPEED_CONTROL_METHOD SPEED_CONTROL_OPEN_LOOP |
Speed Control Method. | |
#define | SPEED_CONTROLLER_TIME_BASE 200 |
Speed Controller Time Base. | |
#define | SPEED_CONTROLLER_MAX_DELTA 1 |
Speed Controller Maximum Delta (Applicable for Open Loop Control) | |
#define | SPEED_CONTROLLER_MAX_SPEED 400 |
Speed Controller Maximum Speed. | |
#define | PID_K_P 100 |
PID Controller Proportional Gain Constant (Only for Closed Loop) | |
#define | PID_K_I 10 |
PID Controller Integral Gain Constant (Only for Closed Loop) | |
#define | PID_K_D_ENABLE TRUE |
PID Controller Derivative Control Enable Flag (Only for Closed Loop) | |
#define | PID_K_D 0 |
PID Controller Derivative Gain Constant (Only for Closed Loop) | |
#define | GATE_RTOP 1000000 |
Top resistor value in the gate voltage potential divider. | |
#define | GATE_RBOTTOM 71500 |
Bottom resistor value in the gate voltage potential divider. | |
#define | REMOTE_DEBUG_MODE FALSE |
Set the remote debug mode. | |
These defines can be modified by the user.
#define COMMUTATION_TICKS_STOPPED 6000 |
#define CURRENT_ERROR_THRESHOLD 816 |
Current Error Threshold (Register Value)
This macro specifies the threshold value for current error as a register value. When the current measured by the controller exceeds this threshold, it triggers the controller to take protective action, by disabling all PWM outputs, essentially allowing the motor to coast.
The range is 0-1023.
This value is not scaled and represents the raw register value. To obtain the register value from the current in amperes, you can use the formula:
\[ \text{Register Value} = \frac{\text{CURRENT} \times \text{CURRENT_SENSE_RESISTOR} \times \text{CURRENT_GAIN}}{0.004887586 \times 1000000} \]
Where:
The NEVB-3INV-001-01 comes with a current op-amp with a gain factor of 50 and a current sense resistor of value 2 mΩ. This corresponds to approximately 0.049 amperes (A) per register value. The default value is 816 which corresponds to approximately 40 A.
#define CURRENT_FAULT_ENABLE FALSE |
Current Fault Enable.
This macro sets if any action is taken if CURRENT_ERROR_THRESHOLD is exceeded.
#define CURRENT_GAIN 50 |
Current Gain for Current Measurement.
This macro defines the gain factor used in the current measurement circuit. The gain is a unit-less multiplier that amplifies the signal from the current sensor before it is read by the controller. It is used in the calculation to convert the sensor reading into an actual current value.
The NEVB-3INV-001-01 comes with a current op-amp with a gain factor of 50. This is the default value.
#define CURRENT_SENSE_RESISTOR 2000 |
Current Sense Resistor Value.
This macro specifies the resistance value of the current sense resistor in the system, measured in micro-ohms (μΩ). The value is used in conjunction with the current gain to calculate the actual current based on the voltage across the current sense resistor.
The NEVB-3INV-001-01 comes with a current sense resistor of value 2 mΩ. This is the default value.
#define CURRENT_WARNING_THRESHOLD 408 |
Current Warning Threshold (Register Value)
This macro specifies the threshold value for current warning as a register value. When the current measured by the controller exceeds this threshold, it triggers the fault LED to be turned on.
The range is 0-1023.
This value is not scaled and represents the raw register value. To obtain the register value from the current in amperes, you can use the formula:
\[ \text{Register Value} = \frac{\text{CURRENT} \times \text{CURRENT_SENSE_RESISTOR} \times \text{CURRENT_GAIN}}{0.004887586 \times 1000000} \]
Where:
The NEVB-3INV-001-01 comes with a current op-amp with a gain factor of 50 and a current sense resistor of value 2 mΩ. This corresponds to approximately 0.049 amperes (A) per register value. The default value is 408 which corresponds to approximately 20 A.
#define DEAD_TIME 350UL |
Dead Time Specification.
This macro specifies the desired dead time between switching actions in nanoseconds (ns). The resolution of the dead time changes with the selected dead time. The best pre-scaler is chose to provide the best resolution.
The following are the resolution for different dead time ranges:
#define EMULATE_HALL FALSE |
Emulate Motor Spinning.
When enabled, this flag transforms Hall effect sensor inputs into hardware-generated outputs, initiating a motor sequencing process.
#define GATE_RBOTTOM 71500 |
Bottom resistor value in the gate voltage potential divider.
This macro defines the value of the bottom resistor (RBOTTOM) in the potential divider circuit used for measuring the gate voltage. It is specified in ohms (Ω).
The value of RBOTTOM is used to determine the scaling factor for the ADC conversion in the gate voltage measurement circuit.
NEVB-3INV-001-01 has a resistor divider with RTOP of 1 MΩ and RBOTTOM of 71.5 kΩ.
#define GATE_RTOP 1000000 |
Top resistor value in the gate voltage potential divider.
This macro defines the value of the top resistor (RTOP) in the potential divider circuit used for measuring the gate voltage. It is specified in ohms (Ω).
The value of RTOP is used to determine the scaling factor for the ADC conversion in the gate voltage measurement circuit.
NEVB-3INV-001-01 has a resistor divider with RTOP of 1 MΩ and RBOTTOM of 71.5 kΩ.
#define HALL_PULLUP_ENABLE FALSE |
#define MOTOR_POLES 8 |
#define PID_K_D 0 |
PID Controller Derivative Gain Constant (Only for Closed Loop)
This macro specifies the derivative gain constant for the PID controller. This parameter accepts signed integer values in the int16_t range.
#define PID_K_D_ENABLE TRUE |
PID Controller Derivative Control Enable Flag (Only for Closed Loop)
Set this flag to TRUE or FALSE to enable or disable derivative control in the PID controller.
#define PID_K_I 10 |
PID Controller Integral Gain Constant (Only for Closed Loop)
This macro specifies the integral gain constant for the PID controller. This parameter accepts signed integer values in the int16_t range.
#define PID_K_P 100 |
PID Controller Proportional Gain Constant (Only for Closed Loop)
This macro specifies the proportional gain constant for the PID controller. This parameter accepts signed integer values in the int16_t range.
#define REMOTE_DEBUG_MODE FALSE |
#define SPEED_CONTROL_METHOD SPEED_CONTROL_OPEN_LOOP |
Speed Control Method.
Select the type of speed control by setting this macro to either SPEED_CONTROL_OPEN_LOOP or SPEED_CONTROL_CLOSED_LOOP.
#define SPEED_CONTROLLER_MAX_DELTA 1 |
Speed Controller Maximum Delta (Applicable for Open Loop Control)
This macro specifies the maximum allowed change in speed reference by the speed controller after each iteration of the speed loop when using open-loop speed control. Adjust this value as needed. When a user changes the requested speed input, this parameter limits the maximum allowed change per SPEED_CONTROLLER_TIME_BASE.
#define SPEED_CONTROLLER_MAX_SPEED 400 |
Speed Controller Maximum Speed.
This macro specifies the maximum speed, to be used as a setpoint when the maximum speed reference value is input to the speed controller. This "speed" is given as rate of change of the hall effect sensors in Hz.
This parameter is crucial for ensuring that the speed controller does not attempt to change the motor speed beyond a safe and controlled rate.
#define SPEED_CONTROLLER_TIME_BASE 200 |
Speed Controller Time Base.
This macro specifies the number of ticks
between each iteration of the speed loop. One 'tick' is one PWM period. Adjust this value to set the speed control loop time base. Range is 1-255.
#define TIM3_FREQ 200UL |
Desired Electrical Rotational Frequency for "Emulated" Motor.
This macro specifies the desired electrical rotational frequency for the "emulated" motor. The valid range is from 5.08 Hz to 167.67 KHz.
#define TIM4_FREQ 20000UL |
Desired Switching Frequency for MOSFET Gate Signals.
This macro defines the desired switching frequency for the MOSFET gate signals. The resolution of the duty cycle is changes with the selected switching frequency. The best pre-scaler is chose to provide the best resolution.
The absolute PWM Resolution is calculated using the following formula:
\[ \text{Absolute PWM Resolution (%)} = \frac{100}{(F_{HST} / (TIM4_{FREQ} \times TIM4_{PRESCALER} \times 2)) - 1} \]
Where:
The TIM4 Pre-scaler is selected based on the gate switching frequency (TIM4_FREQ):
#define TURN_OFF_MODE TURN_OFF_MODE_COAST |
Turn Off Mode.
Set this macro to either TURN_OFF_MODE_COAST or TURN_OFF_MODE_BRAKE to specify the desired turn mode.