Naze32 Altitude Hold Problem - Any Ideas?

Post Reply
xeo-star
Posts: 9
Joined: Wed Jul 16, 2014 10:59 am

Naze32 Altitude Hold Problem - Any Ideas?

Post by xeo-star »

Chaps,

I've got an issue with the altitude hold on my naze32 and I'm a bit stumped.

Generally it works OK, just hovering it'll stay there all day happy enough.

However if I start some manoeuvres it will occasionally get its self in a twist, applies full throttle and heads for the stars.

If I drop below 50% throttle out of the altitude hold zone I regain control and can descend. Raising the throttle again is normal until I hit 50% and off it shoots full chat for the stars ?

Only way to get it out of this twist is to flick off the barometer then back on again, it then hold altitude fine again?

The sensor is covered with foam and I've tried a couple of types, same thing? Also tried sunny and overcast times, still does it. Also tried still and wind times, again still does it?

I'm trying to identify what triggers this sort of mode it gets into but no patterns yet?

This is th rig if it helps

Image
Any ideas?

xeo-star
Posts: 9
Joined: Wed Jul 16, 2014 10:59 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by xeo-star »

I've also done some logging of a flight when this happens.
On this graph all is well until the vertical red line where things go wrong. Up to this point I’m fairly gently flying back and forth, rolling left and right at a constant (ish) height.
(Barometer is on right hand side axis, all the others are on left hand)
Image

This second graph is zoomed in on where things go wrong.

Image

At the red line vertical line the motor drive signals rapidly go up and the hex heads for the stars but:-
1. The Z accelerometer isn’t showing anything dramatic
2. My RCthrottle command is fairly constant
3. The barometer signal isn’t changing very drastically
Anybody any idea what could be going on?

User avatar
treym
Posts: 258
Joined: Sat Jul 21, 2012 12:28 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by treym »

baro is not really baro ..baro is altitude fusion from accZ and baro ..

to me it looks like accZ is indeed telling model is violently going down

xeo-star
Posts: 9
Joined: Wed Jul 16, 2014 10:59 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by xeo-star »

I'm not sure baro is a fusion, I know alt hold uses a baro and accel z fusion to work but these graphs are raw sensor data.

Also at the red line when things start to go wrong the accel Z is flat, it only goes down rapidly once the throttle Is applied and the hex goes full throttle and up rapidly. The rapid Z accel down is just reporting the hex is going up quickly.

Peter

User avatar
treym
Posts: 258
Joined: Sat Jul 21, 2012 12:28 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by treym »

xeo-star wrote: these graphs are raw sensor data.

if this baro as reported as msp , actually it is not raw baro .. unless you changed the code .


so , it might just a major battery failure :p

xeo-star
Posts: 9
Joined: Wed Jul 16, 2014 10:59 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by xeo-star »

Either way I don't see anything unusual about the baro reading that should cause such dramatic throttle response when its trying to hold alt, unless I'm missing something?

When you say battery failure, I'm not sure I follow. When it happens it shoots up at full throttle, certainly no shortage of battery power.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by Alexinparis »

xeo-star wrote:I'm not sure baro is a fusion, I know alt hold uses a baro and accel z fusion to work but these graphs are raw sensor data.

Also at the red line when things start to go wrong the accel Z is flat, it only goes down rapidly once the throttle Is applied and the hex goes full throttle and up rapidly. The rapid Z accel down is just reporting the hex is going up quickly.

Peter


You're right, the altitude reported in the GUI has no relation with accz.
There is some averaging/LPF on the raw baro data, but the alt value relies only on baro sensor.

accz is used only in baro IMU part algo to estimate BaroPID.
I hope you will find what is wrong.

crazyal
Posts: 84
Joined: Tue Sep 04, 2012 11:25 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by crazyal »

please stop writing stuff without even knowing how stuff works in baseflight.
if any of you knew what they are talking about you'd know that in baseflight the acc readings also influence the altitude reported.
I know because i coded it ;)
you've got some nice graphs there, but i'm not sure what the exact issue is. I'm pretty sure there aren't any overflows in the code.
hmm this looks like it's induced by the acc readings.. did you calibrate the accel on a level surface ?

xeo-star
Posts: 9
Joined: Wed Jul 16, 2014 10:59 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by xeo-star »

Hi Crazyal,

