# mikeflanigan/kroova_sbe architecture

> Architecture diagram of the GitHub repository mikeflanigan/kroova_sbe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mikeflanigan/kroova_sbe
- Repository: https://github.com/mikeflanigan/kroova_sbe

## Overview

Kroova_SBE is a collection of experimental electronics and software for an electronic foiling moth. The principal runtime workflow reads ultrasonic ride-height data, applies servo-control logic, and drives a servo; separate programs record sensor and flight data to CSV. The tree also documents sensor-reader sketches, a control GUI, and simulation work. The sampled controller and logger excerpts support the main calls and data flows; most other branches are represented only by filenames, so their internal relationships are left unspecified.

Main entry points: [`SBE_moth.py`](https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_moth.py) (Ride-height controller), [`Moth_Data_Logging.py`](https://github.com/mikeflanigan/kroova_sbe/blob/master/Moth_Data_Logging.py) (Moth data logger), [`SBE_functions.py`](https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_functions.py) (Serial and servo helpers), [`BBB_ball_tilt.py`](https://github.com/mikeflanigan/kroova_sbe/blob/master/BBB_ball_tilt.py) (Ball-tilt controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Flight control"]
  node_control_app["Ride-height controller<br/>[SBE_moth.py]"]
  node_tilt_controller["Ball-tilt controller<br/>[BBB_ball_tilt.py]"]
  node_wing_controller["Wing controller<br/>[SBE_wing.py]"]
  node_combined_controller["Control and logging"]
  node_control_params["Control parameters"]
  node_serial_helpers["Serial and servo helpers<br/>[SBE_functions.py]"]
end

subgraph group_logging["Data logging"]
  node_data_logger["Moth data logger"]
  node_rev2_logger["Rev2 data logger<br/>[SBE_Logging.py]"]
  node_rev2_helpers["USB mount helpers<br/>[SBE_funcs.py]"]
end

subgraph group_sensors["Sensors and firmware"]
  node_lidar_i2c["LIDAR I2C sketch"]
  node_lidar_pwm["LIDAR PWM sketch"]
  node_lidar_wire["LIDAR Wire sketch"]
  node_toughsonic_sketch["ToughSonic sketch<br/>[ToughSonicRead.ino]"]
  node_rev2_arduino["Rev2 Arduino firmware<br/>[SBE_ardu.ino]"]
end

subgraph group_experiments["Interfaces and experiments"]
  node_gui["Control GUI<br/>[SBE_GUI.py]"]
  node_simulation["Foil simulation"]
  node_tilt_model["Ball-tilt model<br/>[Ball_Tilt_Model.py]"]
end

node_operator(("Operator"))
node_servo["Servo hardware"]
node_ride_sensor["Ultrasonic sensor"]
node_csv_data[("CSV recordings")]
node_usb_storage[("USB storage")]

node_operator -.->|"runs"| node_control_app
node_control_app -->|"loads"| node_control_params
node_control_app -->|"calls"| node_serial_helpers
node_control_app -->|"reads"| node_ride_sensor
node_control_app -->|"drives"| node_servo
node_tilt_controller -->|"imports"| node_serial_helpers
node_tilt_controller -->|"reads"| node_ride_sensor
node_tilt_controller -->|"drives"| node_servo
node_wing_controller -->|"imports"| node_serial_helpers
node_wing_controller -->|"reads"| node_ride_sensor
node_wing_controller -->|"drives"| node_servo
node_combined_controller -->|"loads"| node_control_params
node_combined_controller -->|"reads"| node_ride_sensor
node_combined_controller -->|"writes"| node_csv_data
node_data_logger -->|"imports"| node_serial_helpers
node_data_logger -->|"reads"| node_ride_sensor
node_data_logger -->|"writes"| node_csv_data
node_data_logger -->|"mounts"| node_usb_storage
node_rev2_logger -->|"imports"| node_rev2_helpers
node_rev2_logger -->|"writes"| node_csv_data
node_rev2_logger -.->|"uses"| node_usb_storage
node_operator -.->|"uses"| node_gui

click node_control_app "https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_moth.py"
click node_tilt_controller "https://github.com/mikeflanigan/kroova_sbe/blob/master/BBB_ball_tilt.py"
click node_wing_controller "https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_wing.py"
click node_combined_controller "https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_moth_log_n_control.py"
click node_control_params "https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_control_params.csv"
click node_serial_helpers "https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_functions.py"
click node_data_logger "https://github.com/mikeflanigan/kroova_sbe/blob/master/Moth_Data_Logging.py"
click node_rev2_logger "https://github.com/mikeflanigan/kroova_sbe/blob/master/___Rev2_CodeBase/SBE_Logging.py"
click node_rev2_helpers "https://github.com/mikeflanigan/kroova_sbe/blob/master/___Rev2_CodeBase/SBE_funcs.py"
click node_gui "https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_GUI.py"
click node_simulation "https://github.com/mikeflanigan/kroova_sbe/blob/master/Electronically_Foiling_Moth_Simulation.m"
click node_tilt_model "https://github.com/mikeflanigan/kroova_sbe/blob/master/Ball_Tilt_Model.py"
click node_lidar_i2c "https://github.com/mikeflanigan/kroova_sbe/blob/master/LIDARLite_I2C_Library_GetDistance_ContinuousRead/LIDARLite_I2C_Library_GetDistance_ContinuousRead.ino"
click node_lidar_pwm "https://github.com/mikeflanigan/kroova_sbe/blob/master/LIDARLite_PWM_GetDistance_ContinuousRead/LIDARLite_PWM_GetDistance_ContinuousRead.ino"
click node_lidar_wire "https://github.com/mikeflanigan/kroova_sbe/blob/master/LIDARLite_Wire_Library_GetDistance_ContinuousRead/LIDARLite_Wire_Library_GetDistance_ContinuousRead.ino"
click node_toughsonic_sketch "https://github.com/mikeflanigan/kroova_sbe/tree/master/ToughSonicRead/ToughSonicRead.ino"
click node_rev2_arduino "https://github.com/mikeflanigan/kroova_sbe/blob/master/___Rev2_CodeBase/SBE_ardu/SBE_ardu.ino"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_control_app,node_tilt_controller,node_wing_controller,node_combined_controller,node_control_params,node_serial_helpers toneBlue
class node_data_logger,node_rev2_logger,node_rev2_helpers,node_csv_data,node_usb_storage toneAmber
class node_lidar_i2c,node_lidar_pwm,node_lidar_wire,node_toughsonic_sketch,node_rev2_arduino toneMint
class node_gui,node_simulation,node_tilt_model toneRose
class node_operator,node_servo,node_ride_sensor toneIndigo
```

## Components

### Flight control

- [Ride-height controller](https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_moth.py): `SBE_moth.py`
- [Ball-tilt controller](https://github.com/mikeflanigan/kroova_sbe/blob/master/BBB_ball_tilt.py): `BBB_ball_tilt.py`
- [Wing controller](https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_wing.py): `SBE_wing.py`
- [Control and logging](https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_moth_log_n_control.py): `SBE_moth_log_n_control.py`
- [Control parameters](https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_control_params.csv): `SBE_control_params.csv`
- [Serial and servo helpers](https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_functions.py): `SBE_functions.py`

### Data logging

- [Moth data logger](https://github.com/mikeflanigan/kroova_sbe/blob/master/Moth_Data_Logging.py): `Moth_Data_Logging.py`
- [Rev2 data logger](https://github.com/mikeflanigan/kroova_sbe/blob/master/___Rev2_CodeBase/SBE_Logging.py): `___Rev2_CodeBase/SBE_Logging.py`
- [USB mount helpers](https://github.com/mikeflanigan/kroova_sbe/blob/master/___Rev2_CodeBase/SBE_funcs.py): `___Rev2_CodeBase/SBE_funcs.py`

### Sensors and firmware

- [LIDAR I2C sketch](https://github.com/mikeflanigan/kroova_sbe/blob/master/LIDARLite_I2C_Library_GetDistance_ContinuousRead/LIDARLite_I2C_Library_GetDistance_ContinuousRead.ino): `LIDARLite_I2C_Library_GetDistance_ContinuousRead/LIDARLite_I2C_Library_GetDistance_ContinuousRead.ino`
- [LIDAR PWM sketch](https://github.com/mikeflanigan/kroova_sbe/blob/master/LIDARLite_PWM_GetDistance_ContinuousRead/LIDARLite_PWM_GetDistance_ContinuousRead.ino): `LIDARLite_PWM_GetDistance_ContinuousRead/LIDARLite_PWM_GetDistance_ContinuousRead.ino`
- [LIDAR Wire sketch](https://github.com/mikeflanigan/kroova_sbe/blob/master/LIDARLite_Wire_Library_GetDistance_ContinuousRead/LIDARLite_Wire_Library_GetDistance_ContinuousRead.ino): `LIDARLite_Wire_Library_GetDistance_ContinuousRead/LIDARLite_Wire_Library_GetDistance_ContinuousRead.ino`
- [ToughSonic sketch](https://github.com/mikeflanigan/kroova_sbe/tree/master/ToughSonicRead/ToughSonicRead.ino): `ToughSonicRead/ToughSonicRead.ino`
- [Rev2 Arduino firmware](https://github.com/mikeflanigan/kroova_sbe/blob/master/___Rev2_CodeBase/SBE_ardu/SBE_ardu.ino): `___Rev2_CodeBase/SBE_ardu/SBE_ardu.ino`

### Interfaces and experiments

- [Control GUI](https://github.com/mikeflanigan/kroova_sbe/blob/master/SBE_GUI.py): `SBE_GUI.py`
- [Foil simulation](https://github.com/mikeflanigan/kroova_sbe/blob/master/Electronically_Foiling_Moth_Simulation.m): `Electronically_Foiling_Moth_Simulation.m`
- [Ball-tilt model](https://github.com/mikeflanigan/kroova_sbe/blob/master/Ball_Tilt_Model.py): `Ball_Tilt_Model.py`

### Other components

- **Operator**
- **Servo hardware**
- **Ultrasonic sensor**
- **CSV recordings**
- **USB storage**

## Connections

- Operator → Ride-height controller: runs
- Ride-height controller → Control parameters: loads (evidence: `SBE_moth.py`)
- Ride-height controller → Serial and servo helpers: calls (evidence: `SBE_moth.py`)
- Ride-height controller → Ultrasonic sensor: reads (evidence: `SBE_moth.py`)
- Ride-height controller → Servo hardware: drives (evidence: `SBE_moth.py`)
- Ball-tilt controller → Serial and servo helpers: imports (evidence: `BBB_ball_tilt.py`)
- Ball-tilt controller → Ultrasonic sensor: reads (evidence: `BBB_ball_tilt.py`)
- Ball-tilt controller → Servo hardware: drives (evidence: `BBB_ball_tilt.py`)
- Wing controller → Serial and servo helpers: imports (evidence: `SBE_wing.py`)
- Wing controller → Ultrasonic sensor: reads (evidence: `SBE_wing.py`)
- Wing controller → Servo hardware: drives (evidence: `SBE_wing.py`)
- Control and logging → Control parameters: loads (evidence: `SBE_moth_log_n_control.py`)
- Control and logging → Ultrasonic sensor: reads (evidence: `SBE_moth_log_n_control.py`)
- Control and logging → CSV recordings: writes (evidence: `SBE_moth_log_n_control.py`)
- Moth data logger → Serial and servo helpers: imports (evidence: `Moth_Data_Logging.py`)
- Moth data logger → Ultrasonic sensor: reads (evidence: `Moth_Data_Logging.py`)
- Moth data logger → CSV recordings: writes (evidence: `Moth_Data_Logging.py`)
- Moth data logger → USB storage: mounts (evidence: `Moth_Data_Logging.py`)
- Rev2 data logger → USB mount helpers: imports (evidence: `___Rev2_CodeBase/SBE_Logging.py`)
- Rev2 data logger → CSV recordings: writes (evidence: `___Rev2_CodeBase/SBE_Logging.py`)
- Rev2 data logger → USB storage: uses
- Operator → Control GUI: uses
