Question on FREQOUT
Don J
Posts: 12
Hello,
Looking for information on how to shorten this?
I'm writing a program for an Amateur Repeater and this is the ID portion.
It is taking up major space.
I have a BS2 and am still pretty new to this.
Don't need anyone to write the code, just need to be pointed in the
general direction to find the answer or possibly an explanation on
how to shorten this.
Thanks for the help!
Don J
CWID:
PAUSE 50
GOSUB DAH
GOSUB DIT
GOSUB DAH
GOSUB SPACE
GOSUB DIT
GOSUB DIT
GOSUB SPACE
GOSUB DAH
GOSUB DAH
GOSUB DAH
GOSUB DAH
GOSUB DAH
GOSUB SPACE
GOSUB DIT
GOSUB SPACE
GOSUB DAH
GOSUB DAH
GOSUB DAH
GOSUB SPACE
GOSUB DAH
GOSUB DIT
GOSUB DIT
GOSUB DAH
GOSUB DIT
GOSUB SPACE
GOSUB DIT
GOSUB DAH
GOSUB DIT
RETURN
DAH:
FREQOUT 7, 216, 1100
FREQOUT 7, 72, 0
RETURN
DIT:
FREQOUT 7, 72, 1100
FREQOUT 7, 72, 0
RETURN
SPACE:
FREQOUT 7, 144, 0
RETURN
Looking for information on how to shorten this?
I'm writing a program for an Amateur Repeater and this is the ID portion.
It is taking up major space.
I have a BS2 and am still pretty new to this.
Don't need anyone to write the code, just need to be pointed in the
general direction to find the answer or possibly an explanation on
how to shorten this.
Thanks for the help!
Don J
CWID:
PAUSE 50
GOSUB DAH
GOSUB DIT
GOSUB DAH
GOSUB SPACE
GOSUB DIT
GOSUB DIT
GOSUB SPACE
GOSUB DAH
GOSUB DAH
GOSUB DAH
GOSUB DAH
GOSUB DAH
GOSUB SPACE
GOSUB DIT
GOSUB SPACE
GOSUB DAH
GOSUB DAH
GOSUB DAH
GOSUB SPACE
GOSUB DAH
GOSUB DIT
GOSUB DIT
GOSUB DAH
GOSUB DIT
GOSUB SPACE
GOSUB DIT
GOSUB DAH
GOSUB DIT
RETURN
DAH:
FREQOUT 7, 216, 1100
FREQOUT 7, 72, 0
RETURN
DIT:
FREQOUT 7, 72, 1100
FREQOUT 7, 72, 0
RETURN
SPACE:
FREQOUT 7, 144, 0
RETURN
Comments
gosub dah
next
gosub rep1
gosub rep2
rep1:
Gosub dit
gosub dah
gosub dit
return
rep2:
Gosub space
gosub dit
return
Nice try, but there is a REAL problem waiting in that code. See below:
FOR COUNTER = 1 TO 5
GOSUB DAH
NEXT
GOSUB REP1
GOSUB REP2
<
Once you drop through here, the program will start to go off the rails!
REP1:
GOSUB DIT
GOSUB DAH
GOSUB DIT
RETURN
REP2:
GOSUB SPACE
GOSUB DIT
RETURN
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
So, if you want to do it ONCE, put an "END" there.
If you want to do it continuously, put:
MAIN:
FOR COUNTER = 1 TO 5
GOSUB DAY
NEXT
GOSUB REP1
GOSUB REP2
PAUSE 500 ' Pause 1/2 second to 'separate' the messages
GOTO MAIN
Then it will repeat forever, with 1/2 second between messages.
where the 3 msb are the number of elements to send, and the 5 lsb are the pattern. It is possible to include six element punctuation in this scheme by treatment of 110 and 111 as both calling out 6 elements.
You need one subroutine that is called with a variable containing the pattern to play back, or a pointer to that pattern. It takes a little to set it up, but I think you will find the end result much more versatile and easier to follow.
There is an example of this in the Applied Sensors text, to sound out sensor readings in Morse code. There are other examples around too, maybe in the archives of this forum.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Tracy, I've read about the DATA lookup table, but don't
seem to understand it quite yet.
That is the route I'm looking for and will investigate it further.
I do have the CWID working now and have compacted it somewhat,
but it still looks somewhat "bulky".
I have the "What's a Microcontroller" and "Stamp 2 Communications and Control projects" books
and have picked up a lot of info from there.
There is a repeater controller project in the communications book and so far I have learned
alot just reading through the code on that project, but my primary goal
is to write my own program.
Thanks,
Don J
result·VAR BYTE
idx VAR BYTE
'Main loop goes here
'subroutines
CWID:
PAUSE 50
FOR idx= 0 to 27
·· LOOKUP idx, [noparse][[/noparse] 0, 1, 0, 2, 1, 1, 2, 0, 0, 0, 0, 0, 2, 1, 2, 0, 0, 0, 2, 0, 1, 1, 0, 1, 2, 1, 0, 1], result
·· ON result GOSUB DAH, DIT, SPACE
NEXT
RETURN
DAH:
FREQOUT 7, 216, 1100
FREQOUT 7, 72, 0
RETURN
DIT:
FREQOUT 7, 72, 1100
FREQOUT 7, 72, 0
RETURN
SPACE:
FREQOUT 7, 144, 0
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Suppose you have a string you want to send:
cars DATA "CALLING ALL CARS",0 ' null terminates string
A program to send that string would include statements like this:
You see, there are really two tables, one with the string you want to send with the pointer to entries at cars, cars+1, cars+2 etc. until it finishes when it hits the null entry. Then if the entry happens to be a letter from A to Z, it looks up the Morse pattern in the table that starts with mrs_A, and passes the byte pattern it finds there to the subroutine that plays it in code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com