Shop OBEX P1 Docs P2 Docs Learn Events
AM and FM transmitters - AM wav FM two tone — Parallax Forums

AM and FM transmitters - AM wav FM two tone

I have been examining / experimenting with the a.m. and f.m. transmitter code from these threads :

F.M. "wav file" transmitter
DEMO: Direct 2M FM broadcast modulation with the Propeller

A.M. "two tone" transmitter
AM and FM Transmitters

I am using the Application Note AN001 Propeller P8X32A Counters PDF to try to understand the programs and the prop1 counters.

It would be helpful to see how the A.M. "two tone" transmitter could transmit a .WAV file and
how the F.M. transmitter could transmit single tone(s).

I've tried replacing the relevant sections of code, but I'm not receiving the audio.

E.g.

For the A.M. transmitter I tried replacing
 repeat
    frqa := freqa1
    waitcnt(clkfreq/2 + cnt)

    frqa := freqa2
    waitcnt(clkfreq/2 + cnt)      

with
repeat
    p := @wav1 '+ 44
           
    time := cnt
    x := clkfreq / 11025

'
' "wav-loop  from  the F.M  "wav player"
'
     repeat while p++ < @wav2_end   ' just continue from one 'File to next
  '
  ' the "mystery section"  for the A.M.  wav playback 
  '   
  ' FRQA := magicnum + byte[p] << 10            ??????????????????   what should go here ?????????????
     'or
 '       wavbyt := byte[p] '<< 10
 '      'frqa := round( wavbyt * 4_294_967_296.0 / 80_000_000.0)
'  
   waitcnt(time += x)

DAT                                                      
wav1 byte


Conversely for the (former) F.M. "wav player" , to make it output "single tones", I tried replacing the "wav-loop"
with :
frqa := freqa1

Comments

  • Another question :

    Re:
    FRQA := magicnum + byte[p] << 10
    

    The code fragment above frequency modulates the carrier frequency (magicnum) with the current byte read from the wav file.

    But how / why does that work ?

    Sending magicnum to FRQA causes the counter (in PLL SingleEnded PLLDIV=1 mode) to output a particular "carrier" frequency.

    So why doesn't the code above just output a slightly higher carrier frequency than magicnum "alone"
  • mstram wrote: »
    Another question :

    Re:
    FRQA := magicnum + byte[p] << 10
    

    The code fragment above frequency modulates the carrier frequency (magicnum) with the current byte read from the wav file.

    But how / why does that work ?

    Sending magicnum to FRQA causes the counter (in PLL SingleEnded PLLDIV=1 mode) to output a particular "carrier" frequency.

    So why doesn't the code above just output a slightly higher carrier frequency than magicnum "alone"

    It should. Do you have the equipment to measure such a change? The modulation needs to be small enough that from the receiver's standpoint it is still the same channel. For the FM broadcast band the deviation must be less the +-75kHz. If your radio tunes in 100kHz steps, such a change would be almost unnoticeable. And in practice you don't want to use the maximum allowed deviation.


    If byte[] was signed, then it would not affect the carrier frequency. But, that is not the case. 8 bit WAV files are unsigned. And, spin interprets bytes as unsigned.

    From the propeller manual:
    Range of Byte
    Memory that is byte-sized (8 bits) can contain a value that is one of 28 possible combinations
    of bits (i.e., one of 256 combinations). This gives byte-sized values a range of 0 to 255.
    Since the Spin language performs all mathematic operations using 32-bit signed math, any
    byte-sized values will be internally treated as positive long-sized values. However, the actual
    numeric value contained within a byte is subject to how a computer and user interpret it. For
    example, you may choose to use the Sign-Extend 7 operator (~), page 156, in a Spin
    expression to convert a byte value that you interpret as “signed” (-128 to +127) to a signed
    long value.

    I have made my own FM transmitter for Propeller: https://github.com/SaucySoliton/propeller-dds It may have bit-rotted.
  • >> So why doesn't the code above just output a slightly higher carrier frequency than magicnum "alone"

    >It should. Do you have the equipment to measure such a change?

    No I don't. My "equipment" is a ~30 yr old clock-radio :/

    >For the FM broadcast band the deviation must be less the (than) +-75kHz

    Ah! I think I understand how the modulation is working.

    Since the modulation source (wav file) only contains 20 > f < 20k, then that falls within the +-75Khz.

    And since 20-20K is in the audio range, the radio therefore can demodulate it back to audio.
  • Saucy,

    I downloaded your program and will take a look at it.

    The fmtx_demo / Retronitus is very cool !

    And it gave me an idea :)

    Woo hoo !! Your transmitter works great with the SidCog (C64 emulation) !

    I was messing with trying to "connect" SidCog with Fm Transmission, and was only getting very noisy / crude results.
  • The deviation of the code you posted is 
    255<<10 = 261,120
    
    261,120/(2^32)*80,000,000 * 16 = 77819.8 Hz 
    
    So the frequency will vary between carrier and carrier + 78k. The center should be carrier + 39k. Your radio probably wouldn't notice that the carrier is about 40k off frequency. This is direct frequency modulation, where the audio modulates the oscillator frequency.


    I'm glad to hear it's working! The didn't seem to be a lot of interest in it when I first released it. I was kind of disappointed with the signal purity myself. That is different than sound quality.
  • Be aware that while this is cool as heck it is not a practical application, and while you can probably get away with putting these signals into a few inches of wire to broadcast to your local clock radio it's completely illegal. Unfortunately the P1's PLL jitters, and this causes it to emit some fairly strong chirps and spurious emissions which are impossible to filter out and prevent the signal from being Part 15 compliant because they are outside of the broadcast bands.
  • localroger wrote: »
    Be aware that while this is cool as heck it is not a practical application, and while you can probably get away with putting these signals into a few inches of wire to broadcast to your local clock radio it's completely illegal. Unfortunately the P1's PLL jitters, and this causes it to emit some fairly strong chirps and spurious emissions which are impossible to filter out and prevent the signal from being Part 15 compliant because they are outside of the broadcast bands.


    Very true. I've done extensive testing of propeller RF output here: forums.parallax.com/discussion/comment/1429181/#Comment_1429181 This is mostly why I haven't developed the code since. There were hard tradeoffs between sampling rate, number of bits, and cogs used. Getting decent purity requires 2 io pins for 1 output bit. Then add the difficulty of designing an accurate resistive DAC. After all, if you are buying a DAC chip, why not just buy a DDS chip and make things much easier? Hopefully this will change with the P2.
  • >Be aware that while this is cool as heck it is not a practical application,

    It's not meant to be anything more than a learning experience.

    The A.M. transmitter has a range of about 2 inches :smile: (no antennas used)

    The F.M. transmitter is a lot better, but is only about 10 feet.

Sign In or Register to comment.