Looking for two wheel driving formula with X, Y

I am using one joystick to control the robot. The range of value I fot from joy stick is 0~600 and the PWM to motor control is 40~140. So wheels will be nutrul around 95 as center point. 40 will go backward and 140 will go forward. This is what I have:

  int maxVal=140;
  int minVal=40;
  joyX = map(joyX, 0,600,minVal,maxVal);
  joyY = map(joyY, 0,600,minVal,maxVal);
  int speed_L = formula;
  int speed_R = formula;
  speedPinLeft.write(speed_L);
  speedPinRight.write(speed_R);

It's easy to go single direction but it's kinda tricky if I slightly move the joystick to position like joyX:125, joyY:82, by those values the left wheel should go like pretty much full speed forward and right wheel should go very slow backward.

IMAG1380.jpg

I hope the image will explain a bit clear. Both wheel won't move when joyX:95,joyY:95;

Is there a formula to do this kind of 2 wheels driving? What should I have in RED text formula? Thanks in advance if anyone could help.

There is a formula,

heres my best guess, theres probably a better way

maxval€€€ €€equeals 100

min val equeals -100 

map the values

leftmotor equeals x-y

rightmotor equeals x+y

 some checking to make sure your values dont exceed max values

map the values to the nessary motor outputs

** int maxVal=140; int**

  int maxVal=140;
  int minVal=40;
  joyX = map(joyX, 0,600,minVal,maxVal);
  joyY = map(joyY, 0,600,minVal,maxVal);
  int speed_L = joyX-joyY;
  int speed_R = joyX+joyY;
  speedPinLeft.write(speed_L);
  speedPinRight.write(speed_R);

This will make nutrul value to: speed_L:0, speed_R:190. I think that’s not going to work. But thanks for inputs ~

Here it is

L_PWM = (Y - X) + center

R_PWM = (Y+ X) - center

 


Nice!! Thanks Chris~ It

Nice!! Thanks Chris~ It works  perfectlly!

http://www.youtube.com/watch?v=lpNY9Vgqnr0