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
)
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);
}
