-
Notifications
You must be signed in to change notification settings - Fork 0
/
hal_servomotor.h
34 lines (28 loc) · 935 Bytes
/
hal_servomotor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* File: hal_servomotor.h
* Author: Nicolae Hagiu
*
* Created on August 17, 2028, 1:27 PM
*/
#ifndef HAL_SERVOMOTOR_H
#define HAL_SERVOMOTOR_H
#include "general.h"
void vSetServoAngle(T_F16 angle);
#define ANGLE_MIN 0
#define ANGLE_MAX 180
#define LIMIT_INF 60
#define LIMIT_SUP 120
#define OFFSET 4
/* The offset is the Lower bound of the duty cycle interval*/
#define GAIN 0.117
/********** How to calculate gain **************/
/* The period is 20mS */
/* Left -> 4% duty cycle, equivalent to 0.8mS */
/* Right-> 11% duty cycle, equivalent to 2.2mS */
/* Length of percent interval = 11 - 4 = 7% */
/***********************************************/
/* Left Angle -> 60 degrees */
/* Right Angle-> 120 degrees */
/* Length of angle interval = 120 - 60 = 60 */
/* Resolution (GAIN) = 7 / 60 = 0.117 */
#endif /* HAL_SERVOMOTOR_H */