Motor comparison script

General topics and discussions about the VESC and its development.
arvidb
Posts: 230
Joined: 26 Dec 2015, 14:38
Location: Sweden, Stockholm

Motor comparison script

Postby arvidb » 26 Jan 2018, 20:15

I wanted to see what I can expect from different motors given certain battery voltages, battery currents, controller current limits etc., so I wrote an Octave script for this. The result is quite nice:
motor_plt.png
motor_plt.png (25.15 KiB) Viewed 300 times

This is comparing a 1965 rpm/V motor (the one that came with my "BZ-888" RC car) running on 4s LiFePO4 batteries and stock controller, with a range of motors from TPPower (their "4030" range) running on 8s LiFePO4 and a VESC.

The horisontal part of each plot is due to the controller current limit; the curved part is due to battery power limit, and the "cliff" part is due to the motor's characteristics (this is the straight line you'd see continue all the way to the y axis on a DC motor rpm-torque plot).

I post the script here in case someone else finds it useful, too (and maybe there are bugs to find, as well? ;) ):

Code: Select all


#    Copyright 2018 Arvid Brodin
#
#    This is an Octave script to calculate the performance of radio
#    control power systems (battery + motor controller + motor).
#
#    This script is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This script is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

clear;


### Inputs

range = 40000;   # rev/min, max speed to plot.


## Power systems

# U_bat in V, battery voltage at I_bat
# I_bat in A, max battery current
# I_out in A, max controller current
# U_fact (dimensionless), controller max effective duty cycle

#         U_bat [V]   I_bat [A]   I_out [A]         U_fact
vesc  = [     8*3.0          45          60        3^0.5/2 ];
bz888 = [    4*3.06          76         600            1.0 ];

# 3^0.5/2 is max modulation before overmodulation when using space vector modulation


## Motors

# Kv in rev⋅min⁻¹⋅V⁻¹
# Rm in Ω, between two motor leads
# Im in A, max motor current

#        Kv      Rm    Im
m = [
     [ 1965   0.023   120   bz888 ];  # BZ-888 3660 motor, Rm measured, Im guessed
     [ 1750    0.01   105   vesc  ];  # TP4030-6Y
     [ 1500   0.015    90   vesc  ];  # TP4030-7Y
     [ 1300   0.017    78   vesc  ];  # TP4030-8Y
     [ 1170   0.024    71   vesc  ];  # TP4030-9Y
    ];


### Code

P_max = m(:,4) .* m(:,5);   # Max input power (col)
U_eff = m(:,4) .* m(:,7);   # Max effective motor voltage (col)

w = 100:50:range;

# This produces one row for each motor, with the back EMFs
# corresponding to each step of w in the columns:
U_emf = bsxfun(@rdivide, w, m(:,1));

U_torque = bsxfun(@minus, U_eff, U_emf);# The voltage left over for driving a current
U_torque = max(U_torque, 0);


I_max = bsxfun(@rdivide, P_max, U_emf);   # Current given by power limit at each speed
I_max = bsxfun(@min, I_max, m(:,3));   # Individual motor limit
I_max = bsxfun(@min, I_max, m(:,6));   # Controller limit

I_torque = bsxfun(@rdivide, U_torque, m(:,2));      # I = U/R
I_torque = min(I_torque, I_max);
T = bsxfun(@rdivide, I_torque, (m(:,1) * (2*pi/60)));   # T = I/Kv in SI units

h = figure(1);
set(h, "defaultaxesfontname", "DejaVu Sans")

plot(w, T);
xlabel("Speed [rev⋅min⁻¹]");
ylabel("Torque [Nm]");

ltext = num2str(m(:,1));            # Kv
ltext = strcat(ltext, " RPM/V; Imax = ");
ltext = strcat(ltext, num2str(min(m(:,3), m(:,6)), "%3d"));# min(Im, Iout)
ltext = strcat(ltext, " A; Ueff = ");
ltext = strcat(ltext, num2str(U_eff, "%.1f"));
ltext = strcat(ltext, " V; Pbat = ");
ltext = strcat(ltext, num2str(P_max, "%.0f"));
ltext = strcat(ltext, " W");
legend(ltext);

title(sprintf("Comparison of torque vs speed of motors of different Kv with different batteries & controllers."));


## Note: bsxfun will replicate the input arrays along their "singleton dimensions", i.e. the dimensions along which the size of the array is 1, so that they match the size of the corresponding dimension of the other array. This is what is called "singleton expansion".

Return to “General”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest