Welcome to Multi-Rotor UK. Please login or sign up.

Wednesday,August 21, 2019, 14:22:50

Login with username, password and session length

Shoutbox

Andy7:
21 Aug 2019 12:15:41
Gaza - can you make the subject line section in the forum topic list wider? It's cutting off the subject field really short.
Andy7:
19 Aug 2019 09:14:20
Good for you!  ~~
DarkButterfly:
18 Aug 2019 19:13:57
Had another negative encounter, it's been a few years since the last one, just an uneducated ******, going on about drones being illegal yada yada yada.    :-/
Still that didn't spoil my flying time, had an absolute blast  ~~
Gaza07:
07 Aug 2019 19:52:01
ooooh mrs jones  :D
hoverfly:
30 Jul 2019 15:26:34
D.B. you tightwad.. :cool:
atomiclama:
29 Jul 2019 20:14:10
DB that just means you have shed loads of props in the first place ;-)
DarkButterfly:
29 Jul 2019 18:53:33
Just had a thought, even with all the crashing I've done, I haven't bought any replacement props in over a year ~~
ched:
09 Jul 2019 19:45:42
May the sun shine and winds be light for BFU#8. Son't forget lots of vids for those of us unable to attend.  :D
Gaza07:
09 Jul 2019 18:10:30
Hope you all have a great day  :beer2:
Andy7:
09 Jul 2019 14:05:28
BFU#8 details locked in for this saturday - see the head of the forum thread for all details.
Members
  • Total Members: 8066
  • Latest: badger1
Stats
  • Total Posts: 196561
  • Total Topics: 19802
  • Online Today: 38
  • Online Ever: 530
  • (Tuesday,June 26, 2012, 08:34:46 )
Users Online
Users: 2
Guests: 26
Total: 28

Theme Changer





3d - Printworx

Printing 3d Forum

Multiwii code mod - Varying Roll and Pitch PIDS on the fly

Started by teslahed, Sunday,November 11, 2012, 14:31:08

Previous topic - Next topic

teslahed

Sunday,November 11, 2012, 14:31:08 Last Edit: Thursday,November 15, 2012, 12:10:36 by teslahed
More recent versions of Multiwii have a setting called ';T P A'; which allows you to set a % value that the Roll and Pitch PIDs reduce by when throttle is at 100%. If you set ';T P A'; to 0.5 then at full throttle your Roll and Pitch PIDs will reduce by half, 0.25 and they';ll reduce by a quarter. The default is 0 which corresponds to zero reduction in PID strength at full power (or no effect in other words).

This is used in some models that are more prone to feedback wobbles at high power settings like helicopters and flying wings. I thought it might help my mini-quad that wobbles a bit at full power.

When i was looking up the explanation for all this i discovered this thread over on the multiwii forums;

http://www.multiwii.com/forum/viewtopic.php?f=8&t=1562&start=90

Shamelessly stealing little nellie';s idea and PatrikE';s how-to, it seems you can alter the Multiwii code so that an auxiliary channel rather than the throttle will control the PID strength reduction. I';ve managed to set mine so that one of my potentiometers adjusts between full PID strength and 50% (say) when i have ';T P A'; set to 0.5 in the multiwiiconf windows program.

I';ve tested it over my bed and it definitely works.

In order to set this up you need to use the arduino software to open up the MultiWii.INO file.

Search for the code section that looks like;

#define BREAKPOINT 1500
  // PITCH & ROLL only dynamic PID adjustemnt,  depending on throttle value
  if   (rcData[THROTTLE]<BREAKPOINT) {
    prop2 = 100;
  } else {
    if (rcData[THROTTLE]<2000) {
      prop2 = 100 - (uint16_t)conf.dynThrPID*(rcData[THROTTLE]-BREAKPOINT)/(2000-BREAKPOINT);
    }


The key bit here is ';rcData[THROTTLE]';. You can change this to ';rcData[AUX3]'; or in my case ';rcData[AUX1]'; (as i only have one auxillary input on this old PARIS multiwii board) and the result is that the ';T P A'; value will now be controlled by the auxillary channel rather than the throttle. It is also worth changing ';BREAKPOINT 1500'; to ';BREAKPOINT 1200'; just so that you get to use more of the travel on the potentiometer as the signal usually starts around 1000.

The result should look like this;

#define BREAKPOINT 1200  //CHRIS TELFORD modified this part 11/11/2012
  // PITCH & ROLL only dynamic PID adjustemnt,  depending on AUX1 value
  if   (rcData[AUX1]<BREAKPOINT) {
    prop2 = 100;
  } else {
    if (rcData[AUX1]<2000) {
      prop2 = 100 - (uint16_t)conf.dynThrPID*(rcData[AUX1]-BREAKPOINT)/(2000-BREAKPOINT);
    } else {
      prop2 = 100 - conf.dynThrPID;
    }
  }


Now make sure your radio is configured so that Auxillary1 is controlled by a potentiometer and it should all work. You can adjust the strength of your PIDs in flight with the potentiometer and adjust the total amount adjustable with the ';T P A'; value in the multiwiiconf program.

One circlip short of a quadcopter.
 1 lobe short of an antenna.

neagron

thats very clever stuff chris,theres a lot in there if you no what your doing,unlike me thats just stumbles around,Marty. :scotland:

teslahed

I';ve just been testing this flying around outside - it works very well, pretty much as you';d expect.

I set my Pitch and Roll PIDs too high by about 0.5 so that the quadcopter would fly, but only just, then got the thing hovering in front of me whilst i adjusted the PID strength down until it flew smoothly.

Now I just need to find a way of ';reading off'; the PID value after adjusting it so that i can then set that value as the fixed value in the GUI afterwards.
One circlip short of a quadcopter.
 1 lobe short of an antenna.

Gaza07

Nice mod Chris well done, I may give this a go on one of my spare copters  ~~

teslahed

Monday,November 12, 2012, 19:19:19 #4 Last Edit: Thursday,November 15, 2012, 12:12:49 by teslahed
I posted my findings up on the official multiwii forum;

http://www.multiwii.com/forum/viewtopic.php?f=7&t=2745&p=26629#p26629

And Patrik came back with an excellent addition;

Quote from: PatrikEYou can read the data if you insert a few rows after the calculations.
At the end of main loop after writeMotors();


mixTable();
  writeServos();
  writeMotors();

  //DebugPrint TPA dynData
    #define TPA_DEBUGDATA  // Comment of not needed
    #if defined (TPA_DEBUGDATA)
     for(axis=0;axis<2;axis++) {   
      debug[axis]=dynP8[axis];     // debug 0 & 1  P for Roll/Nick
      debug[axis+2]=dynD8[axis];   // debug 2 & 3  D for Roll/Nick
     }
   #endif
  // End of Print TPA dynData

}


The code also goes in the MultiWii.INO file, right at the bottom.

After adding this bit of code the P and D terms can be read in the MultiWiiConf windows program in the debug boxes along the bottom when the quadcopter is connected up. With a phone and bluetooth you could read of the values in flight, otherwise you can read of the best value after you';ve landed as long as you don';t twiddle the potentiometer after you';ve found the sweet spot.

Seems like this should allow for quicker PID tuning if used properly.
One circlip short of a quadcopter.
 1 lobe short of an antenna.

Gaza07

This makes it even better like you say you will now know what the settings are and can take note  ~~