Let's Make Robots!

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.

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.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

L_PWM = (Y - X) + center

R_PWM = (Y+ X) - center

 


Nice!! Thanks Chris~ It works  perfectlly!

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

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 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 ~