Week Review 5/2/2024

Float Code and Electronics

PCB

This week on the float I made significant progress on the code. I needed to integrate the depth sensor code into the firmware for the float which presented a interesting timing challenge. Many sequences need to be kept in sync in order for the code to function correctly. I first wanted to convert my code to run entirely using millis() because I found that the alarm interrupt routine does not work with the Blue Robotics Depth Sensor Library because reading from the depth sensor takes too much time.

I wrote the following function so I could cleanly handle timing:

bool time_check(unsigned long starting_time, unsigned long current_time, unsigned long target_time) {
  if (current_time - starting_time >= target_time) {
    return (true);
  } else {
    return (false);
  }
}

This allows me to have blocking loops while also checking depth by using the following code snipet.

while (not(time_check(starting_time, millis(), TIME_FLOATING))) {
  check_depth();
}

Pesky Errors

I got the basic functionality of the float working, but I have a lingering error. Roughly 10% of profiles the microcontroller will reset mid profile, this poses an issue because it goes back into communication mode in that case. This happens when the motor is changing directions, I want to solve this error completely in the future, but as of right now we do not have time for a hardware solution.

I have two plans, first ramping up the motor speed until it reaches full speed to hopefully prevent any voltage drop. I wrote the code to do that, but I did not have enough time to test its functionality. If that does not completely resolve the error I plan on focusing fully on error recovery.

I will have a flag in EEPROM that has where the float is in its profiling sequence, and I will save the depth data in an EEPROM buffer as well. Whenever the microcontroller starts it will check that file to see where it is supposed to be so it should be able to recovery gracefully from errors.

After the regional competition I will try to diagnose the root cause of the issue, but in the meantime it needs to work.