- HOW TO INITIALIZE DRIVE WITH JOYSTICKS HOW TO
- HOW TO INITIALIZE DRIVE WITH JOYSTICKS FULL
Assume the (x,y) joystick values are cartesian coordinates on a square plane.
HOW TO INITIALIZE DRIVE WITH JOYSTICKS FULL
Here's a solution that doesn't require complicated if/else chains, doesn't reduce the power when moving full forward or rotating in place, and allows for smooth curves and transitions from moving to spinning. If largest axis < 100%, scale until = 100%.
LR = 0 (centered), FB = full fwd -> Both motors run full forwards.įB was 100%, Lr = 0%. Right motor = K x (Front_Back - Left_Right) Left motor = K x (Front_Back + Left_Right)
eg if Left motor result = 125 and Right motor result = 80 then. If any result exceeds 100% then adjust K so result = 100% and use same K value for other motor also. Centre zero, +Ve for forward motion of pot Other assumptions can be made.įB = front-back pot. A joystick could be constructed where the above is not true, but these are unusual.Īssume that the joystick is of the type that increasing Y% when X = 100% will reduce X. If both are on a joystick type arrangement, if Yaxis = 100% and Xaxis = 0%, then adding some B will usually reduce A. If pots are mechanically independant then both can be at 100% simultaneously. So, all that said, here is a simple off-the-cuff starting solution out of my head which seems like good start. But, if you had been standing still you would have accelerated one or other track to achieve the same result. So, if you are already running at maximum forwards speed on both motors you must decrease one or other track speed in order to turn. To get rotation you have to have one track going faster that the other. For example, if you push the FB (Forward-Backward pot fully forwards, and if both motors then run at full speed ahead, how do you deal with the addition of a small amount of LR (Left-Right) pot being added. Of course, the output should be "analog" that is, it should allow gradual transition from for example from option a) to b) to c).Īn issue is that you have to make decisions about how fast a track is moving under pure signals from a single pot and what to do when signals from the other pot are included. The goal is to mix joystick analog signals to achive following response :Ī)Throttle forward, direction neutral = vehicle moving forwardī)Throttle forward, direction left = vehicle moving forward and turning leftĬ)Throttle neutral, direction left = vehicle turning left IN PLACE that is right motor full forward, left motor full reverse (positive values enable forward PWM pin, negative enable reverse PWM pin, 0 disables both) The motors are controlled by 2 H-bridge drivers, 2 PWM pins for each (Forward, backward), like so: Rest position is (direction and throttle neutral) 512,512 I have a analog stick, that gives 2 analog values: HOW TO INITIALIZE DRIVE WITH JOYSTICKS HOW TO
I am looking for information about how to implement proper mixing of 2 analog joystick signals (X an Y axis) to control a dual differential motor drive ("tank like" drive) using a uC (ATMega328p in my case, but same should apply to any uC with ADC inputs and PWM outputs):