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
Post Reply
User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Helicopter integration

Post by Hamburger »

Hi,
me thinks it is about time to integrate Helicopter support into MWii. We have the thread here
viewtopic.php?f=7&t=611&hilit=helicopter plus the special version PatrikE has in his branch.
Over at RCG this thread http://www.rcgroups.com/forums/showthread.php?t=1592666 and software from leadfeather.
Anything else?

My first hardware for doing the integration will be a 450 sized flybared CP heli and a Crius lite board - both collecting dust too long already.
Before I begin I would like to compile your valuable input on this topic - fire away.
Thanks, Hamburger

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

Re: Helicopter integration

Post by PatrikE »

Hi Hamburger,

I have made a few cahanges in the HeliMode.
The servosettings in made same way as for Airplane in config.h.
But is using Max and Min for servotravel.

Maby i should try to fix my 450 to.
I also have a old KALT baron 22cc Gasser but it suffers from huge vibrations after a bad "Landing".
But i don't have big hope for it because spares is hard to find for old machines.

/Patrik

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

Re: Helicopter integration

Post by Hamburger »

Patrik,

yes, obtaining parts for old hardware gets difficult too soon. Economically you are encouraged to buy a new one!

I have not yet looked at your code nor at the 'leadfeather code'.
I like the idea of reusing common parts from airplane mode.

Is the code archive in your branch in the rep your latest code?

Hamburger

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

Re: Helicopter integration

Post by PatrikE »

I keep the latest confirmed version in the rep.
The helipart has not really been tested IRL by me only on the desktop.
It was requested by some people but i haven't seen if anyone really tested it.

I don't know about the code leadfeather have used.

I will add flaps for airplane to the rep this evening. Thats the latest changes but will not effect heli.

The Airplaneguide is qite popular.
It have almost 600 visits last month...

/Patrik

User avatar
howardhb
Posts: 189
Joined: Tue Oct 11, 2011 7:10 pm
Location: Port Elizabeth, South Africa

Re: Helicopter integration

Post by howardhb »

Hamburger, I recommend getting rid of the fly-bar before you start :shock:
If left on, it will "fight" what Multiwii is trying to achieve.

Converting the head to Flybar-less is really simple.
Attached is a document I wrote that describes exactly how to do it.
I've got a $29 Flybarless unit (CopterX Cx1000) which has nothing more than an atmega48 and an ITG3200, no acellerometers.
I've also got a $220 BeastX fylbarless unit.... they fly exactly the same.
So, I'll be keen to try this heli version of Multiwii. :mrgreen:

H.
Attachments
Howardhb - How to convert a HK450Pro head to Flybarless.zip
How to make a flybarless rotor-head
(96.58 KiB) Downloaded 536 times

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

Re: Helicopter integration

Post by Hamburger »

Hi Howard,
yes, I will convert to FBL. Though it might be tempting to try and compete with helicommand for flybared stabilization.
Thanks for the how-to. And it is very encouraging to hear about your first hand experience and comparison to well respected commercial product.
Btw, what software do you run on the atmega48?
Hamburger

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

Re: Helicopter integration

Post by PatrikE »

The fly-bar already do the work of the Gyro.
On a heli With fly-bar I think the Levelmode with Acc will be most usable.

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

Re: Helicopter integration

Post by Hamburger »

Would it be possible to simulate FBL by removing the weights and paddles from the cflybar?
Or is that too much mechanics between swashplate and blades still?

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

Re: Helicopter integration

Post by PatrikE »

Well there's always one way to find out isn't it?' :twisted:

Like NIKE says....
JUST DO IT.......

User avatar
howardhb
Posts: 189
Joined: Tue Oct 11, 2011 7:10 pm
Location: Port Elizabeth, South Africa

Re: Helicopter integration

Post by howardhb »

Hamburger wrote:Would it be possible to simulate FBL by removing the weights and paddles from the cflybar?
Or is that too much mechanics between swashplate and blades still?


It will be un-flyable!

There exists a phenomenon called Gyroscopic Precession. (Heli rotor blades become a gyroscope, once spinning) http://helicopterflight.net/gyroscopic%20P.htm
This is where (when setting up a flybarless head) the "phasing" is set, to ensure that the activation points (ball links from each servo) are 90 degrees to the rotor blade.
This setting must be done perfectly, or else, roll inputs will couple some pitching action and vice versa.
H.

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

Re: Helicopter integration

Post by PatrikE »

Iw'e udated the branch with more settings for collective pitch.

http://code.google.com/p/multiwii/source/browse/#svn%2Fbranches%2FPatrikE

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

Re: Helicopter integration

Post by Hamburger »

I have not looked at the latest changes. It is difficult to diff your entire heli branch against what?

