Shop OBEX P1 Docs P2 Docs Learn Events
review the program — Parallax Forums

review the program

ArchiverArchiver Posts: 46,084
edited 2004-04-08 21:43 in General Discussion
Hi Stampers, again, Please I need a help of any to review the following program
and let me know what is its problem. it suppose to rotate the servo by pulses
and disply 1 and then 2. it is close to the one in the exercise but it is not
working well:

'{$STAMP BS2}
' What's a Microcontroller - RotateBridgeUsingDebugTerminal.bs2
' Send messages to the BASIC Stamp to control a Bridge using
' the Debug Terminal and 7-Segments display location.
' {$PBASIC 2.5}
counter VAR Word
pulses VAR Word
duration VAR Word
OUTH = %00000000 'outh initialized to
low.
DIRH = %11111111 'set P8-P15
DO

'main routine.
DO
DEBUG "Enter 1000 to rotate Bridge:", CR
DEBUGIN DEC duration
IF duration < 1000 THEN
DEBUG "You must type 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
IF duration > 1000 THEN
DEBUG "You must typr 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
LOOP UNTIL duration > 999 AND duration < 1001
DEBUG "BRIDGE is rotating...", CR
FOR counter = 1 TO pulses
PULSOUT 7, 1000
PAUSE 20
NEXT
DEBUG "BRIDGE IN FLOWER HALL (1)"
PAUSE 1000
GOSUB TURN1
DO
DEBUG "Enter 1000 to rotate Bridge:", CR
DEBUGIN DEC duration
IF duration < 500 THEN
DEBUG "You must type 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
IF duration > 1000 THEN
DEBUG "You must type 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
LOOP UNTIL duration > 999 AND duration < 1001
DEBUG "BRIDGE is rotating...", CR
FOR counter = 1 TO pulses
PULSOUT 7, 1000
PAUSE 20
NEXT
DEBUG "BRIDGE IN ROCK HALL (2)"
PAUSE 1000
GOSUB TURN2
LOOP
'
Subroutines
TURN1:
OUTH = %10000100 '1
PAUSE 1000
RETURN
TURN2:
OUTH = %11010011 '2
PAUSE 1000
RETURN



Thank you all




Thank You

Khaled Sherbini

IIT Chicago, IL USA
Ph.D. Architectural Student
312-217-3594
http://www.khaledsherbini.com

Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway - Enter today

