rtlopez / esp-fc

Flight controller software for hobbyist
MIT License
253 stars 58 forks source link

wobbly #97

Closed ArshaanTech closed 11 months ago

ArshaanTech commented 1 year ago

Hey! The flight controller is working! but there is a problem the drone keeps wobbling a lot which I think it shouldn't... anything I can do to help it?

Mathew3000 commented 1 year ago

Check the mounting of the IMU, this seems like a vibration issue to me. Otherwise check your pid tune

ArshaanTech commented 1 year ago

The imu is mounted nicely with flex quick. pid is by default.

Mathew3000 commented 1 year ago

Depending on your quad you might need to tune the pid

ArshaanTech commented 1 year ago

I don't actually know how to edit PID values... any suggestions?

ArshaanTech commented 1 year ago

do you think i should rather use Double sided tape? or fevi quick is better

rtlopez commented 1 year ago

@ArshaanTech We need more details about your build and configuration

  1. list all used components and show photo of your build
  2. go to the CLI tab and type status command and then dump and place result here
  3. If you are using ESC that you asked in #94 then it is probably the reason, 60Hz is way below recommended rate, you need ESC, that supports OneShot125 protocol at least, and can be updated with 1000Hz.
ArshaanTech commented 1 year ago

I changed the ESC im using a 4in BLHeli ESC with Dshot 600 firmware. Im using ESP32 non mini, MPU6050 and a ppm receiver. The frame is 3D printed custom.

Status:

ESPF ESP32 v0.2.0-RC2 e4ec8b3 Oct 11 2023 20:48:31 8.4.0 201103
STATUS: 
    cpu freq: 240 MHz
  gyro clock: 8000 Hz
   gyro rate: 2000 Hz
   loop rate: 2000 Hz
  mixer rate: 2000 Hz
  accel rate: 501 Hz
   baro rate: 0 Hz
    mag rate: 0 Hz

 gyro device: MPU6050/I2C
 baro device: NONE
  mag device: NONE
     rx rate: 43
     rx lpfs: 0.00, 0.14

 arming disabled: 65542

dump:

