Super simple gimbal improvement

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
klaudius666
Posts: 14
Joined: Thu Apr 05, 2012 5:59 pm
Contact:

Super simple gimbal improvement

Post by klaudius666 »

Hi.
My numeric servos where a little noisy and introduced some micro vibration when using super simple gimbal system. http://www.rcgroups.com/forums/showthread.php?t=1793759
tried this to solve it by updating output.ino. seems working pretty well on my configuration. if someone try this, please let me know if it's working too.


Image



Code: Select all

 
   #ifdef SERVO_MIX_TILT
   // Simple CameraGimbal By Bledy http://youtu.be/zKGr6iR54vM
    if (rcOptions[BOXCAMSTAB]) {
      #define LOWPASSFILTER(OLDVALUE,VALUE,FILTER) ((VALUE*(8-FILTER)+OLDVALUE*FILTER)/8)
     
      #define TILT_FILTER 7 //      (7 maximum filtering 0:no filter)
      int16_t s0 = constrain(TILT_PITCH_MIDDLE - (-TILT_ROLL_PROP) * angle[PITCH] /16 - TILT_ROLL_PROP * angle[ROLL] /16 , TILT_PITCH_MIN, TILT_PITCH_MAX);
      int16_t s1 = constrain(TILT_ROLL_MIDDLE + (-TILT_ROLL_PROP) * angle[PITCH] /16 - TILT_ROLL_PROP * angle[ROLL] /16 , TILT_ROLL_MIN, TILT_ROLL_MAX);
      servo[0]=LOWPASSFILTER(servo[0],s0,TILT_FILTER);
      servo[1]=LOWPASSFILTER(servo[1],s1,TILT_FILTER);
    } else {
        // to use it with A0_A1_PIN_HEX
      #if defined(A0_A1_PIN_HEX) && (NUMBER_MOTOR == 6) && defined(PROMINI)
        servo[2] = constrain(TILT_PITCH_MIDDLE  + rcData[AUX3]-1500 , TILT_PITCH_MIN, TILT_PITCH_MAX);
        servo[3] = constrain(TILT_ROLL_MIDDLE   + rcData[AUX4]-1500,  TILT_ROLL_MIN, TILT_ROLL_MAX);     
      #else
        servo[0] = constrain(TILT_PITCH_MIDDLE  + rcData[AUX3]-1500 , TILT_PITCH_MIN, TILT_PITCH_MAX);
        servo[1] = constrain(TILT_ROLL_MIDDLE   + rcData[AUX4]-1500,  TILT_ROLL_MIN, TILT_ROLL_MAX);
      #endif
    }
  #endif

Gimbal
Posts: 146
Joined: Tue Jul 24, 2012 7:14 pm
Location: Sweden

Re: Super simple gimbal improvement

Post by Gimbal »

I'm speechless, so fu*ing simple and still so genius, the Moose guys seems a little overkill 300€, feel sorry for those whom bought it

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Super simple gimbal improvement

Post by PatrikE »

I'm not shure but this already exist in config.

Code: Select all

#define MMSERVOGIMBAL                  // Active Output Moving Average Function for Servos Gimbal
#define MMSERVOGIMBALVECTORLENGHT 32   // Lenght of Moving Average Vector

Isn't about the same?

Iw'e modified the the code to set up the gimbal from the Gui.
http://multiwii.googlecode.com/svn/branches/PatrikE/Servotest.zip
It's ready for testing now.
Open the servo TAB.

Supported models is
AIRPLANE
FLYING_WING
PPM_PWM_CONVERTER
TRI
HELI_120_CCPM
SERVO_MIX_TILT
SERVO_TILT
Single and DualCopter.

User avatar
ezio
Posts: 827
Joined: Sun Apr 01, 2012 11:03 pm
Location: Paris
Contact:

Re: Super simple gimbal improvement

Post by ezio »

I must say that it is brilliant
maybe I will make one soon

Gimbal
Posts: 146
Joined: Tue Jul 24, 2012 7:14 pm
Location: Sweden

Re: Super simple gimbal improvement

Post by Gimbal »

nice work P, will com in handy, it's the filter that's new or do you mean that now we have two

it would be nice if the third tub was fitted with a servo running from aux for tilt

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

Re: Super simple gimbal improvement

Post by shikra »

PatrikE wrote:I'm not shure but this already exist in config.



Yes _ I think the name is confusing and may not realise.... ... what is mediamobile? perhaps translation issue

