Possible issue with LEVEL I implementation + fix?

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Possible issue with LEVEL I implementation + fix?

Post by shikra »

Hi all - still looking at ways to improve flying in angle mode and improved levelling performance as need smoothest flying for AP/AV rather than the crazy warthox most of you guy do. Still enjoy that too!

Firstly thanks to Alex, Ziss and all the other contributors etc. Performance is awesome. Just get better and better guys. So cool to look at some of the early release and see just how much is packed in there now.

So I've come at this from the approach of what I don't like about how it performs and try to look at the cause/fix. This is what I find...


There is a scenario with level I implementation that can actually exaggerate overshoot, cause wobble and reduce time taken to achieve the desired angle/level- not ideal if flying in angle mode - or if/when it takes time to achieve true level.

I'll try to explain... as the copter is away from where it wants to be, over time the I value will build up to a maximum and keep trying to force the copter in a direction until it reaches the correct angle. This value does decay over time, but the direction of the force will not change until the angle moves the opposite way and the I value eventually changes sign and hence direction. This means for a short time, the I value creates a force in the wrong direction..
If any of you have seen the slow side-side wobble it's possibly this effect. Also shows as a slow wandery feel in level when using low P, High I settings.

You can see this effect well with a very low Level P and using Level I only.

Some simple test code just to see the flight difference.

errorAngleI[axis] = constrain(errorAngleI[axis]+errorAngle,-10000,+10000); //WindUp //16 bits is ok here
if (errorAngle > 0 && errorAngleI[axis]<0 ) errorAngleI[axis] = 0; // DEV - test code - use with precaution. To prevent Windup exaggerating overshoot.
if (errorAngle < 0 && errorAngleI[axis]>0 ) errorAngleI[axis] = 0; // DEV - test code - use with precaution. To prevent Windup exaggerating overshoot.
ITerm = ((int32_t)errorAngleI[axis]*I8[PIDLEVEL])>>12; //32 bits is needed for calculation:10000*I8 could exceed 32768 16 bits is ok for result


Advantages:
- Can run higher I without causing such overshoot.
- Improved slow ground takeoff in level mode. Less likely to wobble/flip.
- Faster return to level/angle
- Slightly less likely to be "wandery" around level

Disadvatages
- Slightly longer loop time.

I don't think this of any real value for acro. The effects are probably not noticeable enough, but would be interesting to test.
I also think this is of more value with the additionally Level velocity "D" slowing down return to level.

I haven't looked at the Baro code, but if it has similar, there may be opportunities to use similar approach...


So I have tried tonight and its definitely better - sharper feel to it. Difficult to tell properly in the dark but seems much more accurate / flies like on rails.
And incredible how much higher PI an be. Badly wobbling copter with PI to high transformed into a pussycat. WOW - MUCH better results than I expected.
Can't wait to try in daytime.

I hope Alex will look at a better implementation of this!!
Last edited by shikra on Wed Feb 08, 2012 11:41 am, edited 1 time in total.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

Just been for a walk with the dog and real pleased with the testing tonight. Thinking through this and wondering why this actually seemed to be such a big improvement. Far more than I expected.

I was trying to stop the Level I force increasing the overshoot.
I just realised that by resetting the I to zero as it passes through the set angle/level position it actually starts the I buildup to prevent the overshoot much quicker. Bonus.

Just to add observations from the testing..

You can ramp up I massively.....
Also Level P. Not quite sure why - maybe becuase I preventing overshoot quicker?
Higher I and P means stronger level/angle hold.
Practically speaking it seemed to stop that wandery feeling you get flying in angle mode. Much more precise.
I underplayed one bit before - a copter with Level PI settings that made it completely unflyable flew almost perfect.

Combined with the Level P constraint is makes it even easier to fly.
Probably not of much interest to acro fliers, but for AP / beginners and rubbish flyers like it should help a lot!!

Love for soemone else to try and provide feedback....

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by copterrichie »

