Shop OBEX P1 Docs P2 Docs Learn Events
BS2PX causing motors to run after program finishes — Parallax Forums

BS2PX causing motors to run after program finishes

Hello,
I have an interesting problem with my BS2PX; what seems to be happening is no matter what motor driven program I code, for my robot, even Parallax example code, when the code is done running and performing it's programmed tasks; it stops for a few seconds and then the left wheel stays still and the right wheel drives forward; the speed starts slow and then gradually increases to full speed until I turn it off. All of the PULSOUT values are updated as required: 1625 to replaced 650, 2125 to replace 850 and 1875 to replace 750. This happens even on a purely basic program to just turn 90 degrees as shown below.

' {$STAMP BS2px}
' {$PBASIC 2.5}

HB25 pin 12
pulseCount VAR Word

FOR pulseCount = 1 TO 24
PULSOUT HB25,650
PULSOUT HB25,650
NEXT

My robot uses two HB25 motor controllers linked together to both run from one pin, pin 12. The reason I know the issue stems from the BS2px is because once I removed the BS2px and installed a BS2 and then modified the values for the BS2 everything thing works as expected and no extra unprogrammed spins as a result.

I know there is that issue with the BS2px where the "No BASIC Stamps found." occurs when uploading a program and I have been using the workaround to re-upload within 2 seconds, which is annoying sometimes considering my robot is over 3 feet tall and hard to hold it while trying to re-upload within the 2 seconds.

Am I missing something with the configuration or did I find another bug?
Any help would be greatly appreciated.
Paul

Comments

  • GenetixGenetix Posts: 1,754
    edited 2018-06-19 20:11
    ptruini,

    When in doubt check the manual.
    https://www.parallax.com/downloads/hb-25-motor-controller-product-documentation

    Notice the timing diagram on page 3 and the note at the bottom of the page.
    BASIC Stamp 1 and 2 programmers using our example code
     will find that a PAUSE 1 command between Pulse #1 and Pulse #2 and a PAUSE 5 after Pulse #2 are adequate.
     This is because code execution time extends the resulting low times just enough to exceed the HB-25’s own hold-off times.
    ***** Those using faster BS2 models or microcontrollers such as the SX will need to observe the minimum pause times more strictly.
    

    You need to add PAUSEs or delay loops to your program so you meet the timing requirements.
  • If this happens after your program is complete, the HB-25s may be responding to noise on the control line after the BS2PX tri-states it. Add a 10K resistor from the control line to ground to see if this cures the problem.

    -Phil
  • ptruiniptruini Posts: 9
    edited 2018-06-20 18:32
    Thank you for your suggestions, I tried them both, but it didn't resolve the issue. I'll continue to try figure out how to silence the noise, but one thing is for certain; it only happens with the BS2px and not a BS2, more than likely due to the speed differences.
  • Do you have a link to the type of motors you are using?
Sign In or Register to comment.