ice
Joined: 30 May 2005 Posts: 10 Location: India
|
Thank you |
Posted: Sun Feb 04, 2007 1:12 pm |
|
|
Thank you for your help,PCM.
It now works.
My servo update in now at 70Hz ,I 'm not able to go lower than that(RTCC_DIV_256).It's slow, but it gets it's position right.
In case anyone finds it useful, hobby servo control code:
Code: |
#include <16F876A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
void long_delay_ms(long count)
{
long k;
for(k = 0; k <count>0).
{
int16 sum;
int16 b=20;
output_high(PIN_C0);
sum=400+(b*20); //change value of b from 0 to 20(1ms to 2ms)
long_delay_ms(sum); // 400 for 1ms,,600 for 1.5ms,800 for 2ms
output_low(PIN_C0);
}
void main()
{
set_timer0(0);
setup_timer_0( RTCC_INTERNAL | RTCC_DIV_256 );
enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);
while(1);
}
|
|
|