Just curious, have you tried re-flashing the ESCs? I have not completely finished testing the new ESCs I purchased from Ken at Quadroufo.com but I had a wobble on my Bicopter that I just could not seem to adjust out. I changed the ESCs and preliminary testing looks promising.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

copterrichie wrote:Just curious, have you tried re-flashing the ESCs? I have not completely finished testing the new ESCs I purchased from Ken at Quadroufo.com but I had a wobble on my Bicopter that I just could not seem to adjust out. I changed the ESCs and preliminary testing looks promising.


Not yet - been reading with interest. To be truthfull I've not felt I've had the need to do it, but want to try out. My flying is more kinda slow / stable stuff. Perhaps I would gain less, but I'll find out when I get time!

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by copterrichie »

Yes, my flying is catered towards aerial video/photography and I would like a smooth platform as much as possible before applying any stabilization on-board or post. I questioned Wardro(spelling) and he said, he does not used flashed ESCs so I was very reluctant to try reflashed ESCs. After giving it much thought, it came to me that Wardo on most of his builds is able to use the Default PID settings or very close to that. Where as my copters requires a custom settings. So, I changed my views quickly. As stated, my preliminary testing looks good, maybe tomorrow I will do a more extended test.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

Quick vid to see the improvement...

In first half of clip I am running with normal level mode, but with double I value to demonstrate the unwanted overshoot effects of current I implementation
In the second half of the clip I am running exactly the same Level PI settings, but have the extra code enabled on a switch.

As you can see, with the settings in the first part it is almost unflyable...
See how its tamed from a lion to pussycat !!

http://www.youtube.com/watch?v=Gl-3MZmeb8A

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Possible issue with LEVEL I implementation + fix?

Post by marbalon »

I don't know your settings but it looks like to big I value. Please try to make this tests:

First test - try to decrease I until you will get a stable flight and the try to add some weight to one arm - just unbalance your tricopter. Then try to fly again with unbalanced tri.
Repeat the same test with your patch.

In my opinion you should get better results with default code, just decrease I.

Regards,
Marcin.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

hi Marcin
Yes I is to high for current code. This is the point.
I put the I value very high to exaggerate the problem to make it more visible for the video. It's only to highlight an issue and help improve the code.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

BTW - this is only a level I issue. Acro is different - I decreases as returns to original position due to additional gyro readings. Looks great.

I think Acro is pretty near perfect, but angle mode flying always felt like there was something not right.

Does make we wonder what other hybrid easy "fly/training" options there are- combining acro and level together in a different way.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by copterrichie »

shikra wrote:Quick vid to see the improvement...

In first half of clip I am running with normal level mode, but with double I value to demonstrate the unwanted overshoot effects of current I implementation
In the second half of the clip I am running exactly the same Level PI settings, but have the extra code enabled on a switch.

As you can see, with the settings in the first part it is almost unflyable...
See how its tamed from a lion to pussycat !!

http://www.youtube.com/watch?v=Gl-3MZmeb8A


Viewing the video leads me to believe, the original PID values is at the root of the problem. I am curious to see what they are if you have a screen shot.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by copterrichie »

P.S. After watching the video, the problem you are having is not related to the one that I had. So please disregard what I said about the ESCs.

Thanks.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

The video is exaggerrated settings for effect - I'm badly explaining myself as usual ;)

Well, I wouldn't say I had too much of a problem... :D :D
http://vimeo.com/35641421

But this should make it much better.....

Just two lines to add - try it!! I am 99% sure you will like the change

A very good test is in level mode do a very slow increase in throttle and watch it take off gently without rocking all over the place. Also fast descents in level mode are a whole lot nicer!

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

If anyone care/dare try it...., files are here. Latest dev releases from Alex with these extras added. Up to and incl r468
Also LCD code amended to allow LCD adjust of Level velocity (D value). Only tested with std serial LCD. Others "should" be OK
Plus slightly amended version of the Level PI constraint.

