PBASIC: Run Motors Simultaneously
lewisg
Posts: 3
Hi, everyone!
I am trying to run two motors simultaneously, but I can't figure out the code.
I am using BASIC Stamp Editor, PBASIC 2.5, and a Parallax Stamps In Class Homework Board.
Thanks!
I am trying to run two motors simultaneously, but I can't figure out the code.
I am using BASIC Stamp Editor, PBASIC 2.5, and a Parallax Stamps In Class Homework Board.
Thanks!
Comments
The Stamps just like most computers, Can only do one thing at a time. But they run really fast and appear to run things simultaneously.
If You'll post some code, I/WE can help You make both motors run.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
In all cases, you can buy external motor controllers that take much of the burden off the Stamp and allow it to handle sensors, make decisions, and set the state of whatever motors you're using.
a VAR Word
FOR a = 0 TO 100
PULSOUT 14,280
NEXT
b VAR Word
FOR b = 0 TO 100
PULSOUT 14,1280
NEXT
c VAR Word
FOR c = 0 TO 200
PULSOUT 14,790
NEXT
d VAR Word
FOR d = 0 TO 100
PULSOUT 15,280
NEXT
e VAR Word
FOR e = 0 TO 100
PULSOUT 15,1280
NEXT
f VAR Word
FOR f = 0 TO 200
PULSOUT 15,790
NEXT
END
FOR a = 0 TO 100
PULSOUT 14,280
pulsout 15,280' send 2 pulses together
pause 10' full wait is 20 ms
NEXT
FOR a = 0 TO 100' reuse a
PULSOUT 14,1280
pulsout 15,280
pause 10
NEXT
FOR a = 0 TO 200
PULSOUT 14,790
PULSOUT 15,790
pause 10
next
end
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
It appears that the motors you are talking about are continuous rotation servos. If so there are a couple problems. The first is that there are no PAUSE statements. Your FOR..NEXT loop will execute many times faster than the servos need the pulses - they expect a pulse once every 20mS (50 times a second). Second, there is no reason why you cannot follow one PULSOUT with another inside each loop - both motors will be running at the same time with one receiving the PULSOUT command a tiny fraction of a second after the other. In most cases this would not be detectable.
Just like erco said! But with formatting
One thing to add, if they are servos and they will always move together, simply tie both signal lines to just one pin. Then they truly will be getting the pulse at exactly the same moment.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Post Edited (W9GFO) : 1/11/2010 8:07:53 PM GMT
Thanks Again
lewisg