Shop OBEX P1 Docs P2 Docs Learn Events
Set a Freq in the FM Radio Module — Parallax Forums

Set a Freq in the FM Radio Module

deanwesterburgdeanwesterburg Posts: 25
edited 2011-11-08 19:29 in General Discussion
Has anyone had any success in setting a specific freq in the FM Radio?

I read the PDF but it does not specify if the FREQSET command is expecting MHZ, KHZ, or something else.

I tried using a channel function by figuring the number of 100 khz steps from the base freq (87 MHZ) to the desired freq (107.1) but was unsuccessfuly.

Any help would be appreciated!

Thanks,

Dean

Comments

  • FranklinFranklin Posts: 4,747
    edited 2011-11-01 19:40
    Would you post your code so we could help?
  • deanwesterburgdeanwesterburg Posts: 25
    edited 2011-11-02 18:52
    Sure. I'm using the DIYPortableRadio.SPIN code from the FM Radio module product page. For simplification, I have included just PUB Main

    PUB Main
    FM.Initialize(8, 9) ' Start FM Radio object
    FM.SeekThreshold(6) ' Set seek threshold
    FM.VolumeSet(1) ' Set volume level to 1
    dira[23..16]~~ ' Set LEDs to outputs
    Buttons.start(_CLKFREQ / 100) ' Start button object

    repeat
    outa[23..16] := Buttons.State
    if Buttons.State == %00000001 If the farthest right button is presses, goto a specific station
    FM.FreqSet(107.1)
    if Buttons.State == %10000000 ' If the P7 button is touched,
    FM.SeekDown ' auto seek down for a station
    if Buttons.State == %01000000 ' If the P6 button is touched,
    FM.SeekUp ' auto seek up for a station
    if Buttons.State == %00100000 ' If the P5 button is touched,
    FM.VolumeDown ' turn the volume down
    if Buttons.State == %00010000 ' If the P4 button is touched,
    FM.VolumeUp ' turn the volume up
    if Buttons.State == %00001000 ' If the P3 button is touched,
    vol := FM.CheckVolume ' Store current volume level
    LedVol ' Call LedVol Method
    outa[23..16]~ ' Turn LEDs off

    waitcnt(clkfreq/4 + cnt) ' Short pause


    I have tried using the FM.FREQSET command with a specific freqency in MHZ, as well as the number of 100 khz steps from the base freq to the desired freq. The documentation on FM.FreqSet is somewhat non-descript on what it is expecting and I'm running out of things to try!

    Thanks!

    Dean
  • deanwesterburgdeanwesterburg Posts: 25
    edited 2011-11-02 18:54
    btw, I added the comment after the fact and I am aware I missed the '. the comment is not in the origional compiled code.
  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2011-11-03 09:38
    The FreqSet method expects the frequency in Hz. So to tune to station 107.1, you would call the method like so: FreqSet(107100000).

    Let us know how that works out, and if you need any other help!
  • deanwesterburgdeanwesterburg Posts: 25
    edited 2011-11-08 19:29
    I figured this out as well when I used other commands to view the frequency. That works Great! Thanks! As a note, the fact that it is expecting HZ is missing from the documentation..

    Thanks again!
Sign In or Register to comment.