As always, backup and know your previous settings. This is dev so no liabilities!!
Make sure Level D is set to 100 to start. Generally decrease for smoother angle mode flying. Higher for faster levelling. I like around 50 for flying.


http://www.flypix.co.uk/shikra/ftp/

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

Re: Possible issue with LEVEL I implementation + fix?

Post by Alexinparis »

Hi,
I will try tomorrow.
Can you confirm it still keeps a perfect horizon if you put some weight at one extremity on an arm ?
This is one advantage of the I term.

Noctaro
Posts: 280
Joined: Thu Sep 08, 2011 11:15 am
Contact:

Re: Possible issue with LEVEL I implementation + fix?

Post by Noctaro »

Hey shikra,
sounds good! i will also give it a try and provide some feedback!

greetz
noc

btw. impressive captures at the castle! :shock:

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

Thanks for looking Alex - I think you will very quickly see the flaw - if not let me know - I know I am real bad at explaining....


Never actually triedd flying with a 2200mah battery on the end of an arm before!! It's -7 outside today, but I test just for you.

I tried with and without the code. It doesn't seem any difference with/without the code. I think that is good!

Doesn't keep perfect horizon though - it seems to settle with avery slight tilt. Very minor maybe 1 degree. Although it has long 20" arms - so does show up more than perhaps a small copter.
I'm guessing that the small tilt is where the rate of I decay (>>12) matches the force from the errorangle summing up.

Actually, thinking about it, I notice you can run a much higher I value with this, so maybe this will help more? In theory it should?

Alexinparis wrote:Hi,
I will try tomorrow.
Can you confirm it still keeps a perfect horizon if you put some weight at one extremity on an arm ?
This is one advantage of the I term.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

Thanks noc - yes, am quite please with the vid. Not bad for on old v1 gopro and Multiwii !!
All flown in level mode too. More suited to what I needed to produce.

Noctaro wrote:Hey shikra,
sounds good! i will also give it a try and provide some feedback!

greetz
noc

btw. impressive captures at the castle! :shock:

User avatar
Quadraf
Posts: 68
Joined: Fri Jan 21, 2011 12:55 am
Location: Deurne Holland
Contact:

Re: Possible issue with LEVEL I implementation + fix?

Post by Quadraf »

Hello Shikra,

Your code is working great. :mrgreen: :mrgreen:
Exactly as you stated, much more stable startup (really noticable with this cold weather). Now my old quad with wornout moters and different ESC's is floating in space 8-) . Great for AP/FPV work. PID tuning can be easily stretched for more precise adjusting.
Keep up the good work :D

Hans

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Possible issue with LEVEL I implementation + fix?

Post by ziss_dm »

Hi Shikra,

Code: Select all

if (errorAngle > 0 && errorAngleI[axis]>0 ) errorAngleI[axis] = 0; // DEV - test code - use with precaution. To prevent Windup exaggerating overshoot. 
if (errorAngle < 0 && errorAngleI[axis]<0 ) errorAngleI[axis] = 0; // DEV - test code - use with precaution. To prevent Windup exaggerating overshoot.


Am I wrong, or after this errorAngleI[axis] is always 0? ;)
So, maybe if you drop I term to zero you would get same results?

regards,
ziss_dm

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

Thanks Hans - that's great its working better for you!!
I could only test in small confined space, but Saturday I could have a proper test and I liked it.

Note the code is still all same from Alex and Ziss - this is only a small additional tweak. Always we look for improvement though. Have a few ideas to try out in the spring.

Quadraf wrote:Hello Shikra,

Your code is working great. :mrgreen: :mrgreen:
Exactly as you stated, much more stable startup (really noticable with this cold weather). Now my old quad with wornout moters and different ESC's is floating in space 8-) . Great for AP/FPV work. PID tuning can be easily stretched for more precise adjusting.
Keep up the good work :D

Hans

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

Hi Ziss - actually no - it's not the same.
So all the code does is to not apply any -ve I term when there is a -ve error angle (because it would force it the wrong way). Kind of an error catch!
The rest of the time it works exactly as it is. Pretty simple really.

