PDA

View Full Version : How can I make a motor stop upon input from a sensor?



sciguy
02-01-2007, 06:21 AM
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 http://forums.parallax.com/images/smilies/smilewinkgrin.gif


[subject added]

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

Chris Savage
02-01-2007, 06:33 AM
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

sciguy
02-01-2007, 07:23 AM
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 Savage
02-01-2007, 07:39 AM
Sciguy,

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

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support

sciguy
02-01-2007, 07:53 AM
i am using servos, sorry I didn't mention that.

Chris Savage
02-01-2007, 08:14 AM
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

allanlane5
02-01-2007, 10:08 AM
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.

sciguy
02-01-2007, 11:26 AM
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.