Urgent!! why unable to freeze my servo at one position

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

Urgent!! why unable to freeze my servo at one position

Postby cheelip » Fri Dec 14, 2012 6:08 pm

Sorry for disturbing, currently i writing the code for controlling 5 servo (3xc40r and 2xc36r) where i able to control the servo to desire angle but the problem was all the servo unable to standstill at one position (not the shaking problem) , i already reloop and given the signal to servo every cycle but still unsuccessfully freeze the servo at one position after i control the servo to certain angle, the power source for the servo were 2 parallel SLA batteries with 6v 4.5ah each (total have 6v and 9ah) and using the power swiching to provide the 12v 8.5a then using LM7895 and TIP2955 to obtain 5v 8.3a output for servo motors, one time only run for one power source circuit and the it was construct sererately and using the 2 way switch to select it, so can anyone figure out what is my problem and really thanks a lot for your advise and helping.
cheelip
Novice
 
Posts: 21
Joined: Thu Jun 09, 2011 4:27 pm

Re: Urgent!! why unable to freeze my servo at one position

Postby low5545 » Fri Dec 14, 2012 6:37 pm

Which servo and what microcontroller are you using?
low5545
Discoverer
 
Posts: 70
Joined: Wed Jul 27, 2011 5:55 pm
Location: Kuala Lumpur

Re: Urgent!! why unable to freeze my servo at one position

Postby cheelip » Fri Dec 14, 2012 7:51 pm

Thanks for replying, The microcontroller i use is PIC16F876A and the servo was buying from cytron with the code "c36r" and "c40r",i successful make the servo freeze before by controlling the servo the desire angle but after yesterday i try then unable to freeze the servo motor, i doubt the internal circuit may spoil bcz when i try yesterday suddenly my servo was very hot then i quickly switch off the power but some later it unable to freeze the servo anymore but still can control the servo to certain angle, the power source circuit was build follow the guideline of ctyron forum previous post so i don't think is the overvoltage problem because i check using the multimeter already and all connections were correct, i suspect the controller inside the servo may spoil already ( i suspect only...but hope don't......(T.T)......and i don't know how to troubleshoot it. This is part of my project built a robot arm with wireless touch scrren interfacing, other part was function well except the servo unable the freeze, do your have any idea? thanks ^^
cheelip
Novice
 
Posts: 21
Joined: Thu Jun 09, 2011 4:27 pm

Re: Urgent!! why unable to freeze my servo at one position

Postby low5545 » Fri Dec 14, 2012 8:06 pm

I'm not an expert in PIC, but try to upload the coding and schematics, that can help us to understand your situation.
low5545
Discoverer
 
Posts: 70
Joined: Wed Jul 27, 2011 5:55 pm
Location: Kuala Lumpur

Re: Urgent!! why unable to freeze my servo at one position

Postby cheelip » Fri Dec 14, 2012 8:52 pm

CODE: SELECT_ALL_CODE
#include <htc.h>
#include <pic.h>                
                        
__CONFIG ( 0x3F32 );                   
#define XTAL   20000000
//#define speed_1   RC4                     
//#define speed_2   RC5
                     
#define servo   RB1
#define servo1   RB2               
#define servo2   RB3
#define servo3   RB4                     
#define servo4   RB5

#define left   RA1
#define right_1   RA2
#define left_1   RA3
#define right_2   RA4
#define left_2   RA5
#define right_3   RC0
#define left_3   RC1
#define right_4   RC2
#define left_4   RC3*/



#define   MHZ   *1000L                   
#define   KHZ   *1                   
#define   DelayUs(x)   { unsigned short _dcnt; \
           _dcnt = (((x)*(20MHZ))/(24MHZ))|1; \
           while(--_dcnt != 0) \
              continue; \
          }


