Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Robotics Chat

Notices


Robotics Chat Specific to discussions about robots and the making of.

Reply
 
LinkBack Thread Tools Display Modes
Old 1st December 2007, 07:43 AM   (permalink (permalink))
Default Driving a servo motor- Timer0, Timer1

This is continuous from "Driving a servo motor - Timer0."

This time we'll use Timer0 to set the pulse width, and Timer1 to set the
period of the pulse train. When Timer1 interrupt is software triggered, the pulses will be generated by the interrupt routine, thus the micro can do something else while generating pulses in the background. MicroController used: P16F628A.

T0T1grapha.jpg

The period of pulses is fixed and pulse width is variable.
The alogorithm is as follow:

Timer1 was set for 16 mS.
Timer0 was set for required pulse width.

START:
Turn on Timer1 and wait for it to overflow.
.....Set pulse high. Turn on Timer0 and wait for Timer0 overflow.
.....When Timer0 overflows, set pulse low. Still waiting for Timer1 overflows.
When Timer1 overflows, it's one period. Reset values in Timer0 and Timer1 and repeat from START.

Timer1 register is consists of TMR1H and TMR1L registers. Maximum steps of increment the two registers
combine= 65536. For Fosc= 4Mhz, each step is 1 uS.

Example to set value in TMR1H and TMR1L register:

Fosc= 4Mhz
Period of pulses= 16 mS
Prescale= 1:1

65536 - (16000 (in uS))/1

= 49536
Convert this number into binary number= 11000001 10000000

TMR1H= 11000001 or 193d
TMR1L= 10000000 or 128d

Refer following program for detail of setup.
This program only send pulses with width of 1.3 mS, which is middle position.

Servo Motor_T0T1_C.txt

Next we'll modify the program to use Timer0 and Timer2........
__________________
May the force be with you.


My project: Simple White Line Follower

http://au.youtube.com/watch?v=8Z_MmrdH4oc

http://i271.photobucket.com/albums/j...nefollower.jpg

Last edited by Wingmax; 2nd December 2007 at 04:01 AM.
Wingmax is offline  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Latest
Driving a servo motor Wingmax Robotics Chat 26 11th February 2008 09:56 PM
Driving a servo motor- Timer0 Wingmax Robotics Chat 14 26th November 2007 11:23 AM
Servo problems bananasiong Micro Controllers 0 16th September 2007 02:15 AM
Servo Controll... In reverse? savage Micro Controllers 9 1st December 2006 03:10 PM
Help required with servo motor controller mayhem Robotics Chat 3 26th May 2006 04:21 PM



All times are GMT. The time now is 03:56 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.