I think the tab should be develop d/ included. Is Alex going to add - can you ask him. There are a whole munch of tunable parameters that would make life so much easier. It should be as timecop does it where we can for the good old tarduino 328. lol

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

Re: Super simple gimbal improvement

Post by shikra »

@klaudius666

Perhaps on small suggestion to improve a little more....?

Consider a two stage filter - first very short or no filter. if the delta from last measure > a value, use new value and reset average to that. Otherwise use the longer term average.
This will help with the downside of a filter being slow to react to big change.

So you get to fix the jitter whilst retaining the ability to respond to fast changes. May start to see small step changes in fast movements, but I think that would be better than current jitter.

Thoughts?

klaudius666
Posts: 14
Joined: Thu Apr 05, 2012 5:59 pm
Contact:

Re: Super simple gimbal improvement

Post by klaudius666 »

Hi shikra.

I'll try your suggestion. you mean a filter like this ?
i think it will generate some steps ?
(if you have some wiki about it ...)

delta=newvalue-oldvalue
if abs (delta)< threethold
{
if delta>0
newvalue+=step
else
newvalue-=step
}
else
{
newvalue+=newvalue * (1-filterratio)+filterratio*oldvalue
}

in fact, in current implementation i need more fixed int precision... i will update to have more precisions bits...

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

Re: Super simple gimbal improvement

Post by shikra »

OK, I'll try to describe:

take current average of last 2-3 readings. Or even just the last one
if abs (current average-last average) > a value that works best (maybe 2x higher than average median noise?)

If its higher, then probability is its not jitter and its a fast change so use this reading as the new servo value

That is first stage


If it is lower, then it is probability of little / small movement only, so use second "filter" as you describe - or how MMgimbalsmoothing works. MM method is probably a little.


The only thing to note is if the first stage triggers, you will usually have to reset new average for the second part. or change one of the array values if using MMgimbal method

klaudius666
Posts: 14
Joined: Thu Apr 05, 2012 5:59 pm
Contact:

Re: Super simple gimbal improvement

Post by klaudius666 »

ok. thanks. it's clear now.

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

Re: Super simple gimbal improvement

Post by Alexinparis »

Hi,
could someone test this solution (ability to control SS Gimbal using 2 AUX for PITCH/ROLL) ?
viewtopic.php?f=16&t=3092&p=31207#p31207

subaru4wd
Posts: 316
Joined: Sat Dec 08, 2012 2:16 am

Re: Super simple gimbal improvement

Post by subaru4wd »

Alexinparis wrote:Hi,
could someone test this solution (ability to control SS Gimbal using 2 AUX for PITCH/ROLL) ?
viewtopic.php?f=16&t=3092&p=31207#p31207


Is that code in the 2.2 pre-release?

I am planning on installing your 2.2pre and then i can test it.

subaru4wd
Posts: 316
Joined: Sat Dec 08, 2012 2:16 am

Re: Super simple gimbal improvement

Post by subaru4wd »

I loaded 2.2 last night and setup config.h like I have before... and my gimbal went crazy. I could not get it to react to frame movement at all. Eventually, the gimbal stopped working all together and now the servo's don't even budge when I power the board.

Sure hope I didn't fry my servo's :( I am about to re-load the last working DEV code I had, and see if i can revive the gimbal. Then I'll go back to messing with 2.2pre

Woppit
Posts: 22
Joined: Tue Jul 17, 2012 11:47 pm

Re: Super simple gimbal improvement

Post by Woppit »

subaru4wd wrote:I loaded 2.2 last night and setup config.h like I have before... and my gimbal went crazy. I could not get it to react to frame movement at all. Eventually, the gimbal stopped working all together and now the servo's don't even budge when I power the board.

Sure hope I didn't fry my servo's :( I am about to re-load the last working DEV code I had, and see if i can revive the gimbal. Then I'll go back to messing with 2.2pre


Hi, I loaded V2.2 pre into my craft and when I powered up the servo's just both moved to one end and jammed (I am using the super simple gimbal, Very cool!)
To get over this problem I patched it with the code at the top of the first post on this thread, now it all works again.

subaru4wd
Posts: 316
Joined: Sat Dec 08, 2012 2:16 am

Re: Super simple gimbal improvement

Post by subaru4wd »

Same with me... both servo's stuck at their end point and jammed.

Im not sure where to put the code. Hopefully the code will make it into the final 2.2

Gimbal
Posts: 146
Joined: Tue Jul 24, 2012 7:14 pm
Location: Sweden

Re: Super simple gimbal improvement

Post by Gimbal »

Hi this servo shit is it fixt or not

Post Reply