Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/22/02 02:42
Read: times


 
#34838 - RE: Example code on howto control a serv
OKay I figured out most of it (I am able to control the servo) using a Timer 2 example I found on the Keil site.

CODE:

#include <REG515.H>

void timer1_ISR (void) interrupt 5 using 1 {
TF2 = 0;
}

void main (void){

/*--------------------------------------
Set the reload values to be 20000 clocks.
--------------------------------------*/
CRCL = (65536UL-20000UL);
CRCH = (65536UL-20000UL) >> 8;

CCEN = 8;

CCL1 = (65536UL-1700UL);
CCH1 = (65536UL-1700UL) >> 8;

TL2 = CRCL;
TH2 = CRCH;

/*--------------------------------------
Set Timer2 for 16-bit auto-reload.
The timer counts to 0xFFFF, overflows,
is reloaded, and generates an interrupt.
--------------------------------------*/
T2CON = 0x11; /* 0XX10001 */


/*--------------------------------------
--------------------------------------*/
ET2 = 1; /* Enable Timer 2 Interrupts */
EAL = 1; /* Global Interrupt Enable */

while (1);
}


What I don't get is that i have to generate pulses with a 1.7 ms width to be able to center it. The Hitec manual clearlt sais 20ms pulse width with 0.9 ms for absolute left, 2.1 ms for absolute right and 1.5 ms for middle.

Is this a defective servo or something?

List of 15 messages in thread
TopicAuthorDate
Example code on howto control a servo            01/01/70 00:00      
RE: Example code on howto control a serv            01/01/70 00:00      
RE: Example code on howto control a serv            01/01/70 00:00      
RE: Example code on howto control a serv            01/01/70 00:00      
RE: Example code on howto control a serv            01/01/70 00:00      
RE: Example code on howto control a servo            01/01/70 00:00      
RE: Example code on howto control a servo            01/01/70 00:00      
RE: Example code on howto control a servo            01/01/70 00:00      
RE: Example code on howto control a serv            01/01/70 00:00      
RE: Example code on howto control a serv            01/01/70 00:00      
RE: Example code on howto control a serv            01/01/70 00:00      
RE: Example code on howto control a serv            01/01/70 00:00      
RE: Example code on howto control a serv            01/01/70 00:00      
RE: Example code on howto control a servo            01/01/70 00:00      
RE: Example code on howto control a servo            01/01/70 00:00      

Back to Subject List