![]() | ![]() | ![]() |
| | |||||||
| Robotics Chat Specific to discussions about robots and the making of. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Hey guyz..can any one plz help me in programming a serv motor interfacing with an ATMEL AT89C51. My servo is capable of rotating only 180' ....any one plz help me with this thing.. | |
| |
| | (permalink) |
| I don't understand your problem. RC servos are pretty straightforward. What is it about changing the pulse width to change position that is causing you a problem? | |
| |
| | (permalink) |
| A servos motor is any motor that has feedback. But many times when you say servo you are referring to an "elbow" motor, not a wheel motor that can spin an infinite number of times in either direction. 180 degrees is the maximum range for most servos. Many only have a 90 degree range. And a few have 270 degrees. Very few have multiple rotations (I've never heard of an RC servo that does). | |
| |
| | (permalink) |
| unless you specifically mod it to rotate. most RC servos are pretty easy to. by the way, I am assuming he means an RC servo. industrial servo motors are a different breed. | |
| |
| | (permalink) |
| I am currently working on a project for school. I am using a MC68HCS12 design board by Axiom. My compiler is ICC ImageCraft. The Servos I am using are three Hitec HS-311 & one HS-635HB. I have modified one HS-311 for continuous rotation. From reading most of these posts it looks like I am not able to drive one of these servos from my microcontroller. Do I need a H-bridge? Can I use a L298 to drive the servos? I did get the HS-311 servo to run directly from my board, but is only goes in one direction. I can't get my test program to execute other instructions. It only executes the first one and that is it. I will supply my code down below so you can see what I did. Keep in mind I was trying a variety of different configurations so I commented a lot of code out. So here is my real problem. Getting my code to control the servo in multiple directions or to a certain spot. Another problem I am having is trying to know the angle the servo is at. I connected the potentiometers wire to my ATD and it has a voltage drop of 1.36V to 0.26V and I am using a 10-bit conversion. After calculating, it looks like my resolution is 1.07mV. I am able to read the ATD but my angles are off. I will supply the math I did. I am sure it is off. Also I noticed that these servos only worked at 330HZ for center, 430HZ for clockwise, and 230HZ for counterclockwise. I would really appreciate some help on this. ---------------------------------------------------------------------------------------- /*PWM Test*/ #include <hcs12dp256.h> #include <lcd.h> #include <STDIO.H> void delay_1sec(void) {//delay_1sec begins int j,k; for(j=0;j<=10;j++) { asm("nop"); for(k=0;k<=0x4000;k++) asm("nop"); } }//delay_1sec ends void init_pwm(void) {//init_pwm begins asm("movb #$01,$00A2");//0x00A2 = 0x01; //PWCLK asm("movb #$01,$00A1");//0x00A1 = 0x01; //PWPOL asm("movb #$0,$00A5");//0x00A5 = 0x00; //PWCTL //DDRP = 0xFF; // //asm("bset $00A0, $01");//0x00A0 = 0x01; //PWEN //asm("swi"); }//init_pwm ends void two_thirtyhz(void) {//three_thirtyhz begins asm("movb #$45,$00B4");//0x00B4 = 0x45; //PWMPER0 asm("movb #$23,$00BC");//0x00BC = 0x23; //PWDTY0 }//three_thirtyhz ends void three_thirtyhz(void) {//three_thirtyhz begins asm("movb #$30,$00B4");//0x00B4 = 0x30; //PWMPER asm("movb #$15,$00BC");//0x00BC = 0x15; //PWDTY0 }//three_thirtyhz ends void four_thirtyhz(void) {//three_thirtyhz begins asm("movb #$20,$00B4");//0x00B4 = 0x20; //PWMPER asm("movb #$10,$00BC");//0x00BC = 0x10; //PWDTY0 }//three_thirtyhz ends void main(void) {//main begins //LCDInit(); // initialize LCD //ADC_int(); //initialize the A to D (ATD) converter init_pwm (); //initialeze the PWM setbaud(BAUD9600); // set bits per second rate (baud)to 9600 bits per second DDRP = 0xFF; asm("movb #$01,$00A2");//0x00A2 = 0x01; //PWCLK asm("movb #$01,$00A1");//0x00A1 = 0x01; //PWPOL asm("movb #$0,$00A5");//0x00A5 = 0x00; //PWCTL asm("movb #$20,$00B4");//0x00B4 = 0x45; //PWMPER0 asm("movb #$10,$00BC");//0x00BC = 0x23; //PWDTY0 asm("bset $00A0, $01");//0x00A0 = 0x01; //PWEN asm("dec $00BC"); asm("dec $00BC"); asm("dec $00BC"); asm("swi"); /*do { four_thirtyhz(); three_thirtyhz(); two_thirtyhz(); read_motor(); delay_1sec(); } /while(1);*/ }//main ends --------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------- /*ATD Math*/ /*Read Motor*/ #include <hcs12dp256.h> #include <STDIO.H> //#pragma interrupt_handler read_sensor void read_motor(void) {//read_motor begins puts("The angle is: "); //displays The angle is: on the screen motor(); delay_1sec(); }//read_motor ends //#pragma interrupt_handler sensor void motor(void) {//moto begins int angle = 0; ATD0CTL5=0x90; while((ATD0STAT0 & 0x80)!= 0x80); angle=((125*ATD0DR0)/256); ascii(angle); puts(" degrees"); }//motor ends //#pragma interrupt_handler ADC_int void ADC_int(void) //initializes the Analog To Digital Converter {//ADC_int begin ATD0CTL2=0xE0; delay_40us(); ATD0CTL3=0x0A; ATD0CTL4=0x01; //0x01 = 10bit Conversion }//ADC_int end //#pragma interrupt_handler delay_40us void delay_40us(void) { int i; for(i=0;i<=0x20;i++) asm("nop"); } //#pragma interrupt_handler delay_1sec void delay_1sec(void) { int j,k; for(j=0;j<=10;j++) { asm("nop"); for(k=0;k<=0x4000;k++) asm("nop"); } } --------------------------------------------------------------------------------------- | |
| |