I will try to explain why....

Imagine holding the multiwii slightly off level.
The I term will build up to it's constrained max.
If you let go, the I term (until constrained) actually will still be increasing because of the error angle.
It will be decreasing because of the >>12, but not fast enough sometimes.
When it reaches error angle of zero, the I term is still valid and will keep pushing it in the wrong direction until the opposite angle I term reduces it.
So normally when we tune I, we simply reduce until this unwanted effect is minimal. With this check we can now run a higher I for faster return and less overshoot.

Here is a short clip showing the difference. First part is with normal code, but I value to high so you can see the effect better on the video. Quick land and flick the switch to enable the two extra lines.
Both running in level mode with the same levelling code PI settings
http://www.youtube.com/watch?v=Gl-3MZmeb8A

It's quick and dirty and I think there are better and more elegant ways to do this,

No use at all to those flying acro, but I want to get the best possible angle mode flying for the guys who are learning - or those who like me want level framed video/photo.

I put two packs through flying completely in level mode and I found it a nice improvement. With the correct level D constraint, it was much more like flying in acro trainer mode, but with a self levelling aspect. Every little tweak helps.


Two other things which were quite obvious -
Slow level takesoffs are no longer a cause for horrible wobbles. Really smooth slow gentle takeoffs are possible.
Fast descents in level mode are much smoother. Much less wobble.


ziss_dm wrote:Hi Shikra,

Am I wrong, or after this errorAngleI[axis] is always 0? ;)
So, maybe if you drop I term to zero you would get same results?

regards,
ziss_dm

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Possible issue with LEVEL I implementation + fix?

Post by ziss_dm »

Hi Shikra,

I will try to rephrase. Could you please explain how after this peace of code:

Code: Select all

if (errorAngle > 0 && errorAngleI[axis]>0 ) errorAngleI[axis] = 0; // DEV - test code - use with precaution. To prevent Windup exaggerating overshoot. 
if (errorAngle < 0 && errorAngleI[axis]<0 ) errorAngleI[axis] = 0; // DEV - test code - use with precaution. To prevent Windup exaggerating overshoot.


errorAngleI[] can be not equal zero? ;)

regards,
ziss_dm

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

OK - hard to read on BB. Back on PC tomorrow morning.
Thanks for looking Ziss - to me I agree - it looks like I have a < reversed so I is always set to zero ??

I don't think that would make for such a nice level. So either I =0 is better with a constrained high level P or my < is different on my test copter. Or both!

I also have one other difference on mine - in level, i constrain the total P+I-D term to get a nice smooth predictable return to angle/level.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

Yes Ziss - good catch on the typo. I am very glad for your time to look at and understand.
I did type out > wrong way. I have amended first post now!

When I did a quick test with the new release and a bad I, the end result looked similar because I had a little P.
So I had one copter with the right code and the other with I always =0 !!

apart from my poor typo, do you think it's worth adding? I can certainly see/feel the difference in flight.
What I would prefer is a less instant cutoff as it passes zero errorangle. I was thinking of maybe some I reduction based upon the rate of angle change as it approaches level. So still provide large I when needed - and allow build up when needed. Or maybe it's acceptable now for code simplicity.
I do think there are a few other level options to explore as well - based around a constant rotational speed. Easy to setup - no real tuning. One for the summer though - it's -5 outside and I don't like cold.....

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: Possible issue with LEVEL I implementation + fix?

Post by ziss_dm »

Hi shikra,

I think, it is better to tine-up PIDs. ;) The phase lag induced by I term can be compensated by P and D terms, that is why PID controller is so universal. In case you limiting PID output, like you suggested here:
viewtopic.php?f=7&t=905

You probably also need to reduce integral windups.

regards,
ziss_dm

capt
Posts: 54
Joined: Wed Jan 19, 2011 10:54 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by capt »

The vids are gone?
I would like to try this dev, maybe tomorrow. Hopefully I will have some time and will give it a try.

