Shop OBEX P1 Docs P2 Docs Learn Events
BSP2x (noise) re-setting randomly — Parallax Forums

BSP2x (noise) re-setting randomly

Hello,
I set up a very basic instruction of moving a parallax servo to about 90 deg and back to 0 deg after 5 seconds.
The processor and servo moved as expected, but a few seconds later and sometimes after a minute or two (randomly) it re-run the program by itself and the servo will move following the program.
Do you know why this can happen randomly?

Thanks

Comments

  • JonnyMacJonnyMac Posts: 9,408

    What is your power supply? Is it enough for the servo and the BS2sx and anything else you're powering?

    Are you keeping the servo refreshed?

    And... it's always useful to provide the code that is giving you problems.

  • Hello Jon,

    Thank you for your reply, I checked all connections and made sure that the batteries are ok. I'm using a separate battery as I'm using the board (super carrier)
    I then changed to the board of education Rev C with a fresh BS2px and a different servo but the same thing happened. I thought because this board has the actual servo sockets will help, but it didn't
    The code is:

    ($Stamp BS2px)
    ($PBasic 2.5)

    Counter VAR Word

    For Counter =1 to 800
    Pulsout 15, 1000
    Pause 20
    Next

    For Counter =1 to 200
    Pulsout 15, 2125
    Pause 20
    Next

    END

    This move the servo nicely 90 degrees, hold it for about 15-16 seconds and return it to the same position.
    The problem it starts repeating the program like 3 or 4 times randomly. The majority of the time it re start the code like every 30-38 seconds after it concluded.
    After those repetitions it eventually stops and never moves again. I removed the "END" at the end of the code to see it it was going to help but it did the same.

    Thanks

  • JonnyMacJonnyMac Posts: 9,408
    edited 2025-08-09 23:06

    Change END to STOP and that should fix the problem (see the help file to learn why).

    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}
    
    counter   VAR   Word  
    
    Main:
      FOR counter = 1 TO 800
        PULSOUT 15, 1000
        PAUSE 20
      NEXT
    
      FOR counter = 1 TO 200
        PULSOUT 15, 2125
        PAUSE 20
      NEXT
    
      STOP
    

    Note, though, if you put any load on your servo you will see drift unless you update it. The team at Legoland once used BASIC Stamps in some of their displays and I showed them this subroutine to create a delay while keeping the servo steady. They used it on a Lego X-Wing display.

    Servo_Pause:
      PULSOUT SERVO, position
      IF delay < 19 THEN
        GOTO SP_Exit
      ELSE
        PAUSE 19
        delay = delay - 19
      ENDIF
    
    SP_Exit:
      PAUSE delay
      RETURN
    
Sign In or Register to comment.