Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2026:vlad.radulescu2901:andrei.coman1301 [2026/05/16 23:08]
andrei.coman1301 Added Pinout Diagram
pm:prj2026:vlad.radulescu2901:andrei.coman1301 [2026/05/23 23:10] (current)
andrei.coman1301 [Jurnal]
Line 12: Line 12:
  
 ===== Descriere generală ===== ===== Descriere generală =====
 +{{:​pm:​prj2026:​vlad.radulescu2901:​software_block_diagram_coman_andrei_madalin_335ca.png?​700|}}
 {{:​pm:​prj2026:​vlad.radulescu2901:​block_diagram_coman_andrei_madalin_335ca.png?​700|}} {{:​pm:​prj2026:​vlad.radulescu2901:​block_diagram_coman_andrei_madalin_335ca.png?​700|}}
 {{:​pm:​prj2026:​vlad.radulescu2901:​pinout_diagram_coman_andrei-madalin_335ca.png?​700|}} {{:​pm:​prj2026:​vlad.radulescu2901:​pinout_diagram_coman_andrei-madalin_335ca.png?​700|}}
Line 38: Line 39:
   * 1x Analog FPV Goggles   * 1x Analog FPV Goggles
   * 1x Radio Control Transmitter   * 1x Radio Control Transmitter