Noctaro
Posts: 280
Joined: Thu Sep 08, 2011 11:15 am
Contact:

Re: Possible issue with LEVEL I implementation + fix?

Post by Noctaro »

Hey,
i did a test with your software release right now!
As you told, it behaves great, really close to perfect. No wobble, smooth return to level.

I could not do a full flighttest as its snowing. I will give further feedback and post a video soon!
Thank you shikra for sharing this. :D
I will definately use it in future!

btw. @developers, please bring back Level D to DEV GUI

greetz
Noc

edit:
just to let you know, i am using level d = 80 right now.

@ziss_dm
i do play around with pid settings since a while.
but i never was able to get my copter that close to perfect behaviour. So it may be a real tuning help for some people.
Last edited by Noctaro on Tue Feb 14, 2012 4:25 pm, edited 1 time in total.

Noctaro
Posts: 280
Joined: Thu Sep 08, 2011 11:15 am
Contact:

Re: Possible issue with LEVEL I implementation + fix?

Post by Noctaro »

hey,
i did another testflight, and it ended in a very strange crash.
Everything went fine, but suddenly the copter began to pitch backwards and did not respond to my input as i did try to correct it, had not enugh time to switch back to acro.
Btw. i reconnected power around 10minutes of flight to avoid temp drift. A minute or two later the crash happened.
I am using the firmware you posted for download.
It felt like the copter would not compensate the lipo weight anymore. As its mounted in the back, and is an asymetric weight. (Go Pro at the front is counterweight but not 100% balanced.)
Never had this behaveiour before. May this be related to your code?

greetz noc
Last edited by Noctaro on Thu Feb 16, 2012 9:52 pm, edited 1 time in total.

capt
Posts: 54
Joined: Wed Jan 19, 2011 10:54 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by capt »

Is it possible some snow blew up into the ESC's? or motors on T/O? I have had that happen and when it does the snow melts and causes strange things to happen as you can imagine.

Noctaro
Posts: 280
Joined: Thu Sep 08, 2011 11:15 am
Contact:

Re: Possible issue with LEVEL I implementation + fix?

Post by Noctaro »

I already thought about this happening, and i would lie if i´d say it can not happen.
Everthing seems to work again, i will do another testflight much higher, to have some reaction time and to ensure that no snow will be blown up to escs.
Right now its snowing too much to do an safe testflight.

greetz noc

Noctaro
Posts: 280
Joined: Thu Sep 08, 2011 11:15 am
Contact:

Re: Possible issue with LEVEL I implementation + fix?

Post by Noctaro »

hey,
did another flighttest, with the same result, but this time i was able to watch some strange behaviour in air before it crashed.
this time one prop and cam mount are gone. I will again uplad a short takeout. I am pretty sure there was no snowflake at my esc.
I do not know whats wrong, but for the next flight i will use the new dev and will try to reproduce the problem.

greetz
noc
Last edited by Noctaro on Thu Feb 16, 2012 9:52 pm, edited 1 time in total.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

Hi guys - sorry for no response - been tied up with some filming - all with multiwii and level mode flying!!!

This one OK...
http://www.youtube.com/watch?v=IKs7Odrz ... ature=plcp

This one was terrible, bad wind turbulence and rain for the shooting, but I captured the scene they wanted (2nd clip....). Gutted to find wate ron lens when finished... But film producer is happy - its 1024, so they can crop and rescale...
http://www.youtube.com/watch?v=_LJWnMqU ... re=channel

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

ziss_dm wrote:Hi shikra,

I think, it is better to tine-up PIDs. ;) The phase lag induced by I term can be compensated by P and D terms, that is why PID controller is so universal. In case you limiting PID output, like you suggested here:
viewtopic.php?f=7&t=905

You probably also need to reduce integral windups.

regards,
ziss_dm


Thanks for your feedback as always....
I hear you - and agree with current approach.
I'm very happy for current standard PID flying in Acro and for normal level. Works fine for me.

