School project ( helicopter)

Discussion in 'The Projects Forum' started by hcwickz, Oct 31, 2011.

  1. hcwickz

    Thread Starter New Member

    Oct 31, 2011
    21
    0
    Hello everyone !

    i am building a rc helicopter. But prior to that , i have to make my dc motor workable first. i had connected the esc to the motor and battery.
    The only part i had not been successful is the dc motor. i made it running
    on my first attempt and it still beep, but it went to vibrative mode the next few trys when it still beep. I am not sure if its the hardware fault or lie on my programming code.

    Anyone enlighten me pls ?
     
  2. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    Hi, and welcome. :)

    I think you need to tell a bit more about your school project, and what you have done so far. A good idea is attaching both you schematics and your source code. For the source code I urge you to use the #-button on the top of the editor. It's called 'code-tags' and makes your source code a lot more readable.
     
  3. hcwickz

    Thread Starter New Member

    Oct 31, 2011
    21
    0
    This is the code below ( not look like is a valid code for running a motor )
    That is my suspect. i dun hav a schematic diagram . but i assume the connection is correct as i hear a beep sound . So far , i has completed the connection of esc . But the motor still not moving . i have been looking for many code examples to make it run ><


    #include <Servo.h>
    Servo myservo; // create servo object to control a servo
    Servo myservol;
    byte incomingByte;
    int val;
    int vall; // variable to read the value from the analog pin
    void setup ()
    {
    Serial.begin(9600);
    myservo.attach(10);
    myservol.attach(11);

    }
    void loop()
    {
    val =analogRead(A0);
    vall=analogRead(A1);
    if (Serial.available())
    {
    incomingByte=Serial.read();
    Serial.print(int(incomingByte));
    if ((int(incomingByte)==254))
    {
    val=Serial.read();
    Serial.print(int(val));
    }
    if ((int(incomingByte)==255))
    {
    vall=Serial.read();
    Serial.print(int(vall));
    }
    }
    myservo.write(val);
    delay(15);
    myservol.write(vall);
    delay(15);
    }
     
  4. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    This is what your code looks like in with code-tags.

    Code ( (Unknown Language)):
    1.  
    2. #include <Servo.h>
    3. Servo myservo; // create servo object to control a servo
    4. Servo myservol;
    5. byte incomingByte;
    6. int val;
    7. int vall; // variable to read the value from the analog pin
    8. void setup ()
    9. {
    10.   Serial.begin(9600);
    11.   myservo.attach(10);
    12.   myservol.attach(11);
    13.  
    14. }
    15. void loop()
    16. {
    17.   val =analogRead(A0);
    18.   vall=analogRead(A1);
    19.   if (Serial.available())
    20.   {
    21.   incomingByte=Serial.read();
    22.   Serial.print(int(incomingByte));
    23.   if ((int(incomingByte)==254))
    24.   {
    25.     val=Serial.read();
    26.     Serial.print(int(val));
    27.   }
    28.   if ((int(incomingByte)==255))
    29.   {
    30.     vall=Serial.read();
    31.     Serial.print(int(vall));
    32.   }
    33. }
    34. myservo.write(val);
    35. delay(15);
    36. myservol.write(vall);
    37. delay(15);
    38. }
    How about telling what compiler you are using? And not so important, the IDE?

    I see a

    Code ( (Unknown Language)):
    1. void setup()
    and

    Code ( (Unknown Language)):
    1. void loop()
    but I do not find any

    Code ( (Unknown Language)):
    1. void main()
    Don't you think you need that last one?

    Also, I'd rename the variables, to a little more self explaining name.
     
  5. hcwickz

    Thread Starter New Member

    Oct 31, 2011
    21
    0
    i am using arduino . i had try different sort of codes . some of this codes
    work for most people to run the motor , but mine cant . the motor still
    continue to vibrate. Btw i am using an analog joystick to run the motor.
     
  6. hcwickz

    Thread Starter New Member

    Oct 31, 2011
    21
    0
    anyone help ? is the above code is anything that deal with pwm ?
     
  7. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    Ok, you're talking about an RC helicopter which AFAIK usually uses a brushless (BLDC) motor, then you mentioned an "ESC" (electronic speed controller); a term which I have only ever seen applied to BLDC controllers in RC hobby applications, so that makes me 99% sure you're talking about a BLDC. is your arduino sending a signal to the ESC, which in turn is supposed to control the motor? If so, is your ESC set up to recognize a PWM signal? Better yet, what is the make/model of your ESC? can you post a link to it? or are you trying to control the motor directly with the Arduino? if so, that will not work; the arduino only puts out 40mA and you need 3 phases and semi-sophisticated commutation control program.
     
  8. hcwickz

    Thread Starter New Member

    Oct 31, 2011
    21
    0
    ya my objective is to make two motors run in forward and backward direction using one analog joystick (1 pot) . i am not sure if my arduino is sending signal to the esc and i not sure about setting up of the pwm signal . i am very lousy in programming . As this is my final year project , my teacher will not tell me its model. Btw, my arduino is powered up via usb cable from the computer . my motor is connected to the last 3 output of the esc. Currently , i have 2 batch of codes with me i could use . i not sure if that is about the signal thingy u are saying about . i will post the code below
     
  9. hcwickz

    Thread Starter New Member

    Oct 31, 2011
    21
    0
    int val=0;
    int vall=0;
    byte ser=0;
    byte serl=0;

    void setup() {

    Serial.begin(9600);
    }

    void loop() {

    val=analogRead(A0);
    vall=analogRead(A1);

    ser=map(val,0,1023,55,125);
    serl=map(vall,0,1023,55,125);
    Serial.print(254,BYTE);
    Serial.print(ser);
    Serial.print(255,BYTE);
    Serial.print(serl);

    delay(80);
    }
     
  10. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    hah? you must have the esc in front of you correct? or how else would you know it isn't working? has your instructor filed off the model number? what would be the point of this exercise if you aren't allowed to know how to interface with the ESC? I'm afraid I can't help you at all without knowing what kind of esc you have.
    how is this code related to your project? all it does is read 2 analog signals (potentiometers?) and scale them to a range of 55 - 125 and then print the number to your computer's serial monitor. it does not send any signal out to the esc.
     
  11. hcwickz

    Thread Starter New Member

    Oct 31, 2011
    21
    0
    ya is in front of me , but i cant see any name from the esc . ok i check it out wit him sooner or later. i find it from the internet and not sure if this is workable for my project. okay so isnt related ? btw , the first attached code earlier work for 2 servo motors using analog joystick but not 2 dc motors . any idea ? sorry for those noob questions.
     
  12. Feign

    Active Member

    Mar 30, 2009
    50
    2
    A beeping speed controller indicates an error, you need to know the manufacturer to decode them.

    Most implement a safe start, you need to move the throttle to full and back to zero to arm them, or some other "voodoo dance", after you connect the battery.
     
Loading...