Modifying Power with the joystick in easy C.

My robot’s left side is moving faster than my right side. How can I adjust the power of my robot so that I can push both joysticks fully forward and have my robot move straight? The program that I am using is easy C.


I don’t personally use easyc, but if I were to do this I would set a variable that reads the joystick input then I would create an if statement to set one sides maxspeed to be lower.


slowerSpeed = 100 //to equal the motors speeds
// remember you want to make the faster side slower to equalise the speed
    int LJoy = Left Joystick
    int RJoy = Right Joystick

    if ( faster side (e.g. LJoy) > slowerSpeed )
          Ljoy = slowerSpeed

     motor Left = LJoy
     motor right = RJoy

There is probably a much better way of doing this, but this should work :stuck_out_tongue:

Nalobots - have you looked thoroughly through your drivetrain to make sure there isn’t more friction on one side than the other? Before looking into a software solution I would suggest making sure there is nothing more you could do mechanically.

The other thing is, if it is just a small difference then you may want to consider just compensating in real time with your joysticks. If the difference is more major you may want to consider checking your drive train for excess friction (as suggested by Jabibi) and whether your motors all have the same gearing (turbro, high speed etc). Remember that a software solution can do nothing but SLOW down your faster side to compensate, something that is not ideal.

Thanks for your new to programming so I’ll see if it works.