It's just the angle mode flying that's not quiteso nice. I think its varying changes in error angle from RC input that's maybe not suiting the model well. Could be small change or maybe even quick 45 degree change.
I'm reasonably competent flying acro, but with the FPV goggles on and angle mode flying it just feels just not quite right . Probably for most fliers using acro its just not an issue, but trying to get it for slow steady smooth filming is what I wnat to improve for

Yes I was also wondering about varying the integral elements. I have reduced the constraint on one because it's crazy high for my one copter. Is good on another. Actually Now I have the level velocity constraint on the whole P+I-D term. Have not tested on all copters to see if it's better place to use it.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

capt wrote:The vids are gone?
I would like to try this dev, maybe tomorrow. Hopefully I will have some time and will give it a try.

Sorry - I post my vids for a short time, then clean up. Can repost if needed!

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

Thats great. did you use the amended code (I originally posted > in wrong direction). If yes - great! If not, your I setting probably needed to be lower
Level D will be back I thin k0- but will be teh velocity constraint. 80 sounds fine - if its works well for you, that's perfect. Actually I run mine pretty low - its for the filming so I get very smooth looking changes.

Noctaro wrote:Hey,
i did a test with your software release right now!
As you told, it behaves great, really close to perfect. No wobble, smooth return to level.

I could not do a full flighttest as its snowing. I will give further feedback and post a video soon!
Thank you shikra for sharing this. :D
I will definately use it in future!

btw. @developers, please bring back Level D to DEV GUI

greetz
Noc

edit:
just to let you know, i am using level d = 80 right now.

@ziss_dm
i do play around with pid settings since a while.
but i never was able to get my copter that close to perfect behaviour. So it may be a real tuning help for some people.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

To Noc...
Oh man - so sorry These things can be so frustrating
It's always possible - the changes are minimal though. I would be really surprised...
Did you make changes in existing code - or the zip file I posted link to? I think the file also has dev code changes to how the motors are driven. I have not looked at this.

I have had similar...
faulty esc *1
wire broken inside bullet to motor Couldn't see because of heatshrnk - full on the wires and it came apart. * 2
Wire on motor windings cracked under flexing. Twisted wire with say 4 strands and 3 broken... *2
Motor bullets - many times in early days - not fitting well, or twist easy. I solder them now..

What is interesting... All the broken wires have been in sub zero temperatures. Clearly the wires are more brittle and break easier.
I had one last week.

edit...
looking at the vids, I'd be inclined to look at the right rear motro/esc/wires as look down on it from above. It seemed to be tipping rear, but also a little unstable in that direction too.

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Possible issue with LEVEL I implementation + fix?

Post by marbalon »

Noctaro wrote:It felt like the copter would not compensate the lipo weight anymore. As its mounted in the back, and is an asymetric weight. (Go Pro at the front is counterweight but not 100% balanced.)
Never had this behaveiour before. May this be related to your code?


I almost sure is related with this code - I told this before. In my opinion we shouldn't touch Level mode. If for someone this will help, Alex please add add this as option - not as regular version.

Marcin.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

Marbalon - we have to continually try new things - if we don't , well we would still not have a wheel.... or maybe a square wheel!! lol
Many times it will not work out... and we are only so far because of Alex, Ziss and co trying new ways

It should remain dev until tested well!!

Inherent problem here is that we all have very different ways of flying. If one code is not suitable for all, we should perhaps have #DEFINE variants for those who just like to recover/hover, assisted trainer mode - or those that wish to fly in angle mode. I think that is what you are saying too.


In Noc's case I just had a look - I sure from timimg and his feedback he would have had the code I unfortunately posted with incorrect < direction.

Noctaro
Posts: 280
Joined: Thu Sep 08, 2011 11:15 am
Contact:

Re: Possible issue with LEVEL I implementation + fix?

Post by Noctaro »

Hey all,
i will recheck the code i have used. I think you are right shikra, i just downloaded the one you posted on your server (archive), if it was not updated i got the error from here. I will have a look for it in the code now. My wiring seems just fine, i reconnected everything had a look at my connections and also did the shake test ;)

