Shop OBEX P1 Docs P2 Docs Learn Events
/////////Got Help??//////\/\/\/\/\/\/\_`-__-~_simple erro? — Parallax Forums

/////////Got Help??//////\/\/\/\/\/\/\_`-__-~_simple erro?

ArchiverArchiver Posts: 46,084
edited 2004-04-02 22:37 in General Discussion
Hello
I fixed the rc time problem
and added returns instead of GOSUB

but my code is still very jerky.
I know its not the motor
because the "following code"
makes motor operate just as I need it to.

"following code"

DO
DEBUG "increnebt by 1", CR

FOR counter = 800 TO 500 STEP 1
PULSOUT 14, counter
PAUSE 100
DEBUG DEC5 counter, CRSRUP
NEXT

PAUSE 1000
LOOP


WHY? Does my code still move jerky??? ie large steps....
what simple thing Am I leaving out?? maybe??



:::::::::::::[noparse]:D[/noparse]ESCRIPTION:::::::


' this program moves a servo motor
' when RCTIME is = or greater than 03000


:::::::::::::[noparse]:D[/noparse]ESCRIPTION:::::::


'{$STAMP BS2}
'{$PBASIC 2.5}

'
'I/O Definitions
'

PhotoA CON 0
PhotoB CON 1
ServoA CON 14
ServoB CON 15

'
'EEPROM MEMEORY
'
RightLeft DATA 800
UpDown DATA 800
StepOne DATA 800


'
'Variables
'

X VAR Word
P VAR Word
lightA VAR Word
lightB VAR Word
counter VAR Word



'
'Program Code
'

Main:
DO

GOSUB Photo_A:

LOOP

'
'Suburoutines
'

Photo_A:
DEBUG "Reading Light from Photo_A Now"
HIGH 0
PAUSE 1
RCTIME 0, 1, lightA
DEBUG HOME, "lightA = ", DEC5 lightA
READ RightLeft, x
IF (lightA > = 03000) THEN Servo_A:
RETURN


Servo_A:


FOR counter = x TO (x - 1) STEP 1
PULSOUT 14, counter
WRITE RightLeft, counter
NEXT
PAUSE 1000
RETURN

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-04-02 21:09
    In a message dated 4/2/2004 2:49:10 PM Eastern Standard Time,
    crazyidagain@y... writes:

    First of all, use English and have a proper subject matter.


    > I fixed the rc time problem
    > and added returns instead of GOSUB

    You don't use RETURN instaed of GOSUB. Thjey work in conjunction. If
    you have a GOSUB then you must have a RETURN. Read the manual on the GOSUB
    command.

    >
    > but my code is still very jerky.
    > I know its not the motor
    > because the "following code"
    > makes motor operate just as I need it to.

    What do you mean by "jerky" code? Do you mean the motor is "jerky"?

    >
    > "following code"
    >
    > DO
    > DEBUG "increnebt by 1", CR
    >
    > FOR counter = 800 TO 500 STEP 1
    > PULSOUT 14, counter
    > PAUSE 100
    > DEBUG DEC5 counter, CRSRUP
    > NEXT
    >
    > PAUSE 1000
    > LOOP
    >
    >
    > WHY? Does my code still move jerky??? ie large steps....
    > what simple thing Am I leaving out?? maybe??
    >
    > You don't need the Step 1. A for next loop will increment in steps of 1
    > unless you specify otherwise.

    If the above code is for driving your servo, you do not pause 100 between
    pulses. You pause 20. Jon Williams mentioned this before.

    The above code would move your servo from 800 to 500. When the for/next loop
    has finished, it loops back to do it again and the servo snaps to 800. If
    you want your servo to move slowly avaoid large rotational jumps.

    This is an infinite loop. You haven't left yourself a way out - how does
    your code get out of this do/loop?

    Sid Weaver
    W4EKQ
    Port Richey, FL


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-02 22:37
    Because, as has been pointed out before, the delay between servo updates
    is too large. You have a 100 millsecond PAUSE between servo refreshes,
    but servos want to be updated every 20 milliseconds or so.

    -- Jon Williams
    -- Parallax


    Original Message
    From: crazyidagain [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=D2z_vHHA4fuCHl5AJghOIILmNwgSPzuJKhPm7hLUxcmchZ0BhCvT7DV3GiMHpyxTd7kjttDfSarvWT3kRykG0g]crazyidagain@y...[/url
    Sent: Friday, April 02, 2004 1:30 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] /////////Got
    Help??//////\/\/\/\/\/\/\_`-__-~_simple erro?


    Hello
    I fixed the rc time problem
    and added returns instead of GOSUB

    but my code is still very jerky.
    I know its not the motor
    because the "following code"
    makes motor operate just as I need it to.

    "following code"

    DO
    DEBUG "increnebt by 1", CR

    FOR counter = 800 TO 500 STEP 1
    PULSOUT 14, counter
    PAUSE 100
    DEBUG DEC5 counter, CRSRUP
    NEXT

    PAUSE 1000
    LOOP


    WHY? Does my code still move jerky??? ie large steps....
    what simple thing Am I leaving out?? maybe??



    :::::::::::::[noparse]:D[/noparse]ESCRIPTION:::::::


    ' this program moves a servo motor
    ' when RCTIME is = or greater than 03000


    :::::::::::::[noparse]:D[/noparse]ESCRIPTION:::::::


    '{$STAMP BS2}
    '{$PBASIC 2.5}

    '
    'I/O Definitions
    '

    PhotoA CON 0
    PhotoB CON 1
    ServoA CON 14
    ServoB CON 15

    '
    'EEPROM MEMEORY
    '
    RightLeft DATA 800
    UpDown DATA 800
    StepOne DATA 800


    '
    'Variables
    '

    X VAR Word
    P VAR Word
    lightA VAR Word
    lightB VAR Word
    counter VAR Word



    '
    'Program Code
    '

    Main:
    DO

    GOSUB Photo_A:

    LOOP

    '
    'Suburoutines
    '

    Photo_A:
    DEBUG "Reading Light from Photo_A Now"
    HIGH 0
    PAUSE 1
    RCTIME 0, 1, lightA
    DEBUG HOME, "lightA = ", DEC5 lightA
    READ RightLeft, x
    IF (lightA > = 03000) THEN Servo_A:
    RETURN


    Servo_A:


    FOR counter = x TO (x - 1) STEP 1
    PULSOUT 14, counter
    WRITE RightLeft, counter
    NEXT
    PAUSE 1000
    RETURN

































    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







    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
Sign In or Register to comment.