Giter VIP home page Giter VIP logo

maverickst / digital_signal_generator Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.32 MB

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

Home Page: https://github.com/MaverickST/digital_signal_generator.git

License: MIT License

C 64.13% CMake 12.45% Python 20.12% C++ 3.30%
irq polling raspberry-pi-pico arduino c python

digital_signal_generator's Introduction

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.

digital_signal_generator's People

Contributors

maverickst avatar cristian-david-araujo 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.