I like to test new approaches and if something goes wrong, thats ok. Its development. I am fine with shikras trys and ideas. And for now its my own fault, as i did not do enough offair testings before going wild.
Also i did not watch/check the code updates!

I will retry the updated code as soon as possible to give some feedback :)

greetz noc

update:
i rechecked the code right now. I found the wrong signs. ;)
Last edited by Noctaro on Thu Feb 16, 2012 9:47 pm, edited 2 times in total.

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

Re: Possible issue with LEVEL I implementation + fix?

Post by Alexinparis »

marbalon wrote:
Noctaro wrote:It felt like the copter would not compensate the lipo weight anymore. As its mounted in the back, and is an asymetric weight. (Go Pro at the front is counterweight but not 100% balanced.)
Never had this behaveiour before. May this be related to your code?


I almost sure is related with this code - I told this before. In my opinion we shouldn't touch Level mode. If for someone this will help, Alex please add add this as option - not as regular version.

Marcin.

If you look at the current dev code, there is only this:

Code: Select all

      PTerm = constrain(PTerm,-D8[PIDLEVEL]*5,+D8[PIDLEVEL]*5);

with D=100 (default), it's like the previous code before because the limit is very high [-500;+500]

Noctaro
Posts: 280
Joined: Thu Sep 08, 2011 11:15 am
Contact:

Re: Possible issue with LEVEL I implementation + fix?

Post by Noctaro »

hey,
@shikra: i added the up to date code to your archive release and things seem to work better now.
But there is one thing thats a bit of confusing. If i hold my copter at the backside and pitch it back(using my hand) in levelmode, the recoverypower seems very limited. Maybe my too low level P(10) settings are causing this or I(0.5). But the main problem, if i push my stick to full pitch forward (still forcing copter off level by hand), there is no reaction, while if switching back to acro(still at full forward pitch), "back motors" go wild as they should. This is a problem, because if getting a really hard lift from wind, i even may not counteract it by stick input (in levelmode). This seems also to be the reason of my crash, it did not react to my stick movement(that was the point where i did panic and not thought of switching back to acro :lol: )

I hope this helps a bit.

greetz noc

btw. Is there a minimum P requirement?

update:
i am testing MultiWii_dev_20111220 now and everything seems to work fine. Will do further tests tomorrow.

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Possible issue with LEVEL I implementation + fix?

Post by marbalon »

Hi,
@shikra
I agree that we should look in to new ideas etc. But I read you first post and explanation and I think you try to fix problems in bad way. Why you want huge I and low P?

- P is mainly used to level a copter
- I to compensate unbalanced situation (and should not to be high) - this will not work with your patch. Did you try fly with unbalanced quad?

So if you want to faster return to level you should increase P. Please try to last suggestion from Alex:

Code: Select all

PTerm = constrain(PTerm,-D8[PIDLEVEL]*5,+D8[PIDLEVEL]*5);


This will allow to use really huge P, so reaction will be strong even for small angles, but can be limited with parameter D.

@Alex
I tested SVN version r568, and it is OK for me, acro and level mode works fine for me.

Now will try to include baro and maybe ACCZ...

btw. I find bugs:

//#define MS561101BA_ADDRESS 0xEF //CBR=1 0xEF I2C address when pin CSB is connected to HIGH (VCC)
should be 0xEC

writeMotors() for pro mini.
...
OCR1A = ((motor[0]>>2) - 250) + 2); should be

OCR1A = ((motor[0]>>2) - 250) + 2;

Regards.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

@ Marbalon

Thanks for reply and time to review
I don't want high I, low P particularly - that was example to show in a clearer way a small issue which *might* affect some people and could possibly be improved a little
I definitely don't want faster return - that was part of the problem - now resolved by the constraint mentioned ....

Just to point out clearly - I am talking about flying in angle mode rather than just return to level... having a fast return in that situation is horrible to fly.

