Strange lockups caused by several things, underlying electrical issue?

Hi,

I've made a simple quadcopter flight controller (schematic included) with an Arduino Nano, which has a curious (likely)electric problem that has me confused pretty well.

TLDR: among other things, putting 5cm wires on a wireless module "fixes" random resets when touching battery wire insulation. Photos, code and schematics included.


It's a pretty simple thing, and it does have decoupling caps on all the logic IC:s (Arduino, APC220 wireless, MPU6050 IMU). With everything connected, the Arduino will lock up after a few seconds, unless I physically touch the battery wire insulators. I'm thinking it's some curious capacitive problem, with which I don't have much experience :o

I've gone through the connections with a continuity checker and everything is solid, I can also shake the board around without problems so I doubt there are loose connections. Board gets it's 5v from the Arduino's regulator which is fed from a 3S lipo. Regulator keeps steady at 4.98V at all times when measured with a multimeter. The MOSFET's are F12N10L, but these issues crop up even when they are ignored (Arduino pin on their gate set to low, and never changed), and they work great. I think it's not about them either.

The program is simple, for testing it reads raw gyro values from the MPU and sends them through the wireless serial module. It has run without crashes for hours on end, and on a breadboard the wireless serial and MPU6050 work with this code without a hitch.

Some odd results of trying to debug this thing:

If the APC220 wireless module is not connected to the actual rx/tx pins, everything runs perfectly and serial data can be read through the USB without issues. Touching the Arduino's tx pin to the module's RX freezes it. The Arduino doesn't listen to the serial, so I don't really see how this could cause any problems, but it does trigger this issue somehow.
It does not crash if the APC220 module is connected with ~5cm long wires to it's socket on the board.

If serial data is not sent, everything again runs well. Sending anything locks it up. Not reading the gyro allows everything else to run without lockups, including wireless serial.
I have tested with 3 different Arduino's, all of which show the same behaviour.

Having the board run 4 brushed motors of about ~4 amps each at variable PWM frequencies (tested all prescalers) and at variable duty cycles never causes any problems. Yet when a person lets go of the battery wires, the crash is nearly instant. I have managed to cause crashes by having the arduino pull a digital pin high that's not connected to anything, and just touching the board edge. How can this happen?

I'm pretty much out of ideas at this point, so any help is much appreciated :slight_smile: atic

Terranova.ino (7.44 KB)

Terranova.pdf (34.6 KB)

Is the APC220 connected correctly? Vcc to Arduino's TX pin; Rx connected to Arduino's 5V.

Ah, I made an error in the schematic, updated now. It's connected correctly, it can send and receive data.

You're powering everything from the Arduino as far as I can see; maybe a separate supply for the peripherals if the Nano can't supply enough power from the 5V.

And your motors use the same supply as the Arduino; maybe a solid buffer capacitor on the line that feeds the Arduino? But I'm now getting outside my area of expertise :wink:

sterretje:
You're powering everything from the Arduino as far as I can see; maybe a separate supply for the peripherals if the Nano can't supply enough power from the 5V.

And your motors use the same supply as the Arduino; maybe a solid buffer capacitor on the line that feeds the Arduino? But I'm now getting outside my area of expertise :wink:

The combined power requirement of the gyro and the APC is ~40 mA, the regulator should handle this easily. It doesn't get hot, and the output stays at a solid 4.98V.

There is a 100uF cap on the input, but I don't think the motors are the issue as they are not connected during testing. And when they are, they cause no problems. I too think this is odd, since they ought to be a much bigger source of interference than a finger's capacitance on the battery wire, or a random, disconnected pin being written "high" :o

Jopj:
, or a random, disconnected pin being written "high" :o

Have you got the unconnected pins configured with pullup or pull down resistors enabled ?

Boardburner2:
Have you got the unconnected pins configured with pullup or pull down resistors enabled ?

The one I managed to cause a crash with was an output for testing. I'm not doing anything for the rest, which I think means they default to inputs without pullups.

This whole problem is truly something I've never encountered before, I'm sitting here scratching my head wondering how can these things have any effect on anything :frowning:

I got this "solved" by putting angled headers onto the APC220 wireless so that it points 90 degrees up. I have no idea why this is so, but it seems solid afterwards. I'm not really comfortable with this board since I never found out what's wrong with it.

It's just serial input? Even if the wireless was picking up some interference, how could garbled serial input crash everything when it's just parsed for integers?

Guess mysteries will be mysteries.

That's a 20mW transmitter, so it could easily affect nearby circuitry if poorly placed and the nearby
circuitry not in a metal can.

MarkT:
That's a 20mW transmitter, so it could easily affect nearby circuitry if poorly placed and the nearby
circuitry not in a metal can.

Really?

Hmm, that does make sense. I only thought about the circuit affecting the transmitter, not the other way around.. It was mounted basically next to the Arduino, and over some of the jumper wires that seemed to have an effect on the behaviour. Good call!

I wonder what kind of interference this actually is, that makes the board lock up. Induced voltage spikes? Re-writing some register/memory values if that's even possible? Quite interesting..

I have managed to cause crashes by having the arduino pull a digital pin high that's not connected to anything, and just touching the board edge. How can this happen?

I would configure all unused analog and digital pins with INPUT_PULLUP to reduce susceptibility to external interference. Otherwise, the high impedance input pins (default) act like antennae.