Shop OBEX P1 Docs P2 Docs Learn Events
DEMO: Direct 2M FM broadcast modulation with the Propeller — Parallax Forums

DEMO: Direct 2M FM broadcast modulation with the Propeller

pedwardpedward Posts: 1,642
edited 2012-01-06 08:34 in Propeller 1
So I was playing with my MFJ SWR meter as a frequency counter and toying with the PLL modes of the Prop. I found out that the prop would generate 220Mhz, so I grabbed my handy talky and started playing with the prop to see if I could generate a carrier the HT would pick up.

As luck would have it, it worked!

Now, the code attached is not exactly kosher; I have a HAM radio license (W0NKE) and I'm permitted to broadcast on those frequencies. If you don't have a HAM license, retune the PLL to a lower frequency in the broadcast FM range.

I arrived at the FRQ value from the equation in the Propeller Data Sheet. Restated, the equation is: FRQx = frequency / 16 / CLKFREQ * 2^32. The extra /16 is to account for the PLL running at 16X the NCO frequency.

The sample program plays a WAV file of 11.025 Khz over the air on 146.550MHz (the 2nd channel off of the national call frequency). In 2M the channel bandwidth is 20Khz and the spacing is 15Khz, I have tested this program to ensure it doesn't modulate wider than the permitted bandwidth.

I couldn't include the WAV file directly, but any 8-bit 11025Hz PCM WAV file will work as long as it fits in the EEPROM.

The bandwidth (and volume) is controlled by the bit shift of the WAV sample. I experimented with various values and found << 5 to provide the best balance of volume and channel use.

