Rename to pico-pio-adc and clean up
This commit is contained in:
parent
5e841595f3
commit
7727826b34
12 changed files with 140 additions and 16 deletions
7
LICENSE
Normal file
7
LICENSE
Normal file
|
@ -0,0 +1,7 @@
|
|||
The person or persons who have associated work with this document (the "Dedicator" or "Certifier") hereby either (a) certifies that, to the best of his knowledge, the work of authorship identified is in the public domain of the country from which the work is published, or (b) hereby dedicates whatever copyright the dedicators holds in the work of authorship identified below (the "Work") to the public domain. A certifier, moreover, dedicates any copyright interest he may have in the associated work, and for these purposes, is described as a "dedicator" below.
|
||||
|
||||
A certifier has taken reasonable steps to verify the copyright status of this work. Certifier recognizes that his good faith efforts may not shield him from liability if in fact the work certified is not in the public domain.
|
||||
|
||||
Dedicator makes this dedication for the benefit of the public at large and to the detriment of the Dedicator's heirs and successors. Dedicator intends this dedication to be an overt act of relinquishment in perpetuity of all present and future rights under copyright law, whether vested or contingent, in the Work. Dedicator understands that such relinquishment of all rights includes the relinquishment of all rights to enforce (by lawsuit or otherwise) those copyrights in the Work.
|
||||
|
||||
Dedicator recognizes that, once placed in the public domain, the Work may be freely reproduced, distributed, transmitted, used, modified, built upon, or otherwise exploited by anyone for any purpose, commercial or non-commercial, and in any way, including by methods that have not yet been invented or conceived.
|
62
README.md
Normal file
62
README.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
# Pico PIO ADC
|
||||
|
||||
Sigma-delta ADC demo for Raspberry Pi Pico using PIO.
|
||||
|
||||
|
||||
## Building
|
||||
|
||||
1. Clone with `git clone --recursive` to get the alternative stdio.
|
||||
2. You need to have `PICO_SDK_PATH` set.
|
||||
3. Just run `cmake -B build src` to configure the project.
|
||||
4. And then `cmake --build build` to build it.
|
||||
5. Flash the firmware via `picotool load -f build/pico-pio-adc.uf2`.
|
||||
|
||||
|
||||
## GNU Radio Companion
|
||||
|
||||
The GNU Radio Companion examples work with a FIFO that receives the stream from the serial.
|
||||
Build creates a simple tool to move the bytes around, so you can do this:
|
||||
|
||||
```
|
||||
mkfifo samples.fifo
|
||||
build/tools/serial /dev/ttyACM1 >samples.fifo
|
||||
```
|
||||
|
||||
Then GRC can grab the samples.
|
||||
|
||||
If you tire of having to start the serial tool manually, you can do this:
|
||||
|
||||
```
|
||||
watch -n1 'build/tools/serial /dev/ttyACM1 >samples.fifo'
|
||||
```
|
||||
|
||||
This restarts it in a second once it quits.
|
||||
|
||||
|
||||
## Circuit
|
||||
|
||||
<a href="https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCBMCmC0Cc4CsA6ALAdkhgbB+GYYAHDmAAyIbkjkoRI1JxEBQASiPGmiLGJGIhi8HHwFDeSED3Jz5IAMwpFtNXSSsATiAxJI4+Ab0GEYmpEjzWAYxBIcNMyBwO+omeBTyfv+WDgMWhQMHkUwfWIRcjR4fSC6UNpbXX13MRM1XgDYITAUHFj4blIorEVyRWyC6XJWAHNUgxpMsHNkgHcm9OE0IWc6roo0JzAjbv5xup1M51cxAZlqVgjpbl5+R3AY0a2KSBGlFU7tw8mDYd2aOoAXGQ8mLevwPjpiJCi+pEViciJK2LBJDcSDwch6b5oQTEA7bGgAE2gADMAIYAVwANjdWF0HE4PHjxOYcfY9mJCQ9tKSaGMDIToWoKHIGtSoFFWRVeNcqYTzqzFky6pxebT+ZYuVkaMpVM8NFSRs9Oeo4dN7u1YgsHirmV0NT1eZTOEqLFhlRAfgo6JVlXK7Aqslrqn5nXIckF+ChGORLK44tQBIwNvlGDKSQI2j0wOFTJS7ITRfNwOMnS6-G7XiEeIJFBhCOCkGgcKQM0lBr1+h51j06gA3U74sREKzVyXiGo2z1UpsN8CQCMC6x2cOaxt99XgOCIWAaKJNnBWASUfQQbmNYeMsfgdp1Nebhnr43JIeb0XrhnZSdA0J5sC4IvwETfdRdxdJi4nqYq1h1y5v8Cv0VnjOfJXA7TQumIPo-yrQCww-C5oz-Mtfw8X8JGSVYuB4Xs8h2HDtgOKVjmlKlWnGRNAKWZC8I8TJKS6MiDEgvIphZTIGUyQ86jsRjunPCdci8Vw-nIYgmx4HBChwVQQNqUi0lotJKMsaxOBgrYREbLYpBkBUfCOGV1E7XEtgJPZWIAB3ARDnCjAQ-0M7kACNhGkvhxXAKFVEUJAV1YAAPOF+kI3tcHcnNPFhdgAAUrBGAAdABnAB6JL4QAS3qdKbhRDE0oAewAWxRdKADsAt0MT3NE4RFFUWArGkbIxAAcWigBJAB5JLIAqjAqv4eziDq8RKE8CM2q6pLFD6qrflq1RhvG1qOu6xK6kC-qIFvMRhpk-BlpASa1rACqKAwerTzqqcSEQZqQAAFQAC2gRLoCSpF0qxaAtESpKUS0d7EoAKzRRKbg+-KtCSr6MTBm4tBRG50vy0qABozvBS6wqjB9xAuw6bhewGYb+xLSvyj6vpuH6yvqJKnNe9LETJomgcRGx0uK5HUZQTGCf4bCo0BQWIHugA5fL0repLEqelELLpgrXqStmkpelEawATySjF0qRZHSvqPmXI8wa6VzLhiUCn1xHCGQKnEQRDvYFFSvhIqkva9gkuip78puAPEdKxLpcDrQKuBJxBCoER3OLe7nulpKsprFXEvqEr0YZtEIdD0rVbRLRysCqP3IJsSp2wGh7r1wrsrJ4r-K5tFCph0qLNzpKa3yrEUXqaA+a8lxTQatwLvdMA0Dk4e8FMSA3BwOIneaVh8qgAxCkZHyoUbEI4vCNBFEKAsjBXbxXTUaRLCUKApSUCUqlv6L8tD5G0-+92kvF6BM-foGADKmVSq5USmvGQ0gt40h3pAckwRtovAACL6yRD9aApVka5SSp1XOndsRAA">
|
||||
<img src="images/circuitjs.png" alt="Circuit Schema" />
|
||||
</a>
|
||||
|
||||
Click the image to open interactive version in Paul Falstad's excellent online simulator.
|
||||
|
||||
|
||||
## Screenshots
|
||||
|
||||
Please note that all these are with **AMS-1117** linear voltage regulator replacing the stock switched regulator on Pico. This is done by jumpering `3V3_EN` pin to `GND`, feeding `VSYS` to the regulator input and passing the regulator output to `3V3` pin. The `3V3` rail is then decoupled with `10uF` ceramic capacitor to `GND` on the analog board.
|
||||
|
||||
<details>
|
||||
<summary>Noise Floor</summary>
|
||||
<img src="images/noise-floor.png" width="956" />
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>IR Blast, full rate</summary>
|
||||
<img src="images/ir-blast-full.png" width="956" />
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>IR Blast, tuned at 38 kHz</summary>
|
||||
<img src="images/ir-blast-narrow.png" width="931" />
|
||||
</details>
|
|
@ -69,7 +69,7 @@ blocks:
|
|||
alias: ''
|
||||
begin_tag: pmt.PMT_NIL
|
||||
comment: ''
|
||||
file: /home/mordae/work/smart/pico-pdm/samples.fifo
|
||||
file: ../samples.fifo
|
||||
length: '0'
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
|
|
|
@ -109,7 +109,7 @@ blocks:
|
|||
alias: ''
|
||||
begin_tag: pmt.PMT_NIL
|
||||
comment: ''
|
||||
file: /home/mordae/work/smart/pico-pdm/samples.fifo
|
||||
file: ../samples.fifo
|
||||
length: '0'
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
|
@ -567,6 +567,7 @@ blocks:
|
|||
|
||||
connections:
|
||||
- [blocks_char_to_float_0, '0', blocks_float_to_complex_0, '0']
|
||||
- [blocks_char_to_float_0, '0', blocks_float_to_complex_0, '1']
|
||||
- [blocks_complex_to_mag_squared_0, '0', qtgui_time_sink_x_0_0, '0']
|
||||
- [blocks_file_source_0, '0', blocks_char_to_float_0, '0']
|
||||
- [blocks_float_to_complex_0, '0', blocks_freqshift_cc_0, '0']
|
||||
|
|
BIN
images/circuitjs.png
Normal file
BIN
images/circuitjs.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 136 KiB |
BIN
images/ir-blast-full.png
Normal file
BIN
images/ir-blast-full.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 467 KiB |
BIN
images/ir-blast-narrow.png
Normal file
BIN
images/ir-blast-narrow.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 388 KiB |
BIN
images/noise-floor.png
Normal file
BIN
images/noise-floor.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 475 KiB |
|
@ -1,17 +1,27 @@
|
|||
cmake_minimum_required(VERSION 3.21)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(tools
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools
|
||||
BINARY_DIR ${CMAKE_BINARY_DIR}/tools
|
||||
CMAKE_ARGS -DCMAKE_C_COMPILER=cc
|
||||
-DCMAKE_CXX_COMPILER=c++
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)
|
||||
|
||||
project(pdmtest)
|
||||
project(pico-pio-adc)
|
||||
pico_sdk_init()
|
||||
|
||||
add_executable(pdmtest main.c)
|
||||
add_executable(pico-pio-adc main.c)
|
||||
|
||||
add_subdirectory(vendor/pico-stdio-usb-simple)
|
||||
|
||||
target_link_libraries(
|
||||
pdmtest
|
||||
pico-pio-adc
|
||||
pico_stdio_usb_simple
|
||||
|
||||
pico_divider
|
||||
|
@ -27,7 +37,7 @@ target_link_libraries(
|
|||
hardware_vreg
|
||||
)
|
||||
|
||||
target_compile_definitions(pdmtest PRIVATE
|
||||
target_compile_definitions(pico-pio-adc PRIVATE
|
||||
PLL_SYS_REFDIV=1
|
||||
PLL_SYS_VCO_FREQ_HZ=1584000000
|
||||
PLL_SYS_POSTDIV1=6
|
||||
|
@ -35,16 +45,16 @@ target_compile_definitions(pdmtest PRIVATE
|
|||
SYS_CLK_HZ=132000000
|
||||
)
|
||||
|
||||
pico_add_extra_outputs(pdmtest)
|
||||
pico_add_extra_outputs(pico-pio-adc)
|
||||
|
||||
set_property(TARGET pdmtest PROPERTY C_STANDARD 23)
|
||||
target_compile_options(pdmtest PRIVATE -Wall -Wextra -Wnull-dereference)
|
||||
target_compile_definitions(pdmtest PUBLIC PICO_MAX_SHARED_IRQ_HANDLERS=8u)
|
||||
target_compile_definitions(pdmtest PUBLIC PICO_STDIO_ENABLE_CRLF_SUPPORT=1)
|
||||
target_compile_definitions(pdmtest PUBLIC PICO_STDIO_DEFAULT_CRLF=1)
|
||||
target_compile_definitions(pdmtest PUBLIC PICO_STDIO_AUX=1)
|
||||
set_property(TARGET pico-pio-adc PROPERTY C_STANDARD 23)
|
||||
target_compile_options(pico-pio-adc PRIVATE -Wall -Wextra -Wnull-dereference)
|
||||
target_compile_definitions(pico-pio-adc PUBLIC PICO_MAX_SHARED_IRQ_HANDLERS=8u)
|
||||
target_compile_definitions(pico-pio-adc PUBLIC PICO_STDIO_ENABLE_CRLF_SUPPORT=1)
|
||||
target_compile_definitions(pico-pio-adc PUBLIC PICO_STDIO_DEFAULT_CRLF=1)
|
||||
target_compile_definitions(pico-pio-adc PUBLIC PICO_STDIO_AUX=1)
|
||||
|
||||
target_include_directories(pdmtest PRIVATE include)
|
||||
target_include_directories(pico-pio-adc PRIVATE include)
|
||||
|
||||
#pico_set_binary_type(pdmtest no_flash)
|
||||
#pico_set_binary_type(pdmtest copy_to_ram)
|
||||
#pico_set_binary_type(pico-pio-adc no_flash)
|
||||
#pico_set_binary_type(pico-pio-adc copy_to_ram)
|
||||
|
|
2
src/tools/.clangd
Normal file
2
src/tools/.clangd
Normal file
|
@ -0,0 +1,2 @@
|
|||
CompileFlags:
|
||||
CompilationDatabase: ../../build/tools
|
6
src/tools/CMakeLists.txt
Normal file
6
src/tools/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.21)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
project(tools)
|
||||
|
||||
add_executable(serial serial.c)
|
36
src/tools/serial.c
Normal file
36
src/tools/serial.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *path = "/dev/ttyACM1";
|
||||
|
||||
if (argc >= 2)
|
||||
path = argv[1];
|
||||
|
||||
int fd = open(path, O_RDONLY | O_NOCTTY);
|
||||
if (fd < 0)
|
||||
return 1;
|
||||
|
||||
struct termios tty;
|
||||
tcgetattr(fd, &tty);
|
||||
cfmakeraw(&tty);
|
||||
tty.c_cflag |= CLOCAL;
|
||||
tty.c_cflag &= ~(HUPCL | CRTSCTS);
|
||||
tcsetattr(fd, TCSANOW, &tty);
|
||||
|
||||
uint8_t buf[4];
|
||||
int sofar = 0;
|
||||
|
||||
while (1) {
|
||||
int n = read(fd, buf, sizeof(buf));
|
||||
if (n > 0) {
|
||||
fwrite(buf, n, 1, stdout);
|
||||
} else {
|
||||
return n < 0;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue