Monday, March 10, 2014

Tower Pro Micro servo 99 sg90 control

Tower Pro Micro servo 99 sg90 control. 



The inbuilt controller of servo is already programmed with a closed loop control system using a pot. All that required is to give a pulse train with 5% to 10% duty cycle with 20ms as period.





 Most schematics on the internet shows a direct connection between micro controller and servo control pin. That is not correct.




It is required to use a buffer/ current driver for the servo. Use a transistor to connect control pin to micro controller.




The code:

#include<reg52.h>
sbit servo_pin = P1^0;
void delay(unsigned int);
void main()
{
int k,i=0,a[4]={6,12,21,12};
 pin = 0;
while(1)
{
for(k=0;k<100;k++)
{
servo_pin=1;
  delay(a[i]); // a[i] is Ton period  (Ton is precalculated)
  servo_pin=0; // The array a[i] values are calculated to stop the motor at 0, 90 and 180 degrees
  delay(200-a[i]);        //200 represents 20ms(i.e., 200x0.1ms)
}                 //200-a[i] is Toff(=T-Ton=20-Ton)
i++;
if(i==4)
i=0;
}
}

void delay(unsigned int ms)   \\ delay for 0.1ms (tested on oscilloscope)
{
int i,j;
for(i=0;i<ms;i++)
for(j=0;j<11;j++);
}


Solar Car

Solar Powered Electric Car Specifications: 1. Solar Panels -----  3 x 120W 2. BLDC Motor ------ 48v, 3KW  3. BLDC Motor Contro...