unsigned char a;
unsigned short i;
unsigned short keep=0;
unsigned short keep_1=0;
unsigned short keep_2=0;
unsigned short keep_3=0;
unsigned short keep_4=0;
unsigned short speed=2;
unsigned short speed_1=2;
unsigned short speed_2=2;
unsigned short speed_3=2;
unsigned short speed_4=2;
//unsigned short speed_temp;


unsigned char uart_rec(void)         // subrountine to receive text from PC
{
   while (RCIF == 0);
   a = RCREG;
   return a;
}

void DelayMs(unsigned short y)
{
   unsigned short   i;
   do {
      i = 4;
      do {
         DelayUs(250);
      } while(--i);
   } while(--y);
}


         
void main(void)
{
   SPBRG=129;//0x81;               // uart configuration
   BRGH=1;   
   TXEN=1;
   CREN=1;
   SPEN=1;
   SYNC=0;
   RX9=0;

    DelayMs(250);
   ADCON1=0b00000111;
   TRISB = 0b00000000;            
   PORTB = 0b00000000;            
   keep=232;
   //......
   //this is start position initialisation
   //......

   while(1)         //a is the receive signal from controller      
   {         //enable continuos receive
   if(OERR==0) a=uart_rec();   //receive sata if overrun error free
   else CREN=0;
   
   if(a==0x6B)   {speed=2;}//k
   //.......
   //This part is speed selection, because the pic have limited pwm module so if use if statement to creat pwm
   //......

   
   //part below is infinite loop for controlling the 5 servo
   if(a==0x61)   
         {if(keep>=394)   {keep=394;}
         else   {keep=keep+speed;}
         }
   if(a==0x62)
         {if(keep<=70)      {keep=70;}
         else   {keep=keep-speed;}
         }
   // redo same statement above for the next 4 servo
   //...................
   
         
         servo=1;   
         i=keep;
            
         for(i;0<i;--i) {DelayUs(1);}
         servo=0;
   // redo same statement above for the next 4 servo
   //........
         DelayMs(9); // the DelayMs not exactly the ms delay, i calculate from the stopwatch list of MPlab         
         
      
   }
      
}



//from the schematic,sv1 to sv5 is for servo,sv6 is for power switching,sv9 for 9v batterysv7 for wirelessmodule,sv8 for 6v9a battery, if not so talent to summarising but try to make the coding as short as possible, hope you free to read it, thank....
Attachments
5_servo.jpg
cheelip
Novice
 
Posts: 21
Joined: Thu Jun 09, 2011 4:27 pm

Re: Urgent!! why unable to freeze my servo at one position

Postby royalstorm7 » Fri Dec 14, 2012 11:39 pm

hi .. C36R is ok for me ... just want to know ... u want to have a independent angle or same angle for every servos? .. i did something with multiple servos last time .. attached pic is my project ..

royalstorm7@yahoo.com
Attachments
DSCN0445.jpg
royalstorm7
Apprentice
 
Posts: 52
Joined: Sat Sep 04, 2010 1:37 pm

Re: Urgent!! why unable to freeze my servo at one position

Postby cheelip » Sat Dec 15, 2012 12:45 am

thanks for your kindness,royalstorm7 and low5545, really appriaciate to your help, .....i think maybe found the problem already, it may cause by this coding from above

" if(OERR==0) a=uart_rec(); //receive sata if overrun error free
else CREN=0;"

so if i disable this code then i can freeze the servos, this code is receiving the signal from the wireless module in order to control each servo to different angle, but before this i using the switches direct control the servos was not problem at all!! if after i upgrading system to using the wireless interfacing with touch panel to control the servo then need to insert the code above then problem arise, this code was preventing continuous sending the pwm signal but i still can control the servos angle, haha so weird and annoying, i still try debuging the code and do you have any idea to modify the code in order to having the continuous pwm signal??? thanks again (^^)



if i found out something then will let you know, i still new but try my best....
cheelip
Novice
 
Posts: 21
Joined: Thu Jun 09, 2011 4:27 pm


Return to DC Motor

Who is online

Users browsing this forum: No registered users and 16 guests

cron