Zap'Em Blast'Em Robots
robots that play laser tag!
Loading...
Searching...
No Matches
motor_driver.h File Reference

Header file for motor control structure and interface functions. More...

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include "stm32f4xx_hal.h"

Go to the source code of this file.

Data Structures

struct  motor_t
 Motor object data structure. More...

Functions

void set_duty (motor_t *p_mot, int32_t duty)
 Sets the duty cycle and direction of the motor.
void enable (motor_t *p_mot)
 Enables the motor by setting both channels to maximum.
void disable (motor_t *p_mot)
 Disables the motor by setting both channels to zero.
void go_to (motor_t *p_mot, int k_p, int where, int from)
 Uses proportional control to move motor to a target.

Detailed Description

Header file for motor control structure and interface functions.

Author
Kai De La Cruz

Created on: May 29, 2025

Function Documentation

◆ disable()

void disable ( motor_t * p_mot)

Disables the motor by setting both channels to zero.

Parameters
p_motPointer to motor object

Disables the motor by setting both channels to zero.

Parameters
p_motPointer to the motor structure

◆ enable()

void enable ( motor_t * p_mot)

Enables the motor by setting both channels to maximum.

Parameters
p_motPointer to motor object

Enables the motor by setting both channels to maximum.

Parameters
p_motPointer to the motor structure

◆ go_to()

void go_to ( motor_t * p_mot,
int k_p,
int where,
int from )

Uses proportional control to move motor to a target.

Parameters
p_motPointer to motor object
k_pProportional gain
whereTarget position
fromCurrent position

Uses proportional control to move motor to a target.

Parameters
p_motPointer to the motor structure
k_pProportional gain
whereTarget position
fromCurrent position

◆ set_duty()

void set_duty ( motor_t * p_mot,
int32_t duty )

Sets the duty cycle and direction of the motor.

Parameters
p_motPointer to motor object
dutyDuty cycle (-100 to 100)

Sets the duty cycle and direction of the motor.

Parameters
p_motPointer to the motor structure
dutyDesired duty cycle (-100 to 100 percent)