Nano clone L-led flickering randomly after first upload. No new uploads possible

Hi All,

I am a software guy, new to Arduino, and not very strong in electronics (however I have access to a 74 y/o father who is a retired electronics engineer and has a treasure of electronics equipment I can use. besides that I myself own a soldering station and a multimeter :slight_smile: )

The following has happened to me quite consistently while going through 5 Nano clones;
A fresh Nano connected to my PC via USB will happily accept Blink sketch (or any other). The blink will work for a while, but most of the time after a while (10 seconds - a few hours?), the L-led starts flickering randomly rather than blinking. When I try to load something else, or reload the Blink IDE reports any of the following

  • stk500_recv(): programmer is not responding
  • stk500_getsync() attempt 1 of 10: not in sync: resp=0x4a

Often with varying response codes. same behaviour with other sketches, among my own.
Occasionally it succeeds in uploading a new sketch.
It seems (cannot reproduce accurately) that when I leave a Nano unhooked for a couple of hours, the hook it up and immediately upload a sketch, it has the best chance of success. Success here means being able to upload. Running it is again almost always problematic.

I have one Nano that has been running my project code for a few weeks now, so i do not dare to hook it up to IDE.

Some facts

  • I run win10 and arduino IDE 1.8.12 and recently installed older version 1.8.8
  • tried PC and a laptop. Tried various USB ports of both machines
  • I have used Nano clones from two separate manufacturers
  • Installed CH340 drivers, confirmed correct COM port and board type in IDE
  • Tried both, the 328P and 328P (Old bootloader) configs
  • Tried 100s of combinations of: Restart IDE, Reconnect nano to USB, holding down / not holding down
    reset button while connecting - with various time intervals, etc.
  • Suspicious of static electricity, I wired myself and the Arduino GND to a separate ground from the wall outlet.
  • I verified earth/ground works in that wall socket.
  • I tried the Loop-Back Test as described on this forum, at every SEND I see RX and TX flickering, but no feedback in my monitor (Putty and Serial Monitor in Arduino IDE)
  • Tried to reburn the bootloader via a separate, fresh nano that i turned into ISP. After few tries the burning succeeded, but loading a sketch was again a pain.
  • My target project consists of a set up with a 28BYJ-48 stepper and ULN2003 driver. But new Nanos show described behaviour even when I install a sketch on a fresh board, before attaching the rest of the hardware.
  • I use 5v external power adapter , no ground. This goes into 5v and GND of board (not during
    programming, only when in my target project set up) and in parallel to 5v and GND of the Stepper controller. So i feed the stepper externally from the Nano's perspective

Now my question goes without asking probably; What is / could be wrong here?

Second to that; what does the flickering L-led mean? Is it the Reset being triggered? And if so, is there a reason why it triggers it? and is there a way (for debugging) to disable or pull down the reset circuit?

Any help is much appreciated!

Thanks
Remvs

P.s. For completeness my projects code below

* Controls 28BYJ-48 stepper motor driving my 3d printed clock
 * Moves clock minute hand forward 1 minute every 60 seconds
 * It self corrects its delay()
 */
 

#include <Stepper.h>
#define STEPS 2038                    // the number of steps in one revolution of your motor (28BYJ-48)
const unsigned int c_goal  = 60000;   // ultimate goal of total cycle time: 1 minute
unsigned long myTimeStart  = 0;       // Cycle start time
unsigned long myTimeActual = 0;       // Actual measured cycle time (ms)
unsigned int pause         = c_goal;  // delay in ms
int tmp_int;                          // Temp integer

Stepper stepper(STEPS, 8, 10, 9, 11);
     
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  stepper.setSpeed(15); // rpm
  //Initialize serial and wait for port to open:
  //Serial.begin(57600); while (!Serial) {  ;  } // wait for serial port to connect. Needed for native USB
  
} 

void loop() {
  /*
   * 
   * move clock forward 1 minute. Wait 60000 ms and measure how long full cycle actually took.
   * Calculate corrected Wait for next loop so that full cycle takes 60000 again
   */
  myTimeStart =  millis();
  //Serial.print("myTimeStart: "); Serial.println(myTimeStart);
  //Serial.print("pause: "); Serial.println(pause);
    
  stepper.step(STEPS*6.0404);               // 6 rotations == 1 minute on the clock dial -> 6.0416 to compensate for various losses (empirical)
                                            //                                              6.0416 -> 6.0404 to compensate for running 2 mins p/week fast
  delay(pause);                             // wait ~1 minute (self-corrects)
  
  myTimeActual = millis() - myTimeStart;    // calculate actual time spent for 1 cycle
  //Serial.print("myTimeActual: "); Serial.println(myTimeActual);
  
  tmp_int = myTimeActual - c_goal;          //Calc absolute deviation from goal ( abs() tolerates no function calls/calculations inside its belly )
  tmp_int = abs(tmp_int);

  //Correct length of next pause
  if (myTimeActual > c_goal) {
     // Actual cycle was a bit longer than our goal
     pause = pause - (tmp_int); //calculate next pause;
  } else if (myTimeActual < c_goal) {
     // Actual cycle was shorter than our goal
     pause = pause + (tmp_int); //calculate next pause;
  }  else {
     // pause was spot-on
  };
    
 //Serial.print("pause: "); Serial.println(pause);
}

