Society of Robots - Robot Forum
Software => Software => Topic started by: superchiku 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.....
-
just index the array with i
like
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--
-
by doin this will i get the turning motion of the servo from left to right and then from right to left
-
a servo will go to the corresponding angle wherever it was
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
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);}
}
-
forgot to denote that PORTD.7 is connected to the servo control(yellow) pin
-
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
-
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
-
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?
-
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
-
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
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
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
-
may be iam not using delay_ms in a correct way
can u tell the procedure and the maximum delay that can be given
-
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
-
you also dont forget to include the corresponding library <delay.h>
-
ok but tell me how does it work??
-
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
-
well what iam saying is if i write delay_ms(5) then what is delayed and how much it is delayed??
-
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
-
well then i have been doing it the correct way now another dbt is it
_delay_ms
or
delay_ms
-
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
-
k will do that
\