RepositoryCCNChina
SH

shuai132/ScopeMCU

虚拟示波器 MCU端

119stars
29forks
0issues
1views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: stm32f103

#1 Repository of the month

1
TINIX TRENDING·Topic: cubemx

#1 Repository of the month

1
TINIX TRENDING·Topic: scope

#1 Repository of the month

ScopeMCU

Build Status

Oscilloscope for MCU

MCU: STM32F103C8Tx

需配合ScopeGUI使用

截图说明见wiki

最新版Releases

Introduction

用最少的硬件成本,做一个实用的虚拟示波器。

这是硬件部分,基于STM32最小系统,不使用任何片外外设。 可以方便地移植到其他硬件(只需要ADC、定时器、串口/USB即可)。 采样率和采样深度等参数取决于芯片性能。

Features

  • Timer触发ADC+DMA 精确采样
  • ADC数值已校准(使用内部基准电压)
  • 采样率无级可调 最高采样率1Msps
  • 采样深度可调 当前6144(1024*6)点
  • 内置自测信号(1kHz方波)
  • 多种触发方式(自动、正常、单次)
  • FFT频谱分析(上位机实现)
  • USB CDC 高速数据传输

注:

  • 未设计前端运放电路,只用于采集0~3.3V信号。
  • 为了采样精度和校准,当前最高采样率: 70ksps

IO Map

必需

管脚作用
PA0ADC通道
PA11USB DM USB接口
PA12USB DP USB接口

可选

管脚作用
PC13LED指示灯 采样过程为低电平
PA81kHz方波信号 用于自测
PA9USART1 TX 调试串口
PA10USART1 RX 调试串口

移植

设计上把可移植性作为重要目标,可以很方便地移植到其他单片机、Arduino、DSP等硬件。

只需硬件提供指定功能实现函数即可,具体见ScopeCore中public方法的注释或移植步骤。

注:

  • 需要C++11支持,推荐使用arm-none-eabi编译器和cmake构建,已在Windows、macOS、Ubuntu下测试通过。
  • 为了方便软件设计和数据解析,直接打包结构体作为消息单元。注意要和上位机保持一致的字节序(arm、x86、arduino均为小端模式)。

移植步骤

  • 初始化scope
    // 在全局初始化
    static const size_t MaxSn = 1024 * 6;   // 取决于RAM大小
    static uint8_t Buffer[Message::CalcBytes(MaxSn)];
    static ScopeMCU scopeMcu(MaxSn, Buffer);
    ...

    scopeMcu.setVolLimits(0, 3300);
    scopeMcu.setFsLimits(1, 10000);
    scopeMcu.setMcuImpl(
            {
                    .sendData = [](uint8_t* data, size_t size) {
                        // 用串口发送数据
                    },
                    .startADC = []{
                        // 开始采样
                    },
                    .stopADC = []{
                        // 停止采样
                    },
                    .setSampleFs = [](uint32_t fs) {
                        // 设置采样率 返回实际的采样率
                    },
                    .onSampling = [](bool sampling) {
                        // 可用来控制指示灯状态
                    },
            });
  • 当收到串口数据
    scopeMcu.onRead(data, size);
  • 当一次ADC转换完成
    scopeMcu.onADC(vol);

注:

  • startADC之前不要触发onADC

DevelopTools

  • STM32CubeMX
  • arm-none-eabi-gcc
  • CLion(CMake)
  • OpenOCD
  • ST-LINK

Install Requirements(for macOS)

  • config OpenOCD and ST-LINK
brew install openocd
brew install stlink
brew cask install gcc-arm-embedded

Usage

Similar Projects

Discover other similar projects and AI models.

RepositoryC
anfractuosity/flipperscope

Attempt at an oscilloscope application for the flipper zero. Measures voltage and frequency.

164
Jan 3, 2025
RepositoryC
Crazy-Geeks/STM32-ARGB-DMA

STM32 Library for Addressable LEDs: WS2812(b), WS2811, SK6812, etc. Supports RGB & RGBW LEDs.

128
Jun 8, 2023
RepositoryC
flipperdevices/flipperzero-firmware

Flipper Zero firmware source code

17.1k
Nov 27, 2026
RepositoryC
stlink-org/stlink

Open source STM32 MCU programming toolset

5.3k
Oct 9, 2026
RepositoryC
cpq/bare-metal-programming-guide

A bare metal programming guide (ARM microcontrollers)

5.1k
Jul 3, 2026
RepositoryC
Bodmer/TFT_eSPI

Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips

5.0k
Apr 3, 2026
RepositoryC
libopencm3/libopencm3

Open source ARM Cortex-M microcontroller library

3.7k
Nov 6, 2026
RepositoryC
zlgopen/awtk

AWTK = Toolkit AnyWhere(a cross-platform embedded GUI)

3.3k
Nov 30, 2026
RepositoryC
but0n/Avem

🚁 轻量级无人机飞控-[Drone]-[STM32]-[PID]-[BLDC]

2.9k
Oct 3, 2023