Shop OBEX P1 Docs P2 Docs Learn Events
How can I make a motor stop upon input from a sensor? — Parallax Forums

How can I make a motor stop upon input from a sensor?

sciguysciguy Posts: 48
edited 2007-02-01 03:26 in BASIC Stamp
Hello all, kinda new to PBASIC, and I just had a quick question. What command would I use to make the basic stamp run a motor until something else happened, and then stop? What comand would encompass this? thanks!

-Jeremy smilewinkgrin.gif


[noparse][[/noparse]subject added]

Post Edited (sciguy) : 1/31/2007 11:25:21 PM GMT

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-31 22:33
    Jeremy,

    That really depends on how the motor is connected to the BASIC Stamp, but could be as simple as a HIGH x to start it and a LOW x to stop it (where x is the I/O pin). You cannot connect the motor directly to the I/O pins, so how do you have it connected?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • sciguysciguy Posts: 48
    edited 2007-01-31 23:23
    the motor is connected and running fine through the motor sockets on the side of the board. Here is the situation: I am using a force sensor that measures raw force input. I want the motor to go, but to stop when that input reaches a certain level. (If the input is below that level, the motor keeps running).
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-31 23:39
    Sciguy,

    Are you sure you’re not using servos? Motors cannot connect directly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • sciguysciguy Posts: 48
    edited 2007-01-31 23:53
    i am using servos, sorry I didn't mention that.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-02-01 00:14
    Servos need to be refreshed in a loop every 20mS or so…Within this loop you will read your sensor and then do a conditional which could change the pulse width value you’re sending to the servos. That way you can affect the servos in relation to your sensor input. Do you have code started for this?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-02-01 02:08
    A 'Servo' will stop when you send it a PULSOUT 750 (which is a 1.5 mSec pulse) repeated every 20 mSec. This assumes the Servo has been adjusted properly.
  • sciguysciguy Posts: 48
    edited 2007-02-01 03:26
    This is what ive got now ( this is just a small part of the program):

    FOR counter = 1 TO 100
    PULSOUT 14, 1000
    PAUSE 5
    NEXT

    the variable for force is "rawForce"

    basically, i want it to stop the motor when the force exceeds zero.
Sign In or Register to comment.