Thanks the reply and yep I think the acc's are calibrated. It flies really well in manual, horizon and horizon with alt hold for most of the time.

Its just when I'm in horizon with mag and baro activated something triggers a full throttle signal after a bit of flying. Its also a repeatable problem, I can get it to do it after a short time in alt hold and rolling gently left and right.

It does make me wonder about an overflow of some sort because:-

1. The sensors report sensibly
2. Its not the pilot input
3. Takes a few mins in this mode to occur
4. Once its triggered it keeps happening until I flick out of alt hold and back in again

Just my thoughts at moment, could be totally wrong.

Could the fact its a hex rather than a quad play any part, just a hex must be less common therefor less tested?

Pete

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by timecop »

No, mixing is done on PID outputs and doesn't matter.

xeo-star
Posts: 9
Joined: Wed Jul 16, 2014 10:59 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by xeo-star »

Cheers TC, that probably rules out it being a hex thats causing an issue.

Still a bit baffeled whats tiggering it. it think I'll inspect soem other sensors see if anything pops out as unusual around the probelm time.

Pete

User avatar
treym
Posts: 258
Joined: Sat Jul 21, 2012 12:28 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by treym »

I do hexa , i can say that this is not the cause ..

could you add some information like : baseflight version, hardware revision and configuration dump ?

I knaw that uncalibrated acc or bad range/lpf calibration will mess with accZ altitude hold .. but the scnerio that you are describing is none of the one i had encountered .

crazyal wrote:please stop writing stuff without even knowing how stuff works in baseflight.
if any of you knew what they are talking about you'd know that in baseflight the acc readings also influence the altitude reported.


well , that was my understanding too .. :)

Code: Select all

    // when the sonar is in his best range
    if (sonarAlt > 0 && sonarAlt < 200)
        EstAlt = BaroAlt;     // THIS is RAW SONAR  with tilt correction
    else
        EstAlt = accAlt; // This is altitude complementary filtered for Altitude estimation (baro & acc)
 


https://github.com/multiwii/baseflight/ ... imu.c#L382

MSP is not reporting rawBaro but EstAlt
https://github.com/multiwii/baseflight/ ... ial.c#L476

brm
Posts: 287
Joined: Mon Jun 25, 2012 12:00 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by brm »

xeo-star wrote:Hi Crazyal,

Thanks the reply and yep I think the acc's are calibrated. It flies really well in manual, horizon and horizon with alt hold for most of the time.

Its just when I'm in horizon with mag and baro activated something triggers a full throttle signal after a bit of flying. Its also a repeatable problem, I can get it to do it after a short time in alt hold and rolling gently left and right.

It does make me wonder about an overflow of some sort because:-

1. The sensors report sensibly
2. Its not the pilot input
3. Takes a few mins in this mode to occur
4. Once its triggered it keeps happening until I flick out of alt hold and back in again

Just my thoughts at moment, could be totally wrong.

Could the fact its a hex rather than a quad play any part, just a hex must be less common therefor less tested?

Pete

interesting picture you presented.

even those who copied the parts of the code do not know what they copied.
therefore no usefull answer - missing :idea:

i spend some time on double integrating the accelerometer.
in general it is a bad idea to do this with the cheap acelerometers you get.
but a combination of low and high passfiltering may tame the accelerometer for navigation purposes.
the current baseflight altitude hold and configuration is not really usefull.
take harakiri and it does it's job out of the box.

there is also a nice approach:
http://www.mathworks.com/matlabcentral/answers/62959-trouble-filtering-and-integrating-acceleration-data
you need at least naze32pro to do so.

btw, today my quad ended the alt-hold session on the ground...

crazyal
Posts: 84
Joined: Tue Sep 04, 2012 11:25 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by crazyal »

xeo-star wrote:Hi Crazyal,

Thanks the reply and yep I think the acc's are calibrated. It flies really well in manual, horizon and horizon with alt hold for most of the time.

Its just when I'm in horizon with mag and baro activated something triggers a full throttle signal after a bit of flying. Its also a repeatable problem, I can get it to do it after a short time in alt hold and rolling gently left and right.

It does make me wonder about an overflow of some sort because:-

1. The sensors report sensibly
2. Its not the pilot input
3. Takes a few mins in this mode to occur
4. Once its triggered it keeps happening until I flick out of alt hold and back in again

