Guest User

Untitled

a guest
Jan 22nd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <wiringPi.h>
  3. #include<unistd.h>
  4.  
  5. #define GPIO 12 //gpio 15 orange pi zero
  6.  
  7. int main()
  8. {
  9.  
  10. int speed = 1500; //MINIMO 1000 MAXIMO 2000
  11. wiringPiSetup();
  12. pinMode (GPIO, OUTPUT);
  13.  
  14. //INICIO CONTROLADOR ESC
  15. /*
  16. Pulsos de 2000us durante 2.5 segundos
  17.  
  18. |--------| pulso de 2000us para indicar el pulso mas alto al controlador ESC
  19. _______ 3.3v
  20. | | |
  21. | | |
  22. | |__________________________________| 0 V
  23.  
  24. |------------------------------------------| 20000 us periodo del controlador ESC
  25.  
  26. 2500 ms / 20 ms = 125 pulsos;
  27. */
  28. for(int i=0;i<125;i++)
  29. {
  30. digitalWrite(GPIO, HIGH);
  31. usleep(2000);//2ms
  32. digitalWrite(GPIO, LOW);
  33. usleep(18000);//18ms
  34. }
  35. /*
  36. Pulsos de 1000us durante 2.5 segundos
  37.  
  38. |----| pulso de 1000us para indicar el pulso mas bajo al controlador ESC
  39. ____ 3.3v
  40. | | |
  41. | | |
  42. | |______________________________________| 0 V
  43.  
  44. |-------------------------------| 20000 us periodo del controlador ESC
  45.  
  46. 2500 ms / 20 ms = 125 pulsos;
  47. */
  48.  
  49. for(int i=0;i<125;i++)
  50. {
  51. digitalWrite(GPIO, HIGH);
  52. usleep(1000);//1ms
  53. digitalWrite(GPIO, LOW);
  54. usleep(19000);//19ms
  55. }
  56. //FIN INICIO CONTROLADOR ESC
  57.  
  58. //Inicio Giro del motor
  59. while(1)
  60. {
  61. digitalWrite(GPIO, HIGH);
  62. usleep(speed);//us
  63. digitalWrite(GPIO, LOW);
  64. usleep(20000-speed);//us
  65. }
  66.  
  67. return 0;
  68. }
Add Comment
Please, Sign In to add comment