Streamlining Code
I'm writing code to control a servo (used on a robot to open and
close the robot's mouth). I'm synching the servo movement to
prerecorded sentences recorded on an isd voice chip.
Everything's working great so far, except for one thing... I'm
running out of memory on the Basic Stamp 2! I've got about 1000 or
so lines of code, I'm assuming I have to get it down to about 500 in
order to make it fit on the Stamp2.
Short of investing in another Stamp, (the 2e for example), can anyone
help me figure out a way to condense the code so that it doesn't hog
so much memory?
Here's a sample of my code, this is for a single syllable in a
sentence:
'OPEN MOUTH
for x = 1 to 8 '(the higher the 2nd number, the SLOWER the servo
movement
pulsout 13, 400 + (x * 60) 'this moves the servo smoothly instead of
jerking it from point to point
next
'CLOSE MOUTH
for x = 1 to 8
pulsout 13,850 - (x * 60)
pause 10
next
I'm new to this. Can anyone think of another way to code this so
that it'll eat up half as much memory?
Thanks in advance.
close the robot's mouth). I'm synching the servo movement to
prerecorded sentences recorded on an isd voice chip.
Everything's working great so far, except for one thing... I'm
running out of memory on the Basic Stamp 2! I've got about 1000 or
so lines of code, I'm assuming I have to get it down to about 500 in
order to make it fit on the Stamp2.
Short of investing in another Stamp, (the 2e for example), can anyone
help me figure out a way to condense the code so that it doesn't hog
so much memory?
Here's a sample of my code, this is for a single syllable in a
sentence:
'OPEN MOUTH
for x = 1 to 8 '(the higher the 2nd number, the SLOWER the servo
movement
pulsout 13, 400 + (x * 60) 'this moves the servo smoothly instead of
jerking it from point to point
next
'CLOSE MOUTH
for x = 1 to 8
pulsout 13,850 - (x * 60)
pause 10
next
I'm new to this. Can anyone think of another way to code this so
that it'll eat up half as much memory?
Thanks in advance.
Comments
and everything that is done repeatedly into a
subroutine. This can be done even if some values
change. For example:
' in section handling a sentence
cntr = 8 ' elsewhere value may be different,
' so set just before subroutine call
GOSUB CloseMouth ' will do subroutine then
' return to next line of code
.
.
.
' subroutines section
CloseMouth:
for x = 1 to cntr
pulsout 13,850 - (x * 60)
pause 10
next
RETURN
Bob Pence
--- fathalloran@y... wrote:
> I'm writing code to control a servo (used on a robot
> to open and
> close the robot's mouth). I'm synching the servo
> movement to
> prerecorded sentences recorded on an isd voice chip.
>
>
> Everything's working great so far, except for one
> thing... I'm
> running out of memory on the Basic Stamp 2! I've
> got about 1000 or
> so lines of code, I'm assuming I have to get it down
> to about 500 in
> order to make it fit on the Stamp2.
>
> Short of investing in another Stamp, (the 2e for
> example), can anyone
> help me figure out a way to condense the code so
> that it doesn't hog
> so much memory?
>
> Here's a sample of my code, this is for a single
> syllable in a
> sentence:
>
> 'OPEN MOUTH
> for x = 1 to 8 '(the higher the 2nd number, the
> SLOWER the servo
> movement
> pulsout 13, 400 + (x * 60) 'this moves the servo
> smoothly instead of
> jerking it from point to point
> next
> 'CLOSE MOUTH
> for x = 1 to 8
> pulsout 13,850 - (x * 60)
> pause 10
> next
>
> I'm new to this. Can anyone think of another way to
> code this so
> that it'll eat up half as much memory?
>
> Thanks in advance.
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject and Body of the message will be
> ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
use parameters to tell only ONE routine to either open or close
mouth:
if want to open mouth, set startnum = 400, factor = 60,my_pause
= 0. then call subroutine
if you want to close mouth, set startnum = 850,factor = -60,
my_pause = 10. then call same subroutine
'either MOUTH
for x = 1 to 8 '(the higher the 2nd number, the SLOWER the
servo
movement
pulsout 13, startnum + (x * factor) 'this moves the servo
pause my_pause
Ken
with enough thrust, pigs fly just fine.
---- On Mon, 02 Jul 2001, fathalloran@y...
(fathalloran@y...) wrote:
> I'm writing code to control a servo (used on a robot to open
and
> close the robot's mouth). I'm synching the servo movement to
> prerecorded sentences recorded on an isd voice chip.
>
> Everything's working great so far, except for one thing...
I'm
> running out of memory on the Basic Stamp 2! I've got about
1000 or
> so lines of code, I'm assuming I have to get it down to about
500 in
> order to make it fit on the Stamp2.
>
> Short of investing in another Stamp, (the 2e for example),
can anyone
> help me figure out a way to condense the code so that it
doesn't hog
> so much memory?
>
> Here's a sample of my code, this is for a single syllable in
a
> sentence:
>
> 'OPEN MOUTH
> for x = 1 to 8 '(the higher the 2nd number, the SLOWER the
servo
> movement
> pulsout 13, 400 + (x * 60) 'this moves the servo smoothly
instead of
> jerking it from point to point
> next
> 'CLOSE MOUTH
> for x = 1 to 8
> pulsout 13,850 - (x * 60)
> pause 10
> next
>
> I'm new to this. Can anyone think of another way to code
this so
> that it'll eat up half as much memory?
>
> Thanks in advance.
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>