dump 
#ESPF ESP32 v0.2.0-RC2 e4ec8b3 Oct 11 2023 20:48:31 8.4.0 201103
set features 536870913
set debug_mode NONE
set debug_axis 1
set gyro_bus AUTO
set gyro_dev AUTO
set gyro_dlpf 256Hz
set gyro_align DEFAULT
set gyro_lpf_type PT2
set gyro_lpf_freq 100
set gyro_lpf2_type PT1
set gyro_lpf2_freq 213
set gyro_lpf3_type PT1
set gyro_lpf3_freq 150
set gyro_notch1_freq 0
set gyro_notch1_cutoff 0
set gyro_notch2_freq 0
set gyro_notch2_cutoff 0
set gyro_dyn_lpf_min 170
set gyro_dyn_lpf_max 425
set gyro_dyn_notch_q 300
set gyro_dyn_notch_count 4
set gyro_dyn_notch_min 80
set gyro_dyn_notch_max 400
set gyro_offset_x -156
set gyro_offset_y -97
set gyro_offset_z -19
set accel_bus AUTO
set accel_dev AUTO
set accel_lpf_type BIQUAD
set accel_lpf_freq 15
set accel_offset_x 292
set accel_offset_y -245
set accel_offset_z -134
set mag_bus AUTO
set mag_dev AUTO
set mag_align DEFAULT
set mag_filter_type BIQUAD
set mag_filter_lpf 10
set mag_offset_x 0
set mag_offset_y 0
set mag_offset_z 0
set mag_scale_x 1000
set mag_scale_y 1000
set mag_scale_z 1000
set baro_bus AUTO
set baro_dev AUTO
set baro_lpf_type BIQUAD
set baro_lpf_freq 10
set vbat_source NONE
set vbat_scale 100
set vbat_mul 1
set vbat_div 10
set vbat_cell_warn 350
set ibat_source NONE
set ibat_scale 100
set ibat_offset 0
set fusion_mode MAHONY
set fusion_gain_p 50
set fusion_gain_i 5
set input_rate_type ACTUAL
set input_roll_rate 20
set input_roll_srate 40
set input_roll_expo 0
set input_roll_limit 1998
set input_pitch_rate 20
set input_pitch_srate 40
set input_pitch_expo 0
set input_pitch_limit 1998
set input_yaw_rate 30
set input_yaw_srate 36
set input_yaw_expo 0
set input_yaw_limit 1998
set input_deadband 3
set input_min 885
set input_mid 1500
set input_max 2115
set input_interpolation AUTO
set input_interpolation_interval 26
set input_filter_type FILTER
set input_lpf_type PT3
set input_lpf_freq 0
set input_ff_lpf_type PT3
set input_ff_lpf_freq 0
set input_lpf_factor 50
set input_rssi_channel 0
set input_0 0 1000 1500 2000 A 1500
set input_1 1 1000 1500 2000 A 1500
set input_2 3 1000 1500 2000 A 1500
set input_3 2 1000 1500 2000 A 1000
set input_4 4 1000 1500 2000 H 1500
set input_5 5 1000 1500 2000 H 1500
set input_6 6 1000 1500 2000 H 1500
set input_7 7 1000 1500 2000 H 1500
set input_8 8 1000 1500 2000 H 1500
set input_9 9 1000 1500 2000 H 1500
set input_10 10 1000 1500 2000 H 1500
set input_11 11 1000 1500 2000 H 1500
set input_12 12 1000 1500 2000 H 1500
set input_13 13 1000 1500 2000 H 1500
set input_14 14 1000 1500 2000 H 1500
set input_15 15 1000 1500 2000 H 1500
set failsafe_delay 4
set failsafe_kill_switch 0
set serial_0 1 115200 115200
set serial_1 0 115200 115200
set serial_2 0 115200 115200
set serial_soft_0 1 115200 0
set scaler_0 0 0 20 400
set scaler_1 0 0 20 400
set scaler_2 0 0 20 200
set mode_0 0 4 1700 2100 0 0
set mode_1 1 5 900 1300 0 0
set mode_2 0 4 900 900 0 0
set mode_3 0 4 900 900 0 0
set mode_4 0 4 900 900 0 0
set mode_5 0 4 900 900 0 0
set mode_6 0 4 900 900 0 0
set mode_7 0 4 900 900 0 0
set pid_sync 1
set pid_roll_p 42
set pid_roll_i 85
set pid_roll_d 24
set pid_roll_f 72
set pid_pitch_p 46
set pid_pitch_i 90
set pid_pitch_d 26
set pid_pitch_f 76
set pid_yaw_p 45
set pid_yaw_i 90
set pid_yaw_d 0
set pid_yaw_f 72
set pid_level_p 55
set pid_level_i 0
set pid_level_d 0
set pid_level_angle_limit 55
set pid_level_rate_limit 300
set pid_level_lpf_type PT1
set pid_level_lpf_freq 90
set pid_yaw_lpf_type PT1
set pid_yaw_lpf_freq 90
set pid_dterm_lpf_type PT1
set pid_dterm_lpf_freq 128
set pid_dterm_lpf2_type PT1
set pid_dterm_lpf2_freq 128
set pid_dterm_notch_freq 0
set pid_dterm_notch_cutoff 0
set pid_dterm_dyn_lpf_min 60
set pid_dterm_dyn_lpf_max 145
set pid_dterm_weight 30
set pid_iterm_limit 30
set pid_iterm_zero 1
set pid_iterm_relax RP
set pid_iterm_relax_cutoff 15
set pid_tpa_scale 10
set pid_tpa_breakpoint 1650
set mixer_sync 1
set mixer_type QUADX
set mixer_yaw_reverse 1
set mixer_throttle_limit_type NONE
set mixer_throttle_limit_percent 100
set mixer_output_limit 100
set output_motor_protocol DSHOT150
set output_motor_async 0
set output_motor_rate 480
set output_servo_rate 0
set output_min_command 1000
set output_min_throttle 1070
set output_max_throttle 2000
set output_dshot_idle 550
set output_0 M N 1000 1500 2000
set output_1 M N 1000 1500 2000
set output_2 M N 1000 1500 2000
set output_3 M N 1000 1500 2000
set output_4 M N 1000 1500 2000
set output_5 M N 1000 1500 2000
set output_6 M N 1000 1500 2000
set output_7 M N 1000 1500 2000
set pin_input_rx 35
set pin_output_0 14
set pin_output_1 25
set pin_output_2 27
set pin_output_3 26
set pin_output_4 -1
set pin_output_5 -1
set pin_output_6 -1
set pin_output_7 -1
set pin_buzzer 0
set pin_serial_0_tx 1
set pin_serial_0_rx 3
set pin_serial_1_tx 33
set pin_serial_1_rx 32
set pin_serial_2_tx 17
set pin_serial_2_rx 16
set pin_i2c_scl 22
set pin_i2c_sda 21
set pin_input_adc_0 36
set pin_input_adc_1 39
set pin_spi_0_sck 18
set pin_spi_0_mosi 23
set pin_spi_0_miso 19
set pin_spi_cs_0 5
set pin_spi_cs_1 13
set pin_spi_cs_2 -1
set pin_buzzer_invert 1
set i2c_speed 1000
set telemetry_interval 1000
set blackbox_dev 0
set blackbox_mode NORMAL
set blackbox_rate 32
set blackbox_mask 0
set wifi_mode OFF
set wifi_ssid 
set wifi_pass 
set wifi_ssid_ap 
set wifi_pass_ap 
set wifi_tcp_port 1111
set mix_outputs -4
set mix_0 0 0 0
set mix_1 0 0 0
set mix_2 0 0 0
set mix_3 0 0 0
set mix_4 0 0 0
set mix_5 0 0 0
set mix_6 0 0 0
set mix_7 0 0 0
set mix_8 0 0 0
set mix_9 0 0 0
set mix_10 0 0 0
set mix_11 0 0 0
set mix_12 0 0 0
set mix_13 0 0 0
set mix_14 0 0 0
set mix_15 0 0 0
set mix_16 0 0 0
set mix_17 0 0 0
set mix_18 0 0 0
set mix_19 0 0 0
set mix_20 0 0 0
set mix_21 0 0 0
set mix_22 0 0 0
set mix_23 0 0 0
set mix_24 0 0 0
set mix_25 0 0 0
set mix_26 0 0 0
set mix_27 0 0 0
set mix_28 0 0 0
set mix_29 0 0 0
set mix_30 0 0 0
set mix_31 0 0 0
set mix_32 0 0 0
set mix_33 0 0 0
set mix_34 0 0 0
set mix_35 0 0 0
set mix_36 0 0 0
set mix_37 0 0 0
set mix_38 0 0 0
set mix_39 0 0 0
set mix_40 0 0 0
set mix_41 0 0 0
set mix_42 0 0 0
set mix_43 0 0 0
set mix_44 0 0 0
set mix_45 0 0 0
set mix_46 0 0 0
set mix_47 0 0 0
set mix_48 0 0 0
set mix_49 0 0 0
set mix_50 0 0 0
set mix_51 0 0 0
set mix_52 0 0 0
set mix_53 0 0 0
set mix_54 0 0 0
set mix_55 0 0 0
set mix_56 0 0 0
set mix_57 0 0 0
set mix_58 0 0 0
set mix_59 0 0 0
set mix_60 0 0 0
set mix_61 0 0 0
set mix_62 0 0 0
set mix_63 0 0 0
rtlopez commented 1 year ago

