How to Stop Continuous Rotation Servo using HSERVO

For a project I’m working on, I need to activate a continuous rotation servo for a short duration then stop. Specifically, I want the servo to make one full rotation then come to a complete stop. I didn’t expect this would be challenging but I’m running into a problem. Here is some of the code I’m using:

[code]
’ BASIC Atom Pro 28

dispense_gumball:

FOR Counter = 1 to 100
HSERVO [gumball\700]
pause 20
NEXT

HSERVO [gumball-16000]
HSERVOWAIT [gumball]

goto main[/code]

Right now when this code is processed, the servo spins at the specified speed for the duration desired but it never stops. I originally was using “0” for the position that follows the counter loop but this did not stop the servo completely. It slowed down to a crawl but continues at this speed even after going back to the main subroutine. I found that a position of -16000 is supposed to “deactivate” the servo according to the BASIC Atom Pro help manual but this has no effect at all.

I’m pretty sure my problem stems from the fact that this is a continuous rotation servo rather than a standard servo. I actually modified a HITEC standard servo by disconnecting the potentiometer horn and gluing the pot at the “centered” position. As far as the servo is concerned it’s always at the zero position no matter how fast and long it turns.

How then do I correctly utilize the HSERVO function to accomplish what I need?

Why not stop pulsing the servo altogether? using a simple if-then-else statement, you could tell the BA to stop pulsing after a certain amount of time has passed.

Would that look the same but without the added code after the For Loop? Originally the “goto main” was right after NEXT but the servo continued to turn anyway. Is there a “DISABLEHSERVO” function or something similar?

First: the documentation for HSERVO is wrong, to stop the pulse signal on a BAP28 you would need to send a -24000. You can see that in the thread:
viewtopic.php?f=4&t=3224&start=18

Also in your code example, you don’t need to keep telling hservo to go the same place. That is you don’t need to tell gumball 100 times to go to 700, once is enough.
You could simple change the code to something like:

Dispense_gumball:
    hservo [gumball\700]
    pause 20*100

    hservo[gumball\24000]
...

I did not compile this nor did I try it. Also when you say that hservo of 0 did not stop, not all servos are created equal. You may try +5 or -5 to see if that works. If one makes it better, but not stop, go more that way…

Kurt

by sending a pulse corresponding to centered on the servo. normally 1.5ms is centered on a servo. So if you glued to POT to the center position it follows you need to send 1.5ms to make the pot think it has reached center and stop rotating. What may be messing with you slightly is there could be some small offset from centered that you need to compensate for. So you may need 1.52ms or 1.45ms to get it to actually stop moving.

Well after adjusting the pulse away from 0, I found a position value that completely stops the servo. I’m still curious however about how to stop the pulses completely. I tried -24000 but the servo just keeps running indefinitely. Is there a way to effectively disable HSERVO and deactivate the servo completely? I don’t mind if the servo is not able to hold it’s position while deactivated.

The -24000 HSERVO command should stop it. Is it possible that your code is calling the Dispense_gumball sub often enough for the servo to not stop?

The other possibility would be to simply not use HSERVO and use pulsout commands instead. Then, when you leave that subroutine and therefore stop sending pulses to the servo, it should go limp.

Also, what version of the IDE (or studio) are you using?

(Keep in mind: I’m not exactly a programming guru here, I tend to use the brute force method of programming so I’m not entirely sure if this’ll work…)

Hi Tobor,

Please tell me which IDE you are using and please “attach” your full code so we can test it here. :smiley:

I’m currently using ATOM-Pro IDE 08.0.1.7. I’ve attached my full code. The problematic code appeared in the very last subroutine when I used a duration of -24000 rather than 60. A duration of 60 will stop my servo but I’d prefer to simply stop sending pulses completely to disable the servo.
marblemaze.bas (5.6 KB)

be aware that this is a very risky assumption for an analog r/c servo. digital servos usually hold position if the pwm signal disappears but there is no specific design behavior for analog servos and as such it varies between stopping, creeping, going for an end at full speed.

I’m not aware of any digital continuous rotation servos. He’s using analog servos and in my experience with no pulses (from Hservo) should not be floating so there shouldn’t be any creeping or end stop slamming. It should just stop.

We will give the code a test in house today.

Specifically I’m using a standard HITEC HS-5475HB which has been hacked for continuous rotation. I planned to use analog but this was all I had laying around at the moment. I removed the mechanical stop and glued the pot to the “center” position which I located based upon a 1500 pulse from a HITEC HFP-20 servo programmer.

You can see a picture of the servo and learn a little more at the following link. I’ll be adding more pictures and video soon as I finish the upgrades for this project.

sites.google.com/site/teamtobor/marble-maze#TOC-Gumball-Dispenser:

Well that certainly does change things…

There is nothing wrong with hservo. Hitec digital servos will not turn off. Even if the servo pulses are removed. There is no Basic Atom code anywhere that will change this. :frowning:

Well at least the mystery is solved. :smiley:

Thanks for the clarification. I was under the impression this servo was analog until I looked up the specs just now for my last post. It didn’t even occur to me that this $30 servo might be digital. I guess I always assumed this was a feature only found in more expensive servos. Thanks! :blush:

Your “Door Opener” RFID project is interesting, I may just implement something like that for the “Cat Door” in the garage! (keeps out the little black and white “striped” kitties)

Alan KM6VV