Continuous Rotation Servo
Somnium
Posts: 46
I'm testing out my servos i got form Parallax and have been having slight difficulty. I'm using the Servo-4 object from the Object Exchange and have been fiddling it to try and move only a certain angle and repeat when necessary... All i have so far are just more questions... Is it possible to move it only a certain angle, such as 30, pause, then do it again?
Comments
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
·
With the continuous rotation servos, you could use the Servo-4 routines, put out a pulse for rotation in the direction you want (every 10-20ms) adjusting the pulse frequency so it's a submultiple of the time you want the servo to move (if the servo needs to move 250ms, put out 25 pulses, every 10ms, each pulse maybe 1.25ms wide (or 1.75ms wide for the other direction), then change the pulse width to 1.5ms to stop the motor.
Post Edited (Mike Green) : 10/15/2006 9:05:26 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Here's the code I have so far... what do you think should happen? Cause it's not doing what I'm hopin wud happen...
2) Since you're only using two servos at the moment, disable the other 2 slots by using zero as a pulse width as described in the comments in Servo4 (like "servo.start(1500,servo1,1000,servo2,0,0,0,0)")
3) Doing a repeat of the "servo.move_to" won't do what you might expect. Once you specify a new position, the Servo4 routines work in parallel to control the servos. The "servo.wait" call is intended to make your program wait until the movement is done.
4) You really have to read the documentation (as limited as it may be) on the routines you're using and make sure you understand it. If you have questions about what things mean, do ask
It sounds like you should read the "What's a microcontroller?" tutorial that's downloadable from the Parallax website. It's written for the Stamp processors, but the same basics apply to the Propeller and the tutorial has plenty of examples. It might be a good exercise for you to translate them for the Propeller. Just be careful about the circuit diagrams. They all show things connected to +5V because that's what the Stamps use. For the Propeller, that should be the +3.3V supply. There are some resistors shown in many of the circuits, usually their values are not critical and they should work fine on the lower supply voltage.
I've switched it to LED to make it somewhat easier... still no progress...
I'm also still having problems adjusting the amount it moves... how do I use the PULSEOUT object? I've tried and nothin worked
[noparse][[/noparse]code]
Post Edited (Somnium) : 10/17/2006 6:42:20 PM GMT
..should read...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
== means is equal too
:= means make equal to
and
dira is a register that is used to set the pins to be outputs or inputs
ina is the register that contains the state of the pins (whether they are defined as inputs or outputs) it does not control them.
outa is a register used to write to output pins
When stuck first read the definitions of the commands and registers you are using, this information cannot be known without reading about it.
knowledge is power and reading provides knowledge.
Graham
Graham
Button that moves a servo
Continuous Rotation servo that moves a certain amount with time
these are all i need... plz I'm getting desperate... I'm still learning this in my class and thought I could do something with it for another class and apparently i'm not capable of it yet... If anyone could help me I'll be ever so grateful... I will learn to do this on my own some time in the near future... but i need this done by thursday and with my brain, i just won't be able to do this...
sorry guys... i feel like i failed u guys... failed the propeller...
Post Edited By Moderator (Chris Savage (Parallax)) : 10/19/2006 9:33:32 PM GMT
Read about the if statement
Read about the repeat statement
UNTIL YOU GET THEM
Think about what you want your program to do. Remember it does it step by step and it only does what you tell it.
Don't just keep trying things, your program working is based on cold hard logic.
You can do this and if you do you will get the credit you deserve, ditto if you don't.
Graham
to my knowledge i don't see anything wrong... or at least that's what I think... only thing it does so far is that when i press the button a couple of times, the servos move in small increments...
servo.move_to(3,1500,50)
servo.move_to(1,800,50)
WaitCnt(8_000_000 + Cnt)
I think the servos are not having enough time to move....but I'm guessing.
James L
how would i go about doing that??
Post Edited (Somnium) : 10/17/2006 9:07:32 PM GMT
Then look at the servo move example more closely, it would seem that you really need to use the:
servo.wait command to give the servos chance to move.
In the servo object there is a function that just produces pulses, the servo.move_to commands just modify the variables than this function uses, if you have them in a repeat loop with no delay or servo.wait function they will never actually be able to respond to the new pulse length.
Graham
p.s. good job on getting the loops sorted!
That would make sure that the servos have finished moving before trying to do something else with them. James makes a
good point. There's only a couple of hundred microseconds between when you tell the servos to move (the first two
"servo.move_to"s) and when you tell them to stop and turn off (the second set of calls).
Thats exactly what i tried out... but no effect...
please try my demo suggestion also
Stop using the modified servo temporarily.· You can make that work later.·
Focus on writing a simple program that can output a pulse of a given·duration.· Once you have mastered that concept, it will be a trivial matter to modify the code to output any duration you want.· And once you master that, it will be easy to modify the code so that it outputs this pulse in response to your button presses.
A standard servo will go the neutral position if given a positive pulse with a duration of 1.5ms.· Full deflection one way is about 2.0ms, and full deflection the other way is about 1.0ms.· A standard servo needs a pulse every 20ms.·
Pseudo code for controlling a standard servo looks like this:
' send a servo a pulse width of X ms
repeat
· set pin high
· wait for X ms to elapse
· set pin low
· wait for 20 ms - X ms time to elapse
Once you get this going, you can experiment by changing the value of X, and see that the servo position changes proportionally to X.
For a continuous rotation servo,·the servo always believes its in the wrong position, and it will move provided you give it a pulse that is something other than its neutral position pulse width (about 1.5ms).· This value will depend on the method you used to make the continuous rotation servo.
So, let's say you've mastered how to send any pulse width out to the servo.· Now you can put your continuous rotation servo back in, and try sending it a non-neutral pulse (something other than about 1.5ms, say 2.0ms).· And you should see the servo move continuously in one direction.· If you give it a 1.0ms pulse, it should move continuously in the opposite direction.
You still need to update the servo with a new pulse every 20ms or else the servo won't move continuously.· If you give it a pulse infrequently, the servo will move, then stop, then move, then stop, with whatever granularity you actually provided the pulses.· So, for your application, you might choose to send a non-neutral pulse for several seconds, or whatever you want, before you stop sending that stream of pulses.· The key is that your pulses will cause the servo the move.· If you don't send the pulse train, the servo won't go anywhere.
Spin code for setting the pin high, waiting, then setting it low looks like the following:
·····outa[noparse][[/noparse]1] := 1· 'pick the pin you really want
···· waitcnt(X·+ cnt) 'make sure to put X into the right units, depends on the speed of·your device, and you can calculate it if you want.
···· outa[noparse][[/noparse]1] := 0
See if you can figure out the rest..
Joel-
·
try this, with nothing else
And try different values instead of 1500. On a continuous rotation servo I think 1500 should stop it rotating but it might need to be 1520 or something, just have a play.
Turning the servo off may not stop it.
Graham
umm... hmm... is it normal for it to go in the direction and keep going? I've tried inputtin different numbers into the "servo.move_to(1,X,1)" and it does the same thing...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.