Shop OBEX P1 Docs P2 Docs Learn Events
Dual-Diferential Drive Algorithm — Parallax Forums

Dual-Diferential Drive Algorithm

Danny22Danny22 Posts: 29
edited 2007-01-05 17:49 in Robotics
Does anyone know or have access to the algorithm that generates "tank style" commands for a single dual-axis joystick much like the ones used in R/C Mixers? I wrote a code in PBasic that works but I am interested in how the big boys do it.

Comments

  • crgwbrcrgwbr Posts: 614
    edited 2007-01-02 13:12
    I'm not sure any of us know what equation they use in RC mixers. Please post what you have come up with.

    crgwbr

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    NerdMaster
    For
    Life
  • Danny22Danny22 Posts: 29
    edited 2007-01-05 17:49
    I built my own Transmitter with variuos joysticks, keypad, display etc. The wheel motor control section consists of a spring-to-center,dual-axis joystick and a linear slide pot. The slide pot sets the maximum speed the robot will go in any direction and the joystick controls speed and direction. The x=axis, y-axis and linear pot are all scaled to 0-250 by the Transmitter and in addition the joystick is configured so that it will always read 125 in the off position(spring-center). The code is simple:

    speed VAR Byte 'y-axis 0-250
    bias VAR Byte 'x-axis 0-250 for steering
    limit VAR Byte 'max speed allowed 0-250
    Lspd VAR Word 'value sent to left motor driver
    Rspd VAR Word 'value sent to right motor driver

    off CON 750
    nul CON 125

    Mtr_Control:
    bias = bias - nul
    Lspd = (off-bias) + ((speed - nul)*2)MIN (off-limit) MAX (off+limit)
    Rspd = (off+bias + ((speed - nul)*2)MIN (off-limit) MAX (off + limit)
    RETURN

    This code does not account for a deceleration loop to keep the robot from jerking to a stop when the joystick is allowed to spring to the center but I take care of that with a separate Stop_Loop. Also when the joystick is in the 3 o'clock or 9 o'clock position for CW and CCW spins the speed will not be any faster than 625 or 875 for each wheel. I again take care of this by adding an offset to the bias when the y-axis is 0. I don't know if I'm on the right track or not. There's probably some cool way of doing all this with some kind of outrageous PID loop so that's why I asked, hoping someone could direct me to a website or maybe have some special knowledge having reverse-engineered an R/C Mixer unit. By the way this code works fine and I'll continue to use it until I find something better. Thanx for your interest, Danny.
Sign In or Register to comment.