UPDATE

I connected RST and 5v via a ~300 Ohm resistor and I could very easily upload 2 sketches! The upload was quick and clean and no flickering L-led.. Programs ran as well.

aAfter that I tried a 3rd sketch, with some added serial output to debug and see if setup() would be triggered more than once. And all of a sudden I as back to where I was; L-led flickers, albeit less bright/ often, and uploads fail. Found a 130 Ohm resistor but hat didn't do much either.

I got the idea from here

https://wiki.hackzine.org/hardware/arduino-disable-auto-reset.html

The big question is how you power the stepper(s)? Arduinos are not designed to power motors and the likes.

PS Karma added for using code tags in your first post.

sterretje:
The big question is how you power the stepper(s)? Arduinos are not designed to power motors and the likes.

PS Karma added for using code tags in your first post.

Sterretje, I power the stepper in parallel from the external power adapter:

remvs:

  • I use 5v external power adapter , no ground. This goes into 5v and GND of board (not during
    programming, only when in my target project set up) and in parallel to 5v and GND of the Stepper controller. So i feed the stepper externally from the Nano's perspective

happy to draw a picture if that helps

Feeding the steppers at run-time in parallel with the the Nano should be OK.

I suppose that you take the Nano out of your set-up for programming purposes?

A drawing will be useful.

Note:
I'm not a power specialist so might not be able to help further.

Thanks for your support!

Attached a drawing.

Please note that the Arduinos show the erratic behavior regardless of them being added to this hardware setup or not,or even having my projects code or the Blink sketch loaded.

Remvs

PS yes, I upload sketches to Arduinos when disconnected from this or any setup

Nano clones :
I have had some failures amongst these , notably with the USB interface . Not saying this is the case for yours but ......

It’s always worth buying at least one genuine device, from Arduino, they are high quality and work out the box - helpful for spotting faults on others . Best plan if you are starting out and it supports the cause too !

I would go back to basics , power the Nano via the USB connection, just ( try to) load blink , change the timings ( to prove you have uploaded) and run it for a while .
Worth using a finger to see if the regulator or usb chip gets hot . The fact they start to misbehave after running for a while ( on USB) suggests they are duffers.

hammy:
It’s always worth buying at least one genuine device, from Arduino, they are high quality and work out the box - helpful for spotting faults on others . Best plan if you are starting out and it supports the cause too !

yes! good idea, for both reasons given!

I gave it another shot, this time with the aim to pinpoint where things go wrong exactly:

  1. I unwrapped my 6th Nano clone and without soldering the pins, immediately hooked it up and uploaded Blink. That went fine. I played with the script a bit, added SIN() to do funny blinks and plot to Serial plotter. All to be able to upload 4 or 5 'different' sketches. I reconnected the Arduino a few times to the USB. All went without any issue. Scripts ran perfectly. I let it blink 'n plot for over an hour. All good so far.

  2. I then loaded my projects script (see original post). This also went fine. I added Serial.println() here and there. It seems the sketch stops when no physical controller / stepper is connected. But after pressing reset it immediately comes to life and does one half cycle. So I am fairly confident it is not the Arduino, nor the sketch (which I keep calling script, sorry..), but simply the lacking hardware. I solder the pins Upload Blink and I let it sit for a while. Finally I upload my project again. It all works like a charm.

  3. Now I hook it up to the controller and stepper motor (using mostly jumper wires). It runs for about 15 minutes when all of a sudden the 4 LEDs on the controller go out (a sure indication of failure I by now know).. #dammit.
    I start examining my set up and found the ground going from power supply to the Nano's GND to be blackened under the plastic cover of the jumper wire connector. The wire broke at the jumper connection when i took it off.

  4. I fixed the ground wire. I took another fresh Nano (I am running low by now), loaded my sketch, soldered the pins and hooked dit up to the circuit. It has been running for over 2 hours now....

TL;DR
A bad connection to the Nano's GND seems to have been the problem.

Sounds like you are overloading the regulator or noise from the motors are interfering with the Nano , crashing it out , maybe even corrupting the boot loader. ?

Are you sure it’s wired as per the diagram ? Burning wires is not a good sign.

hammy:
Sounds like you are overloading the regulator or noise from the motors are interfering with the Nano , crashing it out , maybe even corrupting the boot loader. ?

Are you sure it’s wired as per the diagram ? Burning wires is not a good sign.

I checked many times, so pretty sure.
Also the GND wire was corroded but there was no indication of heat (no melted plastic jumper plug).

Something else I noticed; the Arduino runs at 6-12V ideally; I just noticed I am running it on 5V. How likely is this the cause of the issue?

Your drawing shows it powered on the 5v pin , so 5v is right .

Thanks!

& Karma to all for your support!