mcpField
D
datasheet-interpreter

datasheet-interpreter

github.com/wedsamuel1230文档处理28153 次安装2 周前更新
代码仓库

关于 datasheet-interpreter

datasheet-interpreter 是一项从元器件数据手册 PDF 中提取实用规格的技能,面向创客和嵌入式开发者。它可快速查找引脚、接口、电气限制、时序和寄存器信息,无需生成完整驱动库。

主要功能

  1. 01从 PDF 数据手册提取规格
  2. 02从网址下载或读取本地 PDF
  3. 03查询引脚、接口和工作限制
  4. 04查找时序与寄存器信息
  5. 05生成接线图和示例代码

适用场景

  1. 01查询芯片的 I2C 地址或引脚定义
  2. 02接线前核对电压和电流限制
  3. 03查找时序或寄存器详情
  4. 04根据数据手册制作元器件速查资料

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/wedsamuel1230/embedded-engineering-skills --skill datasheet-interpreter

安装后在 Claude Code 中输入/datasheet-interpreter确认已加载。

附带文件references/common-parameters.mdscripts/extract_specs.py

详细介绍

数据手册解读器

从元器件数据手册 PDF 中提取可操作的规格信息。

资源

脚本
  • scripts/extract_specs.py - 从 URL 下载数据手册 PDF,并通过模式匹配提取规格
参考资料
  • references/common-parameters.md - 数据手册参数解读指南
快速开始
# Extract specs from a datasheet URL
uv run --no-project scripts/extract_specs.py --url "https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf"

# Extract specs with markdown output
uv run --no-project scripts/extract_specs.py --url "https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf" --format markdown

# Extract from local PDF file
uv run --no-project scripts/extract_specs.py --file "local_datasheet.pdf"

# Interactive mode
uv run --no-project scripts/extract_specs.py --interactive

适用场景

  • “这款芯片的 I2C 地址是什么?”
  • “如何连接这个传感器?”
  • “这个模块上的引脚分别有什么作用?”
  • 用户分享了 PDF 数据手册 URL
  • 需要查询时序规格或寄存器信息
  • 无需生成完整驱动程序,只需快速查阅

与其他技能的关系

  • datasheet-parser:生成完整驱动程序库(lexus2k 风格)
  • datasheet-interpreter(本工具):快速提取规格,供即时使用

信息提取工作流

步骤 1:请求数据手册
Please provide:
1. Component name (e.g., "BME280", "MPU6050")
2. Datasheet PDF file or URL (manufacturer version preferred)
3. What specific information you need:
   □ Pin assignments / pinout
   □ I2C/SPI address and protocol
   □ Operating conditions (voltage, current)
   □ Timing requirements
   □ Register map
   □ Example circuit
   □ All of the above
步骤 2:验证 PDF 质量

检查以下内容:

  • 文本可搜索(不是扫描图像)
  • 官方制造商数据手册(不是仿制品或经销商摘要)
  • 标明修订版或版本号
  • 文档完整(如适用,包含寄存器表)

如果 PDF 存在问题:

⚠️ This appears to be a [scanned image | partial datasheet | third-party summary].

For best results, please provide the official manufacturer datasheet from:
- [Manufacturer website link]
- Or search: "[component] datasheet pdf site:manufacturer.com"

提取模板

快速参考卡

为任何元器件生成此卡片:

# [Component Name] Quick Reference

## Basic Info
- **Manufacturer:** [name]
- **Part Number:** [full part number with variants]
- **Datasheet Version:** [rev/date]
- **Description:** [one-line description]

## Electrical Characteristics
| Parameter | Min | Typ | Max | Unit |
|-----------|-----|-----|-----|------|
| Supply Voltage (VDD) | | | | V |
| Operating Current | | | | mA |
| Sleep Current | | | | µA |
| Operating Temp | | | | °C |

## Communication Interface
- **Protocol:** [I2C / SPI / UART / GPIO]
- **Address:** [0xNN (7-bit)] or [selectable via pin]
- **Max Clock:** [frequency]
- **Logic Levels:** [3.3V / 5V tolerant]

## Pinout
| Pin | Name | Type | Description |
|-----|------|------|-------------|
| 1 | VDD | Power | Supply voltage |
| 2 | GND | Power | Ground |
| ... | ... | ... | ... |

