Elevator v2.0
Elevator Documenation
Loading...
Searching...
No Matches
servo.h File Reference

Hardware Application Layer for Servo SG90 motor. More...

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/mcpwm.h"
Include dependency graph for servo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Servo
 Servo struct for SG90 servo motor. More...
 

Macros

#define SERVO_PWM_UNIT   (mcpwm_unit_t)MCPWM_UNIT_0
 
#define SERVO_PWM_SIGNAL   (mcpwm_io_signals_t)(MCPWM0A)
 
#define SERVO_GPIO   14
 
#define SERVO_FREQ   50
 
#define SERVO_TIMER   (mcpwm_timer_t)MCPWM_TIMER_0
 
#define SERVO_MIN_PULSEWIDTH_US   (1000)
 
#define SERVO_MAX_PULSEWIDTH_US   (2000)
 
#define SERVO_MAX_DEGREE   (90)
 
#define SERVO_OPEN   -90
 
#define SERVO_CLOSE   90
 

Typedefs

typedef struct Servo Servo
 

Functions

void moveServo (Servo *servo, int angle)
 moveServo will move the servo motor by angles More...
 
void servoInit (Servo *servo)
 servoInit will initialize servo motor More...
 
void haltServo (Servo *servo)
 haltServo will stop the timer of the mcpwm More...
 
void startServo (Servo *servo)
 startServo will start the time of the mcpwm More...
 

Detailed Description

Hardware Application Layer for Servo SG90 motor.

Author
Jesus Minjares (https://github.com/jminjares4)
Version
0.1
Date
2021-11-27

Macro Definition Documentation

◆ SERVO_CLOSE

#define SERVO_CLOSE   90

◆ SERVO_FREQ

#define SERVO_FREQ   50

◆ SERVO_GPIO

#define SERVO_GPIO   14

◆ SERVO_MAX_DEGREE

#define SERVO_MAX_DEGREE   (90)

◆ SERVO_MAX_PULSEWIDTH_US

#define SERVO_MAX_PULSEWIDTH_US   (2000)

◆ SERVO_MIN_PULSEWIDTH_US

#define SERVO_MIN_PULSEWIDTH_US   (1000)

◆ SERVO_OPEN

#define SERVO_OPEN   -90

◆ SERVO_PWM_SIGNAL

#define SERVO_PWM_SIGNAL   (mcpwm_io_signals_t)(MCPWM0A)

◆ SERVO_PWM_UNIT

#define SERVO_PWM_UNIT   (mcpwm_unit_t)MCPWM_UNIT_0

◆ SERVO_TIMER

#define SERVO_TIMER   (mcpwm_timer_t)MCPWM_TIMER_0

Typedef Documentation

◆ Servo

typedef struct Servo Servo

Function Documentation

◆ haltServo()

void haltServo ( Servo servo)

haltServo will stop the timer of the mcpwm

Parameters
servopass a Servo motor by reference
Returns
None
Parameters
servopass a Servo motor by reference
Returns
None

◆ moveServo()

void moveServo ( Servo servo,
int  angle 
)

moveServo will move the servo motor by angles

Parameters
servopass a Servo by reference
angleint servo angle movment
Note
Rangee for -90 to 90 degrees
Parameters
servopass a Servo by reference
angleint servo angle movment
Note
Rangee for -90 to 90 degrees

◆ servoInit()

void servoInit ( Servo servo)

servoInit will initialize servo motor

Parameters
servopass a Servo motor by reference
Parameters
servopass a Servo motor by reference

◆ startServo()

void startServo ( Servo servo)

startServo will start the time of the mcpwm

Parameters
servopass a Servo motor by reference
Parameters
servopass a Servo motor by reference