Some time ago I calculated Lego NXT motor parameters to use them in mathematical modeling of Lego motor. Also I used them to calculate controller constants for Segway-like robot.
{˙ω=Kτ⋅I−B⋅ω−Ar−τdJ˙I=U−Ra⋅I−Kb⋅ωLa
where:
Some of these parameters can be measured directly. I could measure La and Ra using RLC meter.
Ra = 4.196 Ohm
La = 4.94 mH
But Ra in the equation (1) includes the full circuit resistance, for example internal resistance of batteries. It must be calculated from other measurements.
We will use following scenarios to calculate motor's parameters:
{Kτ⋅I−B⋅ω=Ar+τdRa⋅I+Kb⋅ω=U
The solution of this system can be found in form:
{I=U⋅B+Kb(Ar+τd)Ra⋅B+Kb⋅Kτω=Ra(Ar+τd)−Kτ⋅URa⋅B+Kb⋅Kτ
We can measure I,ω,U and τd. Both equations are linear and have τd as an argument. So, if we know Ar we can find B,Ra,Kτ,Kb using results of measurements in two points.
These measurement gives us three parameters for each point: (τd1,I1,ω1) and (τd2,I2,ω2).
The system that contains results of two measurements:
{I1=U⋅B+Kb(Ar+τd1)Ra⋅B+Kb⋅Kτω1=Ra(Ar+τd1)−Kτ⋅URa⋅B+Kb⋅KτI2=U⋅B+Kb(Ar+τd2)Ra⋅B+Kb⋅Kτω2=Ra(Ar+τd2)−Kτ⋅URa⋅B+Kb⋅Kτ
The graphical representation of measured results:
When I bought Lego EV3 set, I wanted to port my Segway program to EV3. But I need to build EV3 motor model to calculate balance controller constants. In this post I described how I measured and estimated the motor's parameters.
Motor's mathematical model can be described by following equations:{˙ω=Kτ⋅I−B⋅ω−Ar−τdJ˙I=U−Ra⋅I−Kb⋅ωLa
where:
I U | (A) (V) | armature current armature voltage |
ω τd | (rad/sec) (N·m) | shaft's angular velocity shaft's load torque |
La Ra Kτ Kb | (H) (Ω) (N·m/A) (V/(rad/s)) | armature inductance armature resistance torque constant back electromotive force coefficient |
J B Ar | (kg·m²) (N·m/(rad/s)) (N·m) | rotor's moment of inertia viscosity resistance coefficient dry friction force |
Some of these parameters can be measured directly. I could measure La and Ra using RLC meter.
Ra = 4.196 Ohm
La = 4.94 mH
But Ra in the equation (1) includes the full circuit resistance, for example internal resistance of batteries. It must be calculated from other measurements.
We will use following scenarios to calculate motor's parameters:
- Analyzing deceleration curve, when the motor rotates freely without external load and stops due to internal friction. This measurement allow us to find relations between Ar,B and J.
- Measure rotation speed and the motor's current under load. In this case the motor rotates with a constant speed. This measurement allows us to estimate B,Kb,Ra and Kτ.
- Analyzing acceleration curve, when the motor starts rotating without external load. This measurement allows us to adjust parameters calculated on the previous step.
1. Deceleration curve
In this case the motor circuit is open, external load is missing, so the motor model becomes simpler (I=0,τd=0):
{˙ω=−B⋅ω−ArJU=Kb⋅ω
The second expression allows us to find Kb if we know rotation speed. But in this case we cannot measure rotation speed and we will use only the first equation:
{˙ω=−B⋅ω−ArJU=Kb⋅ω
The second expression allows us to find Kb if we know rotation speed. But in this case we cannot measure rotation speed and we will use only the first equation:
˙ω=−B⋅ω−ArJ
The solution of this equation can be found using the initial conditions (ω(0)=ω0):
ω(t)=−ArB+e−B⋅tJ(ω0+ArB)
Because we can measure motor position but not the rotation speed, we need to find motor position function. Integration of rotation speed function with initial condition ϕ(0)=0 gives us the following expression:
ϕ(t)=−Ar⋅tB+(1−e−B⋅tJ)(ω0+ArB)JB
Now we can use least square method to find constants, but some of them are depended on others.
So we should introduce additional independent constants:
{T1=BJT2=ArB
After that we can rewrite the function ϕ(t) from (3):
ϕ(t)=−T2⋅t+ω0+T2T1(1−e−T1⋅t)
I wrote a program that starts the motor and turning the power off after one second of rotation. It measures the motor position every 5 ms and writes them to a log-file. Then a wrote a SciLab script that uses Least Squares method to find dependencies between Ar,B and J. The calculation results are following relations:
BJ=0.4837581433546762ArB=10.697523425732065
and graph that shows measured and calculated motor position.
Now we have relations between Ar,B and J, and we can use them in the next steps.
Because we can measure motor position but not the rotation speed, we need to find motor position function. Integration of rotation speed function with initial condition ϕ(0)=0 gives us the following expression:
ϕ(t)=−Ar⋅tB+(1−e−B⋅tJ)(ω0+ArB)JB
Now we can use least square method to find constants, but some of them are depended on others.
So we should introduce additional independent constants:
{T1=BJT2=ArB
After that we can rewrite the function ϕ(t) from (3):
ϕ(t)=−T2⋅t+ω0+T2T1(1−e−T1⋅t)
I wrote a program that starts the motor and turning the power off after one second of rotation. It measures the motor position every 5 ms and writes them to a log-file. Then a wrote a SciLab script that uses Least Squares method to find dependencies between Ar,B and J. The calculation results are following relations:
BJ=0.4837581433546762ArB=10.697523425732065
and graph that shows measured and calculated motor position.
![]() |
Motor position graph: measured and calculated values |
2. Measurement under load
In case that the motor is steady state (ω=const and I=const), then these differential equations are represented by the following linear equations:{Kτ⋅I−B⋅ω=Ar+τdRa⋅I+Kb⋅ω=U
The solution of this system can be found in form:
{I=U⋅B+Kb(Ar+τd)Ra⋅B+Kb⋅Kτω=Ra(Ar+τd)−Kτ⋅URa⋅B+Kb⋅Kτ
We can measure I,ω,U and τd. Both equations are linear and have τd as an argument. So, if we know Ar we can find B,Ra,Kτ,Kb using results of measurements in two points.
These measurement gives us three parameters for each point: (τd1,I1,ω1) and (τd2,I2,ω2).
The system that contains results of two measurements:
{I1=U⋅B+Kb(Ar+τd1)Ra⋅B+Kb⋅Kτω1=Ra(Ar+τd1)−Kτ⋅URa⋅B+Kb⋅KτI2=U⋅B+Kb(Ar+τd2)Ra⋅B+Kb⋅Kτω2=Ra(Ar+τd2)−Kτ⋅URa⋅B+Kb⋅Kτ
Solution of this system can be found in following form:
{B=I1(Ar+τd2)−I2(Ar+τd1)ω2⋅I1−ω1⋅I2Kb=U(I1−I2)ω2⋅I1−ω1⋅I2Ra=U(ω1−ω2)ω2⋅I1−ω1⋅I2Kτ=ω1(Ar+τd2)−ω2(Ar+τd1)ω2⋅I1−ω1⋅I2
{B=I1(Ar+τd2)−I2(Ar+τd1)ω2⋅I1−ω1⋅I2Kb=U(I1−I2)ω2⋅I1−ω1⋅I2Ra=U(ω1−ω2)ω2⋅I1−ω1⋅I2Kτ=ω1(Ar+τd2)−ω2(Ar+τd1)ω2⋅I1−ω1⋅I2
Measurement assembly
I used a special assembly (LDD model) to measure rotation speed and the current under load. The assembly lifts objects with known weight and recorded the motor positions. From these positions I calculate the rotation speed. Also I used a circuit to measure the motor current using a multimeter.
![]() |
Rendered assembly |
The real assembly photo
NXT based assembly |
This photo was taken on the first attempt of EV3 motor parameters measurement, when I used NXT brick with LeJOS to record motor positions because NXT LeJOS is some kind of "real-time" OS. But LeJOS for EV3 uses embedded Java that requires some time to warm-up and does not allow me to organize stable and precise measurement time intervals. Unfortunately, I found that EV3 and NXT have different electrical parameters so I had to repeat my measurements on EV3 using C++ instead of Java for my program.
I used a wheel from Lego 8051 MotorBike set. The groove when I put the thread has diameter 68 mm. I used scales to measure weight of lifted objects. Then the torque can be calculated:
τd=g⋅m⋅r
Where g is gravitational acceleration, m is object mass, and r is the wheel radius.
τd=g⋅m⋅r
Where g is gravitational acceleration, m is object mass, and r is the wheel radius.
The measurement results
I made a number of measurements and put the results into a table:
Load torque, N*cm |
Motor current, A |
Rotation speed, rad/sec |
---|---|---|
0.00 | 0.054 | 15.8825 |
6.04 | 0.24 | 13.1598 |
9.74 | 0.36 | 11.5017 |
15.28 | 0.54 | 9.0583 |
19.01 | 0.66 | 7.1035 |
The graphical representation of measured results:
Motor parameters estimation
Now we can find the motor parameters. We will use the first and the last row of the table with
measurement results. So:
{τd1=0 N⋅mI1=0.054 Aω1=15.8825 rad/sec
{τd2=0.1901 N⋅mI2=0.66 Aω2=7.1035 rad/sec
Using these reference data we can find the solution of the system (6):
{B=−0.06000677881⋅Ar+0.001016586247Kb=0.4716532815Ra=6.832750917Kτ=0.8693067325⋅Ar+0.2989986520
Using the expression for B and the value for T2 found during the deceleration curve measurement (4) we can find Ar:
−0.06000677881⋅Ar+0.001016586247=Ar10.697523425732065
From this equation we can find Ar=0.006623300293. Then we can calculate other parameters:
B=0.0006191433314Kb=0.4716532815Ra=6.832750917Kτ=0.3047563315
measurement results. So:
{τd1=0 N⋅mI1=0.054 Aω1=15.8825 rad/sec
{τd2=0.1901 N⋅mI2=0.66 Aω2=7.1035 rad/sec
Using these reference data we can find the solution of the system (6):
{B=−0.06000677881⋅Ar+0.001016586247Kb=0.4716532815Ra=6.832750917Kτ=0.8693067325⋅Ar+0.2989986520
Using the expression for B and the value for T2 found during the deceleration curve measurement (4) we can find Ar:
−0.06000677881⋅Ar+0.001016586247=Ar10.697523425732065
From this equation we can find Ar=0.006623300293. Then we can calculate other parameters:
B=0.0006191433314Kb=0.4716532815Ra=6.832750917Kτ=0.3047563315
Because this method has relatively low accuracy (because I used a simple multimeter), I used acceleration curve measurement to find motor parameters with better precision.
3. Acceleration curve
In this case we will find the solution of the motor equation system (1) for ω(t). It has following form:
ω(t)=C1e(ϰ1+ϰ3)t+C2e(ϰ1−ϰ3)t+KτU−Ra(Ar+τd)C5
where
C1=C4C5(ϰ2ϰ3−1)(ϰ1−ϰ3)C2=−C3C5(ϰ2ϰ3+1)(ϰ1+ϰ3)C3=La2(Ar+τd+JUKb(ϰ2−ϰ3))C4=La2(Ar+τd+JUKb(ϰ2+ϰ3))C5=BRa+KbKτ
and where
ϰ1=−BLa+JRa2JLaϰ2=BLa−JRa2JLaϰ3=√ϰ22−KbKτJLa
ω(t)=C1e(ϰ1+ϰ3)t+C2e(ϰ1−ϰ3)t+KτU−Ra(Ar+τd)C5
where
C1=C4C5(ϰ2ϰ3−1)(ϰ1−ϰ3)C2=−C3C5(ϰ2ϰ3+1)(ϰ1+ϰ3)C3=La2(Ar+τd+JUKb(ϰ2−ϰ3))C4=La2(Ar+τd+JUKb(ϰ2+ϰ3))C5=BRa+KbKτ
and where
ϰ1=−BLa+JRa2JLaϰ2=BLa−JRa2JLaϰ3=√ϰ22−KbKτJLa
Because we can get only motor rotation angle from the motor's encoder, we should find expression for ϕ(t) by integrating (8) with respect of initial condition ϕ(0)=0:
ϕ(t)=C6e(ϰ1+ϰ3)t+C7e(ϰ1−ϰ3)t+(KτU−Ra(Ar+τd))tC5−(C6+C7)
where
C6=C1ϰ1+ϰ3C7=C2ϰ1−ϰ3
I used the SciLab script to calculate motor parameters. It uses values (7) as initial values and uses (4) to calculate J and Ar. The source data is the same as for deceleration curve measurement. The script produces following motor parameters:
Ra=6.832749059810827B=0.000726962269165Kτ=0.304766706036738Kb=0.459965726538748J=0.001502739083882Ar=0.007776695904018La=0.00494
The comparison of experimental and calculated motor positions:
ϕ(t)=C6e(ϰ1+ϰ3)t+C7e(ϰ1−ϰ3)t+(KτU−Ra(Ar+τd))tC5−(C6+C7)
where
C6=C1ϰ1+ϰ3C7=C2ϰ1−ϰ3
I used the SciLab script to calculate motor parameters. It uses values (7) as initial values and uses (4) to calculate J and Ar. The source data is the same as for deceleration curve measurement. The script produces following motor parameters:
Ra=6.832749059810827B=0.000726962269165Kτ=0.304766706036738Kb=0.459965726538748J=0.001502739083882Ar=0.007776695904018La=0.00494
The comparison of experimental and calculated motor positions:
![]() |
Experimental and calculated motor angle |
Conclusion
The mathematical model of Lego EV3 motor allows us to calculate controllers using modern techniques like this and check them in a virtual environment.
Very nice post. I have a project where I need to model a Lego EV3 motor and was desperately searching for this information. From other sources I was able to determine rough Ra, Ki and Kb, but the calculation of the other parameters was proving to be quite difficult. Thank you.
ReplyDeleteDo you have the same details for the NXT motor?
ReplyDeleteI have not measured NXT motor's parameters directly. I used motor's characteristics measured by Philo (http://www.philohome.com/motors/motorcomp.htm). You can find NXT motor constants in my post http://nxt-unroller.blogspot.ru/2011/01/motor-controller-with-feed-forward-for.html.
DeleteDo you have the same for Ev3 medium motor.
ReplyDeleteI have not measured EV3 medium motor parameters yet.
DeleteAwesome. I was looking for specs and you saved me a lot of time. Great job!!!
ReplyDeleteThanks for sharing your analysis and results. I will use it and you've save me a lot of time. Juan.
ReplyDelete