## Key Registers (if applicable)
| Address | Name | R/W | Description |
|---------|------|-----|-------------|
| 0x00 | WHO_AM_I | R | Device ID (expect 0xNN) |
| ... | ... | ... | ... |

## Arduino Wiring
| Component Pin | Arduino Uno | ESP32 | Pico |
|---------------|-------------|-------|------|
| VCC | 3.3V | 3.3V | 3V3 |
| GND | GND | GND | GND |
| SDA | A4 | GPIO21 | GP4 |
| SCL | A5 | GPIO22 | GP5 |

## Important Notes
- [Critical warnings from datasheet]
- [Application notes]

常见元器件类别

I2C 传感器

提取:

□ I2C address (7-bit format, note if configurable)
□ WHO_AM_I register address and expected value
□ Configuration register settings
□ Data registers (where to read measurements)
□ Resolution and range options
□ Conversion time / measurement rate

I2C 地址速查表:

元器件地址(7 位)配置引脚备用地址
BME2800x76SDO→GND0x77(SDO→VDD)
BME6800x76SDO→GND0x77(SDO→VDD)
MPU60500x68AD0→GND0x69(AD0→VDD)
SHT300x44ADDR→GND0x45(ADDR→VDD)
BH17500x23ADDR→GND0x5C(ADDR→VDD)
VL53L0X0x29-可通过软件配置
INA2190x40A0,A10x40-0x4F
ADS11150x48ADDR→GND0x49-0x4B
SPI 设备

提取:

□ SPI mode (CPOL, CPHA)
□ Max clock frequency
□ Data order (MSB/LSB first)
□ Command format
□ Chip select behavior (active low?)
电机驱动器

提取:

□ Logic voltage (VCC)
□ Motor voltage range (VM)
□ Current per channel (continuous/peak)
□ Control interface (PWM frequency, step/dir)
□ Protection features (thermal, overcurrent)
□ H-bridge or half-bridge
显示模块

提取:

□ Resolution (width x height)
□ Controller IC (SSD1306, ILI9341, etc.)
□ Interface (I2C, SPI, parallel)
□ Memory map / pixel format
□ Initialization sequence
□ Refresh rate

关键规格查找

电源规划
Search datasheet for:
- "Electrical Characteristics" table
- "Power Consumption" or "Current Consumption"
- "Typical Operating Conditions"
- Sleep/standby modes and their currents

模板输出:

## Power Specs for [Component]

### Operating Modes
| Mode | Typical Current | Conditions |
|------|-----------------|------------|
| Active | XXX mA | [freq, voltage, etc.] |
| Idle | XXX µA | |
| Sleep/Standby | XXX µA | |
| Deep Sleep | XXX nA | |

### Wake-up Time
- From sleep: XXX ms
- From deep sleep: XXX ms
时序要求
Search datasheet for:
- "Timing Characteristics"
- "AC Characteristics"
- Setup/hold times
- Clock specifications
引脚容限
Search datasheet for:
- "Absolute Maximum Ratings"
- "ESD protection"
- "5V tolerant" mentions
- Input voltage specifications

寄存器映射提取

结构化格式
// [Component] Register Definitions
// Extracted from datasheet v[X.Y], p.[N]

// === REGISTER ADDRESSES ===
#define REG_NAME          0x00  // Description

// === BITFIELD DEFINITIONS ===
// REG_NAME (0x00) - [Description]
// Bit 7-6: FIELD_A - [description]
// Bit 5:   FIELD_B - [description]
// Bit 4-0: FIELD_C - [description]

#define REG_NAME_FIELD_A_MASK    0xC0
#define REG_NAME_FIELD_A_POS     6
#define REG_NAME_FIELD_B_BIT     5
#define REG_NAME_FIELD_C_MASK    0x1F
常见寄存器模式

配置寄存器:

- Enable/disable features
- Set operating mode
- Configure interrupt behavior

状态寄存器:

- Data ready flags
- Error/fault indicators
- Interrupt sources

数据寄存器:

- Usually consecutive addresses
- Note byte order (MSB first or LSB first)
- Signed vs unsigned interpretation

接线图生成器

生成基于文本的接线图:

  [Component]          [Arduino Uno]
  ┌─────────┐         ┌───────────┐
  │ VCC ────┼─────────┤ 3.3V      │
  │ GND ────┼─────────┤ GND       │
  │ SDA ────┼─────────┤ A4 (SDA)  │
  │ SCL ────┼─────────┤ A5 (SCL)  │
  │ INT ────┼─────────┤ D2 (INT0) │
  └─────────┘         └───────────┘
  
  Notes:
  - Add 4.7kΩ pull-ups on SDA/SCL if not on module
  - INT is open-drain, needs pull-up

示例代码生成器

根据提取的规格,生成最简可运行示例:

/*
 * [Component] Basic Example
 * Generated from datasheet interpretation
 * 
 * Wiring:
 * - VCC → 3.3V
 * - GND → GND
 * - SDA → A4 (Arduino Uno) / GPIO21 (ESP32)
 * - SCL → A5 (Arduino Uno) / GPIO22 (ESP32)
 */

#include <Wire.h>

#define COMPONENT_ADDR  0x00  // From datasheet p.X
#define REG_WHO_AM_I    0x00  // Expected: 0xNN
#define REG_CTRL        0x00  // Configuration
#define REG_DATA        0x00  // Data output

void setup() {
  Serial.begin(115200);
  Wire.begin();
  
  // Verify communication
  Wire.beginTransmission(COMPONENT_ADDR);
  if (Wire.endTransmission() != 0) {
    Serial.println("Component not found!");
    while(1);
  }
  
  // Read device ID
  uint8_t id = readReg(REG_WHO_AM_I);
  Serial.print("Device ID: 0x");
  Serial.println(id, HEX);
  
  // Initialize
  writeReg(REG_CTRL, 0x00);  // [Configuration value from datasheet]
}

void loop() {
  // Read data
  int16_t data = readReg16(REG_DATA);
  Serial.println(data);
  delay(100);
}

uint8_t readReg(uint8_t reg) {
  Wire.beginTransmission(COMPONENT_ADDR);
  Wire.write(reg);
  Wire.endTransmission(false);
  Wire.requestFrom(COMPONENT_ADDR, (uint8_t)1);
  return Wire.read();
}

void writeReg(uint8_t reg, uint8_t val) {
  Wire.beginTransmission(COMPONENT_ADDR);
  Wire.write(reg);
  Wire.write(val);
  Wire.endTransmission();
}

int16_t readReg16(uint8_t reg) {
  Wire.beginTransmission(COMPONENT_ADDR);
  Wire.write(reg);
  Wire.endTransmission(false);
  Wire.requestFrom(COMPONENT_ADDR, (uint8_t)2);
  int16_t val = Wire.read() << 8;  // MSB first (check datasheet!)
  val |= Wire.read();
  return val;
}

快速查询数据库

常见问题解答

“[component] 需要什么电压?” → 查看“绝对最大额定值”和“推荐工作条件”

“它使用 3.3V 还是 5V?” → 在电气特性中查找“VDD”或“VCC” → 检查 I/O 引脚是否“耐受 5V”

“I2C 的运行速度可以有多快?” → 在时序规格中查找“I2C 时钟频率”(通常标准模式为 100kHz,快速模式为 400kHz)

“如何将它从休眠状态唤醒?” → 查找“电源管理”或“工作模式”部分

“为什么它没有在预期地址响应?” → 检查地址选择引脚(AD0、ADDR、SA0) → 有些数据手册显示的是 8 位地址(除以 2 可得到 7 位地址)


数据手册阅读技巧

关键内容的位置
信息章节名称
I2C 地址“串行接口”或“通信”
电压/电流“电气特性”
引脚排列“引脚配置”或“封装信息”
寄存器“寄存器映射”或“存储器映射”
时序“时序特性”或“交流特性”
示例电路“应用信息”或“典型应用”
数据手册中的警示信号
  • 🚩 缺少绝对最大额定值
  • 🚩 没有版本号或修订号
  • 🚩 寄存器描述前后不一致
  • 🚩 机器翻译文本
  • 🚩 缺少协议时序图

→ 如果发现这些问题,请尝试从原始制造商处查找质量更好的数据手册

共享输出契约

使用共享 Arduino 技能契约: 说明假设、所需工具与版本、实现步骤、 按证明阶段划分的测试/证据、已知限制,以及恢复/安全注意事项。

评论

支持 Markdown