Initialize ESC to control brushless motor with gpio [closed]

0

I am trying to operate a brushless motor with the gpio of an orange pi zero using wiringPi I have managed to turn it once but it does not work always the problem is in the initialization of the ESC controller when it works 2 beep it waits for a second approximately another 2 beep and it already turns the motor but normally it remains doing beep continuously and it does not turn. What I would like to know is the procedure necessary to start the ESC, for what I have read to start it, you have to send a pulse of 2 milliseconds and then a pulse of 1 millisecond, but it only works sometimes.

    
asked by Javier Reyero Huerga 21.01.2018 в 22:14
source

1 answer

0

I found the solution the problem was that it only indicated to the ESC controller the maximum pulse of 2 ms and it is necessary to indicate the maximum and the minimum 1 ms in the case of this controller in that order it can be the opposite the other It works with this code:

#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
            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
            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;
}
    
answered by 22.01.2018 / 12:56
source