Author Topic: servo ratation problem  (Read 3153 times)

0 Members and 1 Guest are viewing this topic.

Offline superchikuTopic starter

  • Supreme Robot
  • *****
  • Posts: 953
  • Helpful? 5
  • cooll
servo ratation problem
« on: March 19, 2008, 12:01:40 AM »
ok i have some doubt in servo rotation now i know 1.5 ms will make the servo turn 90degrees and 2ms upto 180 degree

now suppose i have an array which has values like this

0 0.25ms 0.5ms 1ms 1.5ms 1.7ms 1.9ms 2.0ms

this array will make the servo turn from 0 to 180 degrees now if i want the servo to go in reverse from the 180 degree position do i have to supply values to the servo in the reverse direction of the array like 2.0ms 1.9ms.....
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: servo ratation problem
« Reply #1 on: March 19, 2008, 01:20:22 AM »
just index the array with i


like

Code: [Select]
myArray[i]
and then do a loop incrementing i with i++

and to reverse you have i = array size and decrement a loop with i--
« Last Edit: March 19, 2008, 01:21:34 AM by pomprocker »

Offline superchikuTopic starter

  • Supreme Robot
  • *****
  • Posts: 953
  • Helpful? 5
  • cooll
Re: servo ratation problem
« Reply #2 on: March 19, 2008, 02:21:56 AM »
by doin this will i get the turning motion of the servo from left to right and then from right to left
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: servo ratation problem
« Reply #3 on: March 19, 2008, 08:49:59 AM »
a servo will go to the corresponding angle wherever it was

Quote
i know 1.5 ms will make the servo turn 90degrees and 2ms upto 180 degree

watch out, what you said is wrong ,a 1.5 ms pwm will make the servo go to THE ANGLE 90 (we call it center) wherever the shaft is
so its not a matter of how much you turn it ,its a matter of that the pwm is the final position of the shaft

so if you wanna make your servo turn from 0 to 180 and then from 180 to 0 u make somthin like this
Quote
while(1){
             for(i=0;i++;i<50) / to keep the signal for 1 second
             {PORTD.7 =1;
              delay_ms(1);  /go to angle 0
              PORTD.7=0;
              delay_ms(20);}
             for(i=0;i++;i<50)
             {PORTD.7 =1;
              delay_ms(2); /go to angle 180
              PORTD.7=0;
              delay_ms(20);}
}
good ol' BeNNy

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: servo ratation problem
« Reply #4 on: March 19, 2008, 08:51:53 AM »
forgot to denote that PORTD.7 is connected to the servo control(yellow) pin
good ol' BeNNy

Offline ed1380

  • Supreme Robot
  • *****
  • Posts: 1,478
  • Helpful? 3
Re: servo ratation problem
« Reply #5 on: March 19, 2008, 02:30:37 PM »
benji. is the delay_ms automaticaly defined in avrstudio, or would one need to do additional coding to make it work with the $50 robot
Problems making the $50 robot circuit board?
click here. http://www.societyofrobots.com/robotforum/index.php?topic=3292.msg25198#msg25198

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: servo ratation problem
« Reply #6 on: March 19, 2008, 04:28:33 PM »
well as long as i know avr studio is only an assembly compiler, you cant program there in C
i use codevision as a c compiler and you should include the delay.h library in case you want to use these functions
good ol' BeNNy

Offline ed1380

  • Supreme Robot
  • *****
  • Posts: 1,478
  • Helpful? 3
Re: servo ratation problem
« Reply #7 on: March 19, 2008, 04:58:18 PM »
I GOT WINAVR AND AVR STUDIO. SHOULD HAVE SAID WINAVR.

WHAT ABOUT THE ERROR OF THE OSCILATOR IN THE MCU ITSELF, OR IS THAT NOT SIGNIFICANT ENOUGH TO MATTER?
Problems making the $50 robot circuit board?
click here. http://www.societyofrobots.com/robotforum/index.php?topic=3292.msg25198#msg25198

