Running MULTIPLE engines with Mega2560

Hello world. I'm having issues running my setup with my Mega2560. I'm hoping someone will notice something EASY that I missed... but I'll take any ideas on how to get this up and running. I have uploaded a video (address below) which I hope will help.

Here is the setup:
Power: 9S LiPo battery for motor/escs. 2S LiPo battery for additional power for the escs.
ESCs: 3x Phoenix ICE2 HV 80 ESC
Motors: 3x Himax HC5030-390
Board: Arduino Mega2560

Problem:
The engines are not running as it should. To be more specific, they are running when they are not supposed to. The original program had the UAV testing the controls one by one in the following order:

  1. Left yaw vane
  2. Right yaw vane
  3. Left engine
  4. Right engine
  5. Back engine

Please note that the code has them running ONE AT A TIME.
However, the engines were going crazy (please see video) so I'd thought to isolate the problem by commenting out steps 2-5. So now only the left yaw vane should be tested. However, the engines are still running.

The engines are starting from 0% thrust to 10% then 20% like it's supposed to, but that bit of code is commented out. Also, the throttle commands are separated by a delay(1000) command, but they are running with each other. Not quite at the same time, but one after another, starting before the others had a chance to wind down. The video should make more sense.

The Video:

Code: The entire code has 13 headers/files... but most of those are for the 9DOF stick. I've attached the ones that involve the control stuff.

UAVHover_1_0ctrltest.ino (816 Bytes)

CtrlEngine.ino (883 Bytes)

CtrlYawVanes.ino (757 Bytes)

gln6fgsl:
Problem:
The engines are not running as it should.

How are they supposed to run?

How are they actually running?

Sorry, that post was made a few minutes before I had to leave the house. I've modified the post to be more descriptive as well as the link to the video that finally finished uploading. Please take a look and tell me what you think.

I have no idea what's going wrong, but it looks like a fundamental problem to me. There may be a wiring fault, or a power supply problem, or memory corruption/exhaustion, or any other problem causing your sketch to produce undefined behaviour.

I suggest you put the whole project to one side and write a test sketch that does nothing but initialise and test one of the actuators/motors, and make sure you can successfully control each one in isolation. Then bring them together and ensure you can control them all concurrently in a single sketch without any problems. Then do the same for your sensor inputs and prove that you are getting solid accurate inputs before you try to do anything with them. Only then is it worth trying to introduce your complex control algorithms.

Thanks for the ideas PeterH, although I haven't started using the inputs from the sensor yet. Assuming the individual tests go alright, how would you start bringing them together? Any particular order? I was thinking the individual testing, then the yaw vanes (2) then start adding the escs one by one.

I also had a couple ideas and I'd like some advice on them...

  1. On the mega there is pin slots for analog, digital and pwm(?). Would switching from analog to one of the others have any effect?

  2. I was looking at an older post where you mentioned the following. "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." I do use the gnd from the 2S LiPo there... If I used the same gnd for the servos for the escs, but supplied power through the 2S LiPo, connecting the LiPo gnd into a slot with nothing in it... what do you guys think?

  3. I am using a breadboard to connect all the pins. Is there something that better makes connections on the wires? Did that make any sense?

Report back when the tests are all working. By then you will almost certainly have figured out some of the other answers.

...R

gln6fgsl:
Assuming the individual tests go alright,

gln6fgsl:
connecting the LiPo gnd into a slot with nothing in it...

I don't know what that means. The grounds all need to be connected together.

Breadboard is OK as a way to connect low current circuits together. It's probably not a good bet for connecting high current circuits such as motor power supplies. Chop block electrical connectors are a convenient way to make temporary connections for bigger cables.

My project has three power sources. The primary source, powering the ESC/motors is my 9S LiPo. The circuit/controller has two power sources. One is the D battery/usb connection from the Mega, powering my yaw vanes. The final power source is my 2S LiPo and a UBEC powering the... the escs?

Actually, one side note. My ESCs are Castle Creations ICE HV2 80s, currently discontinued. It has 2 big wires that connect to the battery, 3 big wires that connect to the motor and a three wire cable that connects to the 'transmitter,' which in this case is the Mega. What am I powering with the positive/gnd wires on the cable? I get why a signal line is needed, but why the other two? What are we powering?

Back on topic, my 'circuit' is a bread board. I have a 5V and a gnd wire connected to one side of the board, and the 2S LiPo (which goes through my UBEC) to a positive and a gnd wire on the other side of the board. These are on the pos/neg 'lanes' on either side of the breadboard. What I was thinking was if I connect all the gnd wires from both yaw vanes and the ESCs to the gnd 'lane' from the Mega while keeping the ESC pos wires connected to the 2S LiPo/UBEC 'lane'. I was wondering if the ESCs not being connected to the gnd from the UBEC was going to be a problem.

I hope that actually made some sort of sense.

gln6fgsl:
I hope that actually made some sort of sense.

More or less. The ESCs will have a low current supply to power the electronics and a high current supply which is passed through to the motors.

All the grounds of your various power supplies need to be joined together.

Sorry for the late reply, I just got back in town. And thank you for the answer, I've been wondering about why it needed a second power source. It's a bit late tonight, but I'll try hooking up the grounds together Tuesday morning.