Is it worth taking both pitch and throttle signals from the rx? Then user can set both curves in tx as usual for cp helis.
Edit: I see you take the collective-pitch signal from the rx already.

Maybe I should drop this entire issue and let you integrate HELICOPTER into the main branch. So I wil attach the diffs of the leadfeather chopper version against v1.9. Please have a look and evaluate what could be useful.
So far I see
- uses aux2 to inflight tune level
- correctly addresses motors as motors (I understand your using the servo mechanism for both servo+motor saves some duplication, but it is not clean)
- computes additional outputs for additional tail motor
Attachments
v1.9-vs-chopper-diffs.zip
leadfeather mods - the diff
(3.97 KiB) Downloaded 273 times

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

Re: Helicopter integration

Post by PatrikE »

Hi Hamburger,

You can compare my branch with V2.0
I use 2.0 because i want the Android configurator for fileld tests.

I compared leadfeather chopper with mine and the only thing actually diff is.
- AUX autolevel adjustment.
- Motor + tailmotor controll.
- Most of the setting is done in config in my version.
- Easier to understand my Mixtable.(less parameters)

When i integrated airplane i had the option to choose between Esc or ThrottleServo .
But Alex removed it when he integrated it.
Standard Servos don't like 490Hz but all esc's can handle 50Hz.

It,s easy to reintegrate motorcode if it's Ok with Alex.
Servo[7] is programmed to behave same way as motor[0] With the Arming and Disarming.

The tailmotor can be used same way as tailservo and the offset can be done in Confih.h
But it need to be included in the arm function.


I will try to make a descrition how to setup things to night.

Cheers Patrik

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

Re: Helicopter integration

Post by PatrikE »

Fixed some bugs and modified the mixtable to work same way as for multirotors.

Code: Select all

//           HeliXPIDMIX ( Collective, Pitch/Nick, Roll ) Change sign to invert
 /************************************************************************************************************/ 
    #ifdef HELI_120_CCPM
      servo[3]  =  HeliXPIDMIX( +1, -1  , +0) ;   //    NICK  servo
      servo[4]  =  HeliXPIDMIX( +1, +1/2, +1) ;   //    LEFT servo
      servo[6]  =  HeliXPIDMIX( +1, +1/2, -1) ;   //    RIGHT  servo     
   #endif
 
 /************************************************************************************************************/   
     #ifdef HELI_90_DEG               
      servo[3]  = HeliXPIDMIX( +0, +1, -0) ;       //     NICK  servo
      servo[4]  = HeliXPIDMIX( +0, +0, +1) ;       //     ROLL servo
      servo[6]  = HeliXPIDMIX( +1, +0, +0) ;       //     COLLECTIVE  servo 
     #endif   

To set up the mix.
The mix contains...
HeliXPIDMIX( Collective, Pitch/Nick, Roll )
HeliXPIDMIX( +1, -1 , +0 ) = ( +Collective, -Nick, No Roll ).
If any function is inverted change sign /+- in the mix.


Settings in config is

Code: Select all

//***********************************************************************************************//
//****************************** !!!!  Hellicopter Settings  !!!! *******************************//
//***********************************************************************************************//
// Select the Channel to controll CollectivePitch.
#define CollectivePitch AUX1   // Selectable channels: ROLL,PITCH,THROTTLE,YAW,AUX1,AUX2,AUX3,AUX4

// Set Maximum available movement for the servos. Depending on modell.
#define SERVO_ENDPOINT_HIGH {2000,2000,2000,2000,2000,2000,2000,2000};
#define SERVO_ENDPOINT_LOW  {1020,1020,1020,1020,1020,1020,1020,1020};

// Limit the range of Collective Pitch. 100% is Full Range each way and position for Zero Pitch
#define CollectiveRange { 80, 1500, 80 }// {Min%, ZeroPitch, Max%}.
#define YAWCenter             1500      // Use servo[5] SERVO_ENDPOINT_HIGH/LOW for the endpoits.
#define YAWMOTOR                0       // If a motor is use as YAW Set to 1 else set to 0.

// Limit Maximum controll for Roll & Nick  in 0-100% 
#define ControllRange   { 50, 50 }      //  { ROLL,PITCH }
//*************************************************************************************************//


* Select your coletive channel.
* Make shure servos endpoints match your model.
* Setup collective range and the value for Neutral pitch.
- The range will be +/- from Neutral pitch value.

I still handle the motor as servos.
But the tailrotor will handeled as a engine if #define YAWMOTOR is set to 1.
#define YAWCenter Will set neutral position for the tail.

#define ControllRange Controlls how much Tilt and roll is allowed move.

Most of the settings is normally done in the radio but you should set all maximum rates in the code to enshure the sensors don't exeed the values.

