Helicopter integration

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Helicopter integration

Post by Hamburger »

Metori wrote:I think in flybarred heli gyro is not needed, because flybar working like mechanical gyroscope. I dont know what will happen when I take off FB heli with gyro mode on.

I presume flybar and gyro will fight for control constantly
Hamburger, Does Mega 2560 based flight controllers with MultiWii 2.3 have all servo signals (needed for heli) drived by hardware PWM ?

I have only ever run 328p (cannot do hw.pwm) and 32u4 (now supports hw.pwm for heli) systems on my helis. Only code can tell but I do not currently have easy access to repository. My guess is heli on 2560 works and it will work with hw.pwm. But only one common refresh rate for all 4 servos.

pins for hw.pwm on 2560 are a clean implementation since v2.3, so I suggest you lookup the 2560 pins in config.h and wiki, enable hw.pwm and test.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Helicopter integration

Post by Hamburger »

Romeo84 wrote:finally i solved that issue. i have rewrited some amount of code to do so. if anyone needs this - i'll share

care to share here for others to see? How well does it work?
We could drum up a lower and upper ceiling - aux switch activated - so heli would stay within, or jump back into height corridor.
For me this together with level-mode could have prevented some unintentional heli<->earth contact.

RC Man
Posts: 15
Joined: Sun Sep 29, 2013 7:58 pm

Re: Helicopter integration

Post by RC Man »

Hi yall,
Ohhh do I need some help, lol
I put together a multiwii heli using a minipro and a 6050, just got the collective pitch working, but on the other cyc. movements, I get movement on all 3 servos and left cyc. moves faster than right.
Where can I set this up, what part of the multiwii do I look into. Config h, output ? I have no idea. Would love to get this working, as I have been fiddling with it for 3 days.
Im using the multiwii from Patrik.

Thanks ;)

zwiebacksaege
Posts: 27
Joined: Thu Mar 07, 2013 10:14 am

Re: Helicopter integration

Post by zwiebacksaege »

Hi guys,