Now, there appear to be a significant amount of harmonics coming from this, so I definitely don't recommend hooking this up to a tuned antenna and putting it on the air! This is merely a trinket that you can play with. With a short wire as an antenna, it would transmit 40 feet without any degradation in signal strength.

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2012-01-02 02:42
    Wow, that's a simple bit of code!

    Makes Phils IQ demodulator even more valuable. Prop SDR Transceiver here we come...

    I have too many prop projects already!!!
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2012-01-02 07:33
    I have ditched all of my 2Mtr kit a long time ago and even passed up a chance to have my fathers stuff more recently. I did try generating a signal at about 100MHz so that I could pick it up on a domestic receiver and thought it too phase noisy to be of much use for NBFM. I will have to get this code going and push it into one of the Spec Annys at work.

    When I was a teenager my father would pick up the 137MHz weather sats, and that is still in me, I often look up and see them fly overhead and dream about receiving them again. It is so much easier to get a picture off of the tones now; back then it involved rotating drums or windscreen wiper motors.

    (Those days made me the recycling hoarder that I am, "Thats too good to throw away... Thats bound to be useful, for something... ")
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-01-02 08:01
    I looked at this a couple of years ago, and generated an alternating tone signal http://forums.parallax.com/showthread.php?120170-AM-and-FM-Transmitters . I like your version that transmits a WAV file.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-02 10:11
    pedward,

    'Glad to see another RF experimenter amongst the Propeller crowd!

    Have you scanned the entire two-meter band for your signal? How about for the third harmonic at 439.65 MHz? The reason I ask is that I've tried something similar myself on two meters with the PLL and found that there's enough frequency jitter to produce birdies all over the two-meter band and beyond. The jitter comes from values of frqx that have more than one "1" bit and arises due to the PLL's rather short filtering time constant. Unfortunately, there's no way to filter out the jitter, once it's introduced.

    As a consequence, you might look into ways to control an external VCO with the Propeller to produce a clean signal. I've done a little bit in the HF range, but have not yet come up with a good way to extend that work to the VHF range. Plus, the breadboarding is a little trickier! :)

    -Phil
  • pedwardpedward Posts: 1,642
    edited 2012-01-02 11:45
    Phil, yes there were birdies, but it's hard to tell why when the receiver is so close to the transmitter. The HT appeared to be a little overloaded.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-02 12:16
    I was able to detect birdies at a distance during my experimenting, using an FT817 as the receiver. So they're not due to overload. They really are spurious sidebands due to the PLL's inherent phase noise.

    -Phil

    Addendum: Here's an early thread that talks about jitter and the birdies that result:

    BTW, they can't be blocked adequately with an LC filter.
  • pedwardpedward Posts: 1,642
    edited 2012-01-02 12:23
    I'm under no delusions that the prop will generate a signal clean enough for real use, but it was neat to do!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-02 12:27
    It's a great start and a lot of fun to hear your transmission on a receiver! The Prop II, with its built-in sine/cosine DACs and synth circuitry should go a long way toward making Propeller RF apps simpler. But, in the meantime, there's a lot that can still be done with the Prop I.

    -Phil
  • pedwardpedward Posts: 1,642
    edited 2012-01-02 18:53
    pedward,

    'Glad to see another RF experimenter amongst the Propeller crowd!

    Have you scanned the entire two-meter band for your signal? How about for the third harmonic at 439.65 MHz?

    -Phil

    Nothing but a carrier unsquelch at 439.650. Seems like there are harmonics at 110Khz intervals above the channel, so the Prop PLL is very noisy in this application. I don't fault the prop, it just does what it does. Now, had the PLL logic been setup so it was Before the NCO, like taps in most uC chips, it would address much of the jitter problems.
  • Mark_TMark_T Posts: 1,981
    edited 2012-01-03 04:12
    pedward wrote: »
    I'm under no delusions that the prop will generate a signal clean enough for real use, but it was neat to do!

    Perhaps a crystal or SAW band-pass filter would be up to the task of cleaning up the output?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-03 09:59
    Mark_T wrote:
    Perhaps a crystal or SAW band-pass filter would be up to the task of cleaning up the output?
    Such a filter would have to have an extremely narrow passband, due to the close proximity of some of the spurious sidebands to the desired carrier. Since such a filter can't be tuned, you would lose any advantage of generating the signal from a variable-frequency source. You might as well just modulate a crystal oscillator.

    -Phil
  • pedwardpedward Posts: 1,642
    edited 2012-01-03 14:42
    Phil,

    I was thinking that this could actually make a really useful foxhunt device. It's so simple, doesn't need an antenna, can be programmed into any Prop board, and the harmonics at 110Khz would actually be useful to finding the device, since the harmonics would be at a lower power. You start at the highest harmonic that receives it, then go up to the next to direction find. The closer you get, the stronger the signal on higher harmonics. Since most HTs have worthless power meters on them now, this would be a way of getting around that problem.

    Now, to make a direct conversion receiver that measures the signal strength and displays it on the Quickstart LEDs...
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-03 15:16
    I'm not sure that a sustained, albeit low-power, transmission with so much spurious hash could ever pass muster even under the FCC's Part 15 rules for intentional emitters. The way to eliminate the jitter-induced birdies from a 146.55 MHz carrier, would be to operate the Propeller with a 9.159375 MHz crystal -- assuming you could ever find such a beast.

    -Phil
  • pedwardpedward Posts: 1,642
    edited 2012-01-03 16:08
    But as you modulate the audio onto the carrier, it will generate noise and jitter because the audio samples are not exact powers of 2.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-03 16:31
    That's true enough for FM. You'd have to use CW or AM to keep things at their cleanest.

    -Phil
  • pedwardpedward Posts: 1,642
    edited 2012-01-03 19:03
    Phil, I was talking to a co-worker and showed him this demo on the quickstart board. He is a smart guy, but magically making sound appear from nothing really blew him away! We started talking and I pointed out there are 16 counters that could all be broadcasting on different frequencies. I hinted at the possibility of an "FM-be-gone" from a quickstart board and USB car charger. Same concept as a TV-be-gone, but for broadcast FM in your immediate vicinity -- silence those obnoxious speaker-on-wheels cars. He then made an interesting point: all of the paranoid and conspiracy folks would get really freaked out if their radio started playing "I'll be back" as voice by Arnold in the first terminator movie!

    We then started laughing about all sorts of conspiracy messages you could broadcast, EAS, paranoid ramblings, etc! :lol:

    Since broadcast FM is on 200Khz spacing and is 19.8Mhz wide, that means ~1.2MHz coverage per counter. The harmonics are ~110KHz offset, so that's ~220Khz, which means it's darn close to the channel spacing on broadcast FM. I think you could blank the entire band with nothing more than a quickstart board and some short lengths of wire! :innocent:

    This is all just amusing thoughts, but it's really amazing just how trivial this is!
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2012-01-05 23:25
    Since there are 16 counters can some of them be used to cancel out the harmonics/jitter?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-06 08:34
    Steven,

    At first blush, that seems like it should be possible. I tried something like that once with two of them, starting them with different phases and summing. But then I realized that the Fourier transform is a linear operation, and that any frequency components extant in the individual counter outputs will also be present in their sum -- unless, of course, they're exactly 180 degrees out of phase. But I'm not optimistic that summing any number of outputs having the same frequency but with slightly different phases would produce the desired result.

    One could also try generating individual jitterless components and mixing them to get sum and difference frequencies. This would work fine for maybe one or two steps. But once you get down to the smaller frequency components, filtering out the undesired image and harmonic components would become insurmountable.

    As to the odd harmonics in square waves, theoretically you can sum multiple square waves to approximate a sine wave. IOW, you'd be using square waves as your basis function. In reality, though, you end up with some really weird discontinuities at the zeroes of the expected sine wave that become more prevalent, the more terms you add.

    -Phil
  • I'm a beginner/novice with electronics and DSP,and the propeller, and know some of the terms, but
    I don't understand exactly how this program is modulating the wav file data.

    I've read the parallax docs on the counters, but I still don't understand how the
    counters are used to modulate two waveforms.

    The key lines in the file, I think are :

    FRQA := magicnum + byte[p] << 5

    and previous to that : (setting up CTRA as PLL single ended)

    CTRA:=%00010_111 << 23 + 0

    From what I've read on AM modulation, the process is to multiply the carrier by the
    baseband signal, which I would think would look something like this :

    FRQA := byte[p] << 5 * PHSA[cnt]

    or maybe :
    FRQA := ( byte[p] << 5 * PHSA[cnt] ) + magicnum

    The above two lines are just wild guesses (and from testing on my quickstart and getting no output
    ,apparently incorrect / non-sensical ;) )

    But this :

    FRQA := magicnum + byte[p] << 5

    looks like it is just ADDING the baseband (byte[p]) to the carrier (CTRA setup) ?


    What type of modulation is this program doing ?

    If it's FM (as the title of the thread implies), the code looks different than
    the FM transmitter Dave Hein posted :

    http://forums.parallax.com/discussion/download/67991/FMTransmitter2.spin

    That code is :

    repeat freq1 >> 1
    frqb := freqb + delta
    OUTA[LED1] := 1
    waitcnt(numclks1 + cnt)

    OUTA[LED1] := 0
    frqb := freqb - delta
    waitcnt(numclks1 + cnt)



    I'm reading "Multiplying Signals (Amplitude Modulation)"
    http://www.dspguide.com/ch10/5.htm

    and " Convolution" http://www.dspguide.com/ch6.htm

    to see how that applies to this spin file.

    From the Multiplying signals page:

    "
    Since the spectrum of the carrier is a shifted delta function, the spectrum of the
    modulated signal is equal to the audio spectrum shifted to the frequency of the
    carrier.


    Is that what this code is doing ? :

    FRQA := magicnum + byte[p] << 5

    Mike

Sign In or Register to comment.