/Patrik

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

Re: Helicopter integration

Post by Hamburger »

Patrik,
you are releasing code updates faster than I can view the diffs atm.
So do you want to do the integration into _shared?
I would then convert some of the compile time options into runtime tunable parameters (via LCDconfig()).
What do you think?

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

Re: Helicopter integration

Post by PatrikE »

I have mergd Helicopter to shared now.
I also made a Howto.
Someone who can setup a heil should not have any problems.
But It probobly need some more explinations for a complete beginner.
HeliGuide

/Patrik

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

Re: Helicopter integration

Post by Alexinparis »

Hi,
That sounds nice. we want to see vids now ;)

about the code, please try to respect
- the indent: multiple of 2 spaces, not 3 or 5
- the # function or variable with all uppercase letter: #define UPPERCASE
- the variable definition: first letter of the variable lowercase, the first letter of the second term is Uppercase, for instance: int upperCase;

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

Re: Helicopter integration

Post by Hamburger »

I cannot get it to work - seems a misunderstanding on my part. I use a crius lite board (with 328p) for this.
My TX and RX are spektrum 6 channel in Heli mode - ROLL,PITCH,THROTTLE,YAW,AUX1,Collective-Pitch .
I use AUX1 for activating Level mode.

what works for me:
For testing purposes I defined copter-type QuadX and then I can see all 6 channel inputs behave as expected.

what does not work for me:
for HELI_120_CCPM I set

Code: Select all

#define RCAUXPIN12
#define COLLECTIVE_PITCH      AUX2

Two problems then:
The AUX2-input value stays almost at constant value - definitely not my Collective-Pitch curve from my TX
With that setup I never see proper servo movements for Collective-Pitch inputs from the TX.

Another thing:
there are now 2 competing options for the D12 pin, I think. Do I have to carefully set both? If so, how?
//#define DISABLE_POWER_PIN
#undef D12_POWER

Very confusing; Also, the descriptions in config.h are not clear to me. Maybe it might help to use one self-explanatory name like USE_D12_TO_POWER_WMP_NOT_INPUT ? I expect this to be a feature that is gradually to fade out as current and future boards/setups should power wmp (if still used) directly.

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

Re: Helicopter integration

Post by PatrikE »

I'm only using PPM and use D2 and have not tested it with Pwm.

The problem is...
D12 is used as servo output by the code..
And #define D12_POWER will do as you say change D12 to 5V out for sensors.
USE_D12_TO_POWER_SENSORS_NOT_INPUT


At the moment it's not possible to use D12 as input.. :cry:
But there's. #define RCAUXPIN8 Available and can be used as AUX2 input with Plane & Heli

Will have to find a workaround with this in def.h

Code: Select all

/**************************************************************************************/
/***************          Some unsorted "chain" defines            ********************/
/**************************************************************************************/

#if defined (AIRPLANE) || defined(HELICOPTER) && defined(PROMINI)
  #if defined(D12_POWER)
    #define SERVO_4_PINMODE            ;  // D12
    #define SERVO_4_PIN_HIGH           ;
    #define SERVO_4_PIN_LOW            ;
  #else
    #define POWERPIN_PINMODE           ;
    #define POWERPIN_ON                ;
    #define POWERPIN_OFF               ;
  #endif
  #if defined(RCAUXPIN12)
    #define SERVO_4_PINMODE            ;  // D12
    #define SERVO_4_PIN_HIGH           ;
    #define SERVO_4_PIN_LOW            ;
    #define POWERPIN_PINMODE           ;
    #define POWERPIN_ON                ;
    #define POWERPIN_OFF               ;
  #endif
#endif


Something to think about.
And should be better explained.

Only thing is that i dont think config.h should be a instruction book like it is today!..
Almost 50% of the text is Information today.
It would be better to place links to a wiki...
It is a :twisted: to try to find things in all text as it is..

/Patrik

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

Re: Helicopter integration

Post by Hamburger »

Hi again,
I am making progress slowly.
What I miss is a servoTrim to level the servoArms. On my TX that is called SubTrim. I think I will have to add this and make it configurable via LCDconfig menu.
Also I have to change some servo orientations. Now changing the signs of values that go into HeliXPIDMIX somewhere deep inside of Output.pde is not user friendly. We should provide a more generic setup option like the GYRO_ORIENTATION macro that goes into config.h.

Do you have any hint which PID values I should start with? From my experience with FlyingWing, using the MWii stock settings is way too over responsive / twitchy.

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

Re: Helicopter integration

Post by PatrikE »

OK..
I was just happy to get everything to work at a first stage... ;)

But to make it more userfriendly...
Would it be possible to do something like this in config.

Code: Select all

