# How does rpitx generate arbitrary SSB data with a clock peripheral?

While it wasn't the first to do so, the rpitx software seems to be the most active and mature implementation of what its own comments call "a code fragment by PE1NNZ". The trick is explained in Guido's original Direct SSB Generation by frequency modulating a PLL article — but I don't quite understand how even the original works:

The PLL oscillator can be phase modulated by short manipulations of the configured frequency. Increasing the frequency temporarily and then restoring to its original frequency, will shift the phase upwards, while decreasing the frequency temporarily will decrease the phase of the signal. In this way the phase information for generating a SSB signal can be applied to the RaspberryPi PLL by means of frequency modulation.

This almost makes sense, but then he loses me a bit later:

After some experimenting, amplitude information can be completely rejected [… talks about generating an unsuppressed carrier …]

Now I suppose that if you have complete (and drastic) control over the phase of a sine wave, you can reproduce any other continuous signal simply by "walking" forward and backward along half a cycle of a sine wave — basically just slewing to whichever value between -1 and +1 is needed at the moment. Is that essentially what PE1NNZ's trick reduces down too, or is that a poor way to think about it?

Now even if I'm on the right track above, the rpitx implementation (source code) seemingly has an additional hurdle to overcome:

Rather than controlling the phase of a sine wave, my understanding is that with the Raspberry Pi "hack" the oscillator peripheral being used was meant to be a clock source. Wouldn't that then be a square wave generator then, i.e. generating (at least in its idealized form) only the peak -1 and +1 values and nothing in between?

Certainly I can see how discrete values could still generate an arbitrary waveform after filtering, for example pulse width or pulse-density modulation. But that does not seem to be the way either PE1NNZ or the rpitx contributors seem to be thinking about this — otherwise why not simply bit-bang any GPIO pin instead of using the clock peripheral!

Somehow rpitx is converting arbitrary I/Q data to RF signals through a huge range of frequencies (130 kHz to 750 MHz) — I'd love to understand the theory behind it! Could I use the same trick to turn an FM transceiver into an "All Mode" radio by injecting a suitably transformed input signal?

• If you can control phase and amplitude, then you can generate any waveform. Consider the IQ plane: phase and amplitude are just the same in polar coordinates. It sounds though like he found adjusting the amplitude wasn't really necessary: instead he just puts that energy at the carrier frequency. What's left is more like AM with one sideband suppressed. – Phil Frost - W8II Oct 26 '16 at 0:53
• I also found a presentation including this technique given by one of the authors, at youtube.com/watch?v=Jku4i8t_nPc&t=826, but it doesn't settle my curiousity. – natevw - AF7TB Sep 8 '17 at 21:34

This is an incomplete and theoretical answer as I haven't looked at rpitx in particular.

Rather than controlling the phase of a sine wave, my understanding is that with the Raspberry Pi "hack" the oscillator peripheral being used was meant to be a clock source. Wouldn't that then be a square wave generator then, i.e. generating (at least in its idealized form) only the peak -1 and +1 values and nothing in between?

Yes, but a square wave is a sine wave plus harmonics, and harmonics of a square wave of fundamental frequency $f$ are all at frequencies $2f$ or higher, so a receiver tuned to $f$ will not see the difference, and if it is low-pass filtered appropriately then there is no difference in the transmitted signal.

If this still sounds like a hack, or you wonder if modulation makes a difference, consider that it's perfectly possible to make a RF mixer using a square wave and XOR.

why not simply bit-bang any GPIO pin instead of using the clock peripheral!

Again, I haven't looked at the hardware capabilities involved, but most likely, the peripheral can oscillate at a much higher rate than the Pi's processor can bit-bang the output, thus allowing for a higher carrier frequency. The software control need only operate at (perhaps some small multiple of) the sample rate of the modulating signal, not the RF rate.

SSB comprises both amplitude and phase components. For any instant, plot the baseband signal's Q (quadrature) and I (in-phase) components on the y-axis and x-axis, respectively. The amplitude is the length of the vector from the origin to this (I,Q) point. The phase is the angle between this vector and the x-axis.

PE1NNZ modulates the amplitude of the clock driver by changing its drive strength. Only eight levels are available, corresponding to just 3 bits of audio resolution.

PE1NNZ is only able to modulate the frequency of the clock generator. Instantaneous frequency is the time derivative of instantaneous phase. PE1NNZ takes the time derivative of the phase by taking differences of successive phase calculations and changing the frequency of the clock generator accordingly.

• Thanks, I think this helps me understand after reading it carefully. So I wouldn't be able to apply the same technique to an FM transmitter, without 1) some amount of continuous control over its output power and 2) a much greater deviation than is typically used? – natevw - AF7TB Sep 6 '18 at 22:38
• The deviation of a typical NBFM transmitter might be sufficient; you need a high degree of control over phase and output level to achieve acceptably low distortion. The seminal paper is "Single-Sideband Transmission by Envelope Elimination and Restoration", Leonard Kahn, Proc IRE, 1952. You can see an up-to-date approach in "The Polar Explorer", Machesney et al, QEX, 2017. – Brian K1LI Sep 11 '18 at 4:11