Shop OBEX P1 Docs P2 Docs Learn Events
Running a set of frequencies — Parallax Forums

Running a set of frequencies

datacpsdatacps Posts: 139
edited 2007-07-07 17:16 in General Discussion
I want to save some code space and I looked at the other threads to see if anyone can give me an idea of how to run a set of frequencies with out using this piece af code for every frequency I want to run.
I am a newbie so I don't know how to store a set of data and then run it.rolleyes.gif
freqwanted = 1700
··· LCDChar ClearScreen
··· LCDStr "· Freq OUT = "
··· LCDWord freqWanted
··· SetFreq freqWanted
pause 80000

Instead can freqWanted be something like
freqwanted = 1700, 1950,2200,1890, ect
··· LCDChar ClearScreen
··· LCDStr "· Freq OUT = "
··· LCDWord freqWanted
··· SetFreq freqWanted Run 3min@
I would like to run them 3 minutes each. I can probably write the code for minutes but I don't know how to write it to read the stored set. I don't want to write 5 lines of code for each frequency. I am new so please forgive my ignorance.. Also The SX Chip is incredible. I will use it from now on with all my projects. Parrallax support makes it possible for newbies like me to create their designs.. Thanks to everyone that has helped me..

Comments

  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-07-03 18:51
    You should look at the DATA and READ statements. List your frequencies in a table like this.

    FreqData:
    WDATA 1700, 1950,2200,1890,… etc
    


    Then set up a FOR… NEXT loop and use a READ statement to assign the next value from your data table to your "freqwanted" variable.

    I think that will get you started in the right direction.

    - Sparks
  • datacpsdatacps Posts: 139
    edited 2007-07-05 03:37
    Thanks Sparks. I have been working on it all day I have different values on freqout. I think I have something stored in a different part of the program and it is reading that data. I will try a few more things but I can get it to count down the list at the delay I want. I got to get it to freq out the correct freq and I am good. Thanks for you help. Also are the data values being read in dec. value when I write it like

    Sometimes it starts on 1200 then the next value is 33567 or something like that.
    DO
    high lcd
    freqwanted = freqdata
    FOR setrun = 10 TO 0 step - 1 ' demo values (last invalid)
    read freqdata,freqwanted
    pause 50

    LCDChar ClearScreen
    pause 50
    LCDStr "AutoRun= "
    LCDWord freqWanted
    SetFreq freqWanted
    pause 5000 ' update the display
    if button2 = pressed then goto start ' pause 1/2 second
    NEXT
    loop

    freqdata:
    wdata 1200
    wdata 2000
    wdata 4300
  • BeanBean Posts: 8,129
    edited 2007-07-05 13:07
    I'm not sure why you're doing "freqWanted = freqData" before the loop ???

    Right now your code "READ freqData, freqWanted" will always read the first value in the data set.
    Change "FOR setRun = 10 TO 0 STEP -1" to "FOR setRun = 0 TO 20 STEP 2" and change "READ freqData, freqWanted" to "READ freqData + setRun, freqWanted". That should read through the data values (I assume you have 11 data values ?).

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • datacpsdatacps Posts: 139
    edited 2007-07-07 17:16
    Thanks for your Help Bean.. The last post was my final attempt before I posted. I had it the way the example on SX was but I did not realize that I had to multiply by two for WDATA. SO when a word value is used in WDATA it has to be multiplied by 2 in the steps and byte values.. ? It runs perfectly now . Thanks to you and Sparks..

    DO
    freqwanted = freqdata
    FOR setRun = 0 TO 20 STEP 2
    READ freqData + setRun, freqWanted
    LCDChar ClearScreen
    pause 50
    LCDStr "AutoRun= " ' update the display
    LCDWord freqWanted
    SetFreq freqWanted

    Pause 5000 'This pause set the on time for 5 sec
    'the setrun freq in seconds
    NEXT

    ' User Data
    '====================================================='''====================

    freqdata:

    WDATA 1100
    wDATA 1200
    wDATA 1300
    wDATA 1400
    wDATA 1500
    wDATA 1600
    wDATA 1700
    wDATA 1800
    wDATA 1900
    wDATA 2000
Sign In or Register to comment.