Microcontrollers Are Just Radios in Disguise
...or everything is a radio if you use it wrong enough.
Hackaday Supercon (2024-11-02)
https://cnlohr.github.io/lolra_talk
cnlohr / Slides rev B
|
| | | |
Receiving
- "Transmitting is the easy part" - Dad
|
Who am I?
- Love exploring what microcontrollers are capable of without wads of abstractions.
|
My Rules
- No (or minimal) extra hardware
- SPI, ADC, Timer, DMA? 😃
- Resistors, Capacitors? 😐
- A Transistor? 😬
- Chips? Dedicated Features? 🙅
- The cheaper the better 🤑
- 🧠 and some code
- Original chip designers expect impossible
|
| |
Make a receiver
- Use an ADC triggered off of timer
- Use DMA to save samples
- What about a ch32v003?
- They're cheap (~10¢)
- Actively playing with them
|
|
Sprite_tm
- Used internal PLL
- No external parts
- Cooked it up to 90MHz
- Modulated FM
|
ATTiny85
- OSCCAL (FM)
- PLL 8x
- OC1B and OC1B
- PWM is ÷3, but that's OK. We're square.
|
|
|
|
Toggling
- Run ADC at Fs
- - odd + even
- Finds ½Fs
- Sometimes signal fades
- Picks up harmonics
- One add per sample
|
|
Absolute Maximum Ratings
|
|
|
|
Quadrature
- "I" and "Q" running vars
- +--+, ++--
- Tunes only to ¼Fs
- No signal fades
- add and sub per sample
- Picks up harmonics
|
Harmonics
- Why can we receive them?
- Why are they so weak?
|
Quadrature / Harmonics
- Using Spreadsheets
- Simulate a signal
- Perform the operations
- Cancels out other freqs
- Harmonics (3x, 5x, ...)
- power = √i² + q²
|
Color!
- Requires multiple signals
- No hope of keeping up
- Precompute bitstreams in javascript
- Nothing worked
- Confusing Output
- Got an SDR - didn't match expectation
- What if we write a simulator?
|
- Bring up clock tree and PLL
|
CLKPR = 0x80;
CLKPR = 0x00;
PLLCSR = _BV(PLLE) | _BV( PCKE );
|
|
Lower | Higher |
OSCCAL = BASE;
OSCCAL = BASE;
|
OSCCAL = BASE+1;
OSCCAL = BASE;
|
|
|
TCCR1 = _BV(CTC1) | _BV(CS10);
GTCCR = _BV(COM1B0) | _BV(PWM1B);
OCR1B = 1; // Pulse Width
OCR1C = 2; // Period - 1
|
|
|
| |
Goertzel's Algorithm
code
- "Goertzel's algorithm is fun" - JoslynRenfrey (2020)
- "Goertzel's is 🪄" - cnlohr (2024)
- Goertzel's and DFTs are pixel perfect.
- Per sample, 1x add, mul, sub, mov per tuned frequency.
- Tune anywhere in spectrum.
- Easy to implement with integer math.
|
But, Tuning!
- FFTs
- View received spectrum (can look at one output)
- Had to bump up to the V203
- No FPU (But fixed-point FFT OK)
- 4log(n) operations per sample
- sin/cos correlation
- Requires sin + cos per sample
- Still too slow
|
ch32v003 Receiver
- Implemented quadrature decoding
- Devkits are $4 on Aliexpress
|
|
Toolbox
- Digitally Controlled Oscillator
- Frequency Modulation (FM)
- Dithering
- PLL For Frequency Multiplication
- PWM For Output
- Harmonic Output
- Amplitude Modulation (Limited) (AM)
- SPI/I2S Output instead of PWM
- Reflections when direct sampling
|
NTSC Video
- Started with ATTiny85
- AM Modulated
- Turn PWM On/off
- Different Antennas
- 65MHz
- NTSC Sync Diagram
- 3 Voltage Levels
- Flipped
- More Complicated
|
|
|
|
|
ch32v203 Receiver
- 144 MHz RISC-V, with mul
- ADC: 12-bit 1MHz---------- 4.8MHz------------ 9.6MHz
- Uses ch32v003fun
- More $$ than the 003 (30¢)
- Using a stock $10 devkit (no extra parts)
- Leverage Görg Pflug's Vector Scope
|
- calculator.html
- Started as static generator, now realtime
- USB Full Speed
- WebHID, Canvas, AudioWorkletNode
- Select "Fs" "Tune" "Windowsize"
|
|
LoRa®
- 900MHz (From a GPIO rated for 30MHz)
- 125 kHz channels
- Chirps
- Simple analog -> Sophisticated digital
- Forward Error Correction (Up to Hamming-84SX)
- Whitening Codes
- Diagonal Interleaving
- Gray Codes
- Phases of Symbols
- "You'll probably get about 10-20 feet" - Dad
|
COLOR! Broadcast VHF on an ESP8266
|
Moving to the ESP8266
- No PWMs
- I2S Bus
- Playback pre-programmed bitstream per signal level
- One wire connected to "RX" Pin
|
|
|
FM Stations
- Works well with CB Radio (27MHz)
- Can receive at 100+MHz
- Broadcast FM demod different?
|
LoLRa
|
|
| |
| |
Future Work
- Random Sampling or "Compressive Sensing"
- WSPR
- Processor-to-processor
- Thanks Frank, and everyone in my Discord
|
LoLRa Transmissions
- ☹️ ☹️esp32-s2
- ☹️ ☹️ch32v003 ch32v203 esp8266
- SPI/I2S Bus
- Created tables to mimic a chirp
- Wrote LoRa® + LoRaWAN® protocol
|
〜
|
LoRaWAN®
|
LoLRa Range Test
DCO | FM | Dithering |
PLL | PWM | Harmonics |
AM | SPI/I2S | Reflections |
|
|
|
|
|
|
ESP32-S2 Range Test
DCO | FM | Dithering |
PLL | PWM | Harmonics |
AM | SPI/I2S | Reflections |
|
〜
|
ch32v003
|
|
ESP8266 315 MHz
DCO | FM | Dithering |
PLL | PWM | Harmonics |
AM | SPI/I2S | Reflections |
|
ESP32-S2 WSPR
WSPR Modulation is continuous phase 4 FSK, with 1.4648 Hz tone separation.
DCO | FM | Dithering |
PLL | PWM | Harmonics |
AM | SPI/I2S | Reflections |
DCO | FM | Dithering |
PLL | PWM | Harmonics |
AM | SPI/I2S | Reflections |
|