@ArshaanTech What motors, propellers and Lipo are you using, is it 3S or 4S? Are wobles fast or slow? Do they appear during manouvers or all the time? Are you able to record and share video?

At the beginning you can try

  1. 1k pid loop if CPU load is above 50%
  2. in pid tuning tab reduce master multiplier slider if wobles are fast or increase if they are slow
ArshaanTech commented 1 year ago

i will share video by tomorrow. im using 1000kv motors and 6 inch propellers on a 3s wobbles are fast and they are all the time. The drone keeps wobbling and I have to get throttle way too high sometimes (100%) to control it. The CPU load is only 28% idle and reached max of 35 during caliberation. I can also try with a 6s but I feel that it would be too much power for now so I didn't use it right now. I am also using 35v 1000uf low esr capacitor on esc and a 10v 1000uf low esr capacitor on the 5v regulator output on the Vin pin and ground of the ESP32.

rtlopez commented 1 year ago

What motors are you using exactly? Are they 6S capable? If yes and you are using 3S, then you are getting only fraction of available power (about 25%). That would explain, that you have to raise throttle so high. Few more questions

  1. what mode are you flying, acro or angle? does anything changes if you switch between them?
  2. did you enabled air mode?

If your motors and escs are 6S capable, and propeller size fits to your motor, it should be fine to test that configuration. As safety precondition, you may want to reduce pid gains with master multiplier on first flight. Defaults are for 4S/5inch setups.

