wave_generator
Signal Generator and Oscilloscope on Arduino
Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 2 committers (50.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.8%) to scientific vocabulary
Keywords
Repository
Signal Generator and Oscilloscope on Arduino
Basic Info
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
Signal Generator and Oscilloscope on Arduino
This repo contains an Arduino sketch file for producing periodic analogue signal. This was originally developed for the Arduino Due, but with minimal modification should work with any Arduino board with a digital-analogue-converter output.
The key requirement is that the Arduino board must have a true analogue output port (This was not designed to work with PWM port).
Other than the signal generator itself, there is also a second sketch file for a second Arduino board to read this analogue signal and transfer this data (after digital sampling) to PC for analysis and verification purpose. Essentially it is a (poor man's) oscilloscope with 12-bit resolution.
To ease the data analysis process with the oscilloscope sketch, some useful python functions to read the serial data, plot its time series and frequency profile are provided.
A Jupyter notebook is provided to demonstrate the use of these python functions.
The python code requires numpy, matplotlib, pyserial packages, but you can also just install all required packages with the requirements.txt file with pip -r requirements.txt.
Signal Generator
The signal generator itself is located in arduino/signal_generator/ directory.
At the top of the file, frequency and amplitude can be adjusted.
The number of voltage output value update per oscillation period can also be adjusted. (More means more accurate depiction of desired waveform).
The signal generator outputs the analogue signal on its DAC0 port.
The waveform can also be changed.
I provided square wave, saw wave and sine wave.
These are defined in WaveLUT.hpp header file and it can be easily extended to define any other waveforms.
There is a self_test option at the top of the main sketch file.
1. 0 value means there is no data output from the Arduino board to PC via the native USB port. This should normally be used in production environment after verifying the waveform is correct.
2. 1 value means the Arduino board will output the analogue voltage value it is supposed to output at its DAC0 port to PC.
3. 2 value should only be used when the DAC0 port of the Arduino board is connected to the A0 analogue input port, and then the Arduino board will read the actual analogue volage input value at A0 and transfer that to PC via the native USB port.
These options are meant for self testing if the board is outputting the desired wave form. The number of times values will be reported to PC per DAC value update can also be configured at the top of the sketch file. More frequent reporting gives more accurate description of the actual wave form, and allows for more accurate frequency analysis (subject to Nyquist's theorem of course), but imposes greater pressure on the board and greater bandwidth requirement over USB. (This is why the USB port used must be the native port and not the programming port, which is slow.)
Prior to experiment, you should first calibrate the minimum and maximum output of the DAC output voltage from your arduino board (it is not 0 and 5V).
You can do this by making your arduino output 0 to DAC0, connect DAC0 to A0 and use self_test=1 and see what voltage you get on A0.
To get maximum output voltage, you either output 1023 to DAC0, if your analogue write resolution is 10-bit, or output 4095 to DAC0, if you analogue write resolution is 12-bit. (It is 12-bit capable on Due but you must manually set the resolution to 12-bit, otherwise it is 10-bit by default)
After getting these values, you should put these measured values into the v_out_min_mV and v_out_max_mV variable (in milliVolt).
If you don't do this then your amplitude will be wrong!.
Oscilloscope
The oscilloscope sketch file is in arduino/analogue_data_reader/ directory.
At the top of the file you must ensure that you set the frequency that the board samples the analogue data to PC.
You can either do this by setting the report_period_us variable directly (in microsecond), or calculate an appropriate value by setting the frequency and other variables in the same way you set it for the signal generator sketch file.
Once this sketch file is loaded onto the board via the native port, you can then open the Jupyter notebook in notebooks/data_processing.ipynb to use as an oscilloscope.
The notebook automatically determines which port the board is connected to, read serial data from it, save it to the data/ directory, plot these analogue voltage data into a time series, and perform Fourier transform on it to produce a Fourier domain plot.
IMPORTANT NOTE: You must ensure the report_period_us variable is set in the same way as in the Arduino sketch, otherwise the frequency calculation will be wrong.
This notebook is meant as a guide for the couple of useful functions defined in scripts/data_processing.py. Feel free to use it as a template for further development.
Citation
If you use this work, please cite using the CITATION.cff file contained at repository root.
Owner
- Name: Richard
- Login: relativistic-penguin
- Kind: user
- Location: Cambridge, UK
- Repositories: 1
- Profile: https://github.com/relativistic-penguin
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "WANG" given-names: "RICHARD ZHIPENG" orcid: "https://orcid.org/0000-0001-7621-0416" title: "wave_generator" version: 1.0.0 date-released: 2024-09-13 url: "https://github.com/relativistic-penguin/wave_generator"
GitHub Events
Total
Last Year
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Richard | w****e@g****m | 3 |
| Richard Wang | z****1@c****k | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: about 1 year ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- Jinja2 ==3.1.4
- MarkupSafe ==2.1.5
- Pygments ==2.18.0
- appnope ==0.1.4
- asttokens ==2.4.1
- attrs ==24.2.0
- backcall ==0.2.0
- beautifulsoup4 ==4.12.3
- bleach ==6.1.0
- certifi ==2024.8.30
- charset-normalizer ==3.3.2
- comm ==0.2.2
- contourpy ==1.3.0
- cycler ==0.12.1
- debugpy ==1.8.5
- decorator ==5.1.1
- defusedxml ==0.7.1
- docopt ==0.6.2
- executing ==2.1.0
- fastjsonschema ==2.20.0
- fonttools ==4.53.1
- idna ==3.8
- ipykernel ==6.29.5
- ipython ==8.12.3
- jedi ==0.19.1
- jsonschema ==4.23.0
- jsonschema-specifications ==2023.12.1
- jupyter_client ==8.6.2
- jupyter_core ==5.7.2
- jupyterlab_pygments ==0.3.0
- kiwisolver ==1.4.7
- matplotlib ==3.9.2
- matplotlib-inline ==0.1.7
- mistune ==3.0.2
- nbclient ==0.10.0
- nbconvert ==7.16.4
- nbformat ==5.10.4
- nest-asyncio ==1.6.0
- numpy ==2.1.1
- packaging ==24.1
- pandas ==2.2.2
- pandocfilters ==1.5.1
- parso ==0.8.4
- pexpect ==4.9.0
- pickleshare ==0.7.5
- pillow ==10.4.0
- platformdirs ==4.3.2
- prompt_toolkit ==3.0.47
- psutil ==6.0.0
- ptyprocess ==0.7.0
- pure_eval ==0.2.3
- pyparsing ==3.1.4
- pyserial ==3.5
- python-dateutil ==2.9.0.post0
- pytz ==2024.2
- pyzmq ==26.2.0
- referencing ==0.35.1
- requests ==2.32.3
- rpds-py ==0.20.0
- scipy ==1.14.1
- six ==1.16.0
- soupsieve ==2.6
- stack-data ==0.6.3
- tinycss2 ==1.3.0
- tornado ==6.4.1
- traitlets ==5.14.3
- typing_extensions ==4.12.2
- tzdata ==2024.1
- urllib3 ==2.2.3
- wcwidth ==0.2.13
- webencodings ==0.5.1
- yarg ==0.1.9