problem w/ servo program
Archiver
Posts: 46,084
hey guys,
i'm using a bs2-sx and am having a problem with this program for a
servo. My problem is that the servo will move ccw and cw fine buti
have to load the program everytime i want it to move ccw or cw.
Here's the program:input 8
input 11
again:
if in8 = 0 then ccw
if in11 = 0 then cw
goto again
ccw
pulsout 7, 500
pause 20
goto ccw
cw
pulsout 7, 2500
pause 20
goto cw
Am i missing a statement? Should i program it differently? Any help
would be appreciated. Thanks.
Jon
i'm using a bs2-sx and am having a problem with this program for a
servo. My problem is that the servo will move ccw and cw fine buti
have to load the program everytime i want it to move ccw or cw.
Here's the program:input 8
input 11
again:
if in8 = 0 then ccw
if in11 = 0 then cw
goto again
ccw
pulsout 7, 500
pause 20
goto ccw
cw
pulsout 7, 2500
pause 20
goto cw
Am i missing a statement? Should i program it differently? Any help
would be appreciated. Thanks.
Jon
Comments
servos before but I think you may want
to use a for next loop.
Here is how I would modify the code:
again:
if in8 = 0 then ccw
if in11 = 0 then cw
goto again
ccw:
for b1 = 1 to 100 'will loop ccw 100 times
pulsout 7, 500 'then jump to again
pause 20
next
goto again
cw:
for b2 = 1 to 100 'will loop cw 100 times
pulsout 7, 2500 'then jump to again
pause 20
next
goto again
Like I said I've never worked with servos so you will probably have to play with
the iterations in the for next
loop. i.e. change the 100 to a higher or lower number.
Let me know if this works for you. Also I did not run this program in the
editor so there may be some errors in
the code.
Later,
Chris
jhtoolman2000@y... wrote:
> hey guys,
> i'm using a bs2-sx and am having a problem with this program for a
> servo. My problem is that the servo will move ccw and cw fine buti
> have to load the program everytime i want it to move ccw or cw.
> Here's the program:input 8
> input 11
>
> again:
>
> if in8 = 0 then ccw
> if in11 = 0 then cw
>
> goto again
>
> ccw
> pulsout 7, 500
> pause 20
> goto ccw
>
> cw
> pulsout 7, 2500
> pause 20
> goto cw
>
> Am i missing a statement? Should i program it differently? Any help
> would be appreciated. Thanks.
> Jon
>
> 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/
>hey guys,
>i'm using a bs2-sx and am having a problem with this program for a
>servo. My problem is that the servo will move ccw and cw fine buti
>have to load the program everytime i want it to move ccw or cw.
>Here's the program:input 8
>input 11
(Original Code Snip)
>Am i missing a statement? Should i program it differently? Any help
>would be appreciated. Thanks.
>Jon
This would prevent your program from "locking up"
but I still don't think it would give you the
desired effect you are looking for.
again:
if in8 = 0 then ccw
if in11 = 0 then cw
goto again
ccw
pulsout 7, 500
pause 20
goto again
cw
pulsout 7, 2500
pause 20
goto again
Here's how I might attempt this... (Code untested)
Rate1 = 20 <-- These could be equal, but in a certain
Rate2 = 25 <-- case it might be desirable to have independent
rate control.
Pulse = 1500 <-- Initial Position (Optional)
again:
if in8 = 0 then ccw
if in11 = 0 then cw
goto again
ccw
Pulse = Pulse - Rate1
if Pulse < 500 then Pulse = 500
pulsout 7, Pulse
pause 20
goto again
cw
Pulse = Pulse + Rate2
if Pulse > 2500 then Pulse = 2500
pulsout 7, Pulse
pause 20
goto again
Beau Schwabe IC Mask Designer
National Semiconductor Wired Communications Division
500 Pinnacle Court, Suite 525 Mail Stop GA1 Norcross, GA 30071
Hey Chris,
It worked like a charm! Thanks for your time! Thanks to Beau also
for you time.
Jon
In basicstamps@y..., Chris Ray <laserstud@s...> wrote:
> You have two endless loops that's why you have to reload. I've
never used servos before but I think you may want
> to use a for next loop.
>
> Here is how I would modify the code:
>
> again:
>
> if in8 = 0 then ccw
> if in11 = 0 then cw
>
> goto again
>
> ccw:
> for b1 = 1 to 100 'will loop ccw 100
times
> pulsout 7, 500 'then jump to again
> pause 20
> next
> goto again
>
> cw:
> for b2 = 1 to 100 'will loop cw 100 times
> pulsout 7, 2500 'then jump to again
> pause 20
> next
> goto again
>
> Like I said I've never worked with servos so you will probably have
to play with the iterations in the for next
> loop. i.e. change the 100 to a higher or lower number.
>
> Let me know if this works for you. Also I did not run this program
in the editor so there may be some errors in
> the code.
>
> Later,
> Chris
>
> jhtoolman2000@y... wrote:
>
> > hey guys,
> > i'm using a bs2-sx and am having a problem with this program for a
> > servo. My problem is that the servo will move ccw and cw fine
buti
> > have to load the program everytime i want it to move ccw or cw.
> > Here's the program:input 8
> > input 11
> >
> > again:
> >
> > if in8 = 0 then ccw
> > if in11 = 0 then cw
> >
> > goto again
> >
> > ccw
> > pulsout 7, 500
> > pause 20
> > goto ccw
> >
> > cw
> > pulsout 7, 2500
> > pause 20
> > goto cw
> >
> > Am i missing a statement? Should i program it differently? Any
help
> > would be appreciated. Thanks.
> > Jon
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@y...
> > 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/