[noparse][[/noparse]Non-text portions of this message have been removed]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-04-05 16:31
    In a message dated 4/5/2004 11:28:57 AM Eastern Daylight Time,
    sherbinik@y... writes:


    > DEBUG "BRIDGE is rotating...", CR
    > FOR counter = 1 TO pulses
    > PULSOUT 7, 1000
    >

    You haven't set "pulses" equal to anything - it has no value other than 0.

    Sid


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-05 18:03
    I believe the Servo wants a 1 mS pulse, repeated
    every 20 mSec, to go to one extent (full left?).
    It wants a 2 mS pulse (repeated every 20 to 50
    mSec) to go to the other extent (full right?).
    It wants 1.5 mSec to center.

    PULSOUT in BS2 does 2 uSec counts, so you want
    1000 for 2mSec, and 500 for 1 mSec. These are
    proper in your code.

    You MUST pre-set the pin as output, and LOW,
    BEFORE you issue the PULSOUT. You can do
    both with:

    LOW 7

    This might fix it...

    --- In basicstamps@yahoogroups.com, Khalid Sherbini <sherbinik@y...>
    wrote:
    >
    >
    > Hi Stampers, again, Please I need a help of any to review the
    following program and let me know what is its problem. it suppose to
    rotate the servo by pulses and disply 1 and then 2. it is close to
    the one in the exercise but it is not working well:
    >
    > '{$STAMP BS2}
    > ' What's a Microcontroller - RotateBridgeUsingDebugTerminal.bs2
    > ' Send messages to the BASIC Stamp to control a Bridge using
    > ' the Debug Terminal and 7-Segments display location.
    > ' {$PBASIC 2.5}
    > counter VAR Word
    > pulses VAR Word
    > duration VAR Word
    > OUTH = %00000000 'outh initialized
    to
    > low.
    > DIRH = %11111111 'set P8-P15
    > DO
    >
    > 'main routine.
    > DO
    > DEBUG "Enter 1000 to rotate Bridge:", CR
    > DEBUGIN DEC duration
    > IF duration < 1000 THEN
    > DEBUG "You must type 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > IF duration > 1000 THEN
    > DEBUG "You must typr 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > LOOP UNTIL duration > 999 AND duration < 1001
    > DEBUG "BRIDGE is rotating...", CR
    > FOR counter = 1 TO pulses
    > PULSOUT 7, 1000
    > PAUSE 20
    > NEXT
    > DEBUG "BRIDGE IN FLOWER HALL (1)"
    > PAUSE 1000
    > GOSUB TURN1
    > DO
    > DEBUG "Enter 1000 to rotate Bridge:", CR
    > DEBUGIN DEC duration
    > IF duration < 500 THEN
    > DEBUG "You must type 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > IF duration > 1000 THEN
    > DEBUG "You must type 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > LOOP UNTIL duration > 999 AND duration < 1001
    > DEBUG "BRIDGE is rotating...", CR
    > FOR counter = 1 TO pulses
    > PULSOUT 7, 1000
    > PAUSE 20
    > NEXT
    > DEBUG "BRIDGE IN ROCK HALL (2)"
    > PAUSE 1000
    > GOSUB TURN2
    > LOOP
    > '
    > Subroutines
    > TURN1:
    > OUTH = %10000100 '1
    > PAUSE 1000
    > RETURN
    > TURN2:
    > OUTH = %11010011 '2
    > PAUSE 1000
    > RETURN
    >
    >
    >
    > Thank you all
    >
    >
    >
    >
    > Thank You
    >
    > Khaled Sherbini
    >
    > IIT Chicago, IL USA
    > Ph.D. Architectural Student
    > 312-217-3594
    > http://www.khaledsherbini.com
    >
    >
    > Do you Yahoo!?
    > Yahoo! Small Business $15K Web Design Giveaway - Enter today
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-06 04:03
    Thank you Allan and Newzed for your respond
    I will let you know what is the result after trying your suggestions


    Allan Lane <allan.lane@h...> wrote:
    I believe the Servo wants a 1 mS pulse, repeated
    every 20 mSec, to go to one extent (full left?).
    It wants a 2 mS pulse (repeated every 20 to 50
    mSec) to go to the other extent (full right?).
    It wants 1.5 mSec to center.

    PULSOUT in BS2 does 2 uSec counts, so you want
    1000 for 2mSec, and 500 for 1 mSec. These are
    proper in your code.

    You MUST pre-set the pin as output, and LOW,
    BEFORE you issue the PULSOUT. You can do
    both with:

    LOW 7

    This might fix it...

    --- In basicstamps@yahoogroups.com, Khalid Sherbini
    wrote:
    >
    >
    > Hi Stampers, again, Please I need a help of any to review the
    following program and let me know what is its problem. it suppose to
    rotate the servo by pulses and disply 1 and then 2. it is close to
    the one in the exercise but it is not working well:
    >
    > '{$STAMP BS2}
    > ' What's a Microcontroller - RotateBridgeUsingDebugTerminal.bs2
    > ' Send messages to the BASIC Stamp to control a Bridge using
    > ' the Debug Terminal and 7-Segments display location.
    > ' {$PBASIC 2.5}
    > counter VAR Word
    > pulses VAR Word
    > duration VAR Word
    > OUTH = %00000000 'outh initialized
    to
    > low.
    > DIRH = %11111111 'set P8-P15
    > DO
    >
    > 'main routine.
    > DO
    > DEBUG "Enter 1000 to rotate Bridge:", CR
    > DEBUGIN DEC duration
    > IF duration < 1000 THEN
    > DEBUG "You must type 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > IF duration > 1000 THEN
    > DEBUG "You must typr 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > LOOP UNTIL duration > 999 AND duration < 1001
    > DEBUG "BRIDGE is rotating...", CR
    > FOR counter = 1 TO pulses
    > PULSOUT 7, 1000
    > PAUSE 20
    > NEXT
    > DEBUG "BRIDGE IN FLOWER HALL (1)"
    > PAUSE 1000
    > GOSUB TURN1
    > DO
    > DEBUG "Enter 1000 to rotate Bridge:", CR
    > DEBUGIN DEC duration
    > IF duration < 500 THEN
    > DEBUG "You must type 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > IF duration > 1000 THEN
    > DEBUG "You must type 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > LOOP UNTIL duration > 999 AND duration < 1001
    > DEBUG "BRIDGE is rotating...", CR
    > FOR counter = 1 TO pulses
    > PULSOUT 7, 1000
    > PAUSE 20
    > NEXT
    > DEBUG "BRIDGE IN ROCK HALL (2)"
    > PAUSE 1000
    > GOSUB TURN2
    > LOOP
    > '
    > Subroutines
    > TURN1:
    > OUTH = %10000100 '1
    > PAUSE 1000
    > RETURN
    > TURN2:
    > OUTH = %11010011 '2
    > PAUSE 1000
    > RETURN
    >
    >
    >
    > Thank you all
    >
    >
    >
    >
    > Thank You
    >
    > Khaled Sherbini
    >
    > IIT Chicago, IL USA
    > Ph.D. Architectural Student
    > 312-217-3594
    > http://www.khaledsherbini.com
    >
    >
    > Do you Yahoo!?
    > Yahoo! Small Business $15K Web Design Giveaway - Enter today
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]



    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.

    Yahoo! Groups Links







    Thank You

    Khaled Sherbini

    IIT Chicago, IL USA
    Ph.D. Architectural Student
    312-217-3594
    http://www.khaledsherbini.com

    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-07 04:18
    I can't see where you declare a value for your word-sized variable pulses . I
    suspect that is the root of no motion of the servo problem.It probbably has a
    value of zero. You can Some suggestions, work in the smallest pieces of code
    you can test. Start with the servo motion.Get it moving the way you and then add
    the debug interface. I normally write my first block of code and define most or
    all of my variables. Save it as a separate program. Then once I have all the
    blocks working on their own, I start pasting them together. That way I can
    isolate problems much more easily.

    Khalid Sherbini <sherbinik@y...> wrote:

    Hi Stampers, again, Please I need a help of any to review the following program
    and let me know what is its problem. it suppose to rotate the servo by pulses
    and disply 1 and then 2. it is close to the one in the exercise but it is not
    working well:

    '{$STAMP BS2}
    ' What's a Microcontroller - RotateBridgeUsingDebugTerminal.bs2
    ' Send messages to the BASIC Stamp to control a Bridge using
    ' the Debug Terminal and 7-Segments display location.
    ' {$PBASIC 2.5}
    counter VAR Word
    pulses VAR Word
    duration VAR Word
    OUTH = %00000000 'outh initialized to
    low.
    DIRH = %11111111 'set P8-P15
    DO

    'main routine.
    DO
    DEBUG "Enter 1000 to rotate Bridge:", CR
    DEBUGIN DEC duration
    IF duration < 1000 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    IF duration > 1000 THEN
    DEBUG "You must typr 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    LOOP UNTIL duration > 999 AND duration < 1001
    DEBUG "BRIDGE is rotating...", CR
    FOR counter = 1 TO pulses
    PULSOUT 7, 1000
    PAUSE 20
    NEXT
    DEBUG "BRIDGE IN FLOWER HALL (1)"
    PAUSE 1000
    GOSUB TURN1
    DO
    DEBUG "Enter 1000 to rotate Bridge:", CR
    DEBUGIN DEC duration
    IF duration < 500 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    IF duration > 1000 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    LOOP UNTIL duration > 999 AND duration < 1001
    DEBUG "BRIDGE is rotating...", CR
    FOR counter = 1 TO pulses
    PULSOUT 7, 1000
    PAUSE 20
    NEXT
    DEBUG "BRIDGE IN ROCK HALL (2)"
    PAUSE 1000
    GOSUB TURN2
    LOOP
    '
    Subroutines
    TURN1:
    OUTH = %10000100 '1
    PAUSE 1000
    RETURN
    TURN2:
    OUTH = %11010011 '2
    PAUSE 1000
    RETURN



    Thank you all




    Thank You

    Khaled Sherbini

    IIT Chicago, IL USA
    Ph.D. Architectural Student
    312-217-3594
    http://www.khaledsherbini.com

    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]




    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.

    Yahoo! Groups Links







    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-07 22:48
    I'm using the Debug Terminal to enter the PULSES to I can control the servo
    motion using PC.


    PHILIP GAMBLIN <gremlin8650@y...> wrote:
    I can't see where you declare a value for your word-sized variable pulses . I
    suspect that is the root of no motion of the servo problem.It probbably has a
    value of zero. You can Some suggestions, work in the smallest pieces of code you
    can test. Start with the servo motion.Get it moving the way you and then add the
    debug interface. I normally write my first block of code and define most or all
    of my variables. Save it as a separate program. Then once I have all the blocks
    working on their own, I start pasting them together. That way I can isolate
    problems much more easily.

    Khalid Sherbini wrote:

    Hi Stampers, again, Please I need a help of any to review the following program
    and let me know what is its problem. it suppose to rotate the servo by pulses
    and disply 1 and then 2. it is close to the one in the exercise but it is not
    working well:

    '{$STAMP BS2}
    ' What's a Microcontroller - RotateBridgeUsingDebugTerminal.bs2
    ' Send messages to the BASIC Stamp to control a Bridge using
    ' the Debug Terminal and 7-Segments display location.
    ' {$PBASIC 2.5}
    counter VAR Word
    pulses VAR Word
    duration VAR Word
    OUTH = %00000000 'outh initialized to
    low.
    DIRH = %11111111 'set P8-P15
    DO

    'main routine.
    DO
    DEBUG "Enter 1000 to rotate Bridge:", CR
    DEBUGIN DEC duration
    IF duration < 1000 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    IF duration > 1000 THEN
    DEBUG "You must typr 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    LOOP UNTIL duration > 999 AND duration < 1001
    DEBUG "BRIDGE is rotating...", CR
    FOR counter = 1 TO pulses
    PULSOUT 7, 1000
    PAUSE 20
    NEXT
    DEBUG "BRIDGE IN FLOWER HALL (1)"
    PAUSE 1000
    GOSUB TURN1
    DO
    DEBUG "Enter 1000 to rotate Bridge:", CR
    DEBUGIN DEC duration
    IF duration < 500 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    IF duration > 1000 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    LOOP UNTIL duration > 999 AND duration < 1001
    DEBUG "BRIDGE is rotating...", CR
    FOR counter = 1 TO pulses
    PULSOUT 7, 1000
    PAUSE 20
    NEXT
    DEBUG "BRIDGE IN ROCK HALL (2)"
    PAUSE 1000
    GOSUB TURN2
    LOOP
    '
    Subroutines
    TURN1:
    OUTH = %10000100 '1
    PAUSE 1000
    RETURN
    TURN2:
    OUTH = %11010011 '2
    PAUSE 1000
    RETURN



    Thank you all




    Thank You

    Khaled Sherbini

    IIT Chicago, IL USA
    Ph.D. Architectural Student
    312-217-3594
    http://www.khaledsherbini.com

    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]




    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.

    Yahoo! Groups Links







    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]



    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.

    Yahoo! Groups Links






    Thank You

    Khaled Sherbini

    IIT Chicago, IL USA
    Ph.D. Architectural Student
    312-217-3594
    http://www.khaledsherbini.com

    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-08 06:39
    I'm very new to Stamp. I use BOE Rev C. On this board the servo
    ports connect to pins 12, 13, 14 or 15. Your pulsout is directed to
    pin 7. Maybe the servos aren't getting any signal at all? Hope this
    helps. Good Luck

    --- In basicstamps@yahoogroups.com, Khalid Sherbini <sherbinik@y...>
    wrote:
    > I'm using the Debug Terminal to enter the PULSES to I can control
    the servo motion using PC.
    >
    >
    > PHILIP GAMBLIN <gremlin8650@y...> wrote:
    > I can't see where you declare a value for your word-sized variable
    pulses . I suspect that is the root of no motion of the servo
    problem.It probbably has a value of zero. You can Some suggestions,
    work in the smallest pieces of code you can test. Start with the
    servo motion.Get it moving the way you and then add the debug
    interface. I normally write my first block of code and define most
    or all of my variables. Save it as a separate program. Then once I
    have all the blocks working on their own, I start pasting them
    together. That way I can isolate problems much more easily.
    >
    > Khalid Sherbini wrote:
    >
    > Hi Stampers, again, Please I need a help of any to review the
    following program and let me know what is its problem. it suppose to
    rotate the servo by pulses and disply 1 and then 2. it is close to
    the one in the exercise but it is not working well:
    >
    > '{$STAMP BS2}
    > ' What's a Microcontroller - RotateBridgeUsingDebugTerminal.bs2
    > ' Send messages to the BASIC Stamp to control a Bridge using
    > ' the Debug Terminal and 7-Segments display location.
    > ' {$PBASIC 2.5}
    > counter VAR Word
    > pulses VAR Word
    > duration VAR Word
    > OUTH = %00000000 'outh initialized to
    > low.
    > DIRH = %11111111 'set P8-P15
    > DO
    >
    > 'main routine.
    > DO
    > DEBUG "Enter 1000 to rotate Bridge:", CR
    > DEBUGIN DEC duration
    > IF duration < 1000 THEN
    > DEBUG "You must type 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > IF duration > 1000 THEN
    > DEBUG "You must typr 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > LOOP UNTIL duration > 999 AND duration < 1001
    > DEBUG "BRIDGE is rotating...", CR
    > FOR counter = 1 TO pulses
    > PULSOUT 7, 1000
    > PAUSE 20
    > NEXT
    > DEBUG "BRIDGE IN FLOWER HALL (1)"
    > PAUSE 1000
    > GOSUB TURN1
    > DO
    > DEBUG "Enter 1000 to rotate Bridge:", CR
    > DEBUGIN DEC duration
    > IF duration < 500 THEN
    > DEBUG "You must type 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > IF duration > 1000 THEN
    > DEBUG "You must type 1000 to rotate the BRIDGE", CR
    > PAUSE 1000
    > ENDIF
    > LOOP UNTIL duration > 999 AND duration < 1001
    > DEBUG "BRIDGE is rotating...", CR
    > FOR counter = 1 TO pulses
    > PULSOUT 7, 1000
    > PAUSE 20
    > NEXT
    > DEBUG "BRIDGE IN ROCK HALL (2)"
    > PAUSE 1000
    > GOSUB TURN2
    > LOOP
    > '
    > Subroutines
    > TURN1:
    > OUTH = %10000100 '1
    > PAUSE 1000
    > RETURN
    > TURN2:
    > OUTH = %11010011 '2
    > PAUSE 1000
    > RETURN
    >
    >
    >
    > Thank you all
    >
    >
    >
    >
    > Thank You
    >
    > Khaled Sherbini
    >
    > IIT Chicago, IL USA
    > Ph.D. Architectural Student
    > 312-217-3594
    > http://www.khaledsherbini.com
    >
    >
    > Do you Yahoo!?
    > Yahoo! Small Business $15K Web Design Giveaway - Enter today
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    >
    >
    > 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.
    >
    > Yahoo! Groups Links
    >
    >
    >
    >
    >
    >
    >
    >
    > Do you Yahoo!?
    > Yahoo! Small Business $15K Web Design Giveaway - Enter today
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    >
    > 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.
    >
    > Yahoo! Groups Links
    >
    >
    >
    >
    >
    >
    > Thank You
    >
    > Khaled Sherbini
    >
    > IIT Chicago, IL USA
    > Ph.D. Architectural Student
    > 312-217-3594
    > http://www.khaledsherbini.com
    >
    >
    > Do you Yahoo!?
    > Yahoo! Small Business $15K Web Design Giveaway - Enter today
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-08 21:43
    I believe when the program gets to this line
    FOR counter = 1 TO pulses
    There is no value in pulses.
    From the code you posted it looks like you are reading DEBUG input into
    duration.
    I suggest that if you modify the above FOR statment to
    FOR counter =1 TO 100
    your servo will move.

    Khalid Sherbini <sherbinik@y...> wrote:
    I'm using the Debug Terminal to enter the PULSES to I can control the servo
    motion using PC.


    PHILIP GAMBLIN wrote:
    I can't see where you declare a value for your word-sized variable pulses . I
    suspect that is the root of no motion of the servo problem.It probbably has a
    value of zero. You can Some suggestions, work in the smallest pieces of code you
    can test. Start with the servo motion.Get it moving the way you and then add the
    debug interface. I normally write my first block of code and define most or all
    of my variables. Save it as a separate program. Then once I have all the blocks
    working on their own, I start pasting them together. That way I can isolate
    problems much more easily.

    Khalid Sherbini wrote:

    Hi Stampers, again, Please I need a help of any to review the following program
    and let me know what is its problem. it suppose to rotate the servo by pulses
    and disply 1 and then 2. it is close to the one in the exercise but it is not
    working well:

    '{$STAMP BS2}
    ' What's a Microcontroller - RotateBridgeUsingDebugTerminal.bs2
    ' Send messages to the BASIC Stamp to control a Bridge using
    ' the Debug Terminal and 7-Segments display location.
    ' {$PBASIC 2.5}
    counter VAR Word
    pulses VAR Word
    duration VAR Word
    OUTH = %00000000 'outh initialized to
    low.
    DIRH = %11111111 'set P8-P15
    DO

    'main routine.
    DO
    DEBUG "Enter 1000 to rotate Bridge:", CR
    DEBUGIN DEC duration
    IF duration < 1000 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    IF duration > 1000 THEN
    DEBUG "You must typr 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    LOOP UNTIL duration > 999 AND duration < 1001
    DEBUG "BRIDGE is rotating...", CR
    FOR counter = 1 TO pulses
    PULSOUT 7, 1000
    PAUSE 20
    NEXT
    DEBUG "BRIDGE IN FLOWER HALL (1)"
    PAUSE 1000
    GOSUB TURN1
    DO
    DEBUG "Enter 1000 to rotate Bridge:", CR
    DEBUGIN DEC duration
    IF duration < 500 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    IF duration > 1000 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    LOOP UNTIL duration > 999 AND duration < 1001
    DEBUG "BRIDGE is rotating...", CR
    FOR counter = 1 TO pulses
    PULSOUT 7, 1000
    PAUSE 20
    NEXT
    DEBUG "BRIDGE IN ROCK HALL (2)"
    PAUSE 1000
    GOSUB TURN2
    LOOP
    '
    Subroutines
    TURN1:
    OUTH = %10000100 '1
    PAUSE 1000
    RETURN
    TURN2:
    OUTH = %11010011 '2
    PAUSE 1000
    RETURN



    Thank you all




    Thank You

    Khaled Sherbini

    IIT Chicago, IL USA
    Ph.D. Architectural Student
    312-217-3594
    http://www.khaledsherbini.com

    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]




    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.

    Yahoo! Groups Links







    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]



    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.

    Yahoo! Groups Links






    Thank You

    Khaled Sherbini

    IIT Chicago, IL USA
    Ph.D. Architectural Student
    312-217-3594
    http://www.khaledsherbini.com

    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]



    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.

    Yahoo! Groups Links






    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-08 21:43
    I believe when the program gets to this line
    FOR counter = 1 TO pulses
    There is no value in pulses.
    From the code you posted it looks like you are reading DEBUG input into
    duration.
    I suggest that if you modify the above FOR statment to
    FOR counter =1 TO 100
    your servo will move.

    Khalid Sherbini <sherbinik@y...> wrote:
    I'm using the Debug Terminal to enter the PULSES to I can control the servo
    motion using PC.


    PHILIP GAMBLIN wrote:
    I can't see where you declare a value for your word-sized variable pulses . I
    suspect that is the root of no motion of the servo problem.It probbably has a
    value of zero. You can Some suggestions, work in the smallest pieces of code you
    can test. Start with the servo motion.Get it moving the way you and then add the
    debug interface. I normally write my first block of code and define most or all
    of my variables. Save it as a separate program. Then once I have all the blocks
    working on their own, I start pasting them together. That way I can isolate
    problems much more easily.

    Khalid Sherbini wrote:

    Hi Stampers, again, Please I need a help of any to review the following program
    and let me know what is its problem. it suppose to rotate the servo by pulses
    and disply 1 and then 2. it is close to the one in the exercise but it is not
    working well:

    '{$STAMP BS2}
    ' What's a Microcontroller - RotateBridgeUsingDebugTerminal.bs2
    ' Send messages to the BASIC Stamp to control a Bridge using
    ' the Debug Terminal and 7-Segments display location.
    ' {$PBASIC 2.5}
    counter VAR Word
    pulses VAR Word
    duration VAR Word
    OUTH = %00000000 'outh initialized to
    low.
    DIRH = %11111111 'set P8-P15
    DO

    'main routine.
    DO
    DEBUG "Enter 1000 to rotate Bridge:", CR
    DEBUGIN DEC duration
    IF duration < 1000 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    IF duration > 1000 THEN
    DEBUG "You must typr 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    LOOP UNTIL duration > 999 AND duration < 1001
    DEBUG "BRIDGE is rotating...", CR
    FOR counter = 1 TO pulses
    PULSOUT 7, 1000
    PAUSE 20
    NEXT
    DEBUG "BRIDGE IN FLOWER HALL (1)"
    PAUSE 1000
    GOSUB TURN1
    DO
    DEBUG "Enter 1000 to rotate Bridge:", CR
    DEBUGIN DEC duration
    IF duration < 500 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    IF duration > 1000 THEN
    DEBUG "You must type 1000 to rotate the BRIDGE", CR
    PAUSE 1000
    ENDIF
    LOOP UNTIL duration > 999 AND duration < 1001
    DEBUG "BRIDGE is rotating...", CR
    FOR counter = 1 TO pulses
    PULSOUT 7, 1000
    PAUSE 20
    NEXT
    DEBUG "BRIDGE IN ROCK HALL (2)"
    PAUSE 1000
    GOSUB TURN2
    LOOP
    '
    Subroutines
    TURN1:
    OUTH = %10000100 '1
    PAUSE 1000
    RETURN
    TURN2:
    OUTH = %11010011 '2
    PAUSE 1000
    RETURN



    Thank you all




    Thank You

    Khaled Sherbini

    IIT Chicago, IL USA
    Ph.D. Architectural Student
    312-217-3594
    http://www.khaledsherbini.com

    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]




    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.

    Yahoo! Groups Links







    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]



    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.

    Yahoo! Groups Links






    Thank You

    Khaled Sherbini

    IIT Chicago, IL USA
    Ph.D. Architectural Student
    312-217-3594
    http://www.khaledsherbini.com

    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]



    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.

    Yahoo! Groups Links






    Do you Yahoo!?
    Yahoo! Small Business $15K Web Design Giveaway - Enter today

    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.