
Closed deck x4
OpenLogicEFI/Hardware
Hardware is based off an open source project called Speeduino by Josh Stewart.

基于《综合实验》任务书的文字识别器项目:用 8 个 TCRT5000 红外反射传感器排成一条直线,通过定时器分时驱动 + ADC 采集扫描纸片上的数字字符,数据经 USB 串口上送 PC;PC 端重建图像并训练识别模型,模型经 ST Edge AI 量化为 int8 部署到板载 STM32G0B1RBT6,扫描完成后直接在单片机上推理,结果经 LED 数码管显示(置信度≥30%,保持 5s)并通过串口输出 0-9 各数字概率。
AI PCB SCH is an open-source printed circuit board by Lone-Jade, from the Lone-Jade/My_IntegratedDesignAndPractice_A repository on GitHub. It is a 2-layer board of 100 × 60 mm with 73 parts on 98 nets, routed with 463 tracks and 94 vias.
It is built around the CH340N, TCRT5000 and AMS1117-3.3, with the 2N7002K among its other parts. Its parts include 42 resistors, 12 ICs, 8 capacitors, 8 transistors and 2 connectors. It belongs with the STM32 boards of this library.
基于《综合实验》任务书的文字识别器项目:用 8 个 TCRT5000 红外反射传感器排成一条直线,通过定时器分时驱动 + ADC 采集扫描纸片上的数字字符,数据经 USB 串口上送 PC;PC 端重建图像并训练识别模型,模型经 ST Edge AI 量化为 int8 部署到板载 STM32G0B1RBT6,扫描完成后直接在单片机上推理,结果经 LED 数码管显示(置信度≥30%,保持 5s)并通过串口输出 0-9 各数字概率。
本仓库为按开发阶段整理的提交归档:每个目录是一份独立快照(含必要依赖,可单独使用),供提交/存档/评审使用。
flowchart TD
SEN["8×TCRT5000 反射传感器<br/>U1..U8 直线排列"] --> MCU
subgraph MCU["STM32G0B1RBT6(64MHz)"]
TIM["TIM6 2ms 节拍<br/>更新中断驱动"]
DRV["分时驱动<br/>逐路点亮 LED[n]:PD0..PD6/PD8"]
ADC["ADC1 单通道转换<br/>PA0..PA7 逐路切换"]
UART["USART1 115200<br/>21B 二进制帧 + [AI] 结果行"]
AI["板载推理<br/>ST Edge AI int8 网络<br/>(ai_scan.c)"]
SEG["LED 数码管<br/>PB0-PB7 共阴"]
TIM --> DRV --> ADC
ADC --> UART
UART --> AI
AI --> SEG
end
UART -->|"USB 串口"| PC
subgraph PC["PC 端 Python 工具"]
SCAN["scan_view.py<br/>采集 + 自动分段 → *.csv"]
PRT["make_print_sheet(_fonts).py<br/>打印稿生成(MNIST / 10 种字体)"]
TRN["train_digit.py<br/>PyTorch CNN 训练 + 集成"]
QNT["quantize_onnx.py<br/>int8 QDQ 量化"]
AIE["stedgeai validate<br/>生成 C 模型 + 验证"]| 环节 | 方案 |
|---|---|
| 传感器 | 8×TCRT5000(反射式红外),同一时刻仅 1 路发射管点亮(分时,消除串扰/低功耗) |
| 采集 | ADC1 单通道转换(Scan Disabled),HAL_ADC_ConfigChannel 逐路切换;采样时间 79.5 cycles |
| 节拍 | TIM6 2ms(CubeMX 配置:PSC=64-1, Period=1999),更新中断驱动 |
| 传输 | USART1 115200,二进制帧 21B(行号 + 8×u16 + 校验和),一行 8 通道 = 16ms ≈ 62.5 行/秒 |
| 推理 | ST Edge AI int8 网络(权重 22.4KB、激活 8KB),扫描完成自动板载推理 |
| 显示 | 单 LED 数码管(PB0-PB7 共阴),置信度 ≥30% 显示预测数字并保持 5s |
My_IntegratedDesignAndPractice_A/
├── README.md # 仓库总览(本文件)
│
├── AI_TCRT5000_ScanData/ # 扫描部分(第一阶段,已完成 ✅)
│ ├── Core/ # 采集固件:TIM6 分时驱动 + ADC + 串口二进制帧
│ └── Drivers/ cmake/ *.ioc *.ld startup*.s
│
├── Dataset/ # 最新数据集:0-9 各 30 个 = 300 个扫描 CSV
│ └── datasets/<digit>_scan/ # <digit>-NN.csv(01-20 MNIST 打印体 / 21-30 标准字体)
│
├── Model_v1/ # 第一版模型(历史存档,200 样本、随机 14/3/3)
│ ├── python/ # 训练/预处理/量化/导出/检查脚本
│ ├── c/ # ST Edge AI int8 C 模型(Network/)+ 运行时
│ └── artifacts/ # 模型产物、训练曲线/混淆矩阵、可行性测试报告
│
├── Model_v2/ # 最新版模型(部署,300 样本、固定 20/5/5)
│ ├── python/ # 训练/评估/预处理/量化/导出/检查脚本
│ ├── c/ # 第二轮 int8 C 模型(generate-2)+ 运行时
│ └── artifacts/ # 部署模型、int8 ONNX、划分清单、报告与图片
│
├── Python_Tools/ # 最新 Python 工具链(12 个)
│ └── tools/ # 采集/渲染/打印稿/训练/评估/体检/量化/验证/显示
│
├── AI_TCRT5000_CHAR_RECOGNITION/ # 最新单片机工程(采集 + 板载推理 + 数码管,可构建)数据采集阶段快照:
Core/:采集固件(main.c 分时驱动 / ADC 采集 / 二进制帧组帧;tim/adc/usart/gpio 由 CubeMX 生成)Drivers/ cmake/ *.ioc *.ld startup:CubeMX 工程与 CMake 构建配置datasets/<digit>_scan/<digit>-NN.csv:数字 0-9 各 30 个,共 300 个扫描样本。
row,ch0..ch7,行数 22-118(人工扫描快慢不同);NN = 01-20 为 MNIST 打印体,21-30 为 10 种标准字体(DejaVu/Liberation/URW/C059 等,make_print_sheet_fonts.py 生成打印稿后扫描);Model_v2/artifacts/split_fixed.json;Python_Tools/tools/check_samples.py(黑边/墨量/截断/留出误判分析)。200 样本、随机 14/3/3 划分:
python/:train_digit.py(PyTorch 微型 CNN 22.6k 参数 + LS/WD + 集成 + ONNX 导出)、preprocess.py、quantize_onnx.py、export_ai_studio_data.py、check_samples.pyc/:ST Edge AI 生成的 int8 C 模型(Network/)+ 运行时(Middlewares/ST/AI/)artifacts/:model_best.pt/model_final.pt、model.onnx/model_best_int8.onnx、ai_studio_test.npz、summary_{baseline,enhanced,ensemble}.json、training_log.csv、curves.png/confusion_matrix.png、识别可行性测试报告.md300 样本、固定划分 20/5/5:
python/:train_digit.py(--split fixed + LS/WD + 5 seed 集成 + ONNX 导出)、preprocess.py、eval_model.py、check_samples.py、export_ai_studio_data.py、quantize_onnx.pyc/:第二轮 stedgeai generate-2 生成的 int8 网络(Network/,权重 22,928B)+ 运行时(Middlewares/ST/AI/)artifacts/:model_best.pt(部署模型 seed 1042)、model_final.pt、models_seed{42,1042,2042,3042,4042}.pt(5 个集成模型)、model.onnx/model_best.onnx/model_best_int8.onnx、ai_studio_test.npz、split_fixed.json、summary_fixed_repeats.json/summary_fixed_ensemble.json/train_summary.json、training_log.csv、curves.png/confusion_matrix.png/preprocess_grid.png、识别可行性测试报告.md(含第一轮 §1-§9 与第二轮 §10-§11)最新版全套工具链:
| 工具 | 功能 |
|---|---|
scan_view.py | 串口采集 + 按"数据恢复 4095"自动分段,每字符存一个 CSV |
show_scan.py | CSV 渲染颜色深度图(--thresh 纯黑白二值化) |
make_print_sheet.py | MNIST 打印稿生成(反色 + 加粗 + A4 排版;torchvision/gz 双数据源) |
make_print_sheet_fonts.py | 字体版打印稿生成(10 种系统标准字体,编号 x-21-x-30) |
check_quality.py | 扫描 CSV 质量体检(早期版本) |
preprocess.py | 预处理管线:无纸电平黑边 v2 裁剪 + 固定高度重采样(32×8)+ 逐样本归一化 + 增强 |
train_digit.py | PyTorch 微型 CNN 训练 0-9(固定划分 + LS/WD + 多 seed 集成 + ONNX 导出) |
eval_model.py | 用已训练模型评估指定扫描集(新数据复测) |
check_samples.py | 样本质量体检 + 留出误判分析(建议重扫清单) |
export_ai_studio_data.py | 导出 ST Edge AI 验证 .npz(x_test + one-hot y_test,形状 (N,1,1,10)) |
quantize_onnx.py | ONNX int8 QDQ 静态量化(→ model_best_int8.onnx) |
show_prediction.py | 串口监听,解析[AI] 概率行,终端条形图显示预测 + 历史 |
依赖:numpy / torch(CPU) / matplotlib / pyserial / onnx / onnxruntime(按需)。
当前完整固件,可构建(第二轮 int8 固件):
Core/Src/main.c:采样主循环(TIM6 分时驱动 + ADC 采集 + 二进制帧上送)Core/Src/ai_scan.c:板载 AI 模块——扫描缓冲/结束检测、预处理(黑边裁剪→重采样 32 行→归一化→int8 量化)、stai_network_run 推理、softmax、串口概率输出、数码管驱动Core/Src/seg_display.c:单 LED 数码管驱动(PB0-PB7 共阴)Network/:ST Edge AI 生成的 int8 网络(2026-08-27 generate-2,权重 22.4KB)Middlewares/ST/AI/:ST Edge AI 运行时(头文件 + CM0+ 运行库)AI_TCRT5000_CHAR_RECOGNITION.ioc、Drivers/、cmake/、CMakeLists.txt、CMakePresets.json、startup_stm32g0b1xx.s、STM32G0B1xx_FLASH.ld:CubeMX 工程与 CMake 构建/调试配置模型更新说明:更换模型只需替换
Network/下全部 5 个文件(network.c/h、network_data.c/h、network_details.h),ai_scan.c无需改动(API 不变,输出反量化 scale 由network.h的STAI_NETWORK_OUT_1_SCALE宏自动更新)。
KiCad 工程 AI_PCB_SCH(最新版),与单片机工程配套的硬件设计:
AI_PCB_SCH.kicad_pro:KiCad 工程文件AI_PCB_SCH.kicad_sch:原理图AI_PCB_SCH.kicad_pcb:PCB 版图AI_PCB_SCH.kicad_dru:设计规则AI_PCB_SCH.kicad_prl:工程本地设置(KiCad 自动生成,通常不纳入版本管理)板载 AI 部署所依据的 ST 官方参考资料:
CH14_Edge AI and ST solutions.pdf:ST《Introduction to Artificial Intelligence with STM32》第 14 章《Edge AI and ST solutions》(英文)UM2526人工智能(AI)X-CUBE-AI扩展包入门指南.pdf:ST《UM2526:人工智能(AI)X-CUBE-AI 扩展包入门指南》中文版对应流程与产物:int8 量化/验证见
Model_v2/python/、C 网络生成见Model_v2/c/、固件集成见AI_TCRT5000_CHAR_RECOGNITION/(Network/+Middlewares/ST/AI/)。
| 指标 | Model_v1(200 样本,随机 14/3/3) | Model_v2(300 样本,固定 20/5/5) |
|---|---|---|
| 测试集规模 | 30 样本 | 50 样本 |
| 单模型测试均值 | 81.3% ± 6.5% | 81.2% ± 1.0% |
| 多数投票(PC 端) | 83.3% | 88.0% |
| 部署模型测试 | 76.67% | 82.0% |
| 新字体(域外)识别 | 16% / 52% | 94% |
| int8 部署精度损失 | 零 | 零 |
| 固件资源(Flash / RAM) | 53.1% / 12.0% | 53.10% / 12.04% |
stedgeai validate 50 样本 82.0%,C 模型与参考模型数值一致(rmse=0、nse=1.0、cos=1.0);固件 Flash 53.10% / RAM 12.04%;Model_v2/artifacts/识别可行性测试报告.md。cd AI_TCRT5000_CHAR_RECOGNITION
cmake --preset Debug && cmake --build --preset Debug
openocd -f interface/stlink.cfg -f target/stm32g0x.cfg \
-c "program build/Debug/AI_TCRT5000_CHAR_RECOGNITION.elf verify reset exit"pip install pyserial
python3 Python_Tools/tools/scan_view.py /dev/ttyUSB0 --image # 或 Windows: ... COM3操作:扫一个字符 → 拿开纸片等数据恢复 4095 → 扫下一个;CSV 自动存入 outputs/。
python3 Model_v2/python/train_digit.py --split fixed --repeats 5 # 固定划分重复实验
python3 Model_v2/python/train_digit.py --split fixed --ensemble 5 # 多 seed 投票 + ONNX 导出(部署模型)
python3 Model_v2/python/eval_model.py --digits 0-4 --seq 21-30 # 用已保存模型评估新字体样本(复测)python3 Model_v2/python/export_ai_studio_data.py # 生成验证数据 ai_studio_test.npz
python3 Model_v2/python/quantize_onnx.py # ONNX int8 量化 → model_best_int8.onnx
stedgeai validate --model <int8.onnx> --valinput <ai_studio_test.npz> \
--classifier --mode host --name network --target stm32g0 --workspace <ws> --output <out>
# 生成的 C 代码替换 AI_TCRT5000_CHAR_RECOGNITION/Network/(见 §3.6 模型更新说明)python3 Python_Tools/tools/show_prediction.py /dev/ttyUSB0烧录板载 AI 固件后,扫描数字并拿开纸片,终端即显示 10 类概率条形图与最近历史。
一行 = 一次 8 通道采样(21 字节二进制帧):
[0xAA][0x55][行号 u16 LE][CH0..CH7 × u16 LE][校验和 u8] 共 21 字节
校验和 = 字节 2..19 之和 & 0xFF每次扫描结束(纸片离开),固件另输出一行板载推理结果(文本,与二进制帧共存):
[AI] rows=56 best=9:94% | 0:0% 1:0% 2:0% 3:0% 4:0% 5:1% 6:0% 7:0% 8:5% 9:94%rows = 扫描行数(裁剪前),best = 置信最高数字,其后为 0-9 的预测概率(整数百分比)。
| Qty | Value | Footprint | References |
|---|---|---|---|
| 10 | 10k | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R2, R4, R6, R8, R18, R20, R22, R24, R33, R37 |
| 8 | 100 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R9, R10, R11, R12, R25, R26, R27, R28 |
| 8 | 100k | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R13, R14, R15, R16, R29, R30, R31, R32 |
| 8 | 2N7002K | Package_TO_SOT_SMD:SOT-23_Handsoldering | Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8 |
| 8 | 330 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R1, R3, R5, R7, R17, R19, R21, R23 |
| 8 | 470 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R34, R35, R36, R38, R39, R40, R41, R42 |
| 8 | TCRT5000 | TCRT5000:OPTO_TCRT5000 | U1, U2, U3, U4, U5, U6, U7, U8 |
| 6 | 0.1u | Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder | C2, C4, C5, C6, C7, C8 |
| 1 | 1u | Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder | C3 |
| 1 | AMS1117-3.3 | Package_TO_SOT_SMD:SOT-223-3_TabPin2 | U12 |
| 1 | CH340N | Package_SO:JEITA_SOIC-8_3.9x4.9mm_P1.27mm | U9 |
| 1 | C_Polarized | Capacitor_THT:CP_Radial_D5.0mm_P2.00mm | C1 |
| 1 | Conn_01x04_Pin | Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_Vertical | J1 |
| 1 | SC39-11YWA | Display_7Segment:Sx39-1xxxxx | U11 |
| 1 | STM32G0B1RBTx | Package_QFP:LQFP-64_10x10mm_P0.5mm | U10 |
| 1 | SW_Push | Button_Switch_THT:SW_PUSH_6mm | SW1 |
| 1 | USB_B | Connector_USB:USB_B_Lumberg_2411_02_Horizontal | J2 |

