Arduino Micro card crashing after a few day of use.

Hi everyone,

I am asking your help because I haven't find any similar problem on the forum, I am a beginner.
I built a DIY midi shield with an arduino micro to control 2 servomotors in real time using Ableton live.
It works perfectly but after a few days of use, at one point the card crash, the signal is strongly disturbated, it becomes unusable, the servomotor become mads. The Led on the card is still on, but the card doesn't work anymore.

I have retried several times, but it's always the same after a few days, the card crash. It's not an arduino one, it's an elegoo, I have been told that it could be the reason or the power supply, which is not really qualitative, and maybe not stable enough.

Here is a picture of the circuit. If you have any ideas, it would be really helpfull.
Thanks a lot.

How about a complete schematic showing all power sources, grounds, interconnections, like the format you posted, not a frizzy thing. Post links to each of the hardware items. Include the software as well.

Yes I'm sorry I thought for problem could have come from the card only

Power supply
DMX King (Led driver)
LED 96 + 120 Px

Arduino Nano
Servomotor LDX 227

Cable :
Shielded Cable ( for data )
Power cable ( a similar one)

Soft
Ableton Live 10 Lite
Resolume Arena 6.0.0

And here is the schematic with all the connection, I am sorry if it's not really clear I have made it several times and could not make something clearer...

I don't know if it can help but this is the code inside

#include <MIDI.h>
#include <Servo.h>

Servo myservo1;
Servo myservo2;

#define SPEED 1
// vitesse de 1 à 1000

// quand SPEED == STEP_TIME : ~1 sec pour faire 180° (ou 270° selon le servo)
// quand SPEED == 1000 : mouvement instantané
// ne pas mettre 0, rien ne bougera !

#define STEP_TIME 3 // milliseconds
#define STEP_USEC SPEED // pulse step  

MIDI_CREATE_DEFAULT_INSTANCE();

long next_update = 0;
int target1 = 1500;
int target2 = 1500;
int position1 = 1500;
int position2 = 1500;


void handle_ease(){
  if(millis() > next_update){    
    next_update = millis() + STEP_TIME;

    double change1 = (target1 - position1);
    if(change1 > 0) change1 = min(STEP_USEC*1.0,  change1);
    if(change1 < 0) change1 = max(STEP_USEC*-1.0, change1);
    position1 = (int)round(position1 + change1);
    myservo1.writeMicroseconds(position1);

    double change2 = (target2 - position2);
    if(change2 > 0) change2 = min(STEP_USEC*1.0,  change2);
    if(change2 < 0) change2 = max(STEP_USEC*-1.0, change2);
    position2 = (int)round(position2 + change2);
    myservo2.writeMicroseconds(position2);

  }
}

void setup() {
myservo1.attach(3);
myservo2.attach(4);

MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library.
MIDI.setHandleControlChange(MyCCFunction); // This command tells the MIDI Library
}
void loop() { // Main loop
MIDI.read(); // Continuously check if Midi data has been received.
handle_ease();
}

void MyCCFunction(byte channel, byte number, byte value) {
switch (number) {
case 22:
target1 = map(value, 0, 127, 600, 2400);
break;
case 23:
target2 = map(value, 0, 127, 600, 2400);
break;

}
}

The 1A servos will disturb the power supply rails when they start and stop, so you will need to decouple with capacitors; and also at the Arduino.
I dont quite understand why you built a midi controller to control servos.

Anyway we will need the schematic of that controller.

My first guess would be that the +5 OR GND is getting spikes. You will need to look at the layout of the ground.

Have you wondered why the PSU has two connections for +V and -V ?

You may also need to look at the mains ground connections - where is the whole circuit grounded?

Thanks for your help. I give your karma, for sure.

Well that’s to control them synchronised with sound and video, maybe not the easiest way but....
here is the schematic of the controller.

I am not sure that I understand very well : would it mean that it comes from the motors, which are « making » or « sending » (I don’t know how to say) spikes ?
I should use some capacitors between the motors and the card ? I guess I can find on the forum how to know which capacitor to use ?
Also Motors are not powered enough, I thought it makes them just less powerful but could it be a reason ?