as far as I read this Topic it seems that MultiWii works only good with FBL Systems. Is there no Chance to take the FB of a traditional FB-head into account by decreasing the PID of roll/nick (so that Software doesn't fight against FB) and just realizing the leveling of the copter by the ACC-values?

My main Goal is to make a Logo 14 stable and self-leveling for FPV. There is absolutely no interest in 3D. Tail would be traditionally controlled by a 401 gyro just for convenience of using an established System in first approach.

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

Re: Helicopter integration

Post by PatrikE »

Hi RCman,

Use V2.3 Public
Adjust direction and throws In config.h

Code: Select all

    /* Servo mixing for heli 120
                         {Coll,Nick,Roll} */
    #define SERVO_NICK   { +10, -10,  0 }
    #define SERVO_LEFT   { +10, +5, +10 }
    #define SERVO_RIGHT  { +10, +5, -10 }


/Patrik

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

Re: Helicopter integration

Post by PatrikE »

On a FB heli you should decrease PID for Gyro.
How much i don't know but FB do the Gyro's work mechanically.

RC Man
Posts: 15
Joined: Sun Sep 29, 2013 7:58 pm

Re: Helicopter integration

Post by RC Man »

PatrikE wrote:Hi RCman,

Use V2.3 Public
Adjust direction and throws In config.h

Code: Select all

    /* Servo mixing for heli 120
                         {Coll,Nick,Roll} */
    #define SERVO_NICK   { +10, -10,  0 }
    #define SERVO_LEFT   { +10, +5, +10 }
    #define SERVO_RIGHT  { +10, +5, -10 }


/Patrik



I think I know why its not working right, as I tilt my gyro, it just moves ,and then goes back to level, even when the heli is tilted, I think the 6050 is shot, my Flymentor stays tilted till heli is back to level, and works flawlessly in flight.
Ill load up the 2.3 now, and give it another try, is using this the right one for the ITG MPU 6050?
//#define WMP
//#define ITG3200
//#define MPU3050
//#define L3G4200D
#define MPU6050 //combo + ACC
//#define LSM330

Thanks for the help Patrik :D

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

Re: Helicopter integration

Post by PatrikE »

RC Man wrote:I think I know why its not working right, as I tilt my gyro, it just moves ,and then goes back to level, even when the heli is tilted

That's how acro mode work!.
In Level modes Angle or Horizon swash will hold position like your Flymentor.

RC Man
Posts: 15
Joined: Sun Sep 29, 2013 7:58 pm

Re: Helicopter integration

Post by RC Man »

I know this sounds stupid, but how do I shut acro mode off? Is it in the gui? or do I have to program it out,
2,3 dosnt do anything when I load it after changing to heli 120, When I load 2,1, it works ok.

Metori
Posts: 18
Joined: Thu Jan 16, 2014 1:04 pm
Location: Russia, Vladivostok

Re: Helicopter integration

Post by Metori »

RC Man wrote:I know this sounds stupid, but how do I shut acro mode off? Is it in the gui? or do I have to program it out,
2,3 dosnt do anything when I load it after changing to heli 120, When I load 2,1, it works ok.

You can simply make angle mode always active by setting all angle checkboxes on in the gui. (squares below AUX captions).

BRIThelinoob
Posts: 2
Joined: Wed Feb 05, 2014 3:35 am

Re: Helicopter integration

Post by BRIThelinoob »

Hi guys I was thinking about using a my Multiwii Crius AIOP Board in my nitro heli. But can I still use my hh gyro. If so how do I hook it up, as it's on rudder channel 4 and the single wire on channel 5 (Switchable between rate mode and Heading hold, and what is a "NICK SERVO"

Mike..

RC Man
Posts: 15
Joined: Sun Sep 29, 2013 7:58 pm

Re: Helicopter integration

Post by RC Man »

BRIThelinoob wrote:Hi guys I was thinking about using a my Multiwii Crius AIOP Board in my nitro heli. But can I still use my hh gyro. If so how do I hook it up, as it's on rudder channel 4 and the single wire on channel 5 (Switchable between rate mode and Heading hold, and what is a "NICK SERVO"

Mike..


Hi Mike, you can use a separate tail gyro, no problems, the nick servo is the one that dosnt move when ya tilt the heli sideways, or, the back servo on a Trex.

BRIThelinoob
Posts: 2
Joined: Wed Feb 05, 2014 3:35 am

Re: Helicopter integration

Post by BRIThelinoob »

so you mean the nick servo is really the elevator one..

Mike..

gsenroc
Posts: 10
Joined: Mon Dec 30, 2013 11:45 pm

Re: Helicopter integration

Post by gsenroc »

Hamburger wrote:was asked several times, so here is my wiring diagram for a true nanoWii (_not_ the HK lookalike) with spektrum satellite and HW-PWM:
A3 - vbat
4 buzzer
9 right
10 left
5 yaw
6 motor
11 nick

Best verify servo signal freq with pwm meter - if servo is attached to motor output, then 490Hz motor signal sets servo on fire very quickly.

Hi Hamburger,

Does this pin layout also holds if I uncomment the line

Code: Select all

#define A32U4ALLPINS

Or should I just avoid this line?

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Helicopter integration

Post by Hamburger »

I think this gets activated automatically when you enable nanowii board? You can check in def.h

RC Man
Posts: 15
Joined: Sun Sep 29, 2013 7:58 pm

Re: Helicopter integration

Post by RC Man »

Mike,
The elevator servo, is the one that tilts the heli forward or backwards, I had to learn this as a heli noob in "83"
Now, the mixing channels do this stuff for us. Nick is the rear servo, but the two front servos move with it, in the opposite direction, if ya move the heli front to back (Side to side, it shouldnt move at all) The rear servo, that is.

Frank

gsenroc
Posts: 10
Joined: Mon Dec 30, 2013 11:45 pm

Re: Helicopter integration

Post by gsenroc »

Hamburger wrote:I think this gets activated automatically when you enable nanowii board? You can check in def.h

Yes you're right. I've just checked def.h, it's activated if nanowii is enabled.

There is another thing that makes me curious, the yaw output stays at around 1245 when the board is sitting still. Isn't it supposed to be around 1500 in the middle? I've already calibrated the acc.

Image
Attachments
QQ20140223-1.png
(7.82 KiB) Not downloaded yet

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

Re: Helicopter integration

Post by PatrikE »

gsenroc wrote:The yaw output stays at around 1245 when the board is sitting still. Isn't it supposed to be around 1500 in the middle?

Yaw I-term builds up in PID regulator.

gsenroc
Posts: 10
Joined: Mon Dec 30, 2013 11:45 pm

Re: Helicopter integration

Post by gsenroc »

PatrikE wrote:
gsenroc wrote:The yaw output stays at around 1245 when the board is sitting still. Isn't it supposed to be around 1500 in the middle?

Yaw I-term builds up in PID regulator.

Thanks Patrik, I guess I got it.

rcflyer24
Posts: 1
Joined: Fri Feb 28, 2014 12:51 am

Re: Helicopter integration

Post by rcflyer24 »

Hey all. I have read through this whole post and I still do not understand how to hook up the Helicopter to the Crius board and the receiver. Has someone posted a picture on how to do that? If so can someone point me in the right direction? I have been trying to get my setup going for a couple weeks now without any luck. Thanks so much! I have a Dynham Erazor 450, Crius AIO Pro V2.0 and the standard 6CH Dynham transmitter and receiver. If I missed something along the way I apologize for the duplication.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Helicopter integration

Post by Hamburger »

Erazor is fbl nowadays?

gsenroc
Posts: 10
Joined: Mon Dec 30, 2013 11:45 pm

Re: Helicopter integration

Post by gsenroc »

I'm very close to finish setting up my nanowii hooked up with a barometer, but I have a question before test flight.

I've set the COLLECTIVE_PITCH control via channel AUX2, and I'm going to use a throttle curve which is flat and constant. As I'm going to use baro mode I'm now wondering which channel is going to control the ascend and descend in baro mode. Is that throttle or AUX2 in this case?

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

Re: Helicopter integration

Post by PatrikE »

Baro controlls Throtle.

gsenroc
Posts: 10
Joined: Mon Dec 30, 2013 11:45 pm

Re: Helicopter integration

Post by gsenroc »

PatrikE wrote:Baro controlls Throtle.

But that seems to be a problem for those who use a constant throttle. I only control the ascend and descend by changing the pitch, the throttle is always 80%. Does that mean that if I switch to baro, my constant 80% throttle will just make my heli climbing up and it won't stop?

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

Re: Helicopter integration

Post by PatrikE »

It will apply throttle until the correct altitude is reached.
But you could make a change in the code to move Baro control to Pitch channel.
In V2.3
Row 1166 - 1183.
Change all three apperances
of rcCommand[THROTTLE]
to rcCommand[COLLECTIVE_PITCH]
And in row 991

Note this is untested but should work.

gsenroc
Posts: 10
Joined: Mon Dec 30, 2013 11:45 pm

Re: Helicopter integration

Post by gsenroc »

PatrikE wrote:It will apply throttle until the correct altitude is reached.
But you could make a change in the code to move Baro control to Pitch channel.
In V2.3
Row 1166 - 1183.
Change all three apperances
of rcCommand[THROTTLE]
to rcCommand[COLLECTIVE_PITCH]
And in row 991

Note this is untested but should work.

Thanks very much Patrik, that seems to be the best solution. I'll have a try.

Romeo84
Posts: 16
Joined: Wed Aug 21, 2013 8:32 pm

Re: Helicopter integration

Post by Romeo84 »

Hamburger wrote:
Romeo84 wrote:finally i solved that issue. i have rewrited some amount of code to do so. if anyone needs this - i'll share

care to share here for others to see? How well does it work?
We could drum up a lower and upper ceiling - aux switch activated - so heli would stay within, or jump back into height corridor.
For me this together with level-mode could have prevented some unintentional heli<->earth contact.



OK. I shared. Its for 2.3 ver and crius 2.5 board. My code customizations labeled by 'testromeo' tag


It work normally on my 600 alighn heli Unfortunatelly last weekend when i was tuning PIDs for level mode and gyro smooth parameters my heli in instant go to oscillate and i broken tail blades. Soon i will get new one and will try futher to tune... Can anyone share own PIDs for this heli?
Attachments
MultiWii-RomeoCustom.rar
(131.5 KiB) Downloaded 187 times

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Helicopter integration

Post by Hamburger »

Always sad to crash during pid tuning. I had it happen several times when I started with 325mm helis. Later had good luck with 200mm. Next is stretched 465mm.
Be aware pids depend on gyro smoothing and acc filtering values.
I cannot currently read your archive. Did you set gyro.smoothing to about 70 70 50 to begin with. For level or horizon mode to work one must probably do acc filtering at 10hz

Helis have lots of disturbing vibrations

Romeo84
Posts: 16
Joined: Wed Aug 21, 2013 8:32 pm

Re: Helicopter integration

Post by Romeo84 »

Hamburger wrote:Always sad to crash during pid tuning. I had it happen several times when I started with 325mm helis. Later had good luck with 200mm. Next is stretched 465mm.
Be aware pids depend on gyro smoothing and acc filtering values.
I cannot currently read your archive. Did you set gyro.smoothing to about 70 70 50 to begin with. For level or horizon mode to work one must probably do acc filtering at 10hz

Helis have lots of disturbing vibrations


I started with gyro smoothing at 50 50 10, but when i set it to 20 20 10 heli suddenly started to oscillate. Now i am waiting tail blades from hobbyking... In Moscow unfortunatelly it is not exists at present time..

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Helicopter integration

Post by Hamburger »

I too found that yaw gyro needs high smoothing or oscillation is horrible. I think it is because of long tail boom which multiplies movement effects.

SquidgyB
Posts: 6
Joined: Wed Sep 17, 2014 4:24 pm

Re: Helicopter integration

Post by SquidgyB »

Has anyone tried this with a small CP heli, like an MCP-X?

I have a brushless main & tail MCP-X that I'm going to *try* and get working using an Orange RX (stripped of excess metal/case), Pro Mini and a GY-85...

I've got some testing and fiddly soldering to do before I get anywhere, but I'll try and keep this thread updated with anything pertinent.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Helicopter integration

Post by Hamburger »

I do not know how small mcp-x is.
Gaui 200 fbl with 205mm blades is my smallest with nanowii+spektrum.sat+i2c.oled

RC Man
Posts: 15
Joined: Sun Sep 29, 2013 7:58 pm

Re: Helicopter integration

Post by RC Man »

MCPX has 135 blades, small for a multi wii, maybe integrate a mpu6050 on the 3in1 between the servos and the 3in1.
+ with 4 volts, I dont know how long you could fly. I had a hard time installing in this 450.
Attachments
IMG_1678.JPG

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Helicopter integration

Post by Hamburger »

that 450 looks interesting. Is it tuned for speed? Rotation of tail looks unusual?
Btw. why was it difficult to use MWii - on 450 space is available for regular rx+fbl and mwii should be comparable in size with any of the all in one boards?

RC Man
Posts: 15
Joined: Sun Sep 29, 2013 7:58 pm

Re: Helicopter integration

Post by RC Man »

If you look at the pic, the bottom frames are no longer there, No gyro mount,rx mount.
Had only room under the canopy behind the battery, next to the swashplate.
The tail rotates in reverse, as I dont need so much tail authority racing, Ive since then put my M/W fbl on the side burner,
still interested, but wanting to learn more about fbl and the PID settings, this will help me in understanding the M/W settings for the future.
Keep it up yall, we are going somewhere with this.

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

Re: Helicopter integration

Post by Alexinparis »

Hi,

About MultiWii on mini cp, you can follow this man:
https://www.youtube.com/channel/UCEtmuV ... OmnV27A7Hw
the result is apparently very good, and no problem to do fairly good 3D

According to the description he uses this board:
http://www.hobbyking.com/hobbyking/stor ... o_mag.html

This one should also be a good candidate with brushed output
http://www.hobbyking.com/hobbyking/stor ... rated.html

SquidgyB
Posts: 6
Joined: Wed Sep 17, 2014 4:24 pm

Re: Helicopter integration

Post by SquidgyB »

Ah, so someone's already done it :)

Mine will consist of a Pro Micro, Orange Rx like this one http://orangerx.com/tag/dsm2/ with CPPM, and a GY-85. All pins have been removed, I'll just be using magnet wire of some sort for connections.

Including the ESCs (which were put together and flashed a while ago now, but still have flashing connectors installed) the FC/Rx/ESC combo should be around 8-10g, which is well within the limits for a brushless MCP-X, I think.

I'm not looking to do much 3D flying, or any real "duration" flights. It's more of a learning experience in setting up MultiWii so I can be more confident in setting other things up with it in the future.

Bit of a deep end to jump off into I suppose, but I enjoy figuring stuff out as I go along.

RC Man
Posts: 15
Joined: Sun Sep 29, 2013 7:58 pm

Re: Helicopter integration

Post by RC Man »

Bit of a deep end to jump off into I suppose, but I enjoy figuring stuff out as I go along.

Thats what keeps most of us here going, Me included.
Doing things on the run, so to say.

keep up the good work, and keep us informed.

SquidgyB
Posts: 6
Joined: Wed Sep 17, 2014 4:24 pm

Re: Helicopter integration

Post by SquidgyB »

I looked at the wiring last night, seems simple enough - I'm going off Patrik's blog post so;

D12 = Nickservo
D11 = Left
D10 = Right
D9 = Main motor
D3 = Yaw motor (with corresponding change in config.h)

Am I right in thinking CPPM goes in on D2? (Along with the appropriate config.h modification) That'll save me from wiring up each channel separately. Ignore that, I have an R610 - I believe that's before they did CPPM. So I'm stuck with a set of wires. No biggie.

SDA and SCL from the sensor... go to what I assume are A4 and A5? The Pro Micro's I have are each a little different, some have A6/A7 pinouts, but all have A4/A5, albeit sometimes in different places.

The rest is mainly powertrain (5v supplied from the XP7A) and (very) fiddly soldering. I somehow managed to desolder the tiny servo connectors from the 3in1 board (without destroying them!) and I've set them up with a magnet wire power rail and lighter wire for the signals.

Servos are being pushed at 5v, they should be 4.2v techincally - though they always worked before (the 3in1 had 5v supplied by the XP-7A) so we'll see how they go. Spares are cheaper to pick up than they used to be, too.

I was thinking of swapping D3 with D8 by software, but I'm not sure of the capabilities of D8 compared to D3 - I just wanted to tidy up the wiring so both motors (and servos) are all connected down one end of the board. Having looked into what's required within the code I'm not so sure that's a good idea - it's one thing to change a definition or something in config.h, but I'm not quite ready to go hunting through the code swapping out each reference to D3/D8 to get that sorted. A little extra wire will have to do.

As for vibration isolation/damping, I'll play around with what I set up previously - a plectrum with some double sided foam. I might play around with different solutions to that issue.

SquidgyB
Posts: 6
Joined: Wed Sep 17, 2014 4:24 pm

Re: Helicopter integration

Post by SquidgyB »

I've soldered everything together, and to my delight all LEDs lit up nicely on the first try.

ESCs, FC, sensor, Rx and battery wire together come to ~12g. A little heavy, but not too bad, and definitely flyable.

I've uploaded MultiWii, now I'm just having noobish issues with sensor orientation... I'm searching everywhere for any info on GY-85 orientation but I can't find much. I thought setting GY-85 as the sensor trying different orientations out with a calibration inbetween would get me the right way by trial and error - but i'm flummoxed. Every which way I try it looks to me like some sensors are inverted or on the wrong axis.

On the plus side, servos are responding to movements.

e: Following on from that - I've sorted the orientation, I think I was just being an idiot and probably had it set up correctly from the start - I went over the expected outputs and all was good.

...but... now it seems only 3 of the 5 channels are coming through. I get Pitch, Yaw and Aux1 coming through fine, but Throttle and Roll are stuck at 1500 just like Aux2/3/4. can't see anything obvious in my soldering, but it gets pretty fiddly in there, I've cut the Rx board with a dremel to save weight (just the +ive and -ive rails) and tacked power onto the corresponding PCB traces. I might just get me a CPPM Rx to save all the hassle, but while this is here I'll try and get it sorted one way or another.

I thought it might have something to do with a Pro Mini specific configuration option in config.h, but I can't see anything in there that actually makes a difference.

SquidgyB
Posts: 6
Joined: Wed Sep 17, 2014 4:24 pm

Re: Helicopter integration

Post by SquidgyB »

I decided to scrap the orange Rx - I managed to find an old TFR4 which to my surprise boasts CPPM! So I've re wired the layercake, and now I have all channels responding as expected.

Now to actually make the buzzy little bastard flight worthy.

sachiho
Posts: 3
Joined: Sun Oct 05, 2014 1:38 pm

Re: Helicopter integration

Post by sachiho »

Hi
I am working to fly miniCP by MWC. (Thanks Alexinparis for noticing me)

I was helped very much by this thread. But I'm sorry, I had not fed back my result yet.

I'm using hobbyking nanoWii controller, orange satellite RX, Dual brushless motors and 2S battery.
Here is my recipe (google translated, sorry it is written in Japanese)
https://translate.google.co.jp/translat ... edit-text=


I added the code which improves the tail hold on a pitch pump, and the code of piro optimization to the original MWC code.
Below has the code which I changed.
https://code.google.com/p/multiwii-helimod/


Although I was using 1S battery in early stages, the MWC does not operate correctly on the voltage which is much less than 4V.
When 1S battery was used, two batteries for motors and for MWC needed to be stacked.

1S movie
https://www.youtube.com/watch?v=2iuijpw79OI

After that, I shift to 2S battery and am continuing the try to realize a 3D controller like AS3X.

2S movie
https://www.youtube.com/watch?v=uq7EG7NTdbE

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Helicopter integration

Post by Hamburger »

Hello sachiho,

thank you for your contribution. For easier reading I made a diff against v2.3

Code: Select all

diff -BbwE -r -u MultiWii_2_3/MultiWii/MultiWii.cpp multiwii-helimod/MultiWii/MultiWii.cpp
--- MultiWii_2_3/MultiWii/MultiWii.cpp   2013-11-07 23:56:18.000000000 +0100
+++ multiwii-helimod/MultiWii/MultiWii.cpp   2014-10-06 20:26:31.000000000 +0200
@@ -1335,6 +1335,19 @@
     //-----calculate total PID output
     axisPID[axis] =  PTerm + ITerm + DTerm;
   }
