Skip to content

Digital Signal Generation using Raspberry Pi Pico. The goal is to compare different types of programming flows: polling, irq, polling + irq.

License

Notifications You must be signed in to change notification settings

MaverickST/digital_signal_generator

Repository files navigation

Digital Signal Generator (DSG)

Overview

This project implements a Digital Signal Generator (DSG) device capable of generating four different waveforms: sine, triangular, sawtooth, and square. The user can select the type of waveform generated by the DSG using a push button. Additionally, the device allows the user to input parameters such as amplitude, DC level, and signal frequency using a 4x4 matrix keypad. The current values of amplitude, DC level, frequency, and waveform are displayed every second via the serial or USB interface to a terminal tool.

Features

  • Generates four different waveforms: sine, triangular, sawtooth, and square.
  • User-selectable waveform using a push button.
  • Input parameters via a 4x4 matrix keypad:
    • Amplitude (adjustable between 100mV and 2500mV)
    • DC level (adjustable between 50mV and 1250mV)
    • Frequency (adjustable between 1 Hz and 12,000,000 Hz)
  • Default settings:
    • Sine waveform
    • Amplitude: 1000 mV
    • DC Level: 500 mV
    • Frequency: 10 Hz
  • Signal range: -2450mV to 3750mV

Implementation

This project was developed using a Raspberry Pi Pico microcontroller. Three different programming paradigms for embedded systems were utilized:

  1. Polling: In this implementation, the microcontroller continuously polls the status of input devices (e.g., push button, keypad) to determine user input and generate the appropriate waveform.

  2. Interrupt-driven: In this implementation, the microcontroller utilizes interrupts to handle user input and waveform generation. Interrupts are triggered by events such as button presses or keypad input, allowing for more efficient use of processor resources.

  3. Hybrid (Polling + Interrupts): This implementation combines both polling and interrupts for handling user input and waveform generation. Polling is used for continuous monitoring of input devices, while interrupts are employed to handle time-sensitive events or high-priority tasks.

Usage

  1. Connect the device to a power source.
  2. Select the desired waveform by pressing the push button.
  3. Enter the parameters using the keypad: A (Amplitud), B (Offset), C (Frequency).
  4. Press the 'D' key to finalize each parameter entry.
  5. Monitor the generated signal and its characteristics via the serial or USB interface.

Verification

The generated signal and its characteristics should be verifiable using a measuring instrument such as a multimeter or oscilloscope.

Maximum frequencies

This will consist of finding out the maximum frequency that each programming flow can generate. When the signal is generated, then a oscilloscope is used to measure the frequency of the signal.

For testing purposes, the following parameters were used:

  • Amplitude: 1000mV
  • DC Level: 500mV

The next table sumarizes the testing data.

SAMPLES MicroPython Arduino Polling in C IRQ in C Polling + IRQ in C
16 94Hz 2kHz 15kHz 17kHz 12.5kHz
70 21Hz 450Hz 3.3kHz 3.7kHz 2.4kHz

NOTE: SAMPLES = number of point per signal period

Memory Usage

To obtain the memory usage of the C codes were used the next lines in the CMakeLists.txt file:

SET(GCC_EXE_LINKER_FLAGS    "-Wl,--print-memory-usage")
SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${GCC_EXE_LINKER_FLAGS}")

Polling in C

Memory Region Used Size Region Size %age Used
FLASH: 286288 B 2 MB 13.65%
RAM: 9692 B 256 KB 3.70%
SCRATCH_X: 0 GB 4 KB 0.00%
SCRATCH_Y: 0 GB 4 KB 0.00%

IRQ in C

Memory Region Used Size Region Size %age Used
FLASH: 40540 B 2 MB 1.93%
RAM: 6920 B 256 KB 2.64%
SCRATCH_X: 0 GB 4 KB 0.00%
SCRATCH_Y: 0 GB 4 KB 0.00%

Polling + IRQ in C

Memory Region Used Size Region Size %age Used
FLASH: 40788 B 2 MB 1.94%
RAM: 6924 B 256 KB 2.64%
SCRATCH_X: 0 GB 4 KB 0.00%
SCRATCH_Y: 0 GB 4 KB 0.00%

Polling in MicroPython

To get the memory usage information with microPython it is needed to use the next code lines:

import micropython
micropython.mem_info()

GC: total: 191872, used: 22096, free: 169776

Which means a use of 11.5% of the total memory.

Polling in Arduino

Just uploading the sketch from Arduino IDE to Raspberry Pi Pico, we get the next information:

Global variables use 43172 bytes (15%) of dynamic memory, leaving 227164 bytes for local variables. Maximum is 270336 bytes.

About

Digital Signal Generation using Raspberry Pi Pico. The goal is to compare different types of programming flows: polling, irq, polling + irq.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published