R2R
|
utilities header More...
Go to the source code of this file.
Functions | |
void | M1HIntHandler (void) |
Hall sensor interrupt for motor 1. More... | |
void | M2HIntHandler (void) |
Hall sensor interrupt for motor 2. More... | |
void | motor1Commutate (int State, int control) |
Commutate motor 1 with a given pwm. More... | |
void | motor2Commutate (int State, int control) |
Commutate motor 2 with a given pwm. More... | |
void | motor1PWM (int pwm1, int pwm2, int pwm3) |
Sets the PWM value to motor 1. More... | |
void | motor2PWM (int pwm1, int pwm2, int pwm3) |
Sets the PWM value to motor 2. More... | |
void | motor1ControlPWM (int control) |
Sets the PWM value and direction to motor 1. More... | |
void | motor2ControlPWM (int control) |
Sets the PWM value and direction to motor 2. More... | |
void | motorInit (void) |
Initializes the GPIO pins for the motor. More... | |
void | M1_INL_WRITE (int a, int b, int c) |
Commutation table for motor 1. More... | |
void | M2_INL_WRITE (int a, int b, int c) |
Commutation table for motor 2. More... | |
int | getmotor1PWM (void) |
Returns the current PWM of motor 1. More... | |
int | getmotor2PWM (void) |
Returns the current PWM of motor 2. More... | |
int32_t | getmotor1HALLS (void) |
Returns the current state of the halls for motor 1. More... | |
int32_t | getmotor2HALLS (void) |
Returns the current state of the halls for motor 2. More... | |
void | MotorSPIinit (void) |
Initializes the SPI channels for the motor drivers. More... | |
void | motorDriverInit (void) |
Initializes the SPI commands to set the motor's configuration for 1x PWM mode. More... | |
void | pwmInit (void) |
Initializes PWM. More... | |
utilities header
This file contains the motor functions
int32_t getmotor1HALLS | ( | void | ) |
Returns the current state of the halls for motor 1.
It returns 32 bit number representing the state of the motor as a bit array It is compared to the HALLSTATE definitions to determine the current state.
Void |
int getmotor1PWM | ( | void | ) |
Returns the current PWM of motor 1.
Void |
int32_t getmotor2HALLS | ( | void | ) |
Returns the current state of the halls for motor 2.
It returns 32 bit number representing the state of the motor as a bit array It is compared to the HALLSTATE definitions to determine the current state.
Void |
int getmotor2PWM | ( | void | ) |
Returns the current PWM of motor 2.
Void |
void M1_INL_WRITE | ( | int | a, |
int | b, | ||
int | c | ||
) |
Commutation table for motor 1.
This function contains the commutation table for motor 1 and sets the control pins for each phase accordingly.
int | a phase A |
int | b phase B |
int | c phase C |
void M1HIntHandler | ( | void | ) |
Hall sensor interrupt for motor 1.
This function is used to determine the commutation on motor 1
Void |
void M2_INL_WRITE | ( | int | a, |
int | b, | ||
int | c | ||
) |
Commutation table for motor 2.
This function contains the commutation table for motor 2 and sets the control pins for each phase accordingly.
int | a phase A |
int | b phase B |
int | c phase C |
void M2HIntHandler | ( | void | ) |
Hall sensor interrupt for motor 2.
This function is used to determine the commutation on motor 2
Void |
void motor1Commutate | ( | int | State, |
int | control | ||
) |
Commutate motor 1 with a given pwm.
The state of the commutation is determined by the hall sensing
State | of 1 to 6 |
control | the pwm for the motor |
void motor1ControlPWM | ( | int | control | ) |
Sets the PWM value and direction to motor 1.
This function handles all the commutation for motor 1. This is done via hall sensing to determine the position the BLDC motor is in.
Example: motor2ControlPWM(200); // sets the motor speed to 5% of default, clockwise delayMS(100); //delay for 100 ms motor2ControlPWM(-200); // sets motor speed to 5% of default, counter clockwise.
control | The pwmValue ranges from -maximum pwm period to the positive period. The default pwm period is 4000, 30kHz. |
void motor1PWM | ( | int | pwm1, |
int | pwm2, | ||
int | pwm3 | ||
) |
Sets the PWM value to motor 1.
pwm1 | the pwm output on phase A |
pwm2 | the pwm output on phase B |
pwm3 | the pwm output on phase C |
void motor2Commutate | ( | int | State, |
int | control | ||
) |
Commutate motor 2 with a given pwm.
The state of the commutation is determined by the hall sensing
State | of 1 to 6 |
control | the pwm for the motor |
void motor2ControlPWM | ( | int | control | ) |
Sets the PWM value and direction to motor 2.
This function handles all the commutation for motor 2. This is done via hall sensing to determine the position the BLDC motor is in.
Example: motor2ControlPWM(200); // sets the motor speed to 5% of default, clockwise delayMS(100); //delay for 100 ms motor2ControlPWM(-200); // sets motor speed to 5% of default, counter clockwise.
control | The pwmValue ranges from -maximum pwm period to the positive period. The default pwm period is 4000, 30kHz. |
void motor2PWM | ( | int | pwm1, |
int | pwm2, | ||
int | pwm3 | ||
) |
Sets the PWM value to motor 2.
pwm1 | the pwm output on phase A |
pwm2 | the pwm output on phase B |
pwm3 | the pwm output on phase C |
void motorDriverInit | ( | void | ) |
Initializes the SPI commands to set the motor's configuration for 1x PWM mode.
Void |
void motorInit | ( | void | ) |
Initializes the GPIO pins for the motor.
Initializes the direction, brake, and halt pins for the motor in 1x PWM mode
Void |
void MotorSPIinit | ( | void | ) |
Initializes the SPI channels for the motor drivers.
Initializes SSI1 ~ 4 and their corresponding GPIO pins
Void |
void pwmInit | ( | void | ) |
Initializes PWM.
Initialize PWM on PF0 (motor 1) and PG0 (motor 2), and the default period if 320 SysClk cycles.
Void |