docs: ADC 注入流程 §4 补码值刻度图

§4 的「码」定义表只有文字与数字,台架现场容易把 TPAFE 的
152.59 µV 与 STM32 的 805.66 µV 混着用。新增一张刻度尺对照
图(docs/images/ADC码值刻度.svg),上下两把尺子分别标出
11430 码 ≈ 1.744 V 与 1000 码 ≈ 0.806 V,把"同一整数在两片
转换器上代表不同电压"变成可见的;正文补一句两把尺子差 5.3
倍、§9 每格必须写明所属通道。

生成器 tools/arch_diagram/gen_adc_code_scale_svg.py 沿用图形绘制
流程 §3.2 约定(纯标准库 / html.escape / newline="\n" /
ElementTree 自检 + 文字溢出预检);码制与 LSB 数据集中在
PANELS 常量,换芯片才重画。已登记到 tools/arch_diagram/README.md
与 docs/架构设计/图形绘制流程.md 的生成器表 + 变更记录。

目检用无头 Chrome 截图完成(cairosvg 未装,截图不入库)。
This commit is contained in:
2026-10-27 17:25:51 +08:00
parent e50d2b5cf0
commit 2b4c0e97c2
5 changed files with 256 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
<svg xmlns="http://www.w3.org/2000/svg" width="980" height="512" viewBox="0 0 980 512" font-family="Microsoft YaHei, Segoe UI, PingFang SC, sans-serif">
<rect x="0" y="0" width="980" height="512" fill="#ffffff"/>
<text x="60" y="44" font-size="20" font-weight="700" fill="#0f172a">「码」是 ADC 的最小刻度 —— 两片转换器的刻度大小不同</text>
<text x="60" y="72" font-size="13" fill="#64748b">ADC 输出的是整数(码),不是电压;电压 = 码 × LSB,所以要先知道「1 码值多少伏」</text>
<text x="60" y="92" font-size="13" fill="#64748b">TPAFE5160:16 位双极性,65536 码 = 10 V 跨度 · STM32 ADC1:12 位单极性,4096 码 = 3.3 V 跨度</text>
<text x="60" y="150" font-size="14" font-weight="700" fill="#0f172a">A · TPAFE5160(16 位双极性)</text>
<line x1="60.0" y1="162.0" x2="920.0" y2="162.0" stroke="#cbd5e1" stroke-width="1"/>
<text x="60" y="180" font-size="12" fill="#64748b">码范围 −32768 ~ +32767 · 每 1 码 = 152.59 µV</text>
<line x1="100.0" y1="238.0" x2="900.0" y2="238.0" stroke="#334155" stroke-width="1.8"/>
<line x1="100.0" y1="232.0" x2="100.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="140.0" y1="232.0" x2="140.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="180.0" y1="232.0" x2="180.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="220.0" y1="232.0" x2="220.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="260.0" y1="232.0" x2="260.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="300.0" y1="232.0" x2="300.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="340.0" y1="232.0" x2="340.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="380.0" y1="232.0" x2="380.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="420.0" y1="232.0" x2="420.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="460.0" y1="232.0" x2="460.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="500.0" y1="232.0" x2="500.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="540.0" y1="232.0" x2="540.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="580.0" y1="232.0" x2="580.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="620.0" y1="232.0" x2="620.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="660.0" y1="232.0" x2="660.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="700.0" y1="232.0" x2="700.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="740.0" y1="232.0" x2="740.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="780.0" y1="232.0" x2="780.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="820.0" y1="232.0" x2="820.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="860.0" y1="232.0" x2="860.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="900.0" y1="232.0" x2="900.0" y2="244.0" stroke="#94a3b8" stroke-width="1"/>
<text x="100" y="260" font-size="11" text-anchor="middle" fill="#94a3b8">−32768</text>
<text x="900" y="260" font-size="11" text-anchor="middle" fill="#94a3b8">+32767</text>
<text x="500.0" y="260" font-size="11" text-anchor="middle" fill="#64748b">0</text>
<line x1="639.5" y1="232.0" x2="639.5" y2="210.0" stroke="#2563eb" stroke-width="1" stroke-dasharray="3 3"/>
<circle cx="639.5" cy="238.0" r="5" fill="#2563eb"/>
<text x="639.5263671875" y="202" font-size="13" text-anchor="middle" font-weight="700" fill="#2563eb">11430 码 ≈ 1.744 V</text>
<text x="60" y="328" font-size="14" font-weight="700" fill="#0f172a">B · STM32 ADC1(12 位单极性)</text>
<line x1="60.0" y1="340.0" x2="920.0" y2="340.0" stroke="#cbd5e1" stroke-width="1"/>
<text x="60" y="358" font-size="12" fill="#64748b">码范围 0 ~ 4095 · 每 1 码 = 805.66 µV</text>
<line x1="100.0" y1="416.0" x2="900.0" y2="416.0" stroke="#334155" stroke-width="1.8"/>
<line x1="100.0" y1="410.0" x2="100.0" y2="422.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="200.0" y1="410.0" x2="200.0" y2="422.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="300.0" y1="410.0" x2="300.0" y2="422.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="400.0" y1="410.0" x2="400.0" y2="422.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="500.0" y1="410.0" x2="500.0" y2="422.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="600.0" y1="410.0" x2="600.0" y2="422.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="700.0" y1="410.0" x2="700.0" y2="422.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="800.0" y1="410.0" x2="800.0" y2="422.0" stroke="#94a3b8" stroke-width="1"/>
<line x1="900.0" y1="410.0" x2="900.0" y2="422.0" stroke="#94a3b8" stroke-width="1"/>
<text x="100" y="438" font-size="11" text-anchor="middle" fill="#94a3b8">0</text>
<text x="900" y="438" font-size="11" text-anchor="middle" fill="#94a3b8">4095</text>
<line x1="295.4" y1="410.0" x2="295.4" y2="388.0" stroke="#0d9488" stroke-width="1" stroke-dasharray="3 3"/>
<circle cx="295.4" cy="416.0" r="5" fill="#0d9488"/>
<text x="295.36019536019535" y="380" font-size="13" text-anchor="middle" font-weight="700" fill="#0d9488">1000 码 ≈ 0.806 V</text>
<line x1="60.0" y1="452.0" x2="920.0" y2="452.0" stroke="#cbd5e1" stroke-width="1"/>
<text x="60" y="470" font-size="12" fill="#64748b">刻度疏密仅示意位数差(16 位比 12 位细),不是逐码绘制;1 码的电压当量见各行右侧标注。</text>
<text x="60" y="488" font-size="12" fill="#64748b">两个换算值都来自台架实测码值:11430 与 cal: 行的 1743 mV 自洽,说明「码 × LSB」这条链是通的。</text>
</svg>