I'm worry a bit that you are using 3D printed frame, as it might not be rigid enough. Stiffnes is very important.

Also the best way to diagnose issues is to collect some logs with blacbox logger. This FC firmware operate with serial OpenLog or OpenLager.

ArshaanTech commented 1 year ago

The motors aren't 6s capable, They're rated for 3-4s. Im flying on angle I didn't go acro for now. I think you're right the 3D printed frame could be a problem. I will try different props and a different frame.

ArshaanTech commented 1 year ago

What motors are you using exactly? Are they 6S capable? If yes and you are using 3S, then you are getting only fraction of available power (about 25%). That would explain, that you have to raise throttle so high. Few more questions

  1. what mode are you flying, acro or angle? does anything changes if you switch between them?
  2. did you enabled air mode?

If your motors and escs are 6S capable, and propeller size fits to your motor, it should be fine to test that configuration. As safety precondition, you may want to reduce pid gains with master multiplier on first flight. Defaults are for 4S/5inch setups.

I'm worry a bit that you are using 3D printed frame, as it might not be rigid enough. Stiffnes is very important.

Also the best way to diagnose issues is to collect some logs with blacbox logger. This FC firmware operate with serial OpenLog or OpenLager.

Here is the image of the drone IMG_20231112_162024.jpg

And also the video:

https://github.com/rtlopez/esp-fc/assets/85013497/33ab1526-7b89-4c08-b4a5-3d5931bec7be

One more thing. The esp 32 I am using is quite old but works perfectly. could that be a problem and I should try replacing it with a new one?

rtlopez commented 1 year ago

@ArshaanTech for me it is slow woble/oscillation, I'm pretty sure, it is because of low pid gains and lack of air mode. So you can try

  1. enable air mode in modes tab
  2. In pid tuning tab move master gain slider to the right, by one step and try again

If you notice that it is better, but not enough, move slider next step. Repeat by one step until you feel locked in. If you notice, fast oscilations like shaking, and motor sound modulation, then step back, you hit the limit.

I don't think, that old esp32 module is the reason.

Also I don't see any battery strap in you build. There cannot be any parts, that can move inside. Also pay attention to capacitors, cables and connectors. If they hit the frame, they disrupt gyro. Ensure everything is locked, it is important.

ArshaanTech commented 1 year ago

Okay, I will change the frame and use a sturdy frame from the market. I will enable air mode and I will also try the PID slider.

ArshaanTech commented 1 year ago

