CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RF controlled mobil robots axis movement problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rnome



Joined: 18 Dec 2006
Posts: 20
Location: europe (Turkey)

View user's profile Send private message

RF controlled mobil robots axis movement problem
PostPosted: Mon Dec 25, 2006 4:17 am     Reply with quote

hi everybody

i have great problem about a rf controlled mobile robots' axis movement. i m using a anolog joystic for sensetive control and robot have two dc motors that it ll move as a tank. for each axis (x-y) movement i must use different pwm values and in this case i need to control 242 different pwm values.



i dont know how to control this pwms effectively


i ll use pic16f877 at 4mhz crystal
_________________
live fast, never rest and do your best
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Mon Dec 25, 2006 11:25 am     Reply with quote

I would solve this with a formula. I would interpret the movement as y axis being forward/reverse and the x axis as turn left/right.

signed int8 y_Movement
signed int8 x_Movement
signed int16 M1
signed int16 M2

y_Movement = y_Joystick+128
x_Movement = x_Joystick+128

M1=y_Movement
M2=y_Movement

if x_Movement>0
{ M1=M1-x_Movement
}
else
{ M2=M2+x_Movement
}

Then scale up to 242

M1=242*M1/128
M2=242*M2/128
rnome



Joined: 18 Dec 2006
Posts: 20
Location: europe (Turkey)

View user's profile Send private message

PostPosted: Tue Dec 26, 2006 7:21 pm     Reply with quote

thanks neutone for your effort

i solved this problem with a less sensetive way before nearly madness:)

void cmp(int x, int y)
{
int pwm_x,pwm_y;
if(y>=150){ //forward
pwm_y=(y-125)*2;
motorsur_ileri();
if(x>=150) //forward and right
pwm_x=pwm_y/2;
if(x<=100){ //iforward and left
pwm_x=pwm_y;
pwm_y=pwm_y/2;
}
if(x<150>100) //only forward
pwm_x=pwm_y;
}

if(y>100&&y<150>=150){ //only right
pwm_y=100;
pwm_x=0;
}
if(x<=100){ //only left
pwm_y=0;
pwm_x=100;
}
if(x<150>100){ //stop
pwm_y=0;
pwm_x=0;
}
}

if(y<100>=150) //reverse and right
pwm_x=pwm_y/2;
if(x<150>100) //only reverse
pwm_x=pwm_y;
if(x<=100){ //reverse and left
pwm_x=pwm_y;
pwm_y=pwm_y/2;
}
}
set_pwm1_duty(pwm_y);
set_pwm2_duty(pwm_x);
}
_________________
live fast, never rest and do your best
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group