OpenLogicEFI/Hardware
Hardware is based off an open source project called Speeduino by Josh Stewart.

Stary2001/my-mesh-nodes
Here's all my mesh stuff. Everything here is licensed under CERN OHL-P.

edantoni96/NomobotSK
NomobotSK is a educational robot for kids to learn programming and robotics.

elshazlio/ecng4504-maze-solver_team_5
ECNG 4504 (AUC, Spring 2026): autonomous maze-learning & solving robot — MCU (Arduino), Python BLE host app, KiCAD/docs, team deliverables. Single monorepo per course charter.

tadzio8425/Micromouse
Micromouse developed by the IEEE Robotics and Automation Society chapter of the Universidad de Los Andes, Bogotá (2023-2024).

gili-yankovitch/SwordOfSecrets
To solve the challenge you will need to discover a series of flags, hidden inside the sword. Each one will help you unlock the next step in the challenge, to finally reveal the ultimate secret the sword holds.


tjclement/ecsc23-badge
This repo contains the hardware designs and firmware developed for the ECSC23 hardware challenge by Curious Supplies.
It measures 100 × 60 mm and has 2 copper layers, 1.6 mm thick.
73 parts, built around the CH340N, TCRT5000, AMS1117-3.3 and 2N7002K. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the Lone-Jade/My_IntegratedDesignAndPractice_A repository on GitHub, at the commit this page was made from: the board is Kicad/AI_PCB_SCH.kicad_pcb and its schematic Kicad/AI_PCB_SCH.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask Lone-Jade before reusing the design.