![]() |
Zap'Em Blast'Em Robots
robots that play laser tag!
|
Motor control functions for PWM-based direction and speed handling. More...
#include "motor_driver.h"
#include "encoder_driver.h"
#include "stm32f4xx_hal.h"
#include <stdint.h>
Macros | |
#define | PWM_MAX 4800 |
Maximum PWM value used for scaling duty cycle. |
Functions | |
void | set_duty (motor_t *p_mot, int32_t duty) |
Sets the motor duty cycle and direction using PWM. | |
void | disable (motor_t *p_mot) |
Disables the motor by setting both channels to 0% duty. | |
void | enable (motor_t *p_mot) |
Enables the motor by setting both channels to 100% duty. | |
void | go_to (motor_t *p_mot, int k_p, int where, int from) |
Moves the motor toward a target using proportional control. |
Motor control functions for PWM-based direction and speed handling.
Created on: May 29, 2025
void disable | ( | motor_t * | p_mot | ) |
Disables the motor by setting both channels to 0% duty.
Disables the motor by setting both channels to zero.
p_mot | Pointer to the motor structure |
void enable | ( | motor_t * | p_mot | ) |
Enables the motor by setting both channels to 100% duty.
Enables the motor by setting both channels to maximum.
p_mot | Pointer to the motor structure |
void go_to | ( | motor_t * | p_mot, |
int | k_p, | ||
int | where, | ||
int | from ) |
Moves the motor toward a target using proportional control.
Uses proportional control to move motor to a target.
p_mot | Pointer to the motor structure |
k_p | Proportional gain |
where | Target position |
from | Current position |
void set_duty | ( | motor_t * | p_mot, |
int32_t | duty ) |
Sets the motor duty cycle and direction using PWM.
Sets the duty cycle and direction of the motor.
p_mot | Pointer to the motor structure |
duty | Desired duty cycle (-100 to 100 percent) |