Inspiration PDB - Updates

Board updates!

Kill Switch

The first thing we needed was a kill switch to connect to the board and tell it when to turn both mosfets off. We chose to use magnetic swtiches so that we then wouldn’t need anything to penetrate through the case (just the magnetic field). The switch connected to the board over a vertical JST-PH connector.

Comms

We also wanted to be able to allow the board to communicate to the high-level-controller, a Jetson Xavier, to report battery data. This was done over usb with some simple Serial protocol. On the board side:

void hlcReport() {
  if (micros() - hlcReportPrevUpdate > HLC_REPORT_INTERVAL) {
    char report[100];
    sprintf(report, "[%lu,%s,%s,%s,%s]", millis(), String(batt1V, 3).c_str(), String(batt1Curr, 3).c_str(), String(batt2V, 3).c_str(), String(batt2Curr, 3).c_str()); 
    Serial.write(report);
    memset(report, 0, sizeof(buffer));
  }
}

And on the HLC side (in python)

import serial
import serial.tools.list_ports

def establishPort(port=None):
  if port:
    pdb_port = port
  else:
    available_ports = list(serial.tools.list_ports.comports())
    for port in available_ports:
      if "ItsyBitsy M0 Express" in port.description:
        pdb_port = port.device
  
  return serial.Serial(port=pdb_port, baudrate=115200, timeout=1)


def getBattInfo(serial_device):

  if serial_device.in_waiting:
  
    output = serial_device.readline().decode('ascii').strip()
    incoming = output[output.rfind("[") : len(output) - 1].split(",")
    data = {"Timestamp" : incoming[0], "Batt1V" : incoming[1], "Batt1Curr" : incoming[2], "Batt2V" : incoming[3], "Batt2Curr" : incoming[4]}
    return data
  else :
    return None


def main():

  serial_device = establishPort()

  while True: 
    getBattInfo(serial_device)


if __name__ == "__main__":
  main()

In actuality, this will be running in a ROS node with its own loop, so the while loop isn’t necessary. I just included it here since the pyserial device needs to exist in order to buffer the serial data from the board.

Peripherals

Beeper: I added some beep commands to show when battery states are changing or a battery is low Current: By interfacing to the ACS781, we now have current data logged SD Card: Error data is logged on the card to hopefully help us in teh case that something breaks

… and lots of redundancy in the code to make sure that this thing never fails!

You can see the full project here.

Problems / Mistakes

None so far! The board is working really well, and the sub is happily swimming in the water :D.

That’s all for now!