I know use the Vin instead of the 5V

The whole circuit is grounded by the PSU to the ground of the room. About the two -V and +V : Well people used to use those kind of PSU never told us that there could be a difference between both but actually I never asked myself...

I don’t get what is the layout of ground, I couldn’t find any valuable translation...

b8268b2e-05ed-4474-9381-9d62ca697d30.jpg

b8268b2e-05ed-4474-9381-9d62ca697d30.jpg

I built a DIY midi shield with an arduino micro to control 2 servomotors

I was misled by this statement and your diagram which shows the "midi controller" sending signals to the servos.

You need big electrolytic caps across the power pins at the servos. 1000uF or more.

And maybe 100uF or more across the Arduino.

Your rails should be "star" connected as shown in the diagram - that helps prevent disturbance of the power rails.

Read this: Common ground and why you need one - General Electronics - Arduino Forum

Well I've already read this topic but it makes a while.
My schematics wasn't clear, sorry about that,I already use the star grounding, the whole circuit is connected such as your second schematics.

I've also read this topic that goes in the same direction.

If I understand well I should use 3 capacitors, same one, at least 1000μF one on the board between Vin and Gnd, and 2 other ones on each servos ?
I've been told that the capacitors should be placed as close as possible of the servos...

I bought those capacitors, the black one

Can you explain how the shields are connected on the cables delivering data to the servos?

My suspicion is you may have created a big loop antenna here. Each signal wire needs to
travel alongside a ground-return wire, to avoid creating a loop in the signal path. If the shield
is connected to ground at both ends you may be OK (but will have a ground-loop), but if only
at one end it does nothing to prevent magnetic interference.

I'd definitely use separate power for the servos from any logic boards, that alone could account
for occasional crashes due to spikes/dropouts on the supply. Servos and motors can create
really dirty voltage noise on the rails. Logic devices need stable spike-free power.
Failing that copious decoupling with 1000µF or greater caps on the 5V may be needed.

Once you have separate power you can break the ground-loop and have the data+ground
cables as the only ground connection between servos and Arduino. That would be good.

You've some howlers in the code about handling timeouts:

long next_update = 0;

...

void handle_ease(){
  if(millis() > next_update){    
    next_update = millis() + STEP_TIME;

    ...

  }
}

This will break for several reasons. First next_update is signed, so once it goes negative the
test comparing it to millis() will always trigger. next_update needs to be "unsigned long" just
like the result from millis().

Secondly you will hit the wrap-around issue as there's no subtraction in the test. Wraparound
for millis() is on the order of weeks/months though, so its not likely to be your problem, but it
does need fixing like this:

void handle_ease(){
  if(millis() - next_update > STEP_TIME){    // subtraction essential to avoid wrap-around issues
    next_update += STEP_TIME;   // no need to call millis() again, just schedule next update

[ you might want to rename "next_update" as "prev_update" to match the logic ]

The point of the subtraction is that it returns a value that is always representable as an unsigned long, and always correct, even across wrap-around. This is since computer hardware and thus C integers use arithmetic modulo a power of 2.

Hi, thanks, for your reply !

There's a dupont wires connected to the card's pin for a few centimeter soldered to a shielded cable that goes to the servo's data, but yes I haven't use the shield of the wire (poor me), I can link the data's shield to the GND of the servo and the card. But will it be enough to prevent from spikes, or should I use capacitors anyway ?

This time, I really can't use 2 power supplies (it's in a small box that I can't modify, but for next time, I'll use 2 different one, I clearly see the point now...), but I could use a phone power cable to power the card, that would prevent from circuit's dropouts, but not from spikes due to the data cable ? (that the ground loop would help, or/and capacitors ?)

Thanks for the code, I understand the issu, I'll try once I set a better circuit, that won't make the card crashs...

Hello !
Just to say that I found the solution to my problem. I needed to use transistor between the card and the servo's data.
Here is the new circuit's. No need to use 2 power supplies (even if it would be better for sure)

Thanks for your help. I've learned a lot of things.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.