![]() |
|||||||||||||||||||||||||||||
![]()
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() I use
and
recommend Firefox for the best internet browsing experience. Click below for your free copy today: CLICK
THE IMAGE:
Note:
I find it faster
and easier to use and it has great plugins. It even imports all your current browser settings! There's
no risk as your existing browser is not affected in any way - you can just choose which
one to use.
|
Readers
comments
|
||||||||||||||||||||||||||||
12F675 Tutorial 6 : Driving a standard servo motor with a PIC.Driving a servo motor is easy
even with the small 12F675...
Servo motor driver tutorial. This tutorial uses the 12F675 microcontroller to drive a servo. The microcontroller generates the signals to control a standard servo using Timer 0 interrupts (I used a Futaba servo). It does not do anything clever just sets the servo position to predefined positions at one second intervals. A Timer 0 interrupt creates the 20ms timebase for servo updates using the internal clock and prescaler to accurately set the interrupt repeat rate. Surprisingly servos are absolutely simple to control all the hard work is done for you (in the internals of the servo itself). All you need to do is generate a pulse signal repeated at every 20ms (approx). Jump to Solderless breadboard. Jump to Circuit Diagram. Jump to Software. You need to generate a pulse of the correct time as this determines the servo's position. A pulse high signal of duration of 1.5ms sets the servo motor position to the center or zero degrees.
Note: These are the normal settings acceptable to most servo motors and the software is capable of going outside these ranges but you have to check that your servo is capable of doing this. If the servo hits the end stop then it is not capable and larger current will be drawn and the servo will eventually damage itself. Solderless breadboardThe circuit uses the same plugblock as before but most of the components are not used - all you really need is the ICSP connection and the servo connection, power supply and decoupling capacitors. The LM35DZ, LED and MAX232CPC are not used. If you have them already then leave them on as they can be used later.![]() Circuit diagramThe
servo is only needs a single control line from the 12F675 and an
accurate timing source which is provided here by the internal 4MHz
clock in the 12F675.
Software
Servo
Motor
Software
operation
|
|||||||||||||||||||||||||||||
| ////////////////////////////////////////////////////////////////////// // Pulse out to servo motor void do_servo(void) { unsigned short i; // Tune the output to 604us (full clockwise) for zero input. // Each bit is worth 7us. // For mid position of 128 o/p = 1.5ms // 255 gives 2.39ms. GPIO = (1<<SERVO_PIN); // Set delay_us(604); // Tuned using simulator to 7us for(i=0;i<servoVal;i++) { ; } GPIO &= ~(1<<SERVO_PIN); // Reset } |
| Pulse width | Value servoVal | Servo motor position |
| 1.0ms | 57 | +45° (clockwise rotation) |
| 1.5ms | 128 | zero position |
| 2.0ms | 199 | -45° (anti clockwise) |
| Back | 12F675 Tutorial Index | Next |
![]() |
Don't forget to Sign Up for your Microcontroller
Newsletter
With "Essential tips and techniques", ..."New Site Info" and more... |
![]() |
|
![]() |
Including a
free project :
How to drive
an LCD and 12key keypad using "Only
One 8 Bit Port"
with no
interface logic!...
(Works for any microcontroller)
This costs you : Nothing... ![]() Just fill out the form below and you'll get full C source code and project schematic and description. |
||
|