Brushless motor with reverse.

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rovbuilder
 
Posts: 18
Joined: Mon Aug 07, 2017 7:45 am

Brushless motor with reverse.

Post by rovbuilder »

Hi, my motor (A2212/13T - http://www.rhydolabz.com/documents/26/B ... 12_13T.pdf) beeps quickly and constantly (about 3 times per second) when hooked up to the ESC (Hobbyking 10A car ESC - https://hobbyking.com/en_us/hobbykingr- ... verse.html).

I'm using an Uno to control the motor, this is the code :

Code: Select all

    #include <Servo.h>//Using servo library to control ESC
    Servo ESC; //Creating a servo class with name as esc
    int throttle = 0;  //Variable for the throttle setting.
    #include <PSUSB.h>

    // Satisfy the IDE, which needs to see the include statment in the ino too.
    #ifdef dobogusinclude
    #include <spi4teensy3.h>
    #endif
    #include <SPI.h>

    USB Usb;
    /* You can create the instance of the class in two ways */
    PSUSB PS(&Usb); // This will just create the instance
    //PSUSB PS(&Usb,0x00,0x15,0x83,0x3D,0x0A,0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch

    bool printAngle;
    uint8_t state = 0;

    void setup()
    {
      Serial.begin(115200);   
      while (!Serial);
      Serial.println("Connect ESC");
      delay(2500);  //Allow the user...........time to connect the battery to the ESC. 
      ESC.attach(8,600,2250);
      throttle = 180;  
      Serial.println("Setting throttle to max");
      ESC.write(throttle);   
      delay(2500);
      throttle = 0;  //Set the throttle to zero
      Serial.println("Setting throttle to min");
      ESC.write(throttle);  //Set the ESC signal to the zero position.
      delay(2500);  // allow a delay for the ESC to signal that it is done.
      throttle = 90;  //Set throttle to the neutral position.
      Serial.println("Setting throttle to neutral");
      ESC.write(throttle);
      delay(2500);
      Serial.println("Done");
      delay(2500);
      #if !defined(__MIPSEL__)
      while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
      #endif
      if (Usb.Init() == -1) {
      Serial.print(F("\r\nOSC did not start"));
      while (1); //halt
    }
      ;Serial.println("PSUSB Library Started");
      ;delay(1500);
      
      
    }
    
    void loop()
    {
      int val;
      Usb.Task();
      //Serial.println(F("\tLeftHatY: "));
      //Serial.println(PS.getAnalogHat(LeftHatY));
      val=PS.getAnalogHat(LeftHatY);
      val= 180-map(val,0,255,1,180); //mapping val to minimum and maximum(Change if needed) 
      if (val<4) val=4;
      Serial.println(val);
      ESC.write(val);//using val as the signal to esc
    }
     
The motor doesn't beep when hooked up to a servo tester, so it's not the data lead off the motor, i've tried multiple connecting leads for the data pin, tested the Uno, all is good.

Previously this setup was working (i've tried since with 3 different units of the same ESC with same result), but i'd left it on the bench since September and now it just beeps.

If it was working before that means my PWM settings are correct, what else could it be?

Do ESCs lose their programming after a while, should i find my card and check that?

Image attached to show wiring.


Thanks for any help, Gary :)
Attachments
wiring.jpg
wiring.jpg (560.75 KiB) Viewed 336 times

User avatar
rovbuilder
 
Posts: 18
Joined: Mon Aug 07, 2017 7:45 am

Re: Brushless motor with reverse.

Post by rovbuilder »

All the code that says PS* i had to change because PSThree is a spam word (surely code shouldn't be scanned for spam?).

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Brushless motor with reverse.

Post by adafruit_support_bill »

You'll need to check the manual for your ESC. Many of them use beeps as feedback during programming or to indicate that they are armed.

User avatar
rovbuilder
 
Posts: 18
Joined: Mon Aug 07, 2017 7:45 am

Re: Brushless motor with reverse.

Post by rovbuilder »

Thanks support, turns out it was me being forgetful, days i've been struggling with this, turns out i just forgot to ground the ESC !


Thanks, Gary.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Brushless motor with reverse.

Post by adafruit_support_bill »

Good to hear that you solved it. Thanks for the follow-up.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”