Driving servos

Here ( https://www.robotshop.com/letsmakerobots/node/80 ) Frits had mentioned that either Arduino or PICAXE can control such and such number of servos. I'm pretty new to microcontroller world, so maybe my question will sounds a bit stupid... but I don't really get what we mean by saying "can only control X servos"? Does it actually mean, "platform X can have up to N serial outputs"? Because, AFAIK that's what servos are, aren't they?

Now, I can understand that PICAXE has also limitations due to the built-in Basic interpreter; but why Arduino?

Maybe I'm just misinterpreting the concept of how the servos work though...

To control a servo you need
To control a servo you need a digital output. You drive a servo by sending it pulses. The width of the pulse determines the position the servo will take. Read this: http://www.princeton.edu/~mae412/TEXT/NTRAK2002/292-302.pdf for more info on servos. The number of servos a controller can handle is limited to the number of digital outputs.

Servo pulses

A couple of other things to note about R/C servos and the pulses you’ll need to generate. The pulse must be sent to the servo roughly 50 times per second, so that’s 20ms between pulses. The repition rate is not critical, but it it’s too low, the servo will buzz.

You’ll need to make sure that every pulse is exactly the same width, when the servo isn’t moving. Any variation in pulse width will make the servo move (of course), something known as jitter. So if you have any timing uncertainties (e.g. use of interrupts, memory refresh, DMA activity) in your code, the servo will jitter. This is one reason why microcontrollers make better development machines than full-size PCs for this sort of thing.

I think the hard part of servo driving is to get smooth changes in pulse width from a microcontroller that’s doing many other things at the same time (e.g. driving other servos!).

 

Thanks, this is really
Thanks, this is really helpful!

Thanks, anachrocomputer,

Thanks, anachrocomputer, your remarks are always very informative.

Now, even supposing Arduino controls similar (more or less) number of servos - what are real advantages of that platform over PICAXE? Isn’t it just common argument between “ready building blocks” and “highly customizable”, Windows vs. Linux, C#/.Net vs. C/asm, etc? :slight_smile:

Does Arduino platform have more memory (can it use more memory) than say PICAXE-40? Is Arduino significantly faster?

Arduino has USB as part of the platform… which is good, but not that important… what else?

I’m not trying to start a “religious war” here, rather trying to understand whether it worth to stick to PICAXE-28 or 40 for a bigger project… or maybe it worth trying Arduino. (Neither C/C++ vs. Basic or Windows vs. Linux is a bid deal for me, I’m fine with any language and/or OS.) PICAXE definitely looks SUPER-easy to work with.

Very interesting post :)For

Very interesting post :slight_smile:

For what i’ve read on arduino, there is a library called Servo that will handle most of the work. You just have to call “refresh” every TOT time, once only for all servos. Looks easy to use.

I’ll buy some servos asap :stuck_out_tongue:

 

my servo has done nothing but jitter

Does anyone have an idea about servo/controller compatability as far as voltage? Not knowing anything about servos, i ordered a GWS servo (S03T) that doesn’t respond at all to the digital signal from my picaxe board. however, when i connect or disconnect from the V1, I get this little “wiggle” from it.

I’m assuming that the digital out doesn’t have enough juice to push the servo?

Servo voltage

According to the data for that servo, you should be able to drive it with normal 5V pulses. Are you running your PICAXE from 5Volts? If you are, then it’s possible that there’s a mix-up with either which pin you’re driving, or the pin setup, or the software that’s generating the servo pulses. If you have an oscilloscope, check for pluses of about 1-2ms width, every 20ms or so. If you haven’t, then the first thing to do is to make sure that the pin you’ve chosen is set up as an output (and not as an input). Then, how about a little diagnostic test with an LED? If you slow down your pulse generation code by a factor of, say, 100 then you should see 100-200ms pulses every 2 seconds, which is slow enough to check with an LED/resistor.

But you don’t say how you’re generating the pulses – your own pulse-timing code? Or a PICAXE library routine? Or something else?

servo voltage

on picaxe 28 board, i’m connecting it to a digital out. In my Picaxe programmer i enter:

servo 1, 100

servo 1, 80

servo 1, 120

…etc, just to see if i will get anything. I don’t. When i connect to a Futaba 3000, it works as intended.

check the pin layout like

check the pin layout like anachro mentioned…aside from that, it could be a bad servo…

I’ve run 5 different types of servoes form an 08m(as well as an 18x and 14m) without issue. the only thing I’ve noticed is that the throw is slightly different from one to the other when I was testing them.

You could through a cap in the mix as well(connected between the + and - ) to smooth some of the jitter or use a seperate power source. Using a 470uf cap worked for me.

You also need to put some
You also need to put some pauses in between those commands. It could be that the servo is only using one of the commands and it is already in that position. This would appear that it is doing nothing.

Try those pauses
Aha! I think the idea of putting in some pauses makes sense! Remember that the PICAXE has no way of knowing when the servo has reached the required position. The “servo 1, 100” command does not wait for the servo to finish moving. Communication with servos is one-way, so there’s no way for the controlling device to know what’s happening at the servo end. So, try it with the pauses in and let us know!

Make sure you are using the
Make sure you are using the right type of servo. There are analog servos and there are digital servos. Technically all servos use a digital pulse input to know where to position the arm/wheel, but on a digital servo it also has an internal micro controller that determines the desired position and sends its own pulses at a much faster rate to the motor. This is just supposition, but that internal microcontroller might make the digital servos less forgiving on the accuracy of the pulses sent to it. Also, with the increased pwm rate between the microcontroller and motor the digital servos pull more power so check to be sure you’re not putting too much of a load on your power supply.

I was wondering , how do i

I was wondering , how do i connect a 2nd or even 3rd servo to the picaxe 28X1 ? and would anybody know how to programe each servo ? I whant to add a simple arm to my robot with an electromagnet at the end of it so it will be able to pick up cans.
thanks
The man who smiles when things go wrong has thought of someone to blame it on. - Robert Bloch

You put them on a different

You put them on a different output pin and call them as such:

servo 0, 100

servo 1, 100

servo 2, 100

This would make servos on output pin 0, 1 and 2 and move to position 100.

thanks, do you think thw

thanks, do you think thw chip would need a 2nd power source? 2 servos and 2, 3volt motors.?

Documentation says so, but I
Documentation says so, but I hav enever had any problems with only one power source.

tryed it and it seems to

tryed it and it seems to work well, need to figure out how to work my robot by heart cause it is are TPE project ( french school thing ), bits of code are eady to learn but putting them together to make the robot work is the hard part. thanks for all your help !

Maybe… If you need all

Maybe… If you need all three servos to move at once and at their top speed/torque… yes. If speed/torque etc isn’t important then no. If you fire your servos at once (Steppenwolf reference somewhat intended) then they may fight for current and not operate as quickly as they would on another power source.

Try them all on the same power source as the processor and then move to P2 if needed.

yea i was thinking the same

yea i was thinking the same thing, but figured it out and it easy to add 2nd power source.