+
+    // pirouette optimization ( rotate horizontal error term )
+    // rescale gyrodata to radian:  gyrodata * (freq: cycletime/1000000) * (gyro2deg: 2000/8192) * (deg2rad: 2Pi/360)
+    double GyroToRad  = cycleTime * 0.000000004259;
+    double Sint = sin(-imu.gyroData[YAW] * GyroToRad);
+    double Cost = cos(-imu.gyroData[YAW] * GyroToRad);
+
+    errorGyroI[ROLL]  =  errorGyroI[ROLL]*Cost + errorGyroI[PITCH]*Sint;
+    errorGyroI[PITCH] = -errorGyroI[ROLL]*Sint + errorGyroI[PITCH]*Cost;
+    axisPID[ROLL]  =  axisPID[ROLL]*Cost + axisPID[PITCH]*Sint;
+    axisPID[PITCH] = -axisPID[ROLL]*Sint + axisPID[PITCH]*Cost;
+
+
 #else
   #error "*** you must set PID_CONTROLLER to one existing implementation"
 #endif
diff -BbwE -r -u MultiWii_2_3/MultiWii/Output.cpp multiwii-helimod/MultiWii/Output.cpp
--- MultiWii_2_3/MultiWii/Output.cpp   2013-09-09 23:41:40.000000000 +0200
+++ multiwii-helimod/MultiWii/Output.cpp   2014-10-06 20:26:31.000000000 +0200
@@ -1269,11 +1269,25 @@
     /* Throttle & YAW
     ******************** */
     // Yaw control is common for Heli 90 & 120
