voxl Tmotor f55 esc
-
We recently updated the parameter structure in the ESC params. The ESCs you have are using older params. If you wanted to verify or update those params, please use the following version of voxl-esc tools : https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-esc/-/tree/v1.1.1
If you want to use the latest params, a firmware update and param update is required.
You can use the latest voxl-esc tools : https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-esc/-/tree/v1.2.2update the firmware on all ESCs:
./voxl-esc-upload-firmware-all.sh firmware/modalai_esc_firmware_tmotor_f55a_revc_v0_38_9b6d54b6.bin
At this point the ESCs will make a sad tone because the params will be invalid. Now update the params to the latest default params for the tmotor ESC.
./voxl-esc-upload-params.py --params-file ../voxl-esc-params/FPV_RevB/FPV_RevB.xml
After this, you should have the ESC updated firmware and params to the latest. Next you can diff your desired params against the latest params you just loaded, and create a new version of your params.
I noticed that you have pretty high kp and ki values. If you are just starting out, i would suggest setting kp=0 and ki=0, this will result in performance close to a off-the-shelf ESC. having gains set too high could result in vibrations or motors heating up, it will require some more careful testing.
Additionally, i noticed that your tuning params do not have a lot of precision, which will result in incorrect curve. You should have at least 3 or preferably 6 decimal places for each of a0, a1, a2 to avoid any error. You can copy paste them directly from the calibration procedure.
<param name="pwm_vs_rpm_curve_a0" value="870.0"/>
<param name="pwm_vs_rpm_curve_a1" value="0.5"/>
<param name="pwm_vs_rpm_curve_a2" value="3.0e-06"/>Alex
-
Alex Hi
Thanks for your fast & supporting respond.
1.We got negative values for a0 (-500 to -1000) and not your recommended positive value
<param name="pwm_vs_rpm_curve_a0" value="870.0"/>
<param name="pwm_vs_rpm_curve_a1" value="0.5"/>
<param name="pwm_vs_rpm_curve_a2" value="3.0e-06"/>Should a0 be a negative value (-870) or a positive on (a correctness value?)?
2.We got different parameter values to the curves while running multiple calibration tests t
o the same ESCx-Motx couples,
and of course different values testing a different ESCx-Motx couples.What should be (how to choose/ calculate) the right a0,a1 & a2 values for the single uploaded parameters file (avg?)
Thanks Erez
ps
New voxl-esc-calibrate.py with a0-a2 inside the graphs and
created under the logs foldercat ./voxl-esc-calibrate2.py
Copyright (c) 2020 ModalAI Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
4. The Software is used solely in conjunction with devices provided by
ModalAI Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
For a license to use on non-ModalAI hardware, please contact license@modalai.com
from voxl_esc_setup_paths import *
voxl_esc_setup_paths()from libesc import *
from esc_scanner import EscScanner
import time
import numpy as np
import argparseparser = argparse.ArgumentParser(description='ESC Calibration Script')
parser.add_argument('--device', required=False, default=None)
parser.add_argument('--baud_rate', required=False, default=None)
parser.add_argument('--id', type=int, required=False, default=0)
parser.add_argument('--pwm-min', type=int, required=False, default=10)
parser.add_argument('--pwm-max', type=int, required=False, default=90)
parser.add_argument('--pwm-step', type=int, required=False, default=1)
parser.add_argument('--pwm-step-duration', type=float, required=False, default=0.5) #seconds
args = parser.parse_args()devpath = args.device
baudrate = args.baud_rate
esc_id = args.id
PWM_MIN = args.pwm_min
PWM_MAX = args.pwm_max
PWM_STEP = args.pwm_step
STEPDURATION = args.pwm_step_durationquick scan for ESCs to detect the port
scanner = EscScanner()
(devpath, baudrate) = scanner.scan(devpath, baudrate)if devpath is not None and baudrate is not None:
print('INFO: ESC(s) detected on port: ' + devpath + ', baud rate: ' + str(baudrate))
else:
print('ERROR: No ESC(s) detected, exiting.')
sys.exit(1)#check input arguments
if PWM_MIN < 10 or PWM_MIN > 50:
print('ERROR: Minimum power must be between 10 and 50')
sys.exit(1)if PWM_MAX < 10 or PWM_MAX > 100:
print('ERROR: Maximum power must be between 10 and 100')
sys.exit(1)if PWM_MAX < PWM_MIN:
print('ERROR: Maximum power must be greater than minimum power')
sys.exit(1)TRANSITIONTIME = 0.40
create ESC manager and search for ESCs
try:
esc_manager = EscManager()
esc_manager.open(devpath, baudrate)
except Exception as e:
print('ERROR: Unable to connect to ESCs :')
print(e)
sys.exit(1)wait a little to let manager find all ESCs
time.sleep(0.25)
num_escs = len(esc_manager.get_escs())
if num_escs < 1:
print('ERROR: No ESCs detected--exiting.')
sys.exit(1)esc = esc_manager.get_esc_by_id(esc_id)
if esc is None:
print('ERROR: Specified ESC ID not found--exiting.')
sys.exit(1)warn user
print('WARNING: ')
print('This test requires motors to spin at high speeds with')
print('propellers attached. Please ensure that appropriate')
print('protective equipment is being worn at all times and')
print('that the motor and propeller are adequately isolated')
print('from all persons.')
print('')
print('For best results, please perform this test at the')
print('nominal voltage for the battery used.')
print('')
response = input('Type "Yes" to continue: ')
if response not in ['yes', 'Yes', 'YES']:
print('Test canceled by user')
sys.exit(1)get ESC software version. sw_version < 20 means gen1 ESC, otherwise gen2
sw_version = esc.get_versions()[0]
esc_manager.enable_protocol_logging()
spin up
esc_manager.set_highspeed_fb(esc_id) #tell ESC manager to only request feedback from this ID (so we get feedback 4x more often)
esc.set_target_power(10)
t_start = time.time()
while time.time() - t_start < 1.0:
time.sleep(0.05)
esc_manager.send_pwm_targets()measurements = []
t_test_start= time.time()ramp up from min to max
pwm_now = PWM_MIN #10
while pwm_now <= PWM_MAX:
esc.set_target_power(pwm_now)
t_start = time.time()
print('')
while time.time() - t_start < STEPDURATION:
time.sleep(0.01)
esc_manager.send_pwm_targets()
if pwm_now >= PWM_MIN and time.time() - t_start >= TRANSITIONTIME:
measurements.append(
[esc.get_power(), esc.get_rpm(), esc.get_voltage(), esc.get_current()])
print('POW: %d, RPM: %.2f, Voltage: %.2fV, Current: %.2fA' % (esc.get_power(), esc.get_rpm(), esc.get_voltage(), esc.get_current()))
pwm_now += PWM_STEPclose the manager and UART thread
esc_manager.close()
t_test_stop= time.time()
print ('INFO: Test took %.2f seconds' % (t_test_stop-t_test_start))#d_date=datetime.datetime.now()
d_date="{:%Y%m%d-%H%M%S}".format(datetime.now())
print ("date="+str(d_date))parse measurements
pwms = [data[0] for data in measurements]
rpms = [data[1] for data in measurements]
voltages = [data[2] for data in measurements]
currents = [data[3] for data in measurements]#reported power is 0-100, but in ESC firmware it is 0-1000
motor_voltages = [pwms[i]10.0/999.0(voltages[i]*1000) for i in range(len(pwms))]linear fit or quadratic fit
ply = np.polyfit(rpms, motor_voltages, 2)
motor_voltages_fit = np.polyval(ply, rpms)print corresponding params
print('Quadratic fit: motor_voltage = a2rpm_desired^2 + a1rpm_desired + a0')
print(' a0 = ' + str(ply[2]))
print(' a1 = ' + str(ply[1]))
print(' a2 = ' + str(ply[0]))
print('ESC Params (after scaling):')
print(' pwm_vs_rpm_curve_a0 = ' + str(ply[2]))
print(' pwm_vs_rpm_curve_a1 = ' + str(ply[1]))
print(' pwm_vs_rpm_curve_a2 = ' + str(ply[0]))plot results if possible
try:
import matplotlib.pyplot as plt
except:
print('WARNING: In order to plot the results, install the Python "matplotlib" module')
sys.exit(0)plot the results
plt.plot(rpms, motor_voltages, 'bo')
plt.tight_layout()
plt.plot(rpms, motor_voltages_fit)
print ('Motor Voltage vs. RPM Test')
plt.xlabel('Measured RPM')
plt.ylabel('Commanded Motor Voltage (mV)')
plt.title('Motor Voltage vs. RPM Test')
plt.legend(['Data', 'Fit'], loc=2)
plt.ylim([0, np.max(motor_voltages)+1000])
plt.tight_layout()
print ('Motor Voltage vs. RPM Test')
plt.tight_layout()plot corresponding params
plt.figtext(0.5, 0.01, "Quadratic fit: motor_voltage = a2rpm_desired^2 + a1rpm_desired + a0", ha="center", fontsize=10, bbox={"facecolor":"orange", "alpha":0.5, "pad":5})
plt.figtext(0.2, 0.97, 'a0=%.8f' % ply[2], ha="center", fontsize=10, bbox={"facecolor":"green", "alpha":0.5, "pad":5})
plt.figtext(0.5, 0.97, 'a1=%.8f' % ply[1], ha="center", fontsize=10, bbox={"facecolor":"green", "alpha":0.5, "pad":5})
plt.figtext(0.8, 0.97, 'a2=%.8f' % ply[0], ha="center", fontsize=10, bbox={"facecolor":"green", "alpha":0.5, "pad":5})
plt.tight_layout()plt.savefig('./logs/'+str(d_date)+'ESC#'+str(esc_id)+'_Volt_vs_RPM.jpg',bbox_inches='tight')
#time.sleep(2)plt.figure()
plt.plot(pwms, rpms, 'bo')
print ('RMP vs. PWM Test')
plt.xlabel('Commanded PWM (x/100)')
plt.ylabel('Measured RPM')
plt.title('RPM vs. PWM Test')
plt.tight_layout()plot corresponding params
plt.figtext(0.5, 0.01, "ESC Params (after scaling):", ha="center", fontsize=10, bbox={"facecolor":"orange", "alpha":0.5, "pad":5})
plt.figtext(0.3, 0.97, 'a0=%.8f' % ply[2], ha="center", fontsize=10, bbox={"facecolor":"yellow", "alpha":0.5, "pad":5})
plt.figtext(0.6, 0.97, 'a1=%.8f' % ply[1], ha="center", fontsize=10, bbox={"facecolor":"yellow", "alpha":0.5, "pad":5})
plt.figtext(0.9, 0.97, 'a2=%.8f' % ply[0], ha="center", fontsize=10, bbox={"facecolor":"yellow", "alpha":0.5, "pad":5})plt.savefig('./logs/'+str(d_date)+'ESC#'+str(esc_id)+'_RPM_vs_PWM.jpg',bbox_inches='tight')
plt.show()
plt.close() -
Hi Alex,
I replaced the F55A ESCs firmware from version 33 to version 38
(modalai_esc_firmware_tmotor_f55a_revc_v0_38_9b6d54b6.bin),
and used he new code version (v1.2.2) &
also used the new XML file (FPV_RevB.xml renamed to mpd_params.xml)
but I got the same errors:user@user-CF-54-3:/data/voxl-esc-v1.2.2/voxl-esc-tools$ sudo python3 ./voxl-esc-upload-params.py --params-file ../../voxl-esc-add-new-params/voxl-esc-params/MPD/mpd_params.xml
Detected Python version : 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0]
Found voxl-esc tools bin version: 1.2INFO: Params file name : ../../voxl-esc-add-new-params/voxl-esc-params/MPD/mpd_params.xml
INFO: Params file size : 6835 bytesINFO: All COM ports:
/dev/ttyS4 : n/a
/dev/ttyUSB0 : TTL232R
INFO: UART Port Candidates:
/dev/ttyUSB0
INFO: Scanning for ESC firmware: /dev/ttyUSB0, baud: 2000000
INFO: Scanning for ESC firmware: /dev/ttyUSB0, baud: 250000
INFO: Scanning for ESC firmware: /dev/ttyUSB0, baud: 921600
INFO: Scanning for ESC firmware: /dev/ttyUSB0, baud: 230400
INFO: Scanning for ESC firmware: /dev/ttyUSB0, baud: 57600
INFO: ESC(s) detected on port: /dev/ttyUSB0, baud rate: 57600
INFO: ESCs detected:
INFO: ---------------------
ID: 0, SW: 38, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
ID: 1, SW: 38, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
ID: 2, SW: 38, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
ID: 3, SW: 38, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)INFO: Loading XML config file...
WARNING: Tune Parameter "tone_freqs_10hz" incompatible
WARNING: Tune Parameter "tone_times_ms" incompatible
Traceback (most recent call last):
File "./voxl-esc-upload-params.py", line 124, in <module>
esc.params.parse_xml_string( xml_string )
File "./tmp/voxl-esc-tools-bin-export-1.2/libesc/params.py", line 518, in parse_xml_string
File "./tmp/voxl-esc-tools-bin-export-1.2/libesc/params.py", line 935, in set_packet_metadata
File "./tmp/voxl-esc-tools-bin-export-1.2/libesc/params.py", line 249, in update_crc
File "./tmp/voxl-esc-tools-bin-export-1.2/libesc/params.py", line 165, in get_param_bytes_for_crc
File "./tmp/voxl-esc-tools-bin-export-1.2/libesc/params.py", line 85, in byteify
struct.error: pack expected 12 items for packing (got 4)Erez
-
Alex,
more info
/data/voxl-esc-v1.2.2/voxl-esc-tools$ sudo ./voxl-esc-verify-params.py
Detected Python version : 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0]
Found voxl-esc tools bin version: 1.2
INFO: All COM ports:
/dev/ttyS4 : n/a
/dev/ttyUSB0 : TTL232R
INFO: UART Port Candidates:
/dev/ttyUSB0
Found previous connection information in .voxl_esc_cache ..
Prioritizing /dev/ttyUSB0 @ 57600
INFO: Scanning for ESC firmware: /dev/ttyUSB0, baud: 57600
INFO: ESC(s) detected on port: /dev/ttyUSB0, baud rate: 57600
ID config CRC mismatch 60163 != 0
ERROR: Params for ID 0 are invalid!
ID config CRC mismatch 60163 != 0
ERROR: Params for ID 1 are invalid!
ID config CRC mismatch 60163 != 0
ERROR: Params for ID 2 are invalid!
ID config CRC mismatch 60163 != 0
ERROR: Params for ID 3 are invalid!
ERROR: Some params are invalid or not the same!
Number of ESCs expected : 4
Number of ESCs found : 4
Number of invalid params : 4
Number of matched params : 4 -
Alex,
With the new file it works:
sudo python3 ./voxl-esc-upload-params.py --params-file ../voxl-esc-params/FPV_RevB/FPV_RevB.xml
Detected Python version : 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0]
Found voxl-esc tools bin version: 1.2INFO: Params file name : ../voxl-esc-params/FPV_RevB/FPV_RevB.xml
INFO: Params file size : 7663 bytesINFO: All COM ports:
/dev/ttyS4 : n/a
/dev/ttyUSB0 : TTL232R
INFO: UART Port Candidates:
/dev/ttyUSB0
Found previous connection information in .voxl_esc_cache ..
Prioritizing /dev/ttyUSB0 @ 57600
INFO: Scanning for ESC firmware: /dev/ttyUSB0, baud: 57600
INFO: ESC(s) detected on port: /dev/ttyUSB0, baud rate: 57600
INFO: ESCs detected:
INFO: ---------------------
ID: 0, SW: 38, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
ID: 1, SW: 38, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
ID: 2, SW: 38, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
ID: 3, SW: 38, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)INFO: Loading XML config file...
INFO: Uploading params...
-- board config
-- id config
-- uart config
-- tune config
DONE
INFO: Resetting ESCs...
DONEI'll change the relevant parameters to fit our motor's type.
Thanks
Erez
-
When it comes to comparing the quadratic curve fits, it is difficult to look at just the coefficients and compare them. If you have multiple tests, you should plot the quadratic plots on the same figure and see how repeatable they are. What may seem like a noticeable variation in the coefficients, could still result in curves that are very similar.
By the way, you should not just average values of a0, a1, and a2 to get a0_average, a1_average, and a2_average, as this will result in wrong curve. If you would like to find an average of all 4 runs, then you can just create a quadratic fit of all the points from the 4 data sets - that is the proper way to do it. However, if after plotting the 4 curves they look very similar, you can use any of the 4 individual fits. The PI (Proportional Integral) controller on the ESC will compensate for minor deviations.
The error you saw with params not being valid was due to the latest version of
voxl-esc
tools using new parameter structure. So the solution is (which is what you already figured out) to update the firmware and params to latest. This type of change does not happen too often. We will add this to documentation to make this clear.Alex