Apart from interference with the 5v power supply, what other things should I be checking as possibly causing the Atmega 328s to reset. I can see that they are resetting via the start-up LED flash sequence.
I have built 2 Atmega 328s on pieces of strip board as part of a model railway control system. Each board controls about 5 servos and 5 relay modules on the basis of control signals sent by Serial from a Mega. Everything was working fine until we tried running a train on the tracks.
Running the train causes both Atmega 328s to reset occasionally - and not both at the same instant. Presumably the reset is caused by voltage spikes from the train power system as the problem only happens when the train is moving.
AFAIK there is no direct electrical connection between the 12v track power system and the 5v power for the Arduinos, servos and relays. The relays are used to switch the track power to different section of track. The 5v power comes from some mains powered switch-mode power units which (I think) came from China.
This is a traditional 12v DC power system (not DCC) so the under-board wiring and the control panel wiring is (to be kind) complex. There are many situations where the track power wires run parallel to the 5v DC power wires.
None of the I/O pins on the Atemga 328s are used to take inputs apart from the HardwareSerial connection that talks to the Mega. The reset problem has happened even with the serial wires disconnected.
My assumption is that there is induced interference between the 12v wiring and the 5v wiring - although my amateurish attempt to monitor the 5v supply with my oscilloscope did not show anything. However I hardly ever use the 'scope and I may not have been using it to best effect.
My present plan for the next test is to provide a completely separate 5v supply (ideally from a battery) for the 2 Atmega 328s and their servos and relays.
If anyone can suggest other things that are known to cause a reset I would very much appreciate it.