+    //servo[5] = (axisPID[YAW] * SERVODIR(5,1)) + conf.servoConf[5].middle + servo[7]<<7 + collective<<8;
+
+    // tail precomp from collective
+    if (abs(collective) > YAW_COLL_PRECOMP_DEADBAND ){
+      servo[5] = (axisPID[YAW] * SERVODIR(5,1)) + conf.servoConf[5].middle + (abs(collective)-YAW_COLL_PRECOMP_DEADBAND) * YAW_COLL_PRECOMP;
+    }else{
     servo[5] = (axisPID[YAW] * SERVODIR(5,1)) + conf.servoConf[5].middle;
-    #if YAWMOTOR
+    }
+
+    #if (YAWMOTOR || YAWSTOP)
       servo[5] = constrain(servo[5], conf.servoConf[5].min, conf.servoConf[5].max); // limit the values
-      if (rcCommand[THROTTLE]<conf.minthrottle || !f.ARMED) {servo[5] = MINCOMMAND;} // Kill YawMotor
+      if (rcCommand[THROTTLE] <= conf.minthrottle || !f.ARMED) {servo[5] = MINCOMMAND;} // Kill YawMotor
+      else{
+         if ( servo[5] < 1030) {  // don't stop tail motor
+          servo[5] = 1030;
+        }
+      }
     #endif
