Serial communication optimization - Starwars X-wing

Hello everybody. This is a general question on optimizing and debugging serial communication.

The code seems to work well when I2C devices are connected and powered directly from Arduino but randomly stops working when several I2C devices are used with external Vcc.

There are very idiosyncratic issues that come up. For example, I spent two days just troubleshooting this single issue:
DAC has pull-up resistors built in but they are supposed to be disabled since Arduino has it’s own pull-up for I2C. This was working fine during the prototyping but then I discovered that pull-ups need to be enabled on the DAC if its not powered directly from Arduino (if external vcc is used). Also, this issue doesn’t come up if there are no other i2c devices connected in parallel. it took 2 days of random trial and error to figure this out.

P.S. Little background on the project: We are building 23ft Xwing fighter to raise money for an elementary school STEM program - it’s been 5 year adventure but we are starting to see the proverbial light at the end of the tunnel.

Interior electronics are complete and here is a video to give you a glimpse. Finishing exterior as well (attached picture). The cockpit electronics and wings opening/closing is controlled separately with 3 Arduinos and we finished these couple years back.

The current effort is for the drivetrain. There are two motors at each of rear landing gear and the idea is to make sure to “smooth” out the throttle input since these motors carry so much weight. Also, to monitor current in each motor and stop the craft if the current exceeds allowable limit.

There are very idiosyncratic issues that come up. For example, I spent two days just troubleshooting this single issue:
DAC has pull-up resistors built in but they are supposed to be disabled since Arduino has it’s own pull-up for I2C. This was working fine during the prototyping but then I discovered that pull-ups need to be enabled on the DAC if its not powered directly from Arduino (if external vcc is used). Also, this issue doesn’t come up if there are no other i2c devices connected in parallel. it took 2 days of random trial and error to figure this out. Many other similar issues but I think it’s working currently without “freezing” Arduino up but, I am sure, something else will come up again soon.

May the Force be with you

sensor_measure6_functions_reverse_check3.ino (10.7 KB)