I have been frustrated by a problem with my robot. Each time I would go outside to test, the robot’s processor would hang. I tried various tactics in getting to the bottom of the problem. The real bummer was that my log files would always be empty files. I had nothing to go on.
Well over the last few days, I realized the empty log files were as a result of not commiting or syncing the data to the FAT. I was just writting and writting and only at the end of a run would I press the magic button to close the file. So I added a sync command every second to at least capture up to the last second before the crash.
What I found in my new log files was troubling. It was logging thousands of invalid commands to my debug serial port. I had a phantom hacker!
Well when I go outside to test, I disconnect the FTDI USB to logic level serial cable. When I did that, I left the processor’s RX line disconnected. Any noise on that line would look like a byte. That byte would then get logged to the SD card. But the SD SPI lines ran close to the RX line. In short order I would get a firestorm of bad bytes that would overwhelm the processor.
Solution: A single 10K pullup resistor on the RX line keeps out the noise when the cable is disconnected.