You seem to be toggling pins quite a bit. Take a look at the toggle command. Also, your pause statements are bit of overkill. Why not have a lookup table, and put the long blocks of code into a for loop. It would look something like this:
For i = 0 to 100
toggle pinNumber
LOOKUP i, [noparse][[/noparse]10,58,09, ...], pauseValue
PAUSE pausevalue
NEXT
You must have read my mind....(short story) LOL! I started to that that exact thing at work today and for some reason it ate up more space? I also am wondering if I really need to make sure both pins are off...kinda of redundant... do gosubs take up more space?
Generally, you use subroutines when you have at least 3 or four lines of code but not more than about 20. The way that you have it, you have three times as many commands as before (a GOSUB, a FREQOUT, and a RETURN). Before you just had a FREQOUT. So you need to put more stuff into your subroutines, like maybe a for loop and lookup table.
You can look GOTO and GOSUB up in the BS Manual, but in short a GOTO command goes to a section of code, and never returns. A GOSUB command goes to that section, and keeps going until it hits a RETURN., when it then picks up execution after the GOSUB. A GOSUB command is much preferred over a GOTO.
thanks for the tips on the goto and gosubs... I trried the code without turning off both pins at the end of each cw digit and it works fine...I saved some space there
as for the AUXon and AUxoff I suppose iI have to goto main or a return so they don't "fall thru"?
Aha. Well, since you've simplified your code now, it's easier to implement the "DATA" statement approach.
The following attachment has translated your "DIT", "DAH", and "Pause 660" statements into a 1, 0, or 2 DATA value.
It uses a "-1" to indicate the end of a message.
Now, all you have to do is assign the DATA address to "MsgAddr", and call "SendMessage". This saves a LOT of space.
I've translated your first two messages into DATA statements -- you should be able to do the rest.
Was this a test? LOL I got it to work but for some reason the program didn't like the -1 for a stop bit I changed it to a 6 and added a
6 at the end of each line
IF CheckByte = 6 then return
and it seems to work?????
Maybe beginners luck?
Anyways thanks for the help and you saved me tons of memory and now I am able to pit some preset freqs in the program
Well done. I was a little nervous using the "-1", because I know the BS2 'compare' operators don't really 'know' about negative numbers. Glad you were able to get it to work.
I have really used up the code space on the chip now and I am pretty happy with the finished product. I guess if I really want more space I should upgrade to a better BS2 chip and suggestions? Also The dtmf decode seems to be a little slow ...I can type the dtmf in fast and the BS only decodes the first 2 digits and looses track is this a function of the chip being too slow or maybe the hardware (8880 chip)?
Thanks again for all the help...its guys like you who make this hobby happen and keeps Basic stamps rolling.
My next chip will be a BS2pe so I can do DTMF to I2c for the Si570 chip...
Comments
For i = 0 to 100
toggle pinNumber
LOOKUP i, [noparse][[/noparse]10,58,09, ...], pauseValue
PAUSE pausevalue
NEXT
I created a couple of subroutines -- "Dit:" and "Dah:".· Each call to the subroutine saves you about 6 bytes of storage.
I started to translate all your HIGH 14: Pause 50: LOW 14 instances to a "GOSUB DIT" -- but got tired.· Hopefully, you see the pattern.
Oh, and note that your "AUX1ON:" routine will 'fall through' to "AUX1OFF:" the way you have it now.
Oh, and note the "IF DTMF = 1 THEN CWM1" does a GOTO CWM1.· You CAN do "IF DTMF = 1 THEN GOSUB CWM1" if that's what you want.
The "DATA" statement is the beginning of an example where you 'encode' the Dit/Dah you want to send as data statements.
Post Edited (allanlane5) : 10/28/2008 2:16:04 PM GMT
You must have read my mind....(short story) LOL! I started to that that exact thing at work today and for some reason it ate up more space? I also am wondering if I really need to make sure both pins are off...kinda of redundant... do gosubs take up more space?
I did a
dah: pulsout 13, 180
dit: pulseout 14, 60
spc1: pause 50
spc2: pause 660
and this ate up the code when I
gosub dit
gosub spc1
gosub dah
gosub spc2
for an "a"
Thanks for the other comments I am confused what the differance between the goto and the gosub would be?
Thanks for the comments
Mike WA3O
as for the AUXon and AUxoff I suppose iI have to goto main or a return so they don't "fall thru"?
I am confused a little about the DATA comment but...
Thanks for the tip I was able to save alot of space using the GOSUB'S
Here is the finished product.
Thanks Again
Mike WA3O
Post Edited (MikeyMustang) : 10/29/2008 8:21:41 PM GMT
The following attachment has translated your "DIT", "DAH", and "Pause 660" statements into a 1, 0, or 2 DATA value.
It uses a "-1" to indicate the end of a message.
Now, all you have to do is assign the DATA address to "MsgAddr", and call "SendMessage". This saves a LOT of space.
I've translated your first two messages into DATA statements -- you should be able to do the rest.
Was this a test? LOL I got it to work but for some reason the program didn't like the -1 for a stop bit I changed it to a 6 and added a
6 at the end of each line
IF CheckByte = 6 then return
and it seems to work?????
Maybe beginners luck?
Anyways thanks for the help and you saved me tons of memory and now I am able to pit some preset freqs in the program
Thanks
Mike WA3O
I have really used up the code space on the chip now and I am pretty happy with the finished product. I guess if I really want more space I should upgrade to a better BS2 chip and suggestions? Also The dtmf decode seems to be a little slow ...I can type the dtmf in fast and the BS only decodes the first 2 digits and looses track is this a function of the chip being too slow or maybe the hardware (8880 chip)?
Thanks again for all the help...its guys like you who make this hobby happen and keeps Basic stamps rolling.
My next chip will be a BS2pe so I can do DTMF to I2c for the Si570 chip...
Mike WA3O