Shop OBEX P1 Docs P2 Docs Learn Events
AM and FM Transmitters — Parallax Forums

AM and FM Transmitters

Dave HeinDave Hein Posts: 6,347
edited 2012-08-10 12:05 in Propeller 1
Last summer I wrote a program for the SX to generate an AM radio signal.· I used the radio signal to locate a buried wire in my sprinkler system, and it worked quite well.· I thought I would write a similiar program for the Propeller.· I found it very easy to implement using Spin code to generate the frequency tones, and an assembly routine that generates the carrier frequency.

The RF signal is very crude, but it works.· You can hear it on an AM radio at the main frequency and also at the harmonics.

Dave

Edit:· I looked at the code again, and I realized that the call to cognew should be after txnumclks is set.· It seems to work OK as is, but it would be better to call cognew just before the repeat loop.

Post Edited (Dave Hein) : 2/21/2010 11:51:29 PM GMT
«13

Comments

  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2010-02-20 19:19
    Wow! Does this just use a wire antenna attached to the out pin?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't click on this.....
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-02-20 19:33
    I just connected a short wire to the transmitter pin.· However, this does not transmit much power, and you need to be within a few feet to pick up the signal.· Ideally, the antenna should be a quarter (or is it half) of the wavelength.· At 1 MHz, the wavelength is 1,000 feet!· I think a few feet of wire should work fairly well.

    Dave
  • jazzedjazzed Posts: 11,803
    edited 2010-02-20 19:38
    Dave Hein said...
    I just connected a short wire to the transmitter pin. However, this does not transmit much power, and you need to be within a few feet to pick up the signal. Ideally, the antenna should be a quarter (or is it half) of the wavelength. At 1 MHz, the wavelength is 1,000 feet! I think a few feet of wire should work fairly well.

    Dave
    Nice work. So would this be suitably "quiet" for FCC class B limits?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-20 21:17
    @jazzed - There is no "suitably quiet" unless you're not caught. Part 15 of the FCC rules describe limits for unlicensed operation, but anything to be sold must be approved. If it's not to be sold, it would be ok if no one complained. If anyone complains, you can't use it.

    The routine that Dave posted produces a square wave which has a lot of harmonics, particularly with no filtering on it. Just adding a suitable tuned circuit can help a lot there, but you have to be careful about maximum voltages produced near resonance.
  • localrogerlocalroger Posts: 3,451
    edited 2010-02-21 00:29
    One of the Part 15 limits is that the antenna can't be longer than 10 feet, which is really a drag when doing medium wave TX :-( Although I did have a ham license at one point in my life I've always had a much softer spot for license-free, particularly Part 15 broadcast stuff. Something about the romance of owning your own radio station, even if nobody outside of your house can hear it...

    I would think it should be possible to get the video generator to do a much better approximation of a sine wave at AM frequencies, requiring much less LC smoothing with a lot less voltage transients. I suppose you could then modulate by changing the sine waveform map or using ... I know this is heresy ... an external transistor. Part 15 does allow you 100 milliwatts into your pitiful little stubby antenna, and while 3.3 volts at 30 milliamps is 100 milliwatts you'd have to have a very perfectly tuned antenna system to actually draw 30 mA at 3.3V.
  • jazzedjazzed Posts: 11,803
    edited 2010-02-21 04:45
    localroger said...
    ... Part 15 does allow you 100 milliwatts into your pitiful little stubby antenna, and while 3.3 volts at 30 milliamps is 100 milliwatts you'd have to have a very perfectly tuned antenna system to actually draw 30 mA at 3.3V.
    Yes, that's what I was thinking about. Almost all garage door openers and remote car key-locks work this way. But are they FM or AM? I remember square waves were composed of either even or odd harmonics (which was it?). I never understood what "composed of" meant. I guess it's a measurement term rather than one of composition in the digital sense.

    Also it seems a 10 foot antenna limit means the frequency needs to be pretty high to have a good standing wave ratio and transmit efficiency. Quarter wave was popular when I was a kid. 2 meter radios worked nicely with 18" (50cm) it seems.

    Post Edited (jazzed) : 2/21/2010 4:50:20 AM GMT
  • rokickirokicki Posts: 1,000
    edited 2010-02-21 05:52
    To generate an AM carrier, just using a counter works fine, and it can be modulated pretty
    easily directly in Spin or by using another counter at audio frequencies. Two counters, and
    you can (for instance) broadcast a 1.23KHz tone at 1.09MHz, with no further code needed,
    and the spin then can do anything it wants (like vary one of the counters to sweep the
    tone up and down). The 1.09MHz will be very dirty, but it should be easily receivable.

    Specific frequencies will work much better and be much cleaner (like 80/64=1.25MHz)
    since the counter can generate them with even-length pulses (always 32 clocks high
    and 32 clocks low).
  • LeonLeon Posts: 7,620
    edited 2010-02-21 11:19
    Jazzed:

    Square waves are odd harmonics. Look up Fourier functions.

    A 1/4 wave antenna needs a ground plane, or some radials.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM

    Post Edited (Leon) : 2/21/2010 11:24:08 AM GMT
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-02-21 23:16
    rokicki said...
    To generate an AM carrier, just using a counter works fine, and it can be modulated pretty
    easily directly in Spin or by using another counter at audio frequencies. Two counters, and
    you can (for instance) broadcast a 1.23KHz tone at 1.09MHz, with no further code needed,
    and the spin then can do anything it wants (like vary one of the counters to sweep the
    tone up and down). The 1.09MHz will be very dirty, but it should be easily receivable.
    ...
    rokicki,
    Thanks for the suggestion about using the counters.· I re-did the AM transmitter code using one cog with it's two counters.· It's a shorter program, and it's all in Spin.· It work's great.
    The exciting thing is that I was able to implement an FM-band transmitter as well.· With the 16x phase-locked-loop I was able to generate an RF signal in the 100 MHz range!· It is modulated by adjusting the frequency register of the counter around the center frequency value.· The nice thing about this is that it can be modulated with a fairly high precision baseband signal.· The dynamic range of the baseband signal is around +/- 50,000, or maybe more.
    I have attached both the AM and FM transmitter programs.· It would be interesting to integrate the FM transmitter with a wavefile reader, and you could receive the wavefile audio on an FM receiver.
    Dave
  • lcyepizlcyepiz Posts: 26
    edited 2010-02-22 22:25
    ·· Dave:



    ·· Great job, I never·think that propeller can generate this



    good,good













    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Juramento YAQUI.

    Para ti no habrá sol, para ti no habrá muerte, para ti no habrá dolor, para ti no habrá calor, ni sed,· ni hambre, ni lluvia, ni aire, ni enfermedad, ni familia.Nada te causara temor, todo ha terminado para ti, excepto una cosa: HACER TU TRABAJO. En el puesto que has sido asignado, ahí te quedaras para la defensa de tu nación, de tu gente, de tu raza, de tus costumbres, de tu religión.! Juras cumplir con el divino mandato AHUI....!

    Luis C. Yepiz
    XE2NBW
    ·
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-02-22 23:24
    lcyepiz,

    Thanks.· I hadn't tried the counters before, and they are very useful.· I thought about the FM transmitter some more, and it's not quite as good as I thought.· At a an RF frequency of 100 MHz, the counter has an·average period of 12.8 cycles.· That means that sometimes it produces a·period of 12 cycles and other times it 13 cycles, with an average of 12.8.· The PLL must be very stable to produce a usable RF signal at 100 MHz.· The precision of the modulated signal isn't as good as I thought it would be, but it would still be useful for generating tones and coarsely quantized audio signals.

    Dave·
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-23 01:35
    Dave,

    The trick is to pick a broadcast frequency such that the value used for FRQx has a minimal number of one bits below the most-significant one bit. This will help to reduce PLL jitter and RF birdies.

    -Phil
  • stephenwagnerstephenwagner Posts: 147
    edited 2010-02-23 13:53
    I see some Amateur Radio Applications on the horizon.
    ·
    Nice work Dave.
    ·
    Another old hobby I will have to get restarted.
    ·
    KA2LHT
  • Bill HenningBill Henning Posts: 6,445
    edited 2010-02-23 16:46
    Dave,

    Use one of my 6.25MHz crystals, and you will get 100Mhz dead-on [noparse]:)[/noparse]

    (well, within 30ppm, and PLL drift)

    Bill
    Dave Hein said...
    lcyepiz,


    Thanks. I hadn't tried the counters before, and they are very useful. I thought about the FM transmitter some more, and it's not quite as good as I thought. At a an RF frequency of 100 MHz, the counter has an average period of 12.8 cycles. That means that sometimes it produces a period of 12 cycles and other times it 13 cycles, with an average of 12.8. The PLL must be very stable to produce a usable RF signal at 100 MHz. The precision of the modulated signal isn't as good as I thought it would be, but it would still be useful for generating tones and coarsely quantized audio signals.



    Dave
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com 5.0" VGA LCD in stock!
    Morpheus dual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory/IO kit $89.95, both kits $189.95 SerPlug $9.95
    Propteus and Proteus for Propeller prototyping 6.250MHz custom Crystals run Propellers at 100MHz
    Las - Large model assembler Largos - upcoming nano operating system
  • rokickirokicki Posts: 1,000
    edited 2010-02-23 18:01
    You can also make a "programmable" tuned LC circuit by using an inductor and a set of capacitors, with one leg of each capacitor on a
    single pin of the prop, and selectively "ground" or "float" each capacitor to tune. If your Q is reasonable, you can probably cover a
    frequency band pretty well with just a handful of caps. Not sure how to protect the output pins of the prop, though. Best might be to
    use a single-transistor amplifier, one configured for high-frequency switching.

    But the weak link in all this is the PLL.
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-02-23 18:51
    The time constant of the PLL will determine how mich jitter is in the RF signal.· For this application it seems like·a time constant around 100 usecs would be ideal.· This would allow for a baseband bandwidth of about 10 KHz, while minimizing the RF jitter.· Does anybody know the characteristics of the PLL circuit that is used?

    The tuned LC circuit sounds like a great way to reduce the upper harmonics.· One advantage to the higher RF frequency for FM is that it will have fewer harmonics than a lower frequency because of the slew rate of the output driver.· I don't know what the output signal looks like, but I would guess that the rising and falling edges are rounded a bit.

    Dave
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-23 19:02
    In most cases, the PLL jitter is way too much to be useful for RF work. I've experimented with dithering the phase to reduce birdies in the amateur 2m (144MHz) band, but I was not successful.

    You can tune an LC oscillator with a varactor driven from a filtered DUTY mode output. The output of the oscillator could be fed back to the Prop for closed-loop frequency generation. A more lightly filtered DUTY mode output summed into the same varactor could be used to modulate the frequency. Or ... you might find a happy medium and be able to use the same DUTY mode output for both. This would yield a much cleaner signal than you'd get from the Prop's PLL.

    -Phil
  • cgraceycgracey Posts: 14,133
    edited 2010-02-23 19:22
    Phil Pilgrim···· (PhiPi) said...
    Dave,

    The trick is to pick a broadcast frequency such that the value used for FRQx has a minimal number of one bits below the most-significant one bit. This will help to reduce PLL jitter and RF birdies.

    -Phil
    One thing that works really well is to use the video in broadcast mode to just create a carrier near the target transmit frequency. Then, select another cog's CTRA PLL output for an aural subcarrier. The two will be XOR'd together, giving you two images in the spectrum.

    For example, if you set the video broadcast for a nice big frequency that had no more than 5 MSBs before all 0's out to the LSB (low jitter, no birdies) in FRQB, then made an FM in the 2MHZ +/-100KHz·range on the other cog's CTRA PLL (2MHz is so low that you'll have very low jitter and birdies), you'd get very clear FM audio at·the main broadcast frequency·+/- the 2MHz.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-02-23 19:48
    At least the bandwidth of a broadcast 100MHz receiver at +/- 50KHz will be less suseptable to any jitters. 2Mtr Rx will be +/- 2.5KHz, on modern stuff.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point

    Post Edited (Toby Seckshund) : 2/23/2010 9:11:34 PM GMT
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-02-23 20:12
    Chip: Sorry, but this went straight over my head. I don't understand how you get from 2MHz to 100MHz transmit frequency.

    Dave: Bill's 6.25MHz will get you 100MHz prop operation. DigiKey have (6MHz 96MHz) which I use on a TriBlade, 6.5MHz (104MHz) and 13.5MHz {PLLx8} (108MHz) which I use on the RamBlade.

    Another idea... You can get programmable chips to deliver clock frequencies covering the range 80-108MHz which you could use for feeding the prop and a carrier cct as well.

    VK2TZ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2010-02-23 20:27
    Cluso,

    He is saying 2Mhz plus or minus 100khz.

    Graham

    Son of late G0HLH
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-02-23 21:20
    Graham: I think Chip is mixing the 2MHz with a carrier around 100MHz (say 98MHz +/-2MHz --> 96MHz & 100MHz) but I am not sure how he is saying to do this. Is the mixing inside or outside the prop?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-23 21:28
    The carrier and its offset are being mixed in the chip in the video circuitry via XOR. I think the point of Chip's comment is that you can find a clean PLL frequency near the one you want, then mix it with another clean, but lower frequency to make the final step to the desired frequency. This will give you two clean signals at the sum and difference of the two input frequencies. You will have to filter out the one you don't want, though, and I'm not sure if vestiges of the fundamental remain or not. If so, that will have to be filtered out, too.

    -Phil

    Edit: BTW, Chip explained the conditions for clean PLL output much better than I did. I said to minimize the number of one bits below the most significant one bit. But that's only part of the story. As Chip implied, a better way to look at it is to maximize the number of continguous zeroes beginning with, and reaching upwards from, bit 0.

    Post Edited (Phil Pilgrim (PhiPi)) : 2/23/2010 9:36:26 PM GMT
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-02-23 21:49
    Thanks Phil. So do I understand this correctly...

    In COG #1 we create a 2MHz clean PLL frequency FM modulated (2MHz frequency modulated +/- 100KHz) and output this to say P0. The +/- 100KHz is the audio to be added. Isn't this quite wide or just an example???

    In COG #2 we create a clean frequency near the desired frequency +/- 2MHz and use the video counter to take the input from P0 and mix it and output on say P1.

    Then we would take P1 and externally filter out the unwanted frequency (i.e. band pass the required frequency).

    Somewhere recently I read about a method of tuning by using micro's pins connected to tuning capapacitors and by either tri-stating the pins or grounding (output 0) them you could tune the loading. IIRC you are using something similar on the backpack.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-23 22:13
    You don't have to output the 2MHz signal to a pin. It's picked up internally from the cog's PLLA (mode %00001). I've never done this before, so I'm not sure what steps have to be taken to keep the video quiet so it doesn't amplitude modulate the carrier. Maybe if Chip is still around, he can fill in some more of the details...

    -Phil
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-03-06 20:30
    I've read the information in the Prop manual about the video generator, but I don't quite understand the details of it.· Is there a block diagram of the video generator somewhere?· It would make it a lot easier to understand.

    Dave
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-04-10 17:18
    Dave:
    Thank you, thank you, and in case Thank You.
    I needed a good way to create a carrier for TV (channel 3), and this gave it to me (both the carrier for the NTSC, and the FM aural carrier).
    OH and did I say thank you.
  • ericballericball Posts: 774
    edited 2011-04-10 18:29
    Dave Hein wrote: »
    I've read the information in the Prop manual about the video generator, but I don't quite understand the details of it.· Is there a block diagram of the video generator somewhere?· It would make it a lot easier to understand.
    There's one in the datasheet which is servicable. I've tried to put as much knowledge as possible at http://propeller.wikispaces.com/Video+Generator
  • purplemonkeypurplemonkey Posts: 89
    edited 2012-07-31 07:40
    how is the chip setup connection wise, and what crystal are you using?
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-07-31 08:18
    pm, in my case I just used a short wire for the antenna, and the crystal was 5 MHz.
Sign In or Register to comment.