The same issue persists, The drone is still oscillating and is also drifting. I calibrated the accelerometer and gyro and the receiver values to 1500 uS. image I ensured there are no moving parts in the drone. everything was stuck well with double-sided tape. Airmode was turned on and I increased PID values. Nothing works so far.

https://github.com/rtlopez/esp-fc/assets/85013497/960be549-0ae5-4d93-b375-c3ef89ff3ea6

can there be any other cause for the issue?

Mathew3000 commented 1 year ago

This seems to be still an issue with your tune. Id say. That said, I have tried but never succeeded in flying the F450 frame with Betaflight(stm32)

Mathew3000 commented 1 year ago

Your propellers seem quite small to me compared to your framesize. But that might also just be from the images

ArshaanTech commented 1 year ago

oh... okay so I guess this is just not the right flight controller for this quad? The propellers are not the issue bcz they fit right. is it possible to share a footage of the drone you have built, like how stable it is during angle or acro? possible to show?

rtlopez commented 1 year ago

@ArshaanTech My 5''/4S quad is rock solid https://www.youtube.com/watch?v=22mlmE2FoF0 I have no experience with building such big quads, there is so many factors and without blackbox we can only guess, whats going on. I recommend to investing in this small device. Recently I've created setup instruction https://github.com/rtlopez/esp-fc/blob/master/docs/setup.md and there is mentioned how to connect sd logger.

The second video you've attached is exactly the same as first, was it intentional?

What exactly motors, propellers and batery are you using, maybe your quad is underpowered. Paste your new settings here.

rtlopez commented 1 year ago

@ArshaanTech if you are using 2212 1000kV motors, then you need 8''-10'' size propellers, as this is recommended. 6'' might be way too small.

ArshaanTech commented 1 year ago

Okay i will use 10" props. and I'm sorry for the wrong attachment.

https://github.com/rtlopez/esp-fc/assets/85013497/49ab395d-bc95-437f-82a4-0ea3c1e187dc

The new settings are

  1. 3s battery 60c 2200mAh
  2. 2212 1000kV motors
  3. BLHeli 30A 4 in 1 ESC (Dshot600)
  4. 6" props - I'll use 10" from next time
  5. F450 frame
Mathew3000 commented 1 year ago

The f450 uses 1045 propellers as default

ArshaanTech commented 1 year ago

i will try with 1045, also is it better to use mpu6500 and 8khz instead of mpu6050, is there any noticeable difference?

rtlopez commented 1 year ago

For experienced and demanding users, this may be noticeable. It provides better filtering, less delay, allows the use of higher pid gains and gives a better lock-in effect. But this also requires higher quality components and PID tuning skills. Personally, I recommend using the SPI interface if possible as I2C is about 10 times slower.

ArshaanTech commented 1 year ago

Okay bro Thanks for the advice! I'll take it into consideration. Btw do you have any plans for working on VTX on screen display? I think it would be pretty nice to read analog battery voltage and display it on the FPV feed.

rtlopez commented 1 year ago

Look for a Minim OSD device, it should work, via UART/MSP As far as I know.

ArshaanTech commented 1 year ago

still the same problem. I'll just build a new quad when i have enough money.

ArshaanTech commented 1 year ago

Do you intend on making newer firmware and solving the current betaflight problems? many things that I turn on just turn off automatically after a reboot, The qmc5883 sensor also not working. it's also better to add VTX support. I would say adding GPS and return to launch would be nice. i can help you with the testing if you want. Any plans?

rtlopez commented 1 year ago

If you could choose only one function, what would it be?

ArshaanTech commented 1 year ago

If you could choose only one function, what would it be?

I would like it to be GPS. I think it's nice to have a return to launch at failsafe instead of the drone dropping from mid air. Atleast landing functionality should be enabled. Can you contact me on discord? I would love to help you out in any way I can, Although I'm not an expert at betaflight firmwares.