Joined: 18 Dec 2006 Posts: 20 Location: europe (Turkey)
RF controlled mobil robots axis movement problem
Posted: Mon Dec 25, 2006 4:17 am
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
Posted: Mon Dec 25, 2006 11:25 am
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
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)
Posted: Tue Dec 26, 2006 7:21 pm
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
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