Giter Site home page Giter Site logo

againpsychox / picooscilloscope Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 133 KB

Simple do-it-yourself oscilloscope using Raspberry Pico and ST7796 touch display made for my dad.

C++ 93.28% Python 4.12% C 2.60%
arduino raspberry-pico raspberrypico rp2040 st7796 st7796s xpt2046

picooscilloscope's Introduction

Warning

Work in progress, see To-do section for details.

picOOscilloscope

Simple do-it-yourself oscilloscope using Raspberry Pico and touch display made for my dad.

Hardware

Microcontroller: Raspberry Pi Pico
Display: 4'' TFT SPI ST7796 480x320
Display driver: ST7796(S)
Touch chipset: XPT2046

Microcontroller pins usage

Pin GPIO Notes
1 0 Reserved for UART0 TX
2 1 Reserved for UART0 RX
3 GND Ground
4 2 SPI0 SCK, used for display & touch (shared)
5 3 SPI0 TX (MOSI), used for display & touch (shared)
6 4 SPI0 RX (MISO), used for display & touch (shared)
7 5 Chip select for the display
8 GND Ground
9 6 Reset for the display & touch (shared?)
10 7 Register select (Data/Command) for the display
11 8 Chip select for the touch
...
21 16 S0 control for 74HC4052 for channel 2 (see below for details)
22 17 S1 control for 74HC4052 for channel 2 (see below for details)
23 GND Ground
24 18 S0 control for 74HC4052 for channel 1 (see below for details)
25 19 S1 control for 74HC4052 for channel 1 (see below for details)

Analog front-end

Based on Scoppy (other closed source Pico oscilloscope) analog front-end examples, including FSCOPE-500K Rev 4e.

The front-end this project uses the more complex, dual channel with 4 voltage ranges, portection, 10X probe compatibility, input impedance of 1M||22pF, etc. Simulation using CircuitJS was created, for fun and exploration of the idea. Thanks to that, one can easily understand how the voltage is shifted. It uses two 74HC4052 dual 4-channel analog switch/(de)multiplexer; I even recreated the 74HC4052 inside the simulation too (custom compontent). Basically, the compontent takes 2 digital inptus from the microproessing, which allow for selecting pair of resistors: for voltage division and shift.

Range ID Min voltage Max voltage S1 S0
0 -5.872 V 5.917 V 0 0
1 -2.152 V 2.497 V 0 1
2 -1.120 V 0.949 V 1 0
3 -0.404 V 0.585 V 1 1

Display hardware fix

An issue was reported to the library for controlling the display (and touch) for weird behaviour of display and touch SPI bus sharing misbehaving, resulting in visual gliches affecting last draw instructions right before switching SPI to talk with the touch controller. It turned out, the display was affected by a hardware bug. Explanation, origin and workaround (hardware modification) for the bug are described in TFT_eSPI issues by Bodmer (maintainer of the library). The proposed modification was applied as workaround in this project: shorting one of diodes on the display board.

Software

Environment: PlatformIO inside VS Code

Framework: Arduino (earlephilhower version)

Library TFT_eSPI was used to support the display, with the touch support built-in.

General idea

Used processor RP2040 has 2 CPU cores and 12 DMA channels. ADC can be configured using round-robin to switch between channels and takes samples to special FIFO queue, and DMA then can take those samples to more proper buffer. This buffer will be scanned for fulfilling triggers by process on CPU 1, meanwhile CPU 0 will be responsible for setting everything up and operating UI on the display, including graphing the data.

User interface

There is single graph or split graphs displyed on left, and buttons for configuration and various features.

Notes

Aside from below, you might want to visit also:

  • ./test/embedded/README.md for notes about testing on Pico using PlatformIO with Arduino-Pico core and ThrowTheSwitch Unity testing framework - there were few gotchas.

ADC

Without overclocking, ADC uses USB PLL clock with is 48MHz. The ADC apparently needs 96 clock cycles for sample conversion. See RP2040 datasheet at chapter 4.9. for ADC details.

Sample rate? Depending on frequency:

  • fastest: 48MHz / 96 = 500 kS/s (without overclocking)
  • slowest: 48Mhz / 65536 = 732.421875 S/s
  • slowest rounded: 48Mhz / 48000 = 1000 S/s

Time between samples?

  • fastest 1/500KHz = 2us (without overclocking)
  • slowest: 1/732.421875Hz = 0.00136533333s (a uneven bit over 1.3ms)
  • slowest rounded: 1/1000Hz = 1ms

Total recording time? Assuming 40'000 samples:

  • fastest: 40'000 / 500KHz = 0.08s = 80ms
  • slowest: 40'000 / 1000Hz = 40s

Graphing

Prefered voltage lines for graphs (symetrical by 0V):

  • Range 0: 0.00, 1.00, 2.00, 3.00, 4.00, 5.00, 6.00 V
  • Range 1: 0.00, 0.50, 1.00, 1.50, 2.00, 2.50 V
  • Range 2: 0.00, 0.25, 0.50, 0.75, 1.00, 1.25 V
  • Range 3: 0.00, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60 V

To-do

  1. Graph!
    • Initial code is here, but it doesn't work (yet)! Time to debug...
      • Write few tests: Generate some predicatable patterns into the samples buffer and try figure out what is going on...
    • Logging would be nice to have to allow some debugging...
      • Browse few of those, figure out categories/features
      • Create and fill the table with comparsions
      • (Unlikely) Figure how to adapt my own logging approach
      • Choose one of the approaches and stick with it for the project
      • ... did nice write up at earlephilhower/arduino-pico#2066
    • Or, go and analyse it part by part
    • Or, actually debug it with second Pico? :monkaHmm:
  2. UI
    1. Offset (płynnie; z możliwością trzymania itd; na razie bez limitów i guess)
    2. Menu od próbkowania itd, osobny przycisk albo przycisk
      • pewnie trzeba pogrupować, może: root, topLevelMenu, samplingMenu, triggeringMenu etc.
      • może pasuje poprawić Group
      • przy okazji pomyśleć co zrobić z bombelkowaniem przyciśnięcia, w szczególności jak się nakładają elementy, w przyszłości może być np. prompt czy alert albo coś innego co zasłania graf czy inne przyciski.
    3. Sampling menu
      1. (patrz TODO w root.cpp)
  3. Default values & persist with EEPROM
  4. Make it work ;)

picooscilloscope's People

Contributors

againpsychox avatar

Watchers

 avatar  avatar

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.