#define SERVO_NICK   { +1, -1  ,+0 }  // {Collective,Nick,Roll}
#define SERVO_LEFT   { +1, +1/2,+1 }
#define SERVO_RIGHT  { +1, +1/2,-1 }


And change the MIX in output.

Code: Select all

  static int8_t nickMix[3] =SERVO_NICK;
  static int8_t leftMix[3] =SERVO_LEFT;
  static int8_t rightMix[3]=SERVO_RIGHT;

  //              ( Collective, Pitch/Nick, Roll ) Change sign to invert
  /************************************************************************************************************/
  #ifdef HELI_120_CCPM
  /*
    servo[3]  =  HeliXPIDMIX( +1, -1  , +0) ;   //    NICK  servo
    servo[4]  =  HeliXPIDMIX( +1, +1/2, +1) ;   //    LEFT servo
    servo[6]  =  HeliXPIDMIX( +1, +1/2, -1) ;   //    RIGHT  servo 
   */
    servo[3]  =  HeliXPIDMIX( nickMix[0], nickMix[1], nickMix[2]) ;   //    NICK  servo
    servo[4]  =  HeliXPIDMIX( leftMix[0], leftMix[1], leftMix[2]) ;   //    LEFT servo
    servo[6]  =  HeliXPIDMIX( rightMix[0],rightMix[1],rightMix[2]) ;  //    RIGHT  servo       
  #endif


It compiles but i have no possibillity to test irl right now.
Maby the fraction must be changed to float value?
From 1/2 to 0.5 :?:

/Patrik

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

Re: Helicopter integration

Post by PatrikE »

By the way...
I dont think 1/2 will match static int8_t......

But it was a Idé.
Maby use procent in stead -100 to +100.

Sugestions how to make it is wecome...

SamitV
Posts: 10
Joined: Mon May 21, 2012 11:07 am

Re: Helicopter integration

Post by SamitV »

Hi Patrik...!
I am using a Flyduino board ...
http://flyduino.net/bilder/Flyduino_big.jpg
Pinouts:
http://static.rcgroups.net/forums/attac ... -06-11.jpg
and FreeIMU
http://www.varesano.net/files/imagecach ... uction.jpg

The heli is a TRex 500 clone.

The problem that I'm facing is, I'm not able to get the nick servo to work. The Left Servo(Pitch), Right servo(Aileron) and yaw(rudder) are working fine.
If I am not wrong, the nick servo is supposed to be connected to D37. But this board uses it for the IMU. There are other pins free though...Pin 7 to 11. How do I get to work on one these pins.
Help would be truly appreciated... :)

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

Re: Helicopter integration

Post by PatrikE »

Your problem is that D37 is used as powerpin for the sensors.

You can modify the code to use all available servos.
Change PRI_SERVO_FROM 4 to 0
In def.h

Code: Select all

#elif defined(HELICOPTER)
  #define NUMBER_MOTOR     0
  #define PRI_SERVO_FROM   4 // use servo from 4 to 8
  #define PRI_SERVO_TO     8


To move Nick to pin A0
In output change to servo[0] in the mixtable.

Code: Select all

 //From
    servo[3]  =  HeliXPIDMIX( (nickMix[0]*0.1) , nickMix[1]*0.1, nickMix[2]*0.1) +Mid[3] ;   //    NICK  servo
// to
    servo[0]  =  HeliXPIDMIX( (nickMix[0]*0.1) , nickMix[1]*0.1, nickMix[2]*0.1) +Mid[0] ;   //    NICK  servo

SamitV
Posts: 10
Joined: Mon May 21, 2012 11:07 am

Re: Helicopter integration

Post by SamitV »