Offline superchikuTopic starter

  • Supreme Robot
  • *****
  • Posts: 953
  • Helpful? 5
  • cooll
Re: servo ratation problem
« Reply #8 on: March 19, 2008, 10:54:26 PM »
i think delay ms is not a good option i will rely on the hardware timer and another doubt

suppose the servo is at 120 degree angle and i give a delay of 1.5 ms pwm so it will automatically go to 90 degree no matter what may be the position of the servo initially
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: servo ratation problem
« Reply #9 on: March 20, 2008, 05:45:58 PM »
Quote
suppose the servo is at 120 degree angle and i give a delay of 1.5 ms pwm so it will automatically go to 90 degree no matter what may be the position of the servo initially
true

Quote
i think delay ms is not a good option i will rely on the hardware timer

well i did check with it for servos and it works fine, but if you have available timers go for em

Quote
WHAT ABOUT THE ERROR OF THE OSCILATOR IN THE MCU ITSELF, OR IS THAT NOT SIGNIFICANT ENOUGH TO MATTER?

oscilator error??  i dont think its an error that matters, just hook up your mcu and let it drive them servos

good ol' BeNNy

Offline superchikuTopic starter

  • Supreme Robot
  • *****
  • Posts: 953
  • Helpful? 5
  • cooll
Re: servo ratation problem
« Reply #10 on: March 20, 2008, 10:19:54 PM »
may be iam not using delay_ms in a correct way

can u tell the procedure and the maximum delay that can be given
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: servo ratation problem
« Reply #11 on: March 21, 2008, 05:00:46 AM »
make sure the crystal freq is specified in the compiler

define XTAL 8Mhz

you cant pass a variable into this function in codevision, you just pass it a number,an unsigned integer
so you have a maximum of 0xFFFF
good ol' BeNNy

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: servo ratation problem
« Reply #12 on: March 21, 2008, 05:01:44 AM »
you also dont forget to include the corresponding library <delay.h>
good ol' BeNNy

Offline superchikuTopic starter

  • Supreme Robot
  • *****
  • Posts: 953
  • Helpful? 5
  • cooll
Re: servo ratation problem
« Reply #13 on: March 21, 2008, 08:44:50 AM »
ok but tell me how does it work??
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: servo ratation problem
« Reply #14 on: March 21, 2008, 03:38:26 PM »
what do you mean how does it work? whats inside the function? i didnt check on this
but as long as its preciese im glad with it
good ol' BeNNy

Offline superchikuTopic starter

  • Supreme Robot
  • *****
  • Posts: 953
  • Helpful? 5
  • cooll
Re: servo ratation problem
« Reply #15 on: March 21, 2008, 11:02:44 PM »
well what iam saying is if i write delay_ms(5) then what is delayed and how much it is delayed??
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: servo ratation problem
« Reply #16 on: March 22, 2008, 04:57:48 AM »
Quote
well what iam saying is if i write delay_ms(5) then what is delayed and how much it is delayed??

its pretty much obvious in the function call itself

this one means you are making a delay of 5 milliseconds

the micro stays excuting nothing for 5 millisecs then it steps into whats after it
good ol' BeNNy

Offline superchikuTopic starter

  • Supreme Robot
  • *****
  • Posts: 953
  • Helpful? 5
  • cooll
Re: servo ratation problem
« Reply #17 on: March 23, 2008, 12:05:41 AM »
well then i have been doing it the correct way now another dbt is it
_delay_ms

or

delay_ms
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: servo ratation problem
« Reply #18 on: March 23, 2008, 05:25:57 AM »
Quote
well then i have been doing it the correct way now another dbt is it
_delay_ms

or

delay_ms

check with your compiler and its libraries
in the one im using (codevision) it is delay_ms
good ol' BeNNy

Offline superchikuTopic starter

  • Supreme Robot
  • *****
  • Posts: 953
  • Helpful? 5
  • cooll
Re: servo ratation problem
« Reply #19 on: March 23, 2008, 08:12:32 AM »
k will do that
\
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

 


Get Your Ad Here