School project ( helicopter)

Thread Starter

hcwickz

Joined Oct 31, 2011
21
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 ?
 

nerdegutta

Joined Dec 15, 2009
2,684
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.
 

Thread Starter

hcwickz

Joined Oct 31, 2011
21
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);
}
 

nerdegutta

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

Rich (BB code):
#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);
}
How about telling what compiler you are using? And not so important, the IDE?

I see a

Rich (BB code):
void setup()
and

Rich (BB code):
void loop()
but I do not find any

Rich (BB code):
void main()
Don't you think you need that last one?

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

Thread Starter

hcwickz

Joined Oct 31, 2011
21
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.
 

strantor

Joined Oct 3, 2010
6,798
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.
 

Thread Starter

hcwickz

Joined Oct 31, 2011
21
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
 

Thread Starter

hcwickz

Joined Oct 31, 2011
21
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);
}
 

strantor

Joined Oct 3, 2010
6,798
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
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.
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);
}
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.
 

Thread Starter

hcwickz

Joined Oct 31, 2011
21
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.
 

Feign

Joined Mar 30, 2009
50
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.
 
Top