©2019 Robotics for COMPLETE Beginners

08 

Servos

 

Get excited! Today you are learning about servo motors, one of the easiest (not) to learn and hook up and most popular to use among beginners!

Here is the magnificent servo motor which you likely have seen in RC helicopters, RC cars, RC airplane ailerons, and the arms of simple robots. If you are like me you saw this and it inspired you to get into this hobby! It is definitely worth you time to learn because we are going to use 2 servos to make a turret for our tank that will rotate on both its x and y axis.


So, pay attention!

Servos have 3 leads coming out of them. Voltage, Ground, and the input pulse which you will provide.

 

They contain their own electronic board inside which controls a motor connected to reduction gears.


This is why servos come in tall boxes, there's alot crammed in there!

 

The schematic symbol for a servo is just a circle with the word "servo" inside. 

Servos can also be rewired to operate in the opposite direction, this can come in handy when you want to use 1 pin on your microcontroller to send the same control pulse to two servos which mirror each other.

 

See my Skully McSkullface servo setup.

Servos are both simple and complex in design and use.  Much of their operation depends upon your code which you will start learning soon.

The reason they depend upon code to operate is they require a pulse of electricity at certain intervals which we call frequency...how OFTEN we count. Remember when you were slapping your desk? That was a very crude lesson in Pulse Width Modulation, PWM for short.

Ahhhhh PWM.....PWM....


PWM is set up by you with one of the Timer functions built into your microcontroller (there are about 3 on your AVR 328p that can run at the same time, remember you can use a similar chip, it doesn HAVE to be the 328p).

The timer is merely a clock, tick tock, tick tock. Like a metronome when you practice piano which will tell you when to play your note which will be our electric pulse.

When we set up our timer we will choose which REGISTER the frequency and pulse will be assigned to and then the specific PIN you want to send that pulse out on.  It sounds confusing and it is at first! You have many options in terms of setting frequency, etc. but we can cover all of this much later on. For now, keep it simple.

It may take some time but that is the basic operation. So, review it and come back to it often if it doesn't make sense yet. Remember, I'm trying to cut all the fat and make this as simple as possible for you because it can get complicated REALLY quickly.

Just trust me, take my hand.

 

Come with me if you want to live..
 

Servos will vary in terms of the frequency they operate at.

 

Hobby servos for example can operate at around 20ms.

 

When you set up your microcontroller to operate at a similar frequency they are said to speak the same language.


Imagine the servo, like a soldier, turning on their radio every 20ms and turning it off to save battery.

 

You need to tell the microcontroller, which is the Captain, to do the same so the microcontroller can give their instructions to the servo before they turn off.


Then you can send out positive voltage pulses on the pin which you have chosen.

 

The length of these pulses determines how the servo rotates!

 

Simple yet complicated to understand and setup in the beginning.

 

But don't worry, once you practice you will start to understand. 


The length of pulses generally ranges from 1ms to 2ms.

 

For example, if you send a 1ms pulse every 20ms (remember slapping your desk!) then the servo may rotate counter clockwise and if you send a pulse of 2ms it will rotate clockwise.

 

If the pulse is somewhere in the middle like 1.5 ms it may rotate to its middle point.

 

Pretty cool, huh? Yeah, there are some really smart people in this world.

 

You might be one of them!


If there is no pulse but the servo is still being powered it will resist outside force like your thumb pressing down on it.


Usually you can find out the specifics like frequency, etc by looking at a servo's datasheet which is a topic you will learn much later.

 

It's a deep dive of info not appropriate for now.


Review and practice, review and practice!  Draw it out!

 

Have fun with it!

 

When you start to learn the code for it break your code, find out why its broken.

 

Restore the original file you saved, etc.

We will go into further detail with the actual code and wiring on a breadboard in the final lesson.

For now, try to digest this new information because it will help you learn faster.

Remember the Navy Seal mantra "Slow is Smooth, Smooth is Fast."

That is important to remember.

Be easy on yourself. Take breaks. Enjoy being new!

 

Pop Quiz

1. What are the three leads that connect to a servo?

2. How does PWM work with a servo?

3. What happens when you give an average servo a pulse of 1.5ms?

4. Why do servos usually need code to operate correctly?

Get my favorite books on programming AVR chips I use.

Equip yourself with the most dependable, no hassle, quality usb programmer I use daily.

Make sure you have a basic kit. Arduino is fine, it contains the removable AVR 328p chip we will use.

 

I started with something very similar.

Summary

If you had a belt loop for every component you know how to use you would have to add another because now you know how to use the most sacred and precious of all components.

 

The one component everyone in the world dreams of using to create their very own Iron Man opening and closing helmet.

Keep these treasured secrets safe. Do not let them fall into the wrong hands!

For more subscribe to my channel.