Shop Learn
problem I need help with — Parallax Forums

problem I need help with

edited 2021-12-24 07:19 in Robotics

I wrote a simple program, just to play around with functions (subroutines) and the EEPROM memory stuff. Basically, it's supposed to ramp up to speed, drive forward, backwards, forwards, and then ramp down again. However, running the program, only the left wheel turns, not the right. I's not a hardware problem, because the wheel runs fine with other programs. Any help is appreciated. Here is my code:

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

counter VAR Word
pulsecount VAR Word
address VAR Byte
instruction VAR Byte

DATA "UFFBBFFD"

DO UNTIL (instruction = "Q")

READ address, instruction
address = address + 1

SELECT instruction

CASE "F": GOSUB forward
CASE "B": GOSUB backward
CASE "U": GOSUB ramp_up_forward
CASE "D": GOSUB ramp_down_forward

ENDSELECT

LOOP

END

forward:

FOR counter = 1 TO 25

PULSOUT 13, 800
PULSOUT 12, 700
PAUSE 20

NEXT

backward:

FOR counter = 1 TO 25

PULSOUT 13, 700
PULSOUT 12, 800
PAUSE 20

NEXT

ramp_up_forward:

FOR pulsecount = 1 TO 100

PULSOUT 13, 750 + pulsecount
PULSOUT 13, 750 - pulsecount
PAUSE 20

NEXT

ramp_up_backward:

FOR pulsecount = 1 TO 100

PULSOUT 13, 750 - pulsecount
PULSOUT 13, 750 + pulsecount
PAUSE 20

NEXT

ramp_down_forward:

FOR pulsecount = 100 TO 1

PULSOUT 13, 750 + pulsecount
PULSOUT 13, 750 - pulsecount
PAUSE 20

NEXT

ramp_down_backward:

FOR pulsecount = 100 TO 1

PULSOUT 13, 750 - pulsecount
PULSOUT 13, 750 + pulsecount
PAUSE 20

NEXT

Comments

  • PublisonPublison Posts: 12,255
    edited 2021-12-24 17:53

    The second PulseOut should be changed to PULSEOUT 12 to drive the other wheel.

    FOR pulsecount = 1 TO 100
    
    PULSOUT 13, 750 + pulsecount
    PULSOUT 13, 750 - pulsecount
    PAUSE 20
    
    NEXT
    
    ramp_up_backward:
    
    FOR pulsecount = 1 TO 100
    
    PULSOUT 13, 750 - pulsecount
    PULSOUT 13, 750 + pulsecount
    PAUSE 20
    
    NEXT
    
    ramp_down_forward:
    
    FOR pulsecount = 100 TO 1
    
    PULSOUT 13, 750 + pulsecount
    PULSOUT 13, 750 - pulsecount
    PAUSE 20
    
    NEXT
    
    ramp_down_backward:
    
    FOR pulsecount = 100 TO 1
    
    PULSOUT 13, 750 - pulsecount
    PULSOUT 13, 750 + pulsecount
    PAUSE 20
    
  • edited 2021-12-24 20:19

    well, that's a facepalm if I've ever seen one! I really should have seen that; thank you for your help! It works great now!

  • Good deal. Merry Christmas!

Sign In or Register to comment.