Society of Robots - Robot Forum
Software => Software => Topic started by: yesus on March 01, 2009, 11:34:02 AM
-
hi
i'm totaly green and i need an answer to a simple question:
how do i make servo rotate either forward or backwards with PIC16F627-16F628 or 18F452 (my servos support continuous rotation)
what i want to know is how u make them keep rotating(i'm using assembler language)
plz don't flame me for this question :P
-
Are you asking about how to modify a servo for continuous rotation, or code to run a servo?
I have several robots posted on the main site for PIC 16F877 with source code to download, and a tutorial to modify servos . . .
-
my servos can rotate continuously,what i need is a code in either ASSEMBLER or BASIC to make them do so :P
or just an idea how to do it
-
if u have already modded them ,..,..then u know wat the different pulses u send to it will change its speed instead
of rotating to a specific angle...
i dont know abt pic but gor ave i have designed a code which turns the servo...will work with continuous rotation too...thing is the pulse widths are different..but changing the OCR1A values can take care of that..
#include<stdio.h>
#include<avr/io.h> //for 8mhz internal oscillator controlling servo by centering it
#include<avr/interrupt.h>
#include<util/delay.h>
int main (void)
{
unsigned int i;
DDRD |= _BV(5); // Set PORTD5 as output
DDRC =0x01;
TCCR1B |= (1 << WGM13); // phase and frequency correct mode
ICR1=10000;
TCCR1A|=(1<<COM1A1);//clear oc1a when upcounting and set Oc1a while downcounting
TCCR1B |=(1<<CS11); // Start timer at Fcpu/8
PORTC=0X01;
while(1)
{
for(OCR1A=350;OCR1A<1150;OCR1A++)
{
_delay_ms(1);
}
for(i=1;i<=50;i++)
{
_delay_ms(10);
}
for(OCR1A=1150;OCR1A>350;OCR1A--)
{
_delay_ms(1);
}
for(i=1;i<=50;i++)
{
_delay_ms(10);
}
}
return(0);
}
-
hmm..i didn't have to modify anything,they are just made in such way that they can rotate and have no stopping thingy on the shaft or anything
Parallax Roatation Servo S148
and i have no knowledge of C language :-[
-
err.............its very hard to make u understand ....plzz post the datasheet of ur servo
-
ok,datasheet is available here:
http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/crservo.pdf (http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/crservo.pdf)
the thing is that i can turn it either way usic BASIC commands BUT the pulsout command you find in code attached to servo datasheet is not a BASIC command,only works with BASIC stamp thingy,and i can't make it turn around for a period of time(ie.i can apply pulse to Vo say 20ms and it will turn)and i think i'm missing something quite trivial like delay between pulses or something,but every delay makes it stop and i want it rotate :P
-
i have no idea how do u use basic stamp but if it would have been c...then i what i would have done is that i would have switched on the servo for 1.5 ms 2 ms given it a 20 ms gap...to take it to a particular angle...
now the servo runs in a frequency of 50 hz and with a dutycycle of 20 ms...if u want complete theory for the servo ...go through the servo tutorial or any good member tutorials...
-
that's the thing,i can send it pulse of any widht to servo and i can send any delay to it,but how do i make it rotate???
i know how to turn it this way or the other but i want to make it rotate continouosly(either CW or CCW)
-
u dont unerstand...the duty cycle has to be 20ms...bu if u have continuous rotation servo then if u send pwm of diff pulse widths then that will change the speed at which it rotates ...suppose u sent a 1.5ms pulse then let the rotate at speed x...then if u send a 2 ms pulse thn this speed will either be faster or slower ..depending on the config of ur servo...
-
ok,but what's the delay between pulses??
i'm really trying to understand..just need some guidance
-
hold on,i'm missing something here..i send a pulse or different width to make it rotate CW or CCW but what about the lenght of the rotation? how do i set that?
i did read some servo tutorials but english isn't my first language as u might have guested and i don't fully understand the way servos work
i know that u have to apply a signal or certain width to either center or turn servo(either way depending on signal width) but how do i make it keep turning that way until i want it to stop?
i know that most servos work in 50Hz frequency and that's what i don't understand-do i have to send signal to servo every 20ms or so to make it perform some action??
-
keep doing that in a continuou loop....lby sending pulses of the required length...and when u wantto stop dont send any pulses at all inthe loop
-
heh,seems like NOW i have to learn how to use PWM function,oh joy :P
-
be kind enough tomrk me as helpful hen :D
-
u got it!
-
:D