-
Notifications
You must be signed in to change notification settings - Fork 0
/
ESC_test.c
68 lines (55 loc) · 2.01 KB
/
ESC_test.c
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <wiringPi.h>
#include<unistd.h>
#define GPIO 12 //gpio 15 orange pi zero
int main()
{
int speed = 1500; //MINIMO 1000 MAXIMO 2000
wiringPiSetup();
pinMode (GPIO, OUTPUT);
//INICIO CONTROLADOR ESC
/*
Pulsos de 2000us durante 2.5 segundos
|--------| pulso de 2000us para indicar el pulso mas alto al controlador ESC
_______ 3.3v
| | |
| | |
| |__________________________________| 0 V
|------------------------------------------| 20000 us periodo del controlador ESC
2500 ms / 20 ms = 125 pulsos;
*/
for(int i=0;i<125;i++)
{
digitalWrite(GPIO, HIGH);
usleep(2000);//2ms (cambiar por 1000 si tu controlador se inicia al contrario)
digitalWrite(GPIO, LOW);
usleep(18000);//18ms
}
/*
Pulsos de 1000us durante 2.5 segundos
|----| pulso de 1000us para indicar el pulso mas bajo al controlador ESC
____ 3.3v
| | |
| | |
| |______________________________________| 0 V
|-------------------------------| 20000 us periodo del controlador ESC
2500 ms / 20 ms = 125 pulsos;
*/
for(int i=0;i<125;i++)
{
digitalWrite(GPIO, HIGH);
usleep(1000);//1ms (cambiar por 2000 si tu controlador se inicia al contrario)
digitalWrite(GPIO, LOW);
usleep(19000);//19ms
}
//FIN INICIO CONTROLADOR ESC
//Inicio Giro del motor
while(1)
{
digitalWrite(GPIO, HIGH);
usleep(speed);//us
digitalWrite(GPIO, LOW);
usleep(20000-speed);//us
}
return 0;
}