After

Width:  |  Height:  |  Size: 5.4 KiB

+2
View File
@@ -50,6 +50,7 @@
| `gen_memory_svg.py` | `docs/images/内存布局_*.svg` | RAM / FLASH 布局 |
| `gen_watchdog_svg.py` | `docs/images/看门狗心跳模型.svg` | `TASKS` / `REQ_BITS` / `POLL_STEPS` / `TIMELINE` |
| `gen_adc_frontend_svg.py` | `docs/images/ADC前端电路.svg` | `SUB1` / `NOTE_*` 等文案常量 + 面板坐标(电路拓扑固定,网表变了才重画) |
| `gen_adc_code_scale_svg.py` | `docs/images/ADC码值刻度.svg` | `PANELS` 列表(码范围 / LSB / 实测码标记位置)+ `FOOT`(换芯片才重画) |
---
@@ -144,3 +145,4 @@ sequenceDiagram
| 2026-09-11 | 存量 ASCII 框图清理:`STM32F4-Base存储架构说明.md` 两图(存储栈分层 / 物理分区布局)重绘为 SVG(生成器家族新增 `gen_storage_stack_svg.py` / `gen_partition_svg.py`);`RemoDispBus协议与接收设计说明.md` 删 ASCII 帧图(SVG 帧格式图已在,信息无损失);`测试说明/CH395F_Test_Guide.md` 4 图(2 组件架构 + 2 会话时序)转 Mermaid |
| 2026-10-22 | 澄清 §派生物一句:`simulator/tests/ref/` 下作为像素黄金参考的 `.bin` 已入库,只有派生的 `.png` 目检图仍不入库(原表述把两者混为"参考图不入库",会诱导后来者把整个目录继续忽略掉) |
| 2026-10-27 | 新增 `gen_adc_frontend_svg.py` → `docs/images/ADC前端电路.svg`:把 `docs/硬件平台/ADC通道映射说明.md` §7.1 与 `docs/测试说明/ADC前端注入验证流程.md` §2 的 ASCII 拓扑图换成 SVG。ASCII 版把滤波支路画成挂在信号节点下的一根竖线,读起来像 2:1 分压——恰是要否掉的结论;SVG 把 `ADC7` / `ADC7_GND` 画成两个节点并加 STM32 侧对照面板。生成器沿用 §3.2 约定(纯标准库 / `html.escape` / `newline="\n"` / `ElementTree` 自检 + 文字溢出预检);目检用无头 Chrome 截图完成(`cairosvg` 未装,截图不入库) |
| 2026-10-27 | 新增 `gen_adc_code_scale_svg.py` → `docs/images/ADC码值刻度.svg`:给 `docs/测试说明/ADC前端注入验证流程.md` §4 的「码」定义配图。两张刻度尺上下对照,标出 `11430 码 ≈ 1.744 V`(TPAFE)与 `1000 码 ≈ 0.806 V`(STM32),把"同一整数在两片转换器上代表不同电压"变成可见的,避免台架抄数时混用两套 LSB |
@@ -87,6 +87,14 @@
| TPAFE5160 | 16 位双极性 | −32768 ~ +32767(共 65536 码 = 10 V 跨度) | 152.59 µV | 11430 码 × 152.59 µV ≈ **1.744 V** |
| STM32 ADC1 | 12 位单极性 | 0 ~ 4095(共 4096 码 = 3.3 V 跨度) | 805.66 µV | 1000 码 × 805.66 µV ≈ **0.806 V** |
同一个整数落在两把刻度尺上代表不同电压(图由 `tools/arch_diagram/gen_adc_code_scale_svg.py`
生成,改图请改脚本重跑,勿手改 SVG):
![两把刻度尺:TPAFE5160 16 位双极性 −32768~+32767、1 码 152.59 µV、11430 码≈1.744 V;STM32 ADC1 12 位单极性 0~4095、1 码 805.66 µV、1000 码≈0.806 V](../images/ADC码值刻度.svg)
**两把尺子不能混用**:同样是"1000",在 TPAFE 上是 0.153 V,在 STM32 上是 0.806 V,差 5.3 倍。
所以 §9 记录表里每一格都必须写明是哪一路(UA/UB/… 属 TPAFE,T 属 STM32),抄错一行全盘结论作废。
本文一律用"码"而不是"伏",有两个理由:① 固件 `adc:` 行打印的就是码,抄数不用心算;
② **标定还没做,把码换成伏正是本次要验证的事**——先换算再用,等于默认了尚未验证的系数。
判据里的"码值绝对值 ≤ 10"= 短接后读数离 0 不超过 10 个刻度,即 TPAFE 侧 ≈1.5 mV、
@@ -274,3 +282,4 @@ TPAFE 是双极性、二进制补码,可以注负压;STM32 是单极性,
| 2026-10-27 | **§5.1 步骤 0 判据更正**:原写"端子侧应量到 1 kΩ 量级(串阻 + 转换器输入阻抗**并联**)"两处错——① 端子到 AGND 是**串联**通路(1k + 芯片 1 MΩ + 1k ≈ 1.002 MΩ),1 kΩ 只在**串阻两端**成立;② 芯片输入阻抗是 **1 MΩ 恒定**(`docs/芯片手册/TPAFE5160.md` "Analog Input Impedance" 节),不是可与 1 kΩ 并联出 1 kΩ 的量级。改为三行分测表(串阻两端 / TPAFE 侧对 AGND / STM32 侧对 AGND),并写明本步**只排除短路、不验收正确性**;§8 已知坑补对应一行。`docs/硬件平台/ADC通道映射说明.md` §7"前端偏置"行同步补 1 MΩ 与源阻抗匹配依据 |
| 2026-10-27 | **§5.2 表格可读性修正**:原表单元格里写了 `\|码\|`(未转义竖线),被 GFM 当成列分隔符,整表渲染成乱码;改为"码值绝对值 ≤ 10 / ≤ 5"(§6 判据汇总同病同修)。同时 §5.2 补"做什么"四步(断电短接 → 上电读 `adc:` → 抄进 §9.1 → 断电换下一路),并明确**本节只给判据、要填的表在 §9.1**;§9.1 记录表新增"空载码值(浮空)"列与填法说明,使空载与短接两个数都被记下来 |
| 2026-10-27 | **§4 补「码」的定义**:用户反馈"码这个单位第一次见"。补 16 位双极性(−32768~+32767、1 码 152.59 µV)与 12 位单极性(0~4095、1 码 805.66 µV)两个刻度对照表、换算示例(11430 码 ≈ 1.744 V,与 `cal:` 行的 1743 mV 自洽),并写明本文为何一律用码而不用伏:固件打印的就是码,且**把码换成伏正是本次要验证的事** |
| 2026-10-27 | §4 的「码」定义表配刻度尺图(`docs/images/ADC码值刻度.svg`,生成器 `tools/arch_diagram/gen_adc_code_scale_svg.py`):上下两张刻度尺分别标出 `11430 码 ≈ 1.744 V` 与 `1000 码 ≈ 0.806 V`,把"同一个整数在两片转换器上代表不同电压"画出来;正文补一句两把尺子差 5.3 倍、§9 每格必须写明所属通道,防止台架抄数时混用两套 LSB |