I have a few copters and there is no need for for this on two, but one of them it helps considerably. I think its because its very short arms, big blades. It seems to show up PID characteristics far more than any of my other copters.

Anyway, from the feedback so far I think its no worth continuing down this line. Although all it is doing is catching an error situation, particularly in absence of a D term

When time permits perhaps look at acro mode with a bit of self levelling as an alternative for those who like to fly in a stable mode . I think maybe that is the better approach for those who prefer that style of flying. Been meaning too

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

@Noc

I think I can guess!! I was trying out a few other variations. The effect was a bad constraint on the control inputs.
It is only an error catch - nothing more. Purely to stop I sending it further in the wrong direction because it has not fully decayed to a zero value. The effect should be subtle/negligible for most people.


If you do wish to try in any version of code, just add the middle two lines here...

errorAngleI[axis] = constrain(errorAngleI[axis]+errorAngle,-10000,+10000); //WindUp //16 bits is ok here
if (errorAngle > 0 && errorAngleI[axis]<0 ) errorAngleI[axis] = 0; // DEV - test code - use with precaution. To prevent Windup exaggerating overshoot.
if (errorAngle < 0 && errorAngleI[axis]>0 ) errorAngleI[axis] = 0; // DEV - test code - use with precaution. To prevent Windup exaggerating overshoot.
ITerm = ((int32_t)errorAngleI[axis]*I8[PIDLEVEL])>>12; //32 bits is needed for calculation:10000*I8 could exceed 32768 16 bits is ok for result

Noctaro
Posts: 280
Joined: Thu Sep 08, 2011 11:15 am
Contact:

Re: Possible issue with LEVEL I implementation + fix?

Post by Noctaro »

hey,
thanks for reply,
i tested your mod with yesterdays svn release, and everything seems to work as it should. As holding my copter in my hands i can watch some strange wobbles around level position and some motorpower reduces ((P=9) (I=0.45) (D=70)). But it finds back to level. Stick input is also ok. It seems flyable, i will do some safe air testings tomorrow if weather allows me to.

greetz Noc

update: i could tame the wobbles a bit with (P=11 I=0.25 D=55).
Did a testflight and everything went fine this time. But for now, it seems that i have to continue PID testing to get an good flight experience.

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Possible issue with LEVEL I implementation + fix?

Post by nhadrian »

Hi all,

I found out something interresting.
My mini hexa-copter has some back-drift, especially in pitch direction. If I fly in acro mode, it stays in position for minutes...in any degrees!
But, when I fly in level mode, during fast-forward flight I have to apply more and more stick input for the same speed (and degrees), and when I release the stick, it has a big back-drift and than slowly it goes back to level. I tried to log the datas with WinGUI, but since I have only bluetooth connection right now, I ran out of range quickly. But, it looks like the level code integrates some error during constant stick input.
What do you think guys, will this mod solve this?

BR
Adrian

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

nhadrian - this wouldn't help - sorry. different issue.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

Here is the 1.9 release with the two recent level improvemnt suggestions added.
The previous one included a number of other dev changes which have not had such good feedback. Plus it was using dev code from others. I really need feedback based upon the last true 1.9 non dev release so its a true comparison.

So far this is the best level/atti flying I have experienced...

It WILL reset your config to defaults so take note of what they are.
Also remeber to recalibrate acc and reset the aux1/2 options to enable level !!
In the GUI change Level "D" (or Level "VEL" in LCD). To give the return to level speed you like best - or agle/atti mode flying you prefer.

files here - test carefully....
Alos includes CRIUS defines (I don't have one - provided by a friend)

http://www.flypix.co.uk/shikra/ftp/

capt
Posts: 54
Joined: Wed Jan 19, 2011 10:54 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by capt »

I could not get your release to open in arduino for some reason, only the config file.?

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Possible issue with LEVEL I implementation + fix?

Post by shikra »

I just tried and downloaded to another PC to the one I use and it worked OK.
When you extracted the zip file, did all the files extract OK? Are they physically there?

Post Reply