Oscilloscope Clock on a Raspberry Pi Pico

by CaptainBrainFart in Circuits > Clocks

1127 Views, 3 Favorites, 0 Comments

Oscilloscope Clock on a Raspberry Pi Pico

Oscilloscope Clock

Overview:

Somehow I've built up a collection of old oscilloscopes. They are useful when I'm building or fixing stuff, but the rest of the time, they just sit on the shelf doing nothing. So what I needed was an unusual use for them.

This Instructable is a proof of concept, so only assembled on a solder-less breadboard, and is intended to see if I could get the scopes to display something a bit more interesting than just the usual wobbly lines.

Features:

  • Two independent 8-bit Digital to Analog (DAC) channels using R-2R networks.
  • Oscilloscope XY mode to plot an analogue clock.
  • C++ program
  • Single USB provides power, programming and control.
  • Solder-less construction.

Supplies

Oscilloscope (must have two channels and XY mode)

Raspberry Pi Pico

44 x 330 ohm, 0.25 watt resistors

2 x 400 point solder-less breadboards

Micro-USB cable (to connect to the Raspberry Pi Pico)

Construction

Pico_DAC_schem.png
Pico_DAC_bb.png
IMG_1227.JPG

Image #1: Circuit diagram - the resistors forming the DAC network are all identical values, and connect directly to the GPIO ports on the Raspberry Pi Pico.

Image #2: Layout details - created using Fritzing.

Image #3: Actual layout - same as Fritzing diagram. This is only a proof of concept, so I have just used a solder-less breadboard

Programming the Raspberry Pi Pico

The code is written in C++, and if you want a closer look at how it works, the source is available from the Github repository.

If you just want to use the code, the repository also includes a '.UF2' file which is pre-compiled and ready to run.

To install the UF2 file on the Raspberry Pi Pico...

  1. Download the clock.uf2 file from the Github repository.
  2. On the Raspberry Pi Pico, push and hold the BOOTSEL button and plug the Pico into the USB port of your computer. Release the BOOTSEL button after the Pico is connected.
  3. The Pico will mount as a Mass Storage Device called RPI-RP2.
  4. Drag and drop the clock.uf2 file onto the RPI-RP2 volume.
  5. Once copied, the Pico will re-boot and execute the code.

Technical Details

R-2R network.png
IMG_1243.JPG
IMG_1247.JPG
IMG_1246.JPG

Image #1: R-2R Resistor Ladder...

There are plenty of articles already explaining R-2R DAC operation. I'm not a mathematician, so I wont be covering it here. But if you do want want to see the maths behind the resistor ladder network, a good place to start is the page on Wikipedia. Or, I have put together an Interactive Simulation showing circuit operation.


Stray Capacitance (and the choice of resistor values)...

I originally built the circuit using a 10K resistor network. My thinking at the time was this would simplify construction. But results were disappointing, with frequency response dropping off rapidly for frequencies above 100KHz. After much Googling, I realised the issue was due to stray capacitance.

The combination of the resistor network and the stray capacitance creates an RC filter. So I applied some maths to the issue...

Image #2: At low frequencies (100 Hz) my digital scope measures Vout Pk-Pk = 3.26 volts

To find -3DB multiply Vout by 1 over square root of 2 = 2.3 volts

So I can use the digital scope to measure the output voltage and vary the frequency until I get 2.3 volts. The scope reading jumps around a bit, so I measured two values. 2.2 volts is below the -3DB point and 2.4 volts is above the -3DB point.

Varying the frequency and observing Vout gives...

Image #3: Vout = 2.2 volts @ F = 133KHz

Image #4: Vout = 2.4 volts @ F = 111KHz

Taking the output impedance of the R-2R network as 10K, we can plug these values of F into the formula

C = 1 / (2 * Pi * R * F )

F=111KHz: gives C = 143pF

F=133KHz: gives C = 119pF

So the stray capacitance would seem to be somewhere between 119pF and 143pF.

Using R=10K gives a -3DB frequency of between 111KHz and 133KHz (observed value)

Using R=165 ohms gives a -3DB frequency of 14MHz (calculated value)

Or, to put it another way, using high value resistors in the R-2R network is a really bad idea.

Screen burn...

Just a reminder... leaving the clock running for extended periods on a CRT based oscilloscope, is going to be really bad for the tube, leaving a permanent imprint of the clock face burned into the tube phosphor.

Interface Settings

These settings are only recommendations, and reflect the way I have my system connected. The circuit should work with most terminal emulators on most operating systems.

Operating System:

  • Windows 10 or later - earlier version of Windows won't recognise the USB connection.

Oscilloscope:

  • Horizontal (X) deflection: => Channel 1 (yellow)
  • Vertical (Y) deflection: => Channel 2 (blue)
  • Probe scale: x 1

Terminal software:

  • Putty
  • Speed: 115200
  • Local echo: auto

Clock Application (Supported commands):

  • ? - Help
  • T - Set time
  • Notation: HH:MM:SS or HH,MM,SS
  • HH can be either 12 or 24 hour notation. e.g. '03:00:00' is the same as '15:00:00'
  • Delimiter can be either ':' or ','. e.g. '15:00:00' is the same as '15,00,00'
  • MM is in the range 0<=MM<=59
  • SS is in the range 0<=SS<=59
  • Leading zeros can be omitted. e.g. '1:2:3' is the same as '01:02:03'
  • Trailing parameters can be omitted. e.g. '12:15' is the same as '12:15:00'
  • L - Set level
  • Notation: 2 digit percentage 0<=NN<=100
  • V - Version info
  • X - Invert X axis
  • Y - Invert Y axis