- 
-<note tip> 
-(Not applicable I think but will keep it here just in case I need it later) Aici puneţi tot ce ţine de hardware design:  ​ 
-  * scheme electrice (se pot lua şi de pe Internet şi din datasheet-uri,​ e.g. http://​www.captain.at/​electronic-atmega16-mmc-schematic.png) 
-  * diagrame de semnal ​ 
-  * rezultatele simulării 
-</​note>​ 
  
 ===== Software Design ===== ===== Software Design =====
  
-Did not start this step yet.+==== Description of the firmware ====
  
-<note tip> +Custom flight controller firmware for the Happymodel X14 AIO board (STM32G473CEU6,​ Cortex-M4F @ 170 MHz). The firmware reads stick commands from a Radiomaster Pocket transmitter over an ExpressLRS 2.4 GHz link (CRSF protocol), reads angular rates from the on-board ICM-42688-P IMU, runs a rate-mode PID controller, mixes the result onto four motors via the DShot300 ESC protocol, and in parallel drives the analog OSD overlay (AT7456E), the video transmitter (SmartAudio),​ the battery ADC, and arming/​failsafe safety logic. 
-Descrierea codului aplicaţiei ​(firmware):​ + 
-  * mediu de dezvoltare ​(if any) (e.gAVR StudioCodeVisionAVR+Pure C11, no RTOS. A single super-loop with a cooperative scheduler dispatches tasks at fixed rates (IMU 8 kHz, control 4 kHz, RX 1 kHz, OSD 30 Hz, etc.); all I/O is interrupt or DMA-driven. 
-  * librării şi surse 3rd-party (e.gProcyon AVRlib+ 
-  * algoritmi şi structuri pe care plănuiţi să le implementaţi +==== Development environment ==== 
-  * (etapa 3surse şi funcţii implementate +  * **IDE:** JetBrains CLion 2026.1.2 
-</note>+  * **Build system:** PlatformIO Core 
 +  * **Framework:​** stm32cube (STM32CubeG4 HAL + CMSIS) 
 +  * **Board definition:​** a custom boards/​g473_custom.json written based on the datasheet 
 +  * **Flashing:​** STM32G4 USB ROM bootloader (DFU), no external programmer needed 
 + 
 +==== Libraries and third-party sources ==== 
 +  * **STM32Cube HAL (STM32CubeG4)** STMicroelectronics'​ official low-level library 
 +  * **CMSIS-Core** ARM's standard Cortex-M abstraction 
 +  * **STM32G4 ROM DFU bootloader** not a library, but a third-party-supplied flashing path used in place of writing a custom bootloader 
 +  * **dfu-util** open-source command-line tool invoked by PlatformIO to push firmware ​to the ROM bootloader 
 +  * **Protocol specifications** (data only, no imported code): CRSF (ExpressLRS/​TBS),​ DShot300 (Betaflight wiki), SmartAudio v2, AT7456E datasheet, ICM-42688-P datasheet 
 + 
 +==== Data structures ==== 
 +  * **Blackboard** A single global state_t struct holds every cross-module value: RC channels, IMU samples, PID setpoints, motor outputs, battery, arm/​failsafe flags, and diagnostic counters ​(worst-case RC gap, failsafe rising-edge count, last disarm cause)
 +  * **Task table** Fixed-size array of tasks (functions) indexed by a task_id_t enumEach iteration walks the table, calling any task whose next_due_us has passed and advancing it. 
 +  * **CRSF parse buffer** Fixed 64-byte frame buffer fed one byte at a time from the USART3 RX interrupt. 
 +  * **CRSF state machine** WAIT_SYNC -> READ_LEN -> READ_PAYLOAD -> VALIDATE 
 +  * **DShot DMA buffer** Per-motor 20-word array (16 frame bits + 4 reset-gap entries) written into TIM2 CCRx via DMA1 channels 1–4. 
 +  * **OSD frame buffer** Small array of (rowcol, stroverlay items rebuilt each frame and pushed into the AT7456E character RAM over SPI2. 
 +  * **Per-axis PID state** Static array of three {integ, prev_err, gains} recordsNo dynamic allocation anywhere in the firmware. 
 +   
 + ==== Algorithms ==== 
 + 
 +  * **Cooperative scheduler** Monotonic 32-bit microsecond clock from the DWT cycle counter; uses unsigned subtraction so the comparison stays correct across the ~71 minute wrap. 
 +  * **PID rate controller** Per-axis discrete PID with integrator clamp and output clamp. Integrator and derivative state are reset on every disarm -> arm transition to avoid wind-up from pre-arm stick movement. 
 +  * **Gyro bias auto-calibration** 1000-sample running average of the gyro signal at boot while the drone is stationary; subtracted from every subsequent sample. Calibration is gated by an IMU-still check before the FC is allowed to arm. 
 +  * **Quadcopter mixer** Standard X-configuration mix of throttle/​roll/​pitch/​yaw onto four motors. Outputs are scaled by throttle so the controller cannot demand torque at idle; if any motor saturates, the throttle floor is raised to preserve control authority. 
 +  * **DShot300 bit encoding** 11-bit throttle + 1-bit telemetry-request + 4-bit XOR CRC, encoded as PWM duty 375/1000 for a "​1"​ and 188/1000 for a "​0",​ emitted bit-perfect by TIM2 + DMA with no CPU involvement. 
 +  * **CRSF parser** Byte-fed state machine with CRC-8 (poly 0xD5validation, 11-bits-per-channel unpacking, and link-statistics decode (RSSI, LQ, SNR). 
 +  * **Failsafes** Various safety checks (RC timeout > 250 ms, low battery, etc.). If any trigger, motors are commanded to zero and the FC is force-disarmed. 
 +  * **Arming gate** Bitmask `arming_block` aggregates the set of reasons arming is currently denied ​(boot lock, IMU not calibrated, low battery, failsafe active, arm switch already up at boot). 
 + 
 +   
 +==== Sources ==== 
 +  * **GIT**: https://​github.com/​Coman-Madalin/​FPV-Drone-Firmware
  
 ===== Rezultate Obţinute ===== ===== Rezultate Obţinute =====
Line 91: Line 119:
 {{:​pm:​prj2026:​vlad.radulescu2901:​hardware_progress_5_coman_andrei-madalin_335ca.jpeg?​300|}} {{:​pm:​prj2026:​vlad.radulescu2901:​hardware_progress_5_coman_andrei-madalin_335ca.jpeg?​300|}}
  
 +**23 May 2026** ​  
 +  * Finished Firmware
 +<​html>​
 +<iframe width="​450"​ height="​800"​
 +src="​https://​www.youtube.com/​embed/​LJKSUzEXZfQ"​
 +frameborder="​0"​
 +allow="​accelerometer;​ autoplay; clipboard-write;​ encrypted-media;​ gyroscope; picture-in-picture;​ web-share"​
 +allowfullscreen></​iframe>​
 +</​html>​
 ===== Bibliografie/​Resurse ===== ===== Bibliografie/​Resurse =====
  
-https://​www.happymodel.cn/​index.php/​2025/​10/​09/​x14-elrs-5-in-1-aio-flight-controller-built-in-2-4g-uart-elrs-v3-0-and-openvtx/​+https://​www.happymodel.cn/​index.php/​2025/​10/​09/​x14-elrs-5-in-1-aio-flight-controller-built-in-2-4g-uart-elrs-v3-0-and-openvtx/ ​ 
 + 
 +https://​www.st.com/​resource/​en/​datasheet/​stm32g473cb.pdf 
 + 
 +https://​deepwiki.com/​ExpressLRS/​ExpressLRS/​3.1-crsf-protocol-and-router ​  
 + 
 +https://​betaflight.com/​docs/​wiki/​guides/​current/​Dshot 
 + 
 +https://​www.team-blacksheep.com/​media/​files/​tbs_smartaudio_rev09.pdf
  
 +https://​product.tdk.com/​system/​files/​dam/​doc/​product/​sensor/​mortion-inertial/​imu/​data_sheet/​ds-000347-icm-42688-p-v1.6.pdf
  
  
pm/prj2026/vlad.radulescu2901/andrei.coman1301.1778962128.txt.gz · Last modified: 2026/05/16 23:08 by andrei.coman1301
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0