Running engines with Mega2560

Hello world, can someone help me figure out why my engines aren't running? I have a 10S LiPo battery, a Phoenix ICE2 HV 80 ESC and a brushless motor connected to a breadboard and an Arduino Mega 2560. Please note, I am using the arduino to control the motor instead of a receiver/throttle stick setup.

When I run my program, the motor beeps 5 times, which according to the manual means:

Radio Signal: Signal from receiver is corrupt or non-existent. Check transmitter and receiver.

The motor occasionally has run on this setup, so I think the power is being fed ok, although the motor has run for brief periods while I was trying to figure things out. The signal wires seem to be connected, nice and solid... Am I missing something? I'm going outside to hook up the battery to the charger and see what the reading on that is. But if you have any ideas, please let me know. Thank you.

Before I forget, here is the code I'm using.

************** CtrlEngine.ino
#include <Servo.h>
#include <Wire.h>

Servo eng1; // Engine left of nose.
const int pinEng1 = A8;

void armEngs()
{
eng1.attach(pinEng1);
setThrottle1(0);
delay(1000);
}

void setThrottle1(int thrust)
{
int angle = map(thrust, 0, 100, 0, 180);
eng1.write(angle);
}

************** UAVHover1_0ctrltest.ino
#include <Servo.h>
#include <Wire.h>

void setup()
{
Serial.begin(9600);
armEngs();
}

// Main loop
void loop()
{
setThrottle1(10);
delay(2000);
setThrottle1(20);
delay(2000);
setThrottle1(00);
delay(2000);
}

gln6fgsl:
The motor occasionally has run on this setup, so I think the power is being fed ok, although the motor has run for brief periods while I was trying to figure things out.

Do you mean it's an intermittent problem? If so, concentrate on finding ways to make it come and go.

Oh, and please use [ CODE ] [ /CODE ] tags when posting code. You've been here long enough to know that by now.

Intermittent, like it spun up once or twice in 10 minutes without any input or changes in wiring. I'm wondering if the Serial.begin(9600) might be interfering somehow. And, actually, no one told me about [ CODE ] [ /CODE ] . What does it do?

[ CODE ] [ /CODE ]
This is a sample so I can what this does.
Please ignore these lines.

That intermittent behaviour supports the theory that the Arduino output is not quite what the motor controller is looking for - but is close enough that it manages to lock on to something occasionally.

If I were you I'd be looking for wiring faults and make sure all the grounds were sound. If something was floating, you might get this sort of behaviour.

The CODE tags tell the forum software that the enclosed text should be displayed exactly as-is and not interpreted as forum control codes. Insert code tags by clicking the # button when you're editing your post.

// Like this

Can you clarify something is 'floating'?

Is this coding?

Is it working now?
Okay, the brackets and the words code not capitalized is working. 
Note to self: Keep code in between brackets.

Thank you for that tidbit, by the way.

gln6fgsl:
Can you clarify something is 'floating'?

I mean that something which is supposed to be connected to the Arduino ground is not actually at the same voltage as the Arduino ground.

If your Arduino is producing a 5V PWM signal but the motor controller ground is at higher voltage than the Arduino ground then the motor controller would not see the full 5V.

That message from the motor seems rather strange. In what application does the motor receive a signal from
a controller ? Usually, the ESC receives control signals, and the motor just behaves according to the current
which the ESC supplies to it.

To michinyon: The application is a UAV, and the motor is connected and controlled by a ESC. I've been assuming when PeterH says motor controller, he means a ESC. But again, assuming.

To PeterH: The ESC is connected to a breadboard, and I'm using the +/- slots on the sides. Those slots(? What are they called?) Are connected to the Mega's 5V and Gnd pin. The signal is coming from the analog pin number 8. But none of that should cause floating, should it?

I would consider dropping the servo.write commands using degree values, as that assumes rather non standard min and max pulse widths that the servo library uses as default values and your ESC may not like them. So change:

void setThrottle1(int thrust)
{
  int angle = map(thrust, 0, 100, 0, 180);
  eng1.write(angle);
}

To:

void setThrottle1(int thrust)
{
  int value = map(thrust, 0, 100, 1000, 2000); // convert 0-100% throttle to 1000 to 2000 usec servo pulse
  eng1.writeMicroseconds(value);
}

Lefty

That did it. Thank you again, retrolefty. And thank you all for taking a look and suggesting.

Hi, I'm using PhoenixICE240HV and Hi-Flow Thruster 400HFS-L, power source has 12V/10A.
I'm trying to control via arduino, but unsuccessfully.
Accordingly to user manual I'm gererating 1,5 ms pulse -neutral,than full rev - 1ms than full fwd(2ms).

ARDUINO CODE :

#include <Servo.h> 
Servo myservo;
void setup() 
{ 
  myservo.attach(3);
}
void loop() {
  myservo.write(95); // 1,5 ms -> neutral 
  delay(5000);
  myservo.write(45); // 1 ms -> full reverse
  delay(5000);
  myservo.write(145); // 2 ms -> full forward
  delay(5000);
}

CONNECTION :
Phoenix ICE2 HV 40 is connected to power source, thruster, and to arduino (brown line to arduino GND, orange line to arduino pin 3 (PWM)).

Motor doesn't rotate, only beeps. Please,do you know, where is a error?
Thank you so much indeed.
Tomas.

Did you seriously just hijack a thread AND missed the whole part about the code tags? Did you read the thread you hijacked?

Sorry next time I'll use this tags.
Tomas

I would suggest trying what retrolefty suggested just 3 posts above. It seems to have solved the original posters problem which is the same as yours.

Just saw the hijacking. ... Hope retrolefty's advice helped you as well as it did me. And it seems you got the code tags. :slight_smile: Well, have a good day folks.