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

Friday,March 29, 2024, 15:20:43

Login with username, password and session length

Shoutbox

Bad Raven:
26 Mar 2024 08:41:05
 :(
Andy7:
25 Mar 2024 14:49:21
An excess of work and rain.  :thumbdown:
Bad Raven:
23 Mar 2024 18:12:38
Almost a personal Blog, it would seem. LOTS of members, but NO posts.  :-/   :shrug:
Gaza07:
06 Mar 2024 16:59:49
Anyone still here  :shrug:
ched:
24 Dec 2023 11:48:48
Hope you all have a Great Christmas and a happy New Year.
Bad Raven:
20 Dec 2023 06:17:47
 ~~   :beer2: 
Gaza07:
19 Dec 2023 22:20:27
Merry Christmas All  :beer2:
Bad Raven:
01 Dec 2023 06:59:57
New Simulator Section started!   :beer2:
Bad Raven:
17 Jun 2023 06:52:23
Yes, smaller, same as lots of things as time passes.
Andy7:
08 Jun 2023 22:49:18
 ~~
Members
Stats
  • Total Posts: 201,420
  • Total Topics: 20,260
  • Online today: 35
  • Online ever: 530
  • (Tuesday,June 26, 2012, 08:34:46 )
Users Online
Users: 0
Guests: 27
Total: 27

Theme Changer





3d - Printworx

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

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  ~~
[url="https://www.youtube.com/channel/UCN6zN99iLCIJea5FCQPKf_g"]YouTube[/url]   [url="https://www.printing-3d.co.uk"]printing-3d[/url]  [url="https://www.thingiverse.com/Gaza07/about"]Thingiverse[/url]  [url="https://www.3d-printworx.co.uk"]3d-printworx[/url]

teslahed

#4
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  ~~
[url="https://www.youtube.com/channel/UCN6zN99iLCIJea5FCQPKf_g"]YouTube[/url]   [url="https://www.printing-3d.co.uk"]printing-3d[/url]  [url="https://www.thingiverse.com/Gaza07/about"]Thingiverse[/url]  [url="https://www.3d-printworx.co.uk"]3d-printworx[/url]