Skip to content

Hardware & Firmware Documentation

HannahCutler edited this page Aug 30, 2024 · 4 revisions

Overview

The smartfin hardware is made up of a Particle board, combined with a ICM-20948 (IMU + DMP (Digital Motion Processor)), MAX31725, GPS, and a wet-dry sensor, which allow us to determine acceleration, angle, relative position, water contact, temperature, and general location. These elements are combined in a development board, and in an assembled PCB. The hardware should run embedded C++ code to rotate through its various states, collect accurate data, and send this data back to a database after each surf session. The hardware testing setup also included a Particle Development board and ICM Development Kit.

PCB

The following briefly overviews the current Smartfin PCB (XA0, AKA Version 3.0).

Below is an image of the PCB V2. Red is connected to VBUS, white is connected to USB- (D-), green is connected to USB+ (D+), and black is connected to GND. To upload code to the new PCB, these wires were soldered onto the Smartfin PCB Rev XA0 (version 3). This will allow us to flash and test the new PCB.

Screenshot 2024-08-29 at 2 00 01 PM

Below is the full development board assembly, with GPS, Particle board, IMU, and temperature sensor. It’s important to keep all pins plugged into the foam when not in use to prevent accidental shorts. The board can be powered both from the computer and from the attached battery. The two switches near where the battery attaches to the board control where the power comes from. The color of the indicator light gives the state of the board according to THIS documentation.

Screenshot 2024-08-29 at 2 02 10 PM

Datasheets and Libraries

IMU Hardware Datasheet

IMU Sparkfun Arduino Library

IMU Firmware & Register Datasheet

IMU InvenSense DMP Readme (SparkFun)

Temperature Sensor Datasheet

GPS Module

Software/Firmware

All data collection files are in the SRC file in the repo, broken up by individual sensors into folders. States, tasks, and scheduler are also in the SRC file. All modules are in the lib folder (Ublox GPS, Location Services, Sparkfun ICM, etc). See HERE for scheduler documentation.

Uploading & Flashing

  • Install VSCode

  • If on Ubuntu, install 2020 VSCode version or earlier (new versions have a bug)

  • Make a particle account and password

  • Install Particle Workbench on VSCode. Create a Particle account and login in terminal

  • Clone git repo recursively in order to get all files. If repo is already cloned, use git submodule update -—init -—recursive

  • Install ICM_20948.h file

  • Install CRC32 if not already installed

  • Turn on Switch 6 on the Development Board for USB power

  • For device Asset Tracker Monitor One, [email protected]: Make sure Device ID is selected (e00fce68432f6ede72157b61). Use local compile → flash application (local). If it doesn’t automatically enter DFU mode when flashing (LED will be red), press the RESET and MODE buttons, release RESET, wait for the LED to turn from purple to yellow, then release RESET. The board should now be in DFU mode and ready to flash again.

  • For device Tracker SoM, [email protected]: Make sure you have the correct deviceID (e00fce68a74c41df28b61a2b). To test code, local compile → flash application (local). If DFU does not automatically start (yellow flashing light during flash), then use particle usb dfu to force the device into DFU mode.

  • Use port /dev/ttyACM0 + #CLI to access picoCOM port

  • Use sudo picocom /dev/ttyACM0 -–imap lfcrlf command to access CLI & picocom

  • -–imap lfcrlf will map lf to crlf so that a newline will be used and the formatting issue with the output will be fixed

  • ‘q’ exits the menu

PCB Hardware Testing

To test the PCB, we followed this procedure:

  • Connect to a controlled power supply which is current restricted
  • Use the current source in Sealab with a digital display
  • Make sure that amperage starts high and goes low
  • Voltage should go directly up, then stay high and constant at 5V
  • Don’t switch up GND and VBUS
  • Plug into the computer and power it on, it should enumerate as a USB device
  • If it doesn't show up in listed USB devices, swap D+ and D-. If it still doesn't, there's a bigger issue.

For full documentation of the results of PCB testing, see the hardware changes Wiki here.

Activating Board

  • On plugin, PCB loaded and turned on with a blink program with blue offboard LED (D1), began blinking on USB connection and registered as a USB device with Ubuntu laptops.
  • Boots in listening mode. Must manually use the SN, DevID, ICCID, or IMEI codes to activate the particle device in the particle dashboard. This will automatically activate an additional SIM card.
  • Activate SIM card and connect to cellular. This process should have a green LED.
  • Flash code. This should result in a flashing green light and a flashing yellow light which implies DFU mode.
  • A solid yellow light means the device flashing has failed.

PCB Software Testing

IMU times out with no response during whoamitest, wire.requestFrom

  • Solution: Must uncomment line 29, ICM_20948_C.h

Sampling DMP with delay resulting in No FIFO Data Available error, so all values were random since not correctly reading the packet

  • Fix: Eliminated delay before reading, to read directly from the correct FIFO registers
  • Result: more accurate DMP data, but uncalibrated.

DMP Accuracy does not give us consistent numbers → outputs garbage but garbage doesn’t change

  • Fix: matched up unions, moved accuracy header comparison to a separate function to get lined up union checks.
  • Issue: Registers for accuracy are entirely separate from registers for acceleration. More work needs to be done to get accuracy.

Next Firmware Steps

Calibration of IMU using the ACCEL_CAL_RATE, ACCEL_ALPHA RATE, & ACCEL_A_VAR registers still needs to be done. There are ongoing issues with this use case, and a helpful thread with the SparkFun representatives can be found here.

To implement calibration, the functions ICM_20948_Status_e writeDMPmems(unsigned short reg, unsigned int length, const unsigned char *data) and ICM_20948_Status_e readDMPmems(unsigned short reg, unsigned int length, unsigned char *data) will likely need to be used.

The IMU Firmware and & Register Datasheet will be useful for this firmware development process.