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 should not be modified by the user. More...
Topics | |
PLL Post-scaler Macros | |
PLL post-scaler selection bits (PLLTM1:0) for High Speed Timer in PLLFRQ. | |
Deadtime Pre-scaler Macros | |
Deadtime generator pre-scaler selection bits (DTPS41:0) in TCCR4B. | |
Timer 1 (and 3) Clock Select Macros | |
Timer 1 (and 3) clock selection bits (CS12:0/CS12:0) for TCCR1B/TCCR3B. | |
Timer 4 Clock Select Macros | |
Timer 4 clock selection bits (CS43:0) for TCCR4B. | |
ADC Multiplexer Select Macros | |
ADC multiplexer selection bits (MUX5 and MUX4:0) in ADCSRB and ADMUX respectively. | |
ADC Pre-scaler Macros | |
ADC pre-scaler selection bits (ADPS2:0) in ADCSRA. | |
ADC Reference Macros | |
ADC voltage reference selection bits (REFS1:0) in ADMUX. | |
ADC Auto Trigger Macros | |
ADC auto trigger source selection bits (ADTS3:0) in ADCSRB. | |
Classes | |
struct | motorflags |
Collection of all motor control flags. More... | |
struct | faultflags |
Collection of all fault flags. More... | |
struct | motorconfigs |
Collection of motor configurations. More... | |
Macros | |
#define | FALSE 0 |
FALSE constant value. | |
#define | TRUE (!FALSE) |
TRUE constant value, defined to be compatible with comparisons. | |
#define | F_HST 64000000UL |
High-speed system clock frequency. | |
#define | AH_PIN PB6 |
PIN where high side gate PWM for phase A is connected. | |
#define | BH_PIN PC7 |
PIN where high side gate PWM for phase B is connected. | |
#define | CH_PIN PD7 |
PIN where high side gate PWM for phase C is connected. | |
#define | AL_PIN PB5 |
PIN where low side gate PWM for phase A is connected. | |
#define | BL_PIN PC6 |
PIN where low side gate PWM for phase B is connected. | |
#define | CL_PIN PD6 |
PIN where low side gate PWM for phase C is connected. | |
#define | PWM_PATTERN_PORTB ((1 << AH_PIN) | (1 << AL_PIN)) |
Bit pattern of PWM pins placed on PORTB (Phase A). | |
#define | PWM_PATTERN_PORTC ((1 << BH_PIN) | (1 << BL_PIN)) |
Bit pattern of PWM pins placed on PORTC (Phase B). | |
#define | PWM_PATTERN_PORTD ((1 << CH_PIN) | (1 << CL_PIN)) |
Bit pattern of PWM pins placed on PORTD (Phase C). | |
#define | OC_ENABLE_PORTB ((1 << OC4OE3) | (1 << OC4OE2)) |
#define | OC_ENABLE_PORTC ((1 << OC4OE1) | (1 << OC4OE0)) |
#define | OC_ENABLE_PORTD ((1 << OC4OE5) | (1 << OC4OE4)) |
#define | DIRECTION_FORWARD 0 |
Forward direction flag value. | |
#define | DIRECTION_REVERSE 1 |
Reverse direction flag value. | |
#define | DIRECTION_UNKNOWN 3 |
Unknown direction flag value. | |
#define | HALL_PIN PINB |
PIN register for Hall sensor input. | |
#define | H1_PIN PB1 |
Pin where H1 is connected. | |
#define | H2_PIN PB2 |
Pin where H2 is connected. | |
#define | H3_PIN PB3 |
Pin where H3 is connected. | |
#define | ADC_MUX_L_SPEED ADC_MUX_L_ADC4 |
#define | ADC_MUX_H_SPEED ADC_MUX_H_ADC4 |
#define | ADC_MUX_L_CURRENT ADC_MUX_L_ADC7 |
Lower analog channel selection bits (MUX4:0) for motor current measurement. | |
#define | ADC_MUX_H_CURRENT ADC_MUX_H_ADC7 |
High analog channel selection bit (MUX5) for for motor current measurement. | |
#define | ADC_MUX_L_GATEVREF ADC_MUX_L_ADC6 |
Lower analog channel selection bits (MUX4:0) for motor gateVref measurement. | |
#define | ADC_MUX_H_GATEVREF ADC_MUX_H_ADC6 |
High analog channel selection bit (MUX5) for for motor gateVref measurement. | |
#define | ADC_MUX_L_BREF ADC_MUX_L_ADC0 |
Lower analog channel selection bits (MUX4:0) for motor bref measurement. | |
#define | ADC_MUX_H_BREF ADC_MUX_H_ADC0 |
High analog channel selection bit (MUX5) for for motor bref measurement. | |
#define | ADC_PRESCALER ADC_PRESCALER_DIV_8 |
ADC clock pre-scaler used in this application. | |
#define | ADC_REFERENCE_VOLTAGE ADC_REFERENCE_VOLTAGE_VCC |
ADC voltage reference used in this application. | |
#define | ADC_TRIGGER ADC_TRIGGER_TIMER0_OVF |
ADC trigger used in this application. | |
#define | DIRECTION_COMMAND_PIN PD2 |
Pin where direction command input is located. | |
#define | ENABLE_PIN PD0 |
Enable input pin. | |
#define | REMOTE_PIN PD3 |
Remote input pin. | |
#define | SPEED_INPUT_SOURCE_LOCAL 0 |
Speed input source - Local or speed input pin. | |
#define | SPEED_INPUT_SOURCE_REMOTE 1 |
Speed input source - Remote input. | |
#define | FAULT_PIN_1 PD4 |
Fault Pin 1. | |
#define | FAULT_PIN_2 PB4 |
Fault Pin 2. | |
#define | FAULT_PIN_3 PB7 |
Fault Pin 3. | |
#define | WAVEFORM_BLOCK_COMMUTATION 0 |
Waveform constant for block commutation. | |
#define | WAVEFORM_BRAKING 1 |
Waveform status flag for braking. | |
#define | WAVEFORM_UNDEFINED 3 |
Waveform status flag used for coasting. | |
#define | TURN_OFF_MODE_COAST 0 |
TURN_OFF_MODE value for coasting (disabled drivers). | |
#define | TURN_OFF_MODE_BRAKE 1 |
#define | SPEED_CONTROL_OPEN_LOOP 0 |
Speed control selection for open loop control. | |
#define | SPEED_CONTROL_CLOSED_LOOP 1 |
Speed control selection for closed loop control. | |
#define | SPEED_CONTROLLER_MAX_INPUT 255 |
Maximum Speed Reference Input. | |
#define | CHOOSE_TIM4_PRESCALER(tim4Freq) ((tim4Freq) < 15625 ? 4 : ((tim4Freq) < 31250 ? 2 : 1)) |
Macro to choose Timer4 pre-scaler. | |
#define | CHOOSE_DT_PRESCALER(deadTime) |
Macro to choose Timer4 dead time pre-scaler based on the dead time. | |
#define | FORCE_INLINE inline __attribute__((always_inline)) |
Macro for forcing inline expansion of functions. | |
#define | FAST_ACCESS(register_address) __attribute__((address(register_address))) |
Assign a specific memory address to a variable for fast access. | |
Typedefs | |
typedef struct motorflags | motorflags_t |
Collection of all motor control flags. | |
typedef struct faultflags | faultflags_t |
Collection of all fault flags. | |
typedef struct motorconfigs | motorconfigs_t |
Collection of motor configurations. | |
These defines should not be modified by the user.
#define ADC_MUX_H_BREF ADC_MUX_H_ADC0 |
#define ADC_MUX_H_CURRENT ADC_MUX_H_ADC7 |
#define ADC_MUX_H_GATEVREF ADC_MUX_H_ADC6 |
#define ADC_MUX_H_SPEED ADC_MUX_H_ADC4 |
#define ADC_MUX_L_BREF ADC_MUX_L_ADC0 |
#define ADC_MUX_L_CURRENT ADC_MUX_L_ADC7 |
#define ADC_MUX_L_GATEVREF ADC_MUX_L_ADC6 |
#define ADC_MUX_L_SPEED ADC_MUX_L_ADC4 |
#define ADC_PRESCALER ADC_PRESCALER_DIV_8 |
#define ADC_REFERENCE_VOLTAGE ADC_REFERENCE_VOLTAGE_VCC |
#define ADC_TRIGGER ADC_TRIGGER_TIMER0_OVF |
#define AH_PIN PB6 |
#define AL_PIN PB5 |
#define BH_PIN PC7 |
#define BL_PIN PC6 |
#define CH_PIN PD7 |
#define CHOOSE_DT_PRESCALER | ( | deadTime | ) |
Macro to choose Timer4 dead time pre-scaler based on the dead time.
This macro determines the appropriate dead time pre-scaler for Timer4 based on the provided deadTime value. The deadTime is expected to be an integer value representing nanoseconds.
The pre-scaler is chosen based on the following conditions:
deadTime | The dead time in nanoseconds. |
Definition at line 695 of file main.h.
#define CHOOSE_TIM4_PRESCALER | ( | tim4Freq | ) | ((tim4Freq) < 15625 ? 4 : ((tim4Freq) < 31250 ? 2 : 1)) |
#define CL_PIN PD6 |
#define DIRECTION_COMMAND_PIN PD2 |
#define FAST_ACCESS | ( | register_address | ) | __attribute__((address(register_address))) |
Assign a specific memory address to a variable for fast access.
This macro is used to specify the memory address of a register for fast access, directly instructing the compiler to place the variable at the given address. When parsed by IntelliSense in VSCode, the macro is defined as empty to avoid IntelliSense errors.
#define FORCE_INLINE inline __attribute__((always_inline)) |
Macro for forcing inline expansion of functions.
This macro ensures that a function is always inlined by the compiler, overriding the compiler's own decision process. When parsed by IntelliSense in VSCode, it is defined as a simple inline to avoid IntelliSense errors. For actual compilation, it includes the GCC-specific always_inline
attribute to enforce inlining.
#define OC_ENABLE_PORTB ((1 << OC4OE3) | (1 << OC4OE2)) |
#define OC_ENABLE_PORTC ((1 << OC4OE1) | (1 << OC4OE0)) |
#define OC_ENABLE_PORTD ((1 << OC4OE5) | (1 << OC4OE4)) |
#define SPEED_CONTROL_CLOSED_LOOP 1 |
#define SPEED_CONTROL_OPEN_LOOP 0 |
#define SPEED_CONTROLLER_MAX_INPUT 255 |
Maximum Speed Reference Input.
This macro specifies the maximum speed reference input value that the speed controller should consider which corresponds to the highest possible reading from the ADC This is by default 8 bits as only the top 8 bits of the 10 bit ADC is being used. This corresponds to a value of 255.
#define SPEED_INPUT_SOURCE_LOCAL 0 |
#define SPEED_INPUT_SOURCE_REMOTE 1 |
#define TRUE (!FALSE) |
#define TURN_OFF_MODE_BRAKE 1 |
#define TURN_OFF_MODE_COAST 0 |
#define WAVEFORM_BLOCK_COMMUTATION 0 |
#define WAVEFORM_UNDEFINED 3 |
typedef struct faultflags faultflags_t |
Collection of all fault flags.
This struct contains all fault flags used in this implementation.
typedef struct motorconfigs motorconfigs_t |
Collection of motor configurations.
This struct contains some of the motor configurations. This may support remote implementation.
typedef struct motorflags motorflags_t |
Collection of all motor control flags.
This struct contains all motor control flags used in this implementation.