+
     if (!f.ARMED){
       servo[7] = MINCOMMAND;          // Kill throttle when disarmed
     } else {
diff -BbwE -r -u MultiWii_2_3/MultiWii/config.h multiwii-helimod/MultiWii/config.h
--- MultiWii_2_3/MultiWii/config.h   2013-11-08 00:00:00.000000000 +0100
+++ multiwii-helimod/MultiWii/config.h   2014-10-06 20:26:31.000000000 +0200
@@ -50,7 +50,7 @@
     //#define AIRPLANE
     //#define SINGLECOPTER
     //#define DUALCOPTER
-    //#define HELI_120_CCPM
+    #define HELI_120_CCPM
     //#define HELI_90_DEG
 
   /****************************    Motor minthrottle    *******************************/
@@ -60,16 +60,16 @@
     //#define MINTHROTTLE 1120 // for Super Simple ESCs 10A
     //#define MINTHROTTLE 1064 // special ESC (simonk)
     //#define MINTHROTTLE 1050 // for brushed ESCs like ladybird
-    #define MINTHROTTLE 1150 // (*) (**)
+    #define MINTHROTTLE 0 // (*) (**)
 
   /****************************    Motor maxthrottle    *******************************/
     /* this is the maximum value for the ESCs at full power, this value can be increased up to 2000 */
-    #define MAXTHROTTLE 1850
+    #define MAXTHROTTLE 1950
 
   /****************************    Mincommand          *******************************/
     /* this is the value for the ESCs when they are not armed
        in some cases, this value must be lowered down to 900 for some specific ESCs, otherwise they failed to initiate */
-    #define MINCOMMAND  1000
+    #define MINCOMMAND  0
 
   /**********************************    I2C speed   ************************************/
     #define I2C_SPEED 100000L     //100kHz normal mode, this value must be used for a genuine WMP
@@ -96,7 +96,7 @@
       //#define FREEIMUv035_BMP // FreeIMU v0.3.5_BMP
       //#define FREEIMUv04      // FreeIMU v0.4 with MPU6050, HMC5883L, MS561101BA                  <- confirmed by Alex
       //#define FREEIMUv043     // same as FREEIMUv04 with final MPU6050 (with the right ACC scale)
-      //#define NANOWII         // the smallest multiwii FC based on MPU6050 + pro micro based proc <- confirmed by Alex
+      #define NANOWII         // the smallest multiwii FC based on MPU6050 + pro micro based proc <- confirmed by Alex
       //#define PIPO            // 9DOF board from erazz
       //#define QUADRINO        // full FC board 9DOF+baro board from witespy  with BMP085 baro     <- confirmed by Alex
       //#define QUADRINO_ZOOM   // full FC board 9DOF+baro board from witespy  second edition
@@ -109,7 +109,7 @@
       //#define SIRIUS600       // Sirius Navigator IMU  using the WMP for the gyro
       //#define SIRIUS_AIR      // Sirius Navigator IMU 6050 32U4 from MultiWiiCopter.com           <- confirmed by Alex
       //#define SIRIUS_AIR_GPS  // Sirius Navigator IMU 6050 32U4 from MultiWiiCopter.com with GPS/MAG remote located
-      //#define SIRIUS_MEGAv5_OSD //  Paris_Sirius‚Ñ¢ ITG3050,BMA280,MS5611,HMC5883,uBlox  http://www.Multiwiicopter.com <- confirmed by Alex
+      //#define SIRIUS_MEGAv5_OSD //  Paris_Sirius? ITG3050,BMA280,MS5611,HMC5883,uBlox  http://www.Multiwiicopter.com <- confirmed by Alex
       //#define MINIWII         // Jussi's MiniWii Flight Controller                                <- confirmed by Alex
       //#define MICROWII        // MicroWii 10DOF with ATmega32u4, MPU6050, HMC5883L, MS561101BA from http://flyduino.net/
       //#define CITRUSv2_1      // CITRUS from qcrc.ca
@@ -199,7 +199,7 @@
 
       /* enforce your individual sensor orientation - even overrides board specific defaults */
       //#define FORCE_ACC_ORIENTATION(X, Y, Z)  {imu.accADC[ROLL]  =  Y; imu.accADC[PITCH]  = -X; imu.accADC[YAW]  = Z;}
-      //#define FORCE_GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = -Y; imu.gyroADC[PITCH] =  X; imu.gyroADC[YAW] = Z;}
+      #define FORCE_GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Z; imu.gyroADC[PITCH] =  Y; imu.gyroADC[YAW] = X;}
       //#define FORCE_MAG_ORIENTATION(X, Y, Z)  {imu.magADC[ROLL]  =  X; imu.magADC[PITCH]  =  Y; imu.magADC[YAW]  = Z;}
 
       /* Board orientation shift */
@@ -220,13 +220,13 @@
      * 1 = evolved oldschool algorithm (similar to v2.2)
      * 2 = new experimental algorithm from Alex Khoroshko - unsupported - http://www.multiwii.com/forum/viewtopic.php?f=8&t=3671&start=10#p37387
      * */
-    #define PID_CONTROLLER 1
+    #define PID_CONTROLLER 2
 
     /* NEW: not used anymore for servo coptertypes  <== NEEDS FIXING - MOVE TO WIKI */
     #define YAW_DIRECTION 1
     //#define YAW_DIRECTION -1 // if you want to reverse the yaw correction direction
 
-    #define ONLYARMWHENFLAT //prevent the copter from arming when the copter is tilted
+//    #define ONLYARMWHENFLAT //prevent the copter from arming when the copter is tilted
 
    /********************************    ARM/DISARM    *********************************/
    /* optionally disable stick combinations to arm/disarm the motors.
@@ -281,7 +281,8 @@
 
   /***********************          Heli                           ***********************/
     /* Channel to control CollectivePitch */
-    #define COLLECTIVE_PITCH      THROTTLE
+    //#define COLLECTIVE_PITCH      THROTTLE
+    #define COLLECTIVE_PITCH      AUX2
 
     /* Limit the range of Collective Pitch. 100% is Full Range each way and position for Zero Pitch */
     #define COLLECTIVE_RANGE { 80, 0, 80 }// {Min%, ZeroPitch offset from 1500, Max%}.
@@ -300,6 +301,11 @@
        if inactive, throttle output will be treated as a motor output, so it can drive an ESC */
     //#define HELI_USE_SERVO_FOR_THROTTLE
 
+    // sachiho add for helicopter
+    #define    YAWSTOP                    1    // cut tail motor when throttle is zero :for brushless tail ESC driven by servo PWM signal
+    #define    YAW_COLL_PRECOMP           1.5  // increase tail thrust with respect to abs(collective pitch)
+    #define    YAW_COLL_PRECOMP_DEADBAND  120
+
   /***********************      your individual mixing     ***********************/
     /* if you want to override an existing entry in the mixing table, you may want to avoid editing the
      * mixTable() function for every version again and again.
@@ -343,7 +348,7 @@
          Spektrum Satellites are 3V devices.  DO NOT connect to 5V!
          For MEGA boards, attach sat grey wire to RX1, pin 19. Sat black wire to ground. Sat orange wire to Mega board's 3.3V (or any other 3V to 3.3V source).
          For PROMINI, attach sat grey to RX0.  Attach sat black to ground. */
-      //#define SPEKTRUM 1024
+      #define SPEKTRUM 1024
       //#define SPEKTRUM 2048
       //#define SPEK_SERIAL_PORT 1    // Forced to 0 on Pro Mini and single serial boards; Set to your choice of 0, 1, or 2 on any Mega based board (defaults to 1 on Mega).
       //**************************
@@ -354,7 +359,7 @@
       //   Normally use 3.3V regulator is needed on the power pin!!  If your satellite hangs during bind (blinks, but won't complete bind with a solid light), go direct 5V on all pins.
       //**************************
       //   For Pro Mini, the connector for the Satellite that resides on the FTDI can be unplugged and moved to these three adjacent pins.
-      //#define SPEK_BIND             //Un-Comment for Spektrum Satellie Bind Support.  Code is ~420 bytes smaller without it.
+      #define SPEK_BIND             //Un-Comment for Spektrum Satellie Bind Support.  Code is ~420 bytes smaller without it.
       //#define SPEK_BIND_GROUND 4
       //#define SPEK_BIND_POWER  5
       //#define SPEK_BIND_DATA   6
@@ -502,7 +507,7 @@
       //#define MPU6050_LPF_188HZ
       //#define MPU6050_LPF_98HZ
       //#define MPU6050_LPF_42HZ
-      //#define MPU6050_LPF_20HZ
+      #define MPU6050_LPF_20HZ
       //#define MPU6050_LPF_10HZ
       //#define MPU6050_LPF_5HZ       // Use this only in extreme cases, rather change motors and/or props
 
@@ -510,7 +515,7 @@
       /* GYRO_SMOOTHING. In case you cannot reduce vibrations _and_ _after_ you have tried the low pass filter options, you
          may try this gyro smoothing via averaging. Not suitable for multicopters!
          Good results for helicopter, airplanes and flying wings (foamies) with lots of vibrations.*/
-      //#define GYRO_SMOOTHING {20, 20, 3}    // (*) separate averaging ranges for roll, pitch, yaw
+      #define GYRO_SMOOTHING {60, 60, 1}    // (*) separate averaging ranges for roll, pitch, yaw
 
     /************************    Moving Average Gyros    **********************************/
       //#define MMGYRO 10                      // (*) Active Moving Average Function for Gyros
@@ -850,7 +855,7 @@
      * + want altitude readout and/or variometer
      * + do not use altitude hold feature
      * + want to save memory space */
-    //#define SUPPRESS_BARO_ALTHOLD
+    #define SUPPRESS_BARO_ALTHOLD
 
   /********************************************************************/
   /****           altitude variometer                              ****/
@@ -914,7 +919,7 @@
 
   /***********************         Servo Refreshrates            ***********************/
     /* Default 50Hz Servo refresh rate*/
-    #define SERVO_RFR_50HZ
+    //#define SERVO_RFR_50HZ
 
     /* up to 160Hz servo refreshrate .. works with the most analog servos*/
     //#define SERVO_RFR_160HZ
@@ -946,10 +951,10 @@
      * servo[5] = yaw   servo = pin  5
      * servo[6]  = right servo= pin  9
      */
-    //#define A32U4_4_HW_PWM_SERVOS
+    #define A32U4_4_HW_PWM_SERVOS
 
-    #define SERVO_RFR_RATE  50    // In Hz, you can set it from 20 to 400Hz, used only in HW PWM mode for mega and 32u4
-    //#define SERVO_PIN5_RFR_RATE  200    // separate yaw pwm rate.
+    #define SERVO_RFR_RATE  60    // In Hz, you can set it from 20 to 400Hz, used only in HW PWM mode for mega and 32u4
+    #define SERVO_PIN5_RFR_RATE  100    // separate yaw pwm rate.
                                           // In Hz, you can set it from 20 to 400Hz, used only in HW PWM mode for 32u4
 
 

But I think there is an error in the pirouette code here:

Code: Select all

    errorGyroI[ROLL]  =  errorGyroI[ROLL]*Cost + errorGyroI[PITCH]*Sint;
    errorGyroI[PITCH] = -errorGyroI[ROLL]*Sint + errorGyroI[PITCH]*Cost;
and here

Code: Select all

    axisPID[ROLL]  =  axisPID[ROLL]*Cost + axisPID[PITCH]*Sint;
    axisPID[PITCH] = -axisPID[ROLL]*Sint + axisPID[PITCH]*Cost;

In both cases, the second computation uses the result of xy[ROLL] from the previous line. This is not typical of applying rotation and maybe not intended?

sachiho
Posts: 3
Joined: Sun Oct 05, 2014 1:38 pm

Re: Helicopter integration

Post by sachiho »

Thanks Hamburger,

Oh, you are totally right.
I should write like

Code: Select all

    double errorGyroIROLL =  errorGyroI[ROLL]*Cost + errorGyroI[PITCH]*Sint;
    errorGyroI[PITCH] = -errorGyroI[ROLL]*Sint + errorGyroI[PITCH]*Cost;
    errorGyroI[ROLL]  =  errorGyroIROLL;


I will fix my SVN repository soon.
Thanks again.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Helicopter integration

Post by Hamburger »

so did you experience any difference in behaviour with the correction to piroutte computation?

sachiho
Posts: 3
Joined: Sun Oct 05, 2014 1:38 pm

Re: Helicopter integration

Post by sachiho »

In fact, I was not able to feel the clear difference by fixed code.

Maybe it is because 100 sized heli can not pirouette perfectly at a point like large helis.
Even with piro compensation code, my heli moves to right in CCW pirouette.

Anyway, compared with original MWC which does not include compensation, a great improvement is seen about the pirouette of two or more times rotations.
https://www.youtube.com/watch?v=foMPmT-6b2g

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Helicopter integration

Post by Hamburger »

tail precomp is in r1726 now, even tunable via lcd (and possibly MWiiGui soon).
As I do not fly pid.conroller=2 I am hesitant to copy'n'paste that portion for piro optimization, sorry. Any volunteers to test fly?

ivars
Posts: 1
Joined: Fri Jul 31, 2015 6:43 pm

Re: Helicopter integration

Post by ivars »

I have a HK mini multiwii with dsm2 receiver controller and there is no D12 available for connecting the nick servo. Are there any other possibilities?

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

Re: Helicopter integration

Post by PatrikE »

ivars wrote:I have a HK mini multiwii with dsm2 receiver controller and there is no D12 available for connecting the nick servo. Are there any other possibilities?

Hi and welcome.
Assuming you use 2.4.
You can use A0 -A2 with some trix.
In def.h find this.

Code: Select all

#elif defined(HELICOPTER)

Change the row after to

Code: Select all

#define PRI_SERVO_FROM   1
This will activate all servo outputs.

In Output you need to transfer the data to correct servo port.
search for #ifdef HELI_

You need to add a line last in the mixer .
To use A2..

Code: Select all

servo[2] = servo[3];

Add it on a new line
Line 1426 if you use 120 swash
Line 1436 if you use 90 swash

Good luck
Patrik

Post Reply