What's going on with Arduino Uno RX/TX? Can an Arduino Uno "forget" its own code

Hello,

I am using an Arduino Uno for a collision/obstacle detection module on a small automated guided vehicule.
The uno is powered through two 12V batteries connected in series (24v), we later use a power converted to get 5v for the Arduinos. the Uno uses a shield we made. Its single hardware RX/TX link is being used to communicate with a the slamtec A1M1 lidar module.

For this project, the Uno is just a slave device for a main Arduino Mega board. Since the Arduino Uno serial port is already used by the A1M1, then i opted for using two “classic” pins to make the mega <-> uno communication. With those 2 pins, I have only 4 statuses reported back: evering ok + presence of an obstacle in warning zone + in critical zone + A1M1 communicaiton error. It is therefore pretty hard to know what going on the Uno since we have no Serial communication and cannot really debug with USB due to te A1M1 <-> Uno communication.

I have been using this system since early July on 3 of those small vehicles. And for one of the them specifically, we noticed two strange behaviors:

  1. the Uno <-> A1M1 communication error rate much higher than the two other vehicles (from 0~2 errors per day versus 500+ errors per day. all errors randomly spread during the ~10h in the day when the vehicle is powered on).
  2. No Uno <-> A1M1 communication at all.

I fixed all issues #2 just by reflashing the Uno (I do that with the Arduino IDE). To be more precise, I unplug the A1M1 (so that the Uno reflash operation does not interfere with the A1M1), do the reflash using USB cable re-writing the same .ino file, then remove the USB clable and replug the A1M1.
I was really struggling with #1 until a few days ago, after changing ribbon cables one by one, after changing the A1M1, when I finally swapped the Uno entirely for a new one => errors were gone.
Yes i did check that GND are indeed connected. the A1M1 does accept 5V (but it needs additionnal power for its motors compared to what the Uno 5V pin can deliver, which is just fine.

Is there a way the Uno can “forget” its code because of the Serial communication that goes on pins 0 & 1 ? For instance because somehow the communication could trigger a “flash rewrite / flash erase” event?
(or reflash can only happen with USB port exclusively?)

I should mention that I always try to buy “genuine” arduino boards from “serious” shops (radio-spares and mouser in EU). I always keep myself away from arduino copies/clones.

It’s just fine if i had bad luck with one specific Arduino Uno board (it’s a Rev3 i believe, I can post serial number if required). My concern is that the observe behavior repeats itself over time due to a flaw in the design that I would have missed.

I do want to have two arduinos because i want to keep monitoring the A1M1 and a few switches on a bumper regardless of what the main code does (otherwise I would read the A1M1 from an available hardware serial port on the Mega)

=> under what condition can an Arduino Uno Rev3 “forget” its own code due to data going on pin 0 &1 ?

=> can a noisy 5V power produce an unexpected behavior on Arduino Uno that could explain the observations? (i will check with an oscilloscope soon)

=> Is there anything that can explain the observed behavior?

=> What would you suggest?

thanks

fourchette

fourchette:
=> under what condition can an Arduino Uno Rev3 "forget" its own code due to data going on pin 0 &1 ?

The first thing that would need to happen is to reset the Uno, which activates the bootloader. Next, there would need to be serial communication within the second or so the bootloader is activated. This serial communication would likely need to be in a form that is recognized by the bootloader and makes it write to the flash memory. I suspect that would be unlikely to occur by random chance.

fourchette:
=> can a noisy 5V power produce an unexpected behavior on Arduino Uno that could explain the observations? (i will check with an oscilloscope soon)

I think that's more likely. If the Uno is subjected to harmful conditions, it's possible the flash memory in the chip could be damaged or corrupted in a way that would break the program.

Ok. That helps.

The way the code is designed, when a bumper event is observed (typical digitalRead on a mechanical switch), then an output pin is set to 1, Wich causes the main board (that reads this pin) to stop the vehicle until that pin goes LOW again.
And the only way to put it back to low is by resetting the uno. Un order to do this, I use one of those excellent adafruit led arcade button that I turn on when the bump event occurs. This button is also a mechanical switch between gnd and rst pins I think.

I monitor those bumps events. When I did this design (force users to reset the uno), I thought bump events would rarely occur. In practice for reasons I will not develop here for the sake of clarity, such events can happen up to 40-50 times a day.

And when the reset button is pushed, surely the lidar continues to spin and send data on tx/rx.

Where can I find the protocol to reflzsh an arduino uno?