voxl Tmotor f55 esc
-
Hi Alex
When we try to verify or update ESC params (xml file) to the F5A esc,
we get the following error:data/voxl-esc-add-new-params/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 @ 2000000
INFO: Scanning for ESC firmware: /dev/ttyUSB0, baud: 2000000
INFO: ESC(s) detected on port: /dev/ttyUSB0, baud rate: 2000000
Exception in thread uartserial:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "./tmp/voxl-esc-tools-bin-export-1.2/libesc/uarttransceiver.py", line 100, in run
File "./tmp/voxl-esc-tools-bin-export-1.2/libesc/escmanager.py", line 135, in handle_packets
File "./tmp/voxl-esc-tools-bin-export-1.2/libesc/escmanager.py", line 270, in handle_config_data
File "./tmp/voxl-esc-tools-bin-export-1.2/libesc/esc.py", line 84, in set_params
File "./tmp/voxl-esc-tools-bin-export-1.2/libesc/params.py", line 268, in parse_params
File "./tmp/voxl-esc-tools-bin-export-1.2/libesc/params.py", line 394, in parse_tune_params
Exception: Tune length got: 136, expected: 180
Tune config CRC mismatch 42914 != 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: Params from ID 0 and 1 are not the same
ERROR: Params from ID 0 and 2 are not the same
ERROR: Params from ID 0 and 3 are not the same
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 : 1
user@user-CF-54-3:/data/voxl-esc-add-new-params/voxl-esc-tools$[sudo] password for user:
Starting WizardWhat do you want to do?
- scan 3) spin 5) upload_params
- detect 4) upgrade_firmware
#? 5
Which ?
-
starling_v2 3) fpv_revB 5) MPD
-
sentinel_v1 4) starling_m129
#? 5
uploading params file ../voxl-esc-params/MPD/mpd_params.xml
enabling bridge
Failed to get unit file state for voxl-px4.service: No such file or directory
bridge enabled
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 @ 2000000
INFO: Scanning for ESC firmware: /dev/ttyUSB0, baud: 2000000
INFO: ESC(s) detected on port: /dev/ttyUSB0, baud rate: 2000000
INFO: Detected protocol: firmware
INFO: Additional Information:
INFO: ---------------------
ID : 0
Board : version 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
UID : 0x203135385631500200730034
Firmware : version 37, hash ba6d193a*
Bootloader : version 0, hash 7a01a780ID : 1
Board : version 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
UID : 0x203135385631500200320035
Firmware : version 37, hash ba6d193a*
Bootloader : version 0, hash 7a01a780ID : 2
Board : version 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
UID : 0x203135385631500200340033
Firmware : version 37, hash ba6d193a*
Bootloader : version 0, hash 7a01a780ID : 3
Board : version 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
UID : 0x203135385631500200710034
Firmware : version 37, hash ba6d193a*
Bootloader : version 0, hash 7a01a780
successfully pinged ESCs
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/MPD/mpd_params.xml
INFO: Params file size : 6959 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 @ 2000000
INFO: Scanning for ESC firmware: /dev/ttyUSB0, baud: 2000000
INFO: ESC(s) detected on port: /dev/ttyUSB0, baud rate: 2000000
INFO: ESCs detected:
INFO: ---------------------
ID: 0, SW: 37, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
ID: 1, SW: 37, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
ID: 2, SW: 37, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)
ID: 3, SW: 37, HW: 33: Blheli32 4-in-1 ESC Type B (Tmotor F55A PRO G071)INFO: Loading XML config file...
Traceback (most recent call last):
File "voxl-esc-upload-params.py", line 114, 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)
disabling bridge
bridge disabledwe use the following xml file for the f40 pro 2400kv:
sudo cat ./mpd_params.xml
<?xml version="1.0" encoding="UTF-8"?><!-- 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:-
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer. -
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. -
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. -
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 -->
<EscParameters>
<IdParams>
<param name="id" value="127"/> <!-- 0-7 .. 127 means use hardware ID pins to read ID-->
<param name="dir" value="2"/> <!-- 0=fwd, 1=rev, 2=fwd id-based, 3=rev id-based -->
</IdParams><BoardParams>
<param name="id_map" value="[0, 1, 2, 3, 4, 5, 6, 7]"/> <!-- reserved for future use -->
<param name="vsense_scale" value="6.0"/> <!-- voltage_mv = adc_val_mv * vsense_mult / vsense_ div -->
<param name="isense_scale" value="18.25"/> <!-- Ima * 0.001 * 50 = Vmv, so mult is 1 / (0.001 * 50) = 20 . Note that actual gain is a bit off -->
<param name="isense_zero_mv" value="550"/> <!-- voltage offset of current sensor when current is zero (0.55V by design) -->
</BoardParams><UartParams>
<param name="protocol_version" value="2"/> <!-- reserved for future use -->
<param name="input_mode" value="0"/> <!-- reserved for future use -->
<param name="baud_rate" value="2000000"/> <!-- communication bit rate -->
<param name="char_timeout_ns" value="0"/> <!-- not used -->
<param name="cmd_timeout_ns" value="100000000"/> <!-- timeout for incoming commands before ESC will stop the motor -->
</UartParams><TuneParams>
<param name="pwm_frequency" value="48000"/> <!-- switching freqency of PWM signal going to motors. 24Khz and 48Khz are only options for now -->
<param name="vbat_nominal_mv" value="14800"/> <!-- used for sanity checking and limiting of voltage-dependent funcions -->
<param name="num_cycles_per_rev" value="7"/> <!-- number of pole pairs in the motor. used for converting electrical frequency to mechanical rpm -->
<param name="min_rpm" value="1000"/> <!-- minimum RPM that will be attempted, otherwise capped -->
<param name="max_rpm" value="25000"/> <!-- maximum RPM that will be attempted, otherwise capped -->
<param name="min_pwm" value="50"/> <!-- cap for minimum power to be ever applied. max is 999 -->
<param name="max_pwm" value="999"/> <!-- cap for maximum power to be ever applied. max is 999 -->
<param name="pwm_vs_rpm_curve_a0" value="870.0"/> <!-- this is actually motor_voltage vs rpm curve.. using legacy naming -->
<param name="pwm_vs_rpm_curve_a1" value="0.5"/> <!-- Emax RS1306 3300KV with tri-blade 3x3x3 -->
<param name="pwm_vs_rpm_curve_a2" value="3.0e-06"/>
<param name="kp" value="250"/> <!-- RPM controller proportional gain -->
<param name="ki" value="30"/> <!-- RPM controller proportional gain -->
<param name="max_kpe" value="300"/> <!-- maximum proportional erorr term (max is 999) -->
<param name="max_kie" value="100"/> <!-- maximum integral error term (max is 999) -->
<param name="max_rpm_delta" value="3000"/> <!-- cap for maximum rpm error used in RPM controller --><param name="alignment_time_ns" value="0"/> <param name="spinup_power" value="70"/> <!-- power used to give the motor initial kick (out of 999) --> <param name="latch_power" value="80"/> <!-- power used during latching stage of spin-up (out of 999)--> <param name="min_num_cross_for_closed_loop" value="50"/> <!-- exit latching mode of fixed power after this number of zero crossings --> <param name="brake_to_stop" value="0"/> <!-- apply brake when stopping motor (or not) --> <param name="stall_timeout_ns" value="20000000"/> <!-- after spin-up, if no zero crossing is not detected for this amount of time, motor is considered stalled --> <param name="require_reset_if_stalled" value="0"/> <!-- require sending an array of zero commands to reset before next spin-up, if motor stalled --><!-- <param name="tone_freqs_10hz" value="[200, 215, 225, 250]"/> --> <!-- 200 is 2000Hz, max 255 -->
<!-- <param name="tone_times_ms" value="[10, 10, 10, 10]"/> --> <!-- duration of each tone in units of 10 milli-seconds. Poor naming!!! -->
<param name="tone_powers" value="[100, 100, 100, 100]"/> <!-- max is 255 --><param name="dt_threshold_ns" value="150000"/> <!-- during start up, ignore inter-commutation times less than this val, probably noise --> <param name="max_dt_ns" value="2500000"/> <!-- min and max values for time between two commutations. these are used as caps --> <param name="min_dt_ns" value="10000"/> <param name="dt_bootstrap_ns" value="2000000"/> <!-- filter bootstrap value for commutation dt during start up --> <param name="spinup_stall_dt_ns" value="6000000"/> <!-- during spin-up, if no zero crossing is not detected for this amount of time, motor is considered stalled --> <param name="spinup_stall_check_ns" value="30000000"/> <!-- time after beginning of spinup to start checking for spinup stall --> <param name="timing_advance" value="0"/> <param name="sense_advance" value="0"/> <param name="demag_timing" value="0"/> <!-- unused --></TuneParams>
</EscParameters>Thanks,
Erez
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.binAt 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.xmlAfter 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
-
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.binAt 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.xmlAfter 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() -
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.binAt 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.xmlAfter 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
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
-
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.binAt 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.xmlAfter 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,
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 -
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.binAt 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.xmlAfter 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,
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
-
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-esctools 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login