Just my thoughts at moment, could be totally wrong.

Could the fact its a hex rather than a quad play any part, just a hex must be less common therefor less tested?

Pete

Seems like your accel integration is wondering off. You can try changing the complementary filter weighting to a lowe value.
Like baro_cf_vel to 0.965 and baro_cf_alt to 0.950 for example. Also make sure you really have the quad totally level (check with a water level) when calibrating.
If it's not it'll show wrong acceleration readings on the vertical axis when tilted, which would explain why the integration is producing wrong results.

@brm how about producing some useable code yourself instead of just talking big all the time...

xeo-star
Posts: 9
Joined: Wed Jul 16, 2014 10:59 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by xeo-star »

Thanks for the replies chaps,

I’ll try recalibrating and making sure its spot on, although it was done with a spirit level last time.
I’ll also try lowering the filter levels as you suggested.

I’ve also got some more details:-
Naze32 Rev 5
Afro32 CLI version 2.2 Jun 1 2014 / 22:14:50
3300mAh 3S
Frsky D4R-II

Current Config: Copy everything below here...
aux 0 32
aux 1 0
aux 2 3
aux 3 1
aux 4 0
aux 5 3
aux 6 0
aux 7 0
aux 8 0
aux 9 0
aux 10 0
aux 11 0
aux 12 0
aux 13 0
aux 14 0
aux 15 0
aux 16 0
aux 17 0
aux 18 0
aux 19 0
aux 20 0
mixer HEX6X
feature -PPM
feature -VBAT
feature -INFLIGHT_ACC_CAL
feature -SERIALRX
feature -MOTOR_STOP
feature -SERVO_TILT
feature -SOFTSERIAL
feature -LED_RING
feature -GPS
feature -FAILSAFE
feature -SONAR
feature -TELEMETRY
feature -POWERMETER
feature -VARIO
feature -3D
feature PPM
feature VBAT
feature MOTOR_STOP
feature TELEMETRY
map AETR1234
set looptime = 3500
set emf_avoidance = 0
set midrc = 1500
set minthrottle = 1050
set maxthrottle = 1950
set mincommand = 1050
set mincheck = 1100
set maxcheck = 1900
set deadband3d_low = 1406
set deadband3d_high = 1514
set neutral3d = 1460
set deadband3d_throttle = 50
set motor_pwm_rate = 400
set servo_pwm_rate = 50
set retarded_arm = 0
set flaps_speed = 0
set fixedwing_althold_dir = 1
set reboot_character = 82
set serial_baudrate = 115200
set softserial_baudrate = 9600
set softserial_1_inverted = 0
set softserial_2_inverted = 0
set gps_type = 0
set gps_baudrate = 0
set serialrx_type = 0
set telemetry_provider = 0
set telemetry_port = 0
set telemetry_switch = 0
set vbatscale = 110
set currentscale = 400
set currentoffset = 0
set multiwiicurrentoutput = 0
set vbatmaxcellvoltage = 43
set vbatmincellvoltage = 33
set power_adc_channel = 0
set align_gyro = 0
set align_acc = 0
set align_mag = 0
set align_board_roll = 0
set align_board_pitch = 0
set align_board_yaw = 0
set yaw_control_direction = 1
set acc_hardware = 0
set max_angle_inclination = 500
set moron_threshold = 32
set gyro_lpf = 42
set gyro_cmpf_factor = 600
set gyro_cmpfm_factor = 250
set pid_controller = 0
set deadband = 0
set yawdeadband = 0
set alt_hold_throttle_neutral = 40
set alt_hold_fast_change = 1
set throttle_correction_value = 0
set throttle_correction_angle = 800
set rc_rate = 90
set rc_expo = 65
set thr_mid = 50
set thr_expo = 20
set roll_pitch_rate = 50
set yaw_rate = 45
set tpa_rate = 20
set tpa_breakpoint = 1500
set failsafe_delay = 10
set failsafe_off_delay = 200
set failsafe_throttle = 1200
set failsafe_detect_threshold = 985
set rssi_aux_channel = 0
set yaw_direction = 1
set tri_unarmed_servo = 1
set gimbal_flags = 1
set acc_lpf_factor = 4
set accxy_deadband = 40
set accz_deadband = 40
set acc_unarmedcal = 1
set acc_trim_pitch = 0
set acc_trim_roll = 0
set baro_tab_size = 21
set baro_noise_lpf = 0.600
set baro_cf_vel = 0.985
set baro_cf_alt = 0.965
set mag_declination = 0
set gps_pos_p = 11
set gps_pos_i = 0
set gps_pos_d = 0
set gps_posr_p = 20
set gps_posr_i = 8
set gps_posr_d = 45
set gps_nav_p = 14
set gps_nav_i = 20
set gps_nav_d = 80
set gps_wp_radius = 200
set nav_controls_heading = 1
set nav_speed_min = 100
set nav_speed_max = 300
set nav_slew_rate = 30
set p_pitch = 37
set i_pitch = 30
set d_pitch = 23
set p_roll = 37
set i_roll = 30
set d_roll = 23
set p_yaw = 85
set i_yaw = 45
set d_yaw = 0
set p_alt = 25
set i_alt = 0
set d_alt = 10
set p_level = 73
set i_level = 45
set d_level = 60
set p_vel = 80
set i_vel = 45
set d_vel = 1