Wow thanku so much Patrik.. Will test it right away... Is there any chance by which servo[3] can output data to pins 7,8,9,or 10 (flyduino MEGA board)? These pins are not used for anything I guess. Because right now A0(44) A1(45) A2(46) are being used by the camera gimbal... :(

Katch
Posts: 280
Joined: Thu Aug 04, 2011 1:44 pm

Re: Helicopter integration

Post by Katch »

Is this development still focused on using a tail motor or is there support for belt tails?

SamitV
Posts: 10
Joined: Mon May 21, 2012 11:07 am

Re: Helicopter integration

Post by SamitV »

Its belt driven.

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

Re: Helicopter integration

Post by Hamburger »

Katch wrote:Is this development still focused on using a tail motor or is there support for belt tails?

both.

SamitV
Posts: 10
Joined: Mon May 21, 2012 11:07 am

Re: Helicopter integration

Post by SamitV »

The tail rotor is belt driven from the main rotor.

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

Re: Helicopter integration

Post by Hamburger »

what I meant was you can either drive a tail yaw servo or an ESC to control tail motor rpm.

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

Re: Helicopter integration

Post by PatrikE »

It's selectable in Config.

Code: Select all

    #define YAWMOTOR                0       // If a motor is useed as YAW Set to 1 else set to 0.


Set to 1 if you use a tailmotor.( Controlled by ESC )
Or 0 If you use Belt driven. ( Controlled by servo )

SamitV
Posts: 10
Joined: Mon May 21, 2012 11:07 am

Re: Helicopter integration

Post by SamitV »

I am so sorry Hamburger.. I was sooo lost in connecting the pins and testing.. I thought Patrik asked me if it was belt/motor driven... :( (didn't notice the name). :(

SamitV
Posts: 10
Joined: Mon May 21, 2012 11:07 am

Re: Helicopter integration

Post by SamitV »

Patrik, it is belt driven. So it is set to 0. I tried what you said earlier, but still, the Nick servo doesn't work.

Katch
Posts: 280
Joined: Thu Aug 04, 2011 1:44 pm

Re: Helicopter integration

Post by Katch »

Hamburger wrote:what I meant was you can either drive a tail yaw servo or an ESC to control tail motor rpm.


that's what I wanted to know.

Might be time to rebuild the head on my 450 then.

SamitV
Posts: 10
Joined: Mon May 21, 2012 11:07 am

Re: Helicopter integration

Post by SamitV »

In the Def.h does this have anything to do with assigning nick servo out??

Code: Select all

#define ISR_UART                   ISR(USART0_UDRE_vect)
 
  #define SERVO_1_PINMODE            pinMode(34,OUTPUT);pinMode(44,OUTPUT); // TILT_PITCH - WING left
  #define SERVO_1_PIN_HIGH           PORTC |= 1<<3;PORTL |= 1<<5;
  #define SERVO_1_PIN_LOW            PORTC &= ~(1<<3);PORTL &= ~(1<<5);
  #define SERVO_2_PINMODE            pinMode(35,OUTPUT);pinMode(45,OUTPUT); // TILT_ROLL  - WING right
  #define SERVO_2_PIN_HIGH           PORTC |= 1<<2;PORTL |= 1<<4;
  #define SERVO_2_PIN_LOW            PORTC &= ~(1<<2);PORTL &= ~(1<<4);
  #define SERVO_3_PINMODE            pinMode(33,OUTPUT); pinMode(46,OUTPUT); // CAM TRIG  - alt TILT_PITCH
  #define SERVO_3_PIN_HIGH           PORTC |= 1<<4;PORTL |= 1<<3;
  #define SERVO_3_PIN_LOW            PORTC &= ~(1<<4);PORTL &= ~(1<<3);
  #define SERVO_4_PINMODE            pinMode (37, OUTPUT);                   // new       - alt TILT_ROLL
  #define SERVO_4_PIN_HIGH           PORTC |= 1<<0;
  #define SERVO_4_PIN_LOW            PORTC &= ~(1<<0);
  #define SERVO_5_PINMODE            pinMode(6,OUTPUT);                      // BI LEFT
  #define SERVO_5_PIN_HIGH           PORTH |= 1<<3;
  #define SERVO_5_PIN_LOW            PORTH &= ~(1<<3);
  #define SERVO_6_PINMODE            pinMode(2,OUTPUT);                      // TRI REAR - BI RIGHT
  #define SERVO_6_PIN_HIGH           PORTE |= 1<<4;
  #define SERVO_6_PIN_LOW            PORTE &= ~(1<<4);
  #define SERVO_7_PINMODE            pinMode(5,OUTPUT);                      // new
  #define SERVO_7_PIN_HIGH           PORTE |= 1<<3;
  #define SERVO_7_PIN_LOW            PORTE &= ~(1<<3);
  #define SERVO_8_PINMODE            pinMode(3,OUTPUT);                      // new
  #define SERVO_8_PIN_HIGH           PORTE |= 1<<5;
  #define SERVO_8_PIN_LOW            PORTE &= ~(1<<5);
#endif


For example:

From this

Code: Select all

#define SERVO_4_PINMODE            pinMode (37, OUTPUT);                   // new       - alt TILT_ROLL
  #define SERVO_4_PIN_HIGH           PORTC |= 1<<0;
  #define SERVO_4_PIN_LOW            PORTC &= ~(1<<0);


to

Code: Select all

#define SERVO_4_PINMODE            pinMode (8, OUTPUT);                   // new       - alt TILT_ROLL
  #define SERVO_4_PIN_HIGH           PORTC |= 1<<0;
  #define SERVO_4_PIN_LOW            PORTC &= ~(1<<0);
Last edited by SamitV on Mon May 21, 2012 4:10 pm, edited 1 time in total.

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

Re: Helicopter integration

Post by PatrikE »

Or you can power your sensorboard from a 5V and use the pin for servo!..
#define DISABLE_POWER_PIN

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

Re: Helicopter integration

Post by PatrikE »

Another QickFix ..
around Row 1020 In output.pde

Code: Select all

.......
.......
.......
    for(uint8_t i=3;i<8;i++){
      servo[i]  = constrain( servo[i], servoEndpiont[i][0], servoEndpiont[i][1] );
    }
    servo[0]=servo[3]; // QickFix to change servoPin
  #endif
 
// End of PatrikE Experimentals
/*************************************************************


servofrom must be set in def.h first.

SamitV
Posts: 10
Joined: Mon May 21, 2012 11:07 am

Re: Helicopter integration

Post by SamitV »

Woow Patrik.....! :D It finally worked... I also did Gyro smoothing (my values GYRO_SMOOTHING {60, 60, 20}). I just can't stop jumping and dancing around... :P. Thank you so much...

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

Re: Helicopter integration

Post by PatrikE »

SamitV wrote:It finally worked... just can't stop jumping and dancing around... :P.


just stop jumping and dancing and give us a flight report... ;) 8-)

Btw...
Witch mod did you succsed with? :?:

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

Re: Helicopter integration

Post by Hamburger »

Hi Patrik,
I did edit some code for HELI in _shared:
- HELI: added servo trim to tail servo
- HELI: extend servo trim to int16
- HELI ccpm120: make servo trims accessible via LCD config menu
- HELI: store servo trims in eeprom
!! new eeprom version number; forces reset of config; may require eeprom clear

Also the problem with servo values jumping (overrun?) seems to be fixed now, could not reproduce any more.

SamitV
Posts: 10
Joined: Mon May 21, 2012 11:07 am

Re: Helicopter integration

Post by SamitV »

PatrikE wrote:just stop jumping and dancing and give us a flight report... ;) 8-)
Btw...
Witch mod did you succsed with? :?:


:lol:

I used the one which you posted last :

Code: Select all

.......
.......
.......
    for(uint8_t i=3;i<8;i++){
      servo[i]  = constrain( servo[i], servoEndpiont[i][0], servoEndpiont[i][1] );
    }
    servo[0]=servo[3]; // QickFix to change servoPin
  #endif
 
// End of PatrikE Experimentals
/*************************************************************


I used the camera trigger pin A2/46 ( I will not need this ) instead of A0/44 ( A0/44 & A1/45 are being used by the cam gimbal ). So now all the servos (Right, Left, Nick and Rudder) respond to the IMU.

The servos jittered initially, but after changing the values of GYRO_SMOOTHING to {60, 60, 20} it had no problem.
I haven't tried flying it yet... But few things I noticed with the main rotor blades removed for the trials:

I had to adjust the swash levels in the TX(Airtronics SD10-G) with tweeking still pending. I tried to change in config.h, but nothing happens.
After arming the ESC, and increasing throttle... the collective works exactly as expexted. So no problem in that. But after a few seconds, only the Nick servo jumps and retains position. This happened a few times. I guess the problem is with the I2C error 4 in the GUI.

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

Re: Helicopter integration

Post by Hamburger »

Houston - got a problem - not:
usually happens during setting up and pre-flight check
Symptom:
when not armed, with collective around 50% (0 degree pitch) and above, the swash gets sticky when applying full cyclic input (nick and/or roll).
After releasing cyclic TX input (spring loaded snap back to center), the swash servos stick in their extreme position for approx. 0.5 seconds before returning to level. Also the same LED is rapidly blinking which indicates armed status.
Explanation:
for cp-helicopters you setup a progressive throttle curve like 0-70-95-95-100. Effectively this gives 95% throttle signal when TX throttle/pitch stick is at middle.
When moving the nick/roll stick to their min/max values you execute a level-trim step. Thus the led flicker as confirmation.
what to do:
either avoid it by using d/r on your TX and limit nick/roll inputs to 90%,
or ignore it and at end of setup/check issue a acc-calib command to reset the level and erase the trim.

This took me some time to figure out, so I thought to share for others to spare you the confusion.
@Patrik: maybe this should go into the Heli howto/FaQ

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Helicopter integration

Post by crashlander »

Hello,
that is probably the same issue that I've noticed last summer with Patrick's first CP heli versions (increased cycle time and servo movement delay).
The same issue also occurs with pure gimbal and (probably) with all model types that don't need explicit arming (airplane?, flying wing?).
And since basic MWII setup starts with setting TX endpoints from 1000 to 2000 it will probably be problematic for most users.

Regards Andrej

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

Re: Helicopter integration

Post by Hamburger »

Success:
I converted my e-razor450 to FBL and a clone tail and installed the crius lite together with an OLED as a stabi system.
Together with a friend who is an experienced rc-heli pilot we used two lipos to maiden and initially tune it.
He says the heli in acro mode feels different from what he knows but he only flys flybared helis.
Level mode he knows from multicopter flying but says it does feel wrong for a heli.
We got acro and level mode dialed in. According to him it does not feel perfect yet; the tail has no real heading hold as with a typical heli gyro.
But the copter is definitely flyable now. I will have to add some 30% expo on nick and roll and should be good to go and learn heli-flying. The level mode should help me get out of trouble.

For software I use r809 with these settings:

Code: Select all

#define HELI_120_CCPM
#define COLLECTIVE_PITCH      AUX2 //THROTTLE
// Set Maximum available movement for the servos. Depending on modell.
#define SERVO_ENDPOINT_HIGH {2000,2000,2000,1900,1900,1900,1900,2000};
#define SERVO_ENDPOINT_LOW  {1020,1020,1020,1120,1120,1120,1120,1020};
#define SERVO_OFFSET     {  0,   0,   0,  0,   0,   0,  0,   0 } // Adjust Servo MID Offset & Swash angles
//  0,1,2 nn
//  3 nick
//  4 left
//  5 tail = yaw servo
//  6 right
//  7 motor

// Limit the range of Collective Pitch. 100% is Full Range each way and position for Zero Pitch
#define COLLECTIVE_RANGE { 12, 1500, 80 }// {Min%, ZeroPitch, Max%}.
#define YAW_CENTER             1500      // Use servo[5] SERVO_ENDPOINT_HIGH/LOW for the endpoits.
#define YAWMOTOR                0       // If a motor is use as YAW Set to 1 else set to 0.

// Limit Maximum controll for Roll & Nick  in 0-100%
#define CONTROLL_RANGE   { 100, 100 }      //  { ROLL,PITCH }
// Servo mixing for heli 120 Use 1/10 fractions (ex.5 = 5/10 = 1/2)
//                   {Coll,Nick,Roll}
#define SERVO_NICK   { -10, +10, +0 }
#define SERVO_LEFT   { -10, -5, -10 }
#define SERVO_RIGHT  { +10, +5, -10 }

#define I2C_SPEED 400000L

//#define CRIUS_LITE home-made (180 deg rotated):
#define ITG3200 // gyro
#define ADXL345 // acc
#define GYRO_ORIENTATION(X, Y, Z) {gyroADC[ROLL] = -Y; gyroADC[PITCH] = X; gyroADC[YAW] = -Z;}
#define ACC_ORIENTATION(X, Y, Z)  {accADC[ROLL]  = X;  accADC[PITCH]  = Y; accADC[YAW]  =  Z;}

#undef INTERNAL_I2C_PULLUPS

// 2

#define YAW_DIRECTION -1

#undef ALLOW_ARM_DISARM_VIA_TX_ROLL
#define ALLOW_ARM_DISARM_VIA_TX_YAW

// 3

  #define RCAUXPIN8
  #undef D12_POWER
  #undef DISABLE_POWER_PIN

// 4

  //#define ITG3200_LPF_256HZ     // This is the default setting, no need to uncomment, just for reference
  //#define ITG3200_LPF_188HZ
  #define ITG3200_LPF_98HZ
  //#define ITG3200_LPF_42HZ
  //#define ITG3200_LPF_20HZ
  //#define ITG3200_LPF_10HZ      // Use this only in extreme cases, rather change motors and/or props

  #define GYRO_SMOOTHING {40, 40, 30}

// 5

//#define FAILSAFE
#define FAILSAVE_DELAY     15
#define FAILSAVE_THR0TTLE  (MINTHROTTLE + 300)    // Throttle level used for landing - may be relative to MINTHROTTLE - as in this case

#define LCD_CONF
#define LCD_CONF_AUX
#define SUPPRESS_LCD_CONF_AUX34

#define OLED_I2C_128x64
#define SUPPRESS_OLED_I2C_128x64LOGO

#define LCD_TELEMETRY
#define LCD_TELEMETRY_AUTO "12345"
#define VBATREF 24 // 12.6V - VBATLEVEL1_3S  (for me = 126 - 102 = 24)

#define VBAT 
#define VBATSCALE     79 // mystery 20A ESC/BEC, war HK-SS-ESC:78 //79 //110 // mein spezieller Spannungsteiler 3S
#define VBATLEVEL1_3S 102 // 10.2V unter Last
#define VBATLEVEL2_3S 100 // 10.0V unter Last
#define VBATLEVEL3_3S 98  // 9.8V unter Last
#define NO_VBAT       75 // Avoid beeping without any battery

#define POWERMETER_SOFT
#define PLEVELDIVSOFT 10000
#define PLEVELDIV 1540
#define PSENSORNULL 504

// 6

#define ACC_LPF_FACTOR 1000

#define LOG_VALUES 2
#define DEBUG

//#define LCD_TELEMETRY_FREQ 11       // to send telemetry data over serial 23 <=> 60ms <=> 16Hz (only sending interlaced, so 8Hz update rate)
#define LCD_TELEMETRY_AUTO_FREQ 1667 // to step to next telemetry page 667 <=> 2s

rc-rates for nick and roll in the TX to 50%
tweaked settings via OLED display:
GYRO-smoothing 55, 55, 30
Servo Trims: N L T R: 20, 30, -80, 40
Attachments
screenshot.jpeg
20120525_110709-small.jpg
20120525_110602-small.jpg
PIDs
PIDs

User avatar
howardhb
Posts: 189
Joined: Tue Oct 11, 2011 7:10 pm
Location: Port Elizabeth, South Africa

Re: Helicopter integration

Post by howardhb »

Awesome!
Flybarless heli's, like multicopters MUST have perfectly ballanced rotors. Vibration will force you to increase damping and derease gain. Also, flynbarless heli main-blades must have perfectly matched CG, ie: each blade must have it's centre of mass at the same distance between the blade mounting hole and the blade tip. Do this by putting the blade ontop of a round shaft on a flat surface and roll the round shaft untill the blade see-saw's. Make sure both blade see-saw at the same point.(Add tape at the tip) Once that is done, ballance the blades the normal way. It. Makes ALL the difference!

Another thing is to make sure the cyclic servo's move at least 80 degrees (+-40) to produce the required collective pitch range
(+- 12 degrees) adjust the length of servo arm to suit. This gives the contoll alogorithm "room" to work.

I see only one wire from your "Orange" Rx. What PPM sum are you using?
I also use "Orange" receivers (with satellite rx) but with simple 6 diodes "or" to a PNP transistor direct to throttle. On Multiwii.
This makes nice clean sqaure wave but inverts the PPM signal. Simple software mode fixes that!
attach interrupt FALLING!
If you wish I can send you my modified RX code

Edit: looking closer I see all channel wires to the Rx channels.


H.
Last edited by howardhb on Sat Jun 02, 2012 6:38 pm, edited 1 time in total.

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

Re: Helicopter integration

Post by Hamburger »

yes, it is simple 6chan setup. I am not aware the orange rx can do ppm?
I will go and do the dynamic blade balancing like you described. Static balancing was ok with 23,01 and 23,11 gramm.
From leadfeather's description the need for such high gyro smoothing seems to be common with Helicopters. Not sure why - maybe it is just so much more rotating masses than with multicopters.

User avatar
howardhb
Posts: 189
Joined: Tue Oct 11, 2011 7:10 pm
Location: Port Elizabeth, South Africa

Re: Helicopter integration

Post by howardhb »

Simple PPM sum
Simple PPM sum

Orange rx can' give ppm sum, but with simple inexpensive converter.

Video your results please!

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

Re: Helicopter integration

Post by Hamburger »

@Patrik

with current helicopter code using servo[7] for driving motor, powermeter code is broken; same for using code to drive wii-esc via EXT_MOTOR_RANGE . Maybe other functionality as well on the same basis, I have not investigated further? This does apply to all other copter types (heli 90/120, airplane, single/duocopter) using servo[] for motor driving.
Do we stand a chance to easily 'fix' that, so those copter types will use motor[] and NUMBER_MOTOR like other copter types do?
I would not want to insert special code for this servo/motor special case for various features which rely on the motor definition and motor driving.

What do you think?

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

Re: Helicopter integration

Post by PatrikE »

Single/Duocopter uses motor[] same way as multis.. so no probs there.

Heli 120/90 and airplane use servo[7] To eleminate the need of expensive digial servos for IC motors.

I have not looked at the EXT_MOTOR_RANGE and isn't shure what it do.

A quick fix is to move to motor[].
With motor[] you get 490Hz and is ok for most esc's and digital servos.
But i would like to keep the support for 50Hz Analog servos on throttle.

The best would be if you can select servo/motor in config.
But i don't know enough about the servo/motor coding to fix it.

Sorry! I have no good solution

// Patrik

palton
Posts: 48
Joined: Fri Sep 02, 2011 4:06 pm

Re: Helicopter integration

Post by palton »

As I have understood that EXT_MOTOR_RANGE extends the pwm range to increase from 125 steps resolution to 250 steps resolution, for higher resolution with ESC flashed with wii-esc software with 250 steps resolution.

Post Reply