# 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 screenshots are with **AMS-1117** linear voltage regulator bypassing the Picos RT6150 on-board switching regulator unless the caption says otherwise. 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 with external AMS-1117 linear regulator</summary>
  <img src="images/noise-floor.png" width="956" />
</details>

<details>
  <summary>Noise floor with on-board RT6150 SMPS in <b>PWM</b> mode</summary>
  <img src="images/noise-floor-pwm.png" width="956" />
</details>

<details>
  <summary>Noise floor with on-board RT6150 SMPS in <b>PFM</b> mode</summary>
  <img src="images/noise-floor-pfm.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>