brm
Posts: 287
Joined: Mon Jun 25, 2012 12:00 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by brm »

crazyal wrote:
xeo-star wrote:@brm how about producing some useable code yourself instead of just talking big all the time...

easy - https://www.youtube.com/watch?v=yY8xULg1gUU&list=UUIq1PaR9qEuyT_N0JqyIVpw

xeo-star
Posts: 9
Joined: Wed Jul 16, 2014 10:59 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by xeo-star »

I've done some more investigations this weekend.

Crazyal, I lowered the values you mentioned but they didn't make a noticeable difference, would you recommend lowering them further?

Also I lowered the I and D to zero for both the ATL and the VER but the problem is still present.

I'm also getting rather good at making at occur. If I gently roll left or right then straighten up a little aggressively that tends to trigger it. That's with Horizon, mag and Baron on.

And I recalibrated my accels super carefully.

Any suggestions. I've got a shed load more graphs as well but I don't think they show much.

crazyal
Posts: 84
Joined: Tue Sep 04, 2012 11:25 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by crazyal »

Sure, try decreasing the values more, it basically determines how much the accelerometer influences the readings. So if you set them to 0 the copter only relies on the baro for altitude readings.
If you want, I have attached a .hex with debugging enabled. Debug1 = Acceleration, Debug2 = Velocity and Debug3 = Baro Altitude.
A graph with those values would be very helpful.
I think i managed to trigger it once too, the frsky telemetry display suddenly showed -600m. I just haven't been able to reproduce it up to now.
Attachments
baseflight.zip
(82.57 KiB) Downloaded 177 times

crazyal
Posts: 84
Joined: Tue Sep 04, 2012 11:25 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by crazyal »

seems like brm found a bug thanks btw... i somehow totally missed that when implementing it. xeo-star it could be that the bug in the code caused your issues. Please try it again with this change. I have attached the compiled .hex for that change.
Attachments
baseflight.zip
(67.7 KiB) Downloaded 172 times

brm
Posts: 287
Joined: Mon Jun 25, 2012 12:00 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by brm »

crazyal wrote:seems like brm found a bug thanks btw... i somehow totally missed that when implementing it. xeo-star it could be that the bug in the code caused your issues. Please try it again with this change. I have attached the compiled .hex for that change.


there is one more bug - the same which makes the pt1 element for the pid controller problematic.
tc was not happy with the pt1 element for the pid controller ...

crazyal
Posts: 84
Joined: Tue Sep 04, 2012 11:25 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by crazyal »

hmm you broke it.. deltaT is an uint32_t data type, mutiplying it with 1e-6 and then storing it as integer made the result zero and broke the pt1 element.
I allready fixed it in the code, a pull req is on the way

xeo-star
Posts: 9
Joined: Wed Jul 16, 2014 10:59 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by xeo-star »

Crazyal,

Thanks for the updated file, I'll get it uploaded and give it ago.

I did try the previous one but the problem still occurred but I guess if it is this bug then it still would be present. I was going to post some graphs tonight with the debug readings on as well but is it not worth it now?

Ohh and excuse my ignorance but what's a pull req?

Pete

crazyal
Posts: 84
Joined: Tue Sep 04, 2012 11:25 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by crazyal »

a pull req is kinda how you send your code changes to the main code repository on github.
unfortunately all the .hex i uploaded up to now are pretty useless, this one here should work. I flight tested it briefly and it seemed ok.
Attachments
baseflight.zip
(67.63 KiB) Downloaded 141 times

brm
Posts: 287
Joined: Mon Jun 25, 2012 12:00 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by brm »

[youtube][/youtube]
crazyal wrote:hmm you broke it.. deltaT is an uint32_t data type, mutiplying it with 1e-6 and then storing it as integer made the result zero and broke the pt1 element.
I allready fixed it in the code, a pull req is on the way


i am working with my own code base.
and yes, i have a few more floats.


now you also remove:
uint32_t accTimeSum = 0; // keep track for integration of acc

this doesn't make sense.

crazyal
Posts: 84
Joined: Tue Sep 04, 2012 11:25 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by crazyal »

it's just about the coding style, it still does the same thing. accTimesum gets converted from microseconds into seconds in the althold function.
altough you are right, that can be optimized a bit. brm what were those issues with the pt1 element you mentioned ? stability issues as it's an iir filter ?

today i tested the bugfixed code and it seems to work nicely, so i'm guessing it's working as intended now :-)
Only the default pids have to be adjusted a bit, on my small copter it's a bit bumpy.

User avatar
bulesz
Posts: 71
Joined: Mon May 06, 2013 8:03 pm
Location: Hungary EU

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by bulesz »

Guys I had this twisting in the ANGLE mode with BARO on. I just did the PID tuning and I have made some pitch/roll stress movements and it was made the twist...
Last night I have changed the "acc_lpf_factor" from stock 4 to 100. Now the bird does some strange throttle behaving when in PH (LOITER). The altitude is jumpy a bit and the motors are not consistent...very weird.

Is this coz the "acc_lpf_factor" changed?

I'm on 3500 looptime coz the 3000 caused this weird throttle motor inconsistency in HORIZON mode when hovering....even with lower P...

This bugfixed code is available from the Baseflight Configurator (online FW location)?

Many thanks,
B

crazyal
Posts: 84
Joined: Tue Sep 04, 2012 11:25 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by crazyal »

first of all althold has nothing to do with other flight modes!
it'll behave the same way whether in angle, horizon or arco mode. Also gps functions most likely won't work reliably, as the code isn't really finished.
unfortionately the .hex isn't up to date, but you can try the one i linked in this thread.

User avatar
bulesz
Posts: 71
Joined: Mon May 06, 2013 8:03 pm
Location: Hungary EU

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by bulesz »

Thanks for the info, I will try this hex (currently I'm using the latest from the Baseflight Configurator in the online hex flash tool), and I will try the Harakiri pre 2.6 (for the rev5). As I have red the althold/loiter/RTH is very good with that FW.

Has anybody try the HK fw? How about implement the GPS / althold related code from HK and put to the Baseflight and biuld one reliable FW?

Many thanks,
B

Vertigo
Posts: 41
Joined: Mon Jul 08, 2013 6:58 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by Vertigo »

I have pretty much the opposite problem. When I engage altitude hold, sometimes it will hover fine for a while, but usually within seconds of engaging it, one motor of my Tcopter will be cut and it tumbles to the ground. Its not always the same motor, so I doubt its a wiring issue. Here is one such occurrence caught on (lousy) video:

https://www.youtube.com/watch?v=XRXGp3KJ88o

Im using 2.3 firmware.

pjman
Posts: 34
Joined: Thu Jun 12, 2014 8:55 am

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by pjman »

Are you using angle or horizon mode?

Vertigo
Posts: 41
Joined: Mon Jul 08, 2013 6:58 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by Vertigo »

pjman wrote:Are you using angle or horizon mode?


I was using angle mode

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by timecop »

Can't happen.

eatkabab
Posts: 20
Joined: Sat Aug 16, 2014 6:48 pm

Re: Naze32 Altitude Hold Problem - Any Ideas?

Post by eatkabab »

This is all interesting and useful but I would appreciate some assistance with my more rudimentary issue.

My barometer covered in foam and a case does alight with alt hold, but only if veeeery dosile movements. If I move around too much, it just drops quite a bit and gets a but confused. Also gets confused when going up or down. Just generally less than fantastic performance.

Thanks for any guidance. Sorry if this was too much of a segway from the topic at hand.

Post Reply