Running a set of frequencies
datacps
Posts: 139
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.
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..
I am a newbie so I don't know how to store a set of data and then run it.
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
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
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
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
·
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