I'm trying to control a 12V geared DC motor with encoder through an Arduino by an L298D driver for my self balnace bot.

Based on the angles from the attached gyro sensor and encoder, it calculates the correcting torque by an LQR controller.

I need to produce this calculated torque by PWM of Arduino through the motor driver.


1 Answer 1


$$T=K_t\cdot i$$

Torque is proportional to the current, the torque constant \$K_t [Nm/A]\$ specifies the relation .

There is no direct formula for the voltage relation.


simulate this circuit – Schematic created using CircuitLab

Voltage to current relation, with inductivity neglected

$$V_a = R_a\cdot i_a+\Omega\cdot K_v $$

Voltage to current relation, with inductivity into account $$V_a = R_a\cdot i_a + L_a\dfrac{di_a}{dt} + \Omega\cdot K_v $$

You have also a transfer function, if it can help : https://electronics.stackexchange.com/a/262069/82111

  • \$\begingroup\$ is there a relation between i (armature current)and Vin? \$\endgroup\$
    – user160452
    Feb 5, 2020 at 12:22
  • \$\begingroup\$ habr.com/en/post/220989 \$\endgroup\$
    – user160452
    Feb 5, 2020 at 12:23
  • \$\begingroup\$ im sorry to inform the above answers didnt help my case as i need to apply a specific voltage at motor terminal to get intended torque output. Can i assume a linear approx b/w Vin and o/P Torque? Because i need to code it in arduino \$\endgroup\$
    – user160452
    Feb 5, 2020 at 13:41
  • \$\begingroup\$ Torque of a DC motor is not linearly related to voltage, but average current. So control the current linearly by varying the PWM duty cycle percentage. i.e. when pivoting "backwards", increase PWM and when forwards - decrease PWM. Note this is a four-quadrant problem - the L298D needs to +/- PWM in both forwards and reverse. The goal is, each PWM being 0 to achieve balance. \$\endgroup\$
    – rdtsc
    Feb 5, 2020 at 14:02
  • \$\begingroup\$ @user160452 NO, there is no relation between input voltage and torque. There is a relation between input voltage, motor speed and torque. If you assume a constant speed, maybe full speed, maybe stall, then you could write down a voltage/torque relation, but it would break as soon as the speed varied. \$\endgroup\$
    – Neil_UK
    Feb 5, 2020 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.