Git Product home page Git Product logo

scopemcu's Introduction

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

必需

管脚 作用
PA0 ADC通道
PA11 USB DM USB接口
PA12 USB DP USB接口

可选

管脚 作用
PC13 LED指示灯 采样过程为低电平
PA8 1kHz方波信号 用于自测
PA9 USART1 TX 调试串口
PA10 USART1 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

Links

scopemcu's People

Contributors

shuai132 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

scopemcu's Issues

Cannot build in STM32CubeIDE

When I import as an existing project and click Build:

**** Build of configuration Debug for project ScopeMCU ****

Nothing to build for project ScopeMCU

I tried re-generating the project with CubeMX. No luck.

Ubuntu 22.04 LTS
STM32CubeIDE version: 1.10.1

1MSa possible?

The GUI does not allow setting the sampling frequency larger than 70kHz. And I see that the picture is breaking already at 70kHz.

But I did see others are using an STM32F103-based oscilloscope to get 1MSa sampling rate. Is it possible to achieve this with built-in ADC only? Or USB communication limits the speed to be lower than 70kHz? Will the situation improve if I switch to STM32F429 Discovery board with a (presumably) better ADC?

最高采样率能达到1M吗

我看说明里面特别指出

为了采样精度和校准,当前最高采样率: 70ksps

这个限制是在那实现的,如果不考虑精度,只是要看个大概,能否达到1M?
如何修改?

STM32F4 CDC 不能发送到ScopeGUI,与编译器有关?

楼主您好,
我尝试移植F4的代码到我的F407板子上面,结果遇到了问题。

  1. 编译通过,ADC工作正常,VCP(CDC)串口也有了,可是ScopeGUI打不开VCP,当然也收不到数据。
  2. 检查发现,用其他终端软件也打不开这个VCP,当然也收不到数据。
  3. 进一步检查后发现,可能与编译器有关。 为了找问题,我单独开了一个CDC工程,同一套代码在MDK和CLion(Win10)下面都能正常编译,但是CLion出来的代码就发生CDC不正常,与上面说的一样,PC终端软件收不到CDC_TransmitFS发送的打印内容。 而MDK编译出来的就正常。
    同时,我Win10电脑的CLion系统,编译F103的那一套ScopeMCU(master)代码就全部工作正常。 我的CubeMX也是最新版本。

您遇到过这种问题吗?谢谢。

Clion 2021.2.3

Scanning dependencies of target ScopeMCU.elf
[ 23%] Building C object CMakeFiles/ScopeMCU.elf.dir/App/retarget.c.obj
[ 25%] Building C object CMakeFiles/ScopeMCU.elf.dir/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c.obj
[ 26%] Building C object CMakeFiles/ScopeMCU.elf.dir/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c.obj
[ 28%] Building C object CMakeFiles/ScopeMCU.elf.dir/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c.obj
[ 30%] Building C object CMakeFiles/ScopeMCU.elf.dir/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c.obj
[ 32%] Building C object CMakeFiles/ScopeMCU.elf.dir/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c.obj
: error: expected identifier or '(' before string constant
I:\STM32H7\clion\stm32\ScopeMCU\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c:200:1: note: in expansion of macro '__weak'
200 | __weak void HAL_MspInit(void)
| ^~~~~~
: error: expected identifier or '(' before string constant
I:\STM32H7\clion\stm32\ScopeMCU\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c:211:1: note: in expansion of macro '__weak'
211 | __weak void HAL_MspDeInit(void)
| ^~~~~~
: error: expected identifier or '(' before string constant

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.