On power issues
I wrote a quick C++ program (src/krex/src/util/powermon.cc) to dump the current, power, voltage, and temperature every millisecond; I found that when I was saving to file on the SD card, the immediate power off would cause me to lose data. So, I used nc(1) to pipe the data to my laptop, and it was revealing.
Each line in the log file is a comma-separate list of values; for example, a representative baseline with nothing running is
That's 240mA of current, 1.205W, 5.024V, and 34ºC.
Let's take a look at what happens when I initiate a driving action:
432,2132,4936,34500 432,2132,4936,34000 432,2132,4936,34000 432,2132,4936,34500 432,2132,4936,34000 432,2132,4936,34000 432,2132,4936,34000 432,2132,4936,34000 424,2092,4936,34500 424,2092,4936,34500 424,2092,4936,34500 424,2092,4936,34500 424,2092,4936,34500 424,2092,4936,34000 424,2092,4936,34000 424,2092,4936,34500 424,2092,4936,34500 424,2092,4936,34500 424,2092,4936,34500 424,2092,4928,34500 432,2132,4936,34500 432,2132,4936,34000 432,2125,4920,34000 432,2111,4888,34000 440,2140,4864,34000
You can see the current usage stabilize around 430 mA with a power usage of 2.1W. The temperature remains about constant. The voltage, however, starts dropping:
You can see a current spike when the motors start, and that's when the voltage starts to drop. From Nvidia's docs:
The critical point is that the Jetson Nano module requires a minimum of 4.75V to operate.
The voltage drop from the current spike is pretty clearly causing the undervoltage. So, what can I do? Well, I think the easiest thing is to cut up a USB cable, providing output for both the motor hat and the Jetson. I could probably buffer voltage using a cap, too.
Not the most confidence-inspiring power setup :)
Honestly, what I need to do is to build out a battery pack for this. Maybe an 18650-based LiPo pack, I don't know. The USB power pack is both convenient and a real pain. Ideally, if I could get something the size of the PowerCore 10000 with a pair of USB ports, that would be nice. So power is going to be an issue for a bit until I can sort it out, and I'm backpacking next week, so nothing will get done. I can probably find some time tonight to wire up a battery pack to it though to at least verify my hypothesis about the issue.
On I2C issues
Thankfully, these appear to be sorted out, except for the lidar. For that, I think I need to create a second class of I2C interface that has separate read and write file descriptors.
Once I set up the MPU9250 properly, the initialization problems went away and all seems well with it. Now I need to actually add an interface to the data from it, and support the AK8963 magnetometer.
I mirrored the current sources to Github, and I'll update it occasionally as I get things working.