Question about the 180 degree servo motor

LINIX Brushless, VEXTA Brushless, RC Servo, DC Geared, Linear, Stepper, Tamiya.....

Question about the 180 degree servo motor

Postby woeiyih » Fri Feb 24, 2012 5:41 pm

i using mikroc to compile my code which use to control the angle of the 180 degree servo motor without. at first i open the software and build the project,i set the MHZ to 8Mhz and compile the code and burn the code to pic16f84a, i put the crystal which is 8Mhz as well...bt the motor wont move at all....after that i change the hardware to 4Mhz and rebuild the project with 4Mhz and compile it...and it works...may i know y it cant function while i compile with 8Mhz??

below is my code....
CODE: SELECT_ALL_CODE
unsigned short count=0;

void count_1(){
     for (count=0;count<100;count++){
         PORTB = 0xff;
         delay_ms(1);
         PORTB = 0x00;
         delay_ms(19);
         }
     }
void count_2(){
      for (count=0;count<100;count++){
         PORTB = 0xff;
         delay_ms(2);
         PORTB = 0x00;
         delay_ms(18);
         }
         }

void main() {
     TRISB = 0X00;
     portb = 0x00;
     while(1){
         count_1();
         count_2();
         }
}
woeiyih
Fledgling
 
Posts: 1
Joined: Mon Dec 07, 2009 1:26 pm

Re: Question about the 180 degree servo motor

Postby ABSF » Sat Feb 25, 2012 8:55 am

You didnt list the complete source code so I cant tell exactly what went wrong. :?

My first guess is, when you change the crystal from 4MHz to 8MHz did you change the line
#define _XTAL_FREQ 4000000
to
#define _XTAL_FREQ 8000000

in the header file accordingly ?


The problem is in the delay_ms(xx) functions. If you just double the crystal frequency, then the delay_ms() function will operate 2x faster. A delay_ms(19) would becomes delay_ms(9.5). And that's the reason why your servo motor wont work.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: Question about the 180 degree servo motor

Postby robosang » Fri Mar 02, 2012 9:05 am

Yup, timing is very critical in RC servo control 8-)
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm


Return to DC Motor

Who is online

Users browsing this forum: No registered users and 3 guests

cron