v2.1- Servo stretching 180 degrees?

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download

v2.1- Servo stretching 180 degrees?

Postby RCvertt » Thu Oct 04, 2012 6:32 pm

Does MultiWii v2.1 allow servo movement of 180 degrees?
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby Hamburger » Thu Oct 04, 2012 8:50 pm

Mwii does not know about servo angles.
You must get a servo that has 180deg rangle range and then it should just work.
User avatar
Hamburger
 
Posts: 2557
Joined: Tue Mar 01, 2011 2:14 pm
Location: air

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Thu Oct 04, 2012 11:34 pm

Thanks but it should be possible without the need for a special servo. All servos are capable of 180 movement, or close to it, if a servo stretcher stretches the signal. If we can buy off the shelf devices that can stretch a regular servo from 90 to 180 degrees then why can't we do it in the MultiWii code?

Cass was able to stretch the 1.7 MultiWii servo code for me. You can see a video of it here and his code if you look at the modified ISR part...
http://www.rcgroups.com/forums/showpost ... stcount=57

His explanation of how he stretched the code is here...
http://www.rcgroups.com/forums/showpost ... tcount=137


These are the major parts of the v1.7 code that he either changed or modified that I am aware of. This might not be all of it...
Code: Select all


static uint8_t servoSpeed[6] = {5,5,5,5,5,5}; // servo 0,1,2,3,4,5  range is 1 to 40 with 1 being the slowest movement, 10 works well     //cass3825- Default is all servos set to a speed of 5                                          //QTR- Set servo 3 speed with {0,0,10,0,0,0}       
static uint8_t stretch = 0b00111110; // servo xx543210    //QTD- servo stretching //Boolean for setting each servo [6][5][4][3][2][1][0] on or off. This "0b0001011" sets servo[3] servo[1] servo [0] on for stretching.            //QTR Set servo 3 for stretching with (0b00001000)                             
static uint8_t slow    = 0b00000000; // servo xx543210    //QTD- servo speed      //Boolean for turning on servo speed adjustment.           


ISR(TIMER0_COMPA_vect) {                                                                                             //QTD- Increased 180 degree servo range by cass3825.
  static uint8_t state = 0;
  static uint8_t count;
  if (state == 0) {
    //http://billgrundmann.wordpress.com/2009/03/03/to-use-or-not-use-writedigital/
    #if defined(TRI) || defined (BI)
      DIGITAL_SERVO_TRI_HIGH
    #endif
    if (stretch & 1<<0) OCR0A+= 125; // 500 us
    else OCR0A+= 250; // 1000 us
    state++ ;
  }
  else if (state == 1) {
    if (carry & (1<<0)) OCR0A+= 250; // another 1000 us
    else OCR0A+= atomicServo[0]; // [0-1020] us
    state++;
  }
  else if (state == 2) {
    if (carry & (1<<0)) OCR0A+= atomicServo[0]; // [0-1020] us
    else {
      #if defined(TRI) || defined (BI)
        DIGITAL_SERVO_TRI_LOW
      #endif
      #if defined(BI)
        DIGITAL_BI_LEFT_HIGH
      #endif
      #if defined(SERVO_TILT) || defined(GIMBAL) || defined(FLYING_WING) || defined(QTD)
        DIGITAL_TILT_PITCH_HIGH
      #endif
      if (stretch & 1<<1) OCR0A+= 125; // 500 us
      else OCR0A+= 250; // 1000 us
      state++; } // skip state 3
    state++;
  }
  else if (state == 3) {
    #if defined(TRI) || defined (BI)
      DIGITAL_SERVO_TRI_LOW
    #endif
    #if defined(BI)
      DIGITAL_BI_LEFT_HIGH
    #endif
    #if defined(SERVO_TILT) || defined(GIMBAL) || defined(FLYING_WING) || defined(QTD)
      DIGITAL_TILT_PITCH_HIGH
    #endif
    if (stretch & 1<<1) OCR0A+= 125; // 500 us
    else OCR0A+= 250; // 1000 us
    state++;
  }
  else if (state == 4) {
    if (carry & (1<<1)) OCR0A+= 250; // another 1000 us
    else OCR0A+= atomicServo[1]; // [0-1020] us
    state++;
  }
  else if (state == 5) {
    if (carry & (1<<1)) OCR0A+= atomicServo[1]; // [0-1020] us
    else {
      #if defined(SERVO_TILT) || defined(GIMBAL) || defined(FLYING_WING) || defined(QTD)
        DIGITAL_TILT_PITCH_LOW
        DIGITAL_TILT_ROLL_HIGH
      #endif
      #if defined(BI)
        DIGITAL_BI_LEFT_LOW
      #endif
      if (stretch & 1<<2) OCR0A+= 125; // 500 us
      else OCR0A+= 250; // 1000 us
      state++; } // skip state 6
    state++;
  }
  else if (state == 6) {
    #if defined(SERVO_TILT) || defined(GIMBAL) || defined(FLYING_WING) || defined(QTD)
      DIGITAL_TILT_PITCH_LOW
      DIGITAL_TILT_ROLL_HIGH
    #endif
    #if defined(BI)
      DIGITAL_BI_LEFT_LOW
    #endif
    state++;
    if (stretch & 1<<2) OCR0A+= 125; // 500 us
    else OCR0A+= 250; // 1000 us
  }
  else if (state == 7) {
    if (carry & (1<<2)) OCR0A+= 250; // another 1000 us
    else OCR0A+= atomicServo[2]; // [0-1020] us
    state++;
  }
  else if (state == 8) {
    if (carry & (1<<2)) OCR0A+= atomicServo[2]; // [0-1020] us
    else {
      #if defined(SERVO_TILT) || defined(GIMBAL) || defined(FLYING_WING) || defined(QTD)
        DIGITAL_TILT_ROLL_LOW
      #endif
      #if defined(CAMTRIG)
        DIGITAL_CAM_HIGH
      #endif
      #if defined(QTD)
        DIGITAL_FAN_DOOR_HIGH
      #endif
      if (stretch & 1<<3) OCR0A+= 125; // 500 us
      else OCR0A+= 250; // 1000 us
      state++; } // skip state 9
    state++;
  }
  else if (state == 9) {
    #if defined(SERVO_TILT) || defined(GIMBAL) || defined(FLYING_WING) || defined(QTD)
      DIGITAL_TILT_ROLL_LOW
    #endif
    #if defined(CAMTRIG)
      DIGITAL_CAM_HIGH
    #endif
    #if defined(QTD)
      DIGITAL_FAN_DOOR_HIGH
    #endif
    state++;
    if (stretch & 1<<3) OCR0A+= 125; // 500 us
    else OCR0A+= 250; // 1000 us
  }
  else if (state == 10) {
    if (carry & (1<<3)) OCR0A+= 250; // another 1000 us
    else OCR0A+= atomicServo[3]; // [0-1020] us
    state++;
  }
  else if (state == 11) {
    if (carry & (1<<3)) OCR0A+= atomicServo[3]; // [0-1020] us
    else {
      #if defined(CAMTRIG)
        DIGITAL_CAM_LOW
      #endif
      #if defined(QTD)
        DIGITAL_FAN_DOOR_LOW
        DIGITAL_RETRACT_HIGH
      #endif
      if (stretch & 1<<4) OCR0A+= 125; // 500 us
      else OCR0A+= 250; // 1000 us
      state++; } // skip state 12
    state++;
  }
  else if (state == 12) {
    #if defined(CAMTRIG)
      DIGITAL_CAM_LOW
    #endif
    #if defined(QTD)
      DIGITAL_FAN_DOOR_LOW
      DIGITAL_RETRACT_HIGH
    #endif
    state++;
    if (stretch & 1<<4) OCR0A+= 125; // 500 us
    else OCR0A+= 250; // 1000 us
  }
  else if (state == 13) {
    if (carry & (1<<4)) OCR0A+= 250; // another 1000 us
    else OCR0A+= atomicServo[4]; // [0-1020] us
    state++;
  }
  else if (state == 14) {
    if (carry & (1<<4)) OCR0A+= atomicServo[4]; // [0-1020] us
    else {
      #if defined(QTD)
        DIGITAL_RETRACT_LOW
        DIGITAL_MOTOR_TILT_HIGH
      #endif
      if (stretch & 1<<5) OCR0A+= 125; // 500 us
      else OCR0A+= 250; // 1000 us
      state++; } // skip state 15
    state++;
  }
  else if (state == 15) {
    #if defined(QTD)
      DIGITAL_RETRACT_LOW                     
      DIGITAL_MOTOR_TILT_HIGH                   
      DIGITAL_BI_LEFT_HIGH                     
    #endif
    state++;
    if (stretch & 1<<5) OCR0A+= 125; // 500 us
    else OCR0A+= 250; // 1000 us
  }
  else if (state == 16) {
    if (carry & (1<<5)) OCR0A+= 250; // another 1000 us
    else OCR0A+= atomicServo[5]; // [0-1020] us
    state++;
  }
  else if (state == 17) {
    if (carry & (1<<5)) OCR0A+= atomicServo[5]; // [0-1020] us
    else {
      #if defined (QTD)
        DIGITAL_MOTOR_TILT_LOW
        DIGITAL_BI_LEFT_LOW                    //AH
      #endif
      count = 6;
      state++; // skip state 18
      OCR0A+= 250; }// 1000 us
    state++;
  }
  else if (state == 18) {
    #if defined (QTD)
      DIGITAL_MOTOR_TILT_LOW
      DIGITAL_BI_LEFT_LOW                      //AH
    #endif
    count = 6; // 6 x 1000 us
    state++;
    OCR0A+= 250; // 1000 us
  }
  else if (state == 19) {
    if (count > 0) count--;
    else state = 0;
    OCR0A+= 250;
  }
}
#endif



 #if defined(SERVO)
    for (i=0; i<6; i++) {
      if (stretch & 1<<i) {
        atomicServo[i] = (slowServo[i]-1000)/2;                      //AH Removed "constrain" part so front servos travel far enough.
        if (atomicServo[i] > 255) {
          carry |= 1<<i;
          atomicServo[i] -= 250; }
        else carry &= ~(1<<i); }
      else atomicServo[i] = (slowServo[i]-1000)/4;
    }
  #endif


static int16_t slowServo[6] = {1500,1500,1500,1500,1500,1500};
volatile uint16_t atomicServo[6] = {250,250,250,250,250,250}; //changed from uint8 to uint16 to allow for servo stretching
static uint8_t carry;


void servoManipulation() {
  uint8_t i;
  for (i=0;i<6;i++) {
    if (slow & 1<<i) {
      if (servo[i] > (slowServo[i] + servoSpeed[i])) slowServo[i] += servoSpeed[i];
      else if (servo[i] < (slowServo[i] - servoSpeed[i])) slowServo[i] -= servoSpeed[i]; }
    else slowServo[i] = servo[i]; }
}

RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby Hamburger » Fri Oct 05, 2012 11:56 am

Ok I sse what you mean.
User avatar
Hamburger
 
Posts: 2557
Joined: Tue Mar 01, 2011 2:14 pm
Location: air

Re: v2.1- Servo stretching 180 degrees?

Postby Jonit » Fri Oct 05, 2012 3:56 pm

This is the same question I was asking here: http://www.multiwii.com/forum/viewtopic.php?f=13&t=2487
User avatar
Jonit
 
Posts: 37
Joined: Sat May 12, 2012 10:12 pm
Location: Slovakia

Re: v2.1- Servo stretching 180 degrees?

Postby timecop » Fri Oct 05, 2012 4:00 pm

isn't it just a matter of specifying smaller servomin/max, and its done?
I.e. below1000 us...
timecop
 
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: v2.1- Servo stretching 180 degrees?

Postby doughboy » Fri Oct 05, 2012 4:23 pm

timecop wrote:isn't it just a matter of specifying smaller servomin/max, and its done?
I.e. below1000 us...

no, because the pulse is hard coded to start with a base time of 1000us. then the servo time is added to that as a value ranging from 20-1000, giving you an effective pulse width of 1020-2000.

you need to lower the base time, which is what the code above does.

it is possible to increase the range to say (500 to 2500) = 2000 us by modifying the ISR code for servo.

you need to change the base pulse to 500us. since each call to ISR can only handle 1000us (actually 1020), you need to split that time to 2 calls of 1020us each max. So your effective pulse width is from 500 to 2540us.
doughboy
 
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Fri Oct 05, 2012 7:51 pm

doughboy wrote:...you need to change the base pulse to 500us. since each call to ISR can only handle 1000us (actually 1020), you need to split that time to 2 calls of 1020us each max. So your effective pulse width is from 500 to 2540us.
If you can please do that for us with v2.1 it would be greatly appreciated.

I tried to copy the 1.7 code into 1.9 and I couldn't get it to work. There is too much of a difference between the versions for me to understand the ISR code. Version 2.1 has changed even more so there is no chance of me doing it successfully.

If you or someone else can post stretched versions of 2.1 for us, I can compile it up and test it out.

Hamburger wrote:Ok I sse what you mean.
Cool. Doesn't have to be exactly 180 degrees. Most servos have a physical limit of about 170 or so which is plenty for my needs. If you can do this it would be awesome. If you can make it so that just two servos are stretched, that would be enough for now.

Jonit wrote:This is the same question I was asking here: http://www.multiwii.com/forum/viewtopic.php?f=13&t=2487

Sorry didn't see your post. Hopefully one of us will get some code back to test.
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby timecop » Sat Oct 06, 2012 12:57 am

doughboy wrote:
timecop wrote:isn't it just a matter of specifying smaller servomin/max, and its done?
I.e. below1000 us...

no, because the pulse is hard coded to start with a base time of 1000us. then the servo time is added to that as a value ranging from 20-1000, giving you an effective pulse width of 1020-2000.

you need to lower the base time, which is what the code above does.

it is possible to increase the range to say (500 to 2500) = 2000 us by modifying the ISR code for servo.

you need to change the base pulse to 500us. since each call to ISR can only handle 1000us (actually 1020), you need to split that time to 2 calls of 1020us each max. So your effective pulse width is from 500 to 2540us.


ah, that's too bad. not a problem on proper hardware - baseflight can output servo pulses from 0 to any high limit within pulse period with 1us resolution.
So making it output 500..2500 or 3000 or whatever is trivial, just adjusting servo endpoints.
Sorry, can't help with the 8bit version though :)
timecop
 
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Sat Oct 06, 2012 7:50 pm

timecop wrote:...ah, that's too bad. not a problem on proper hardware ... Sorry, can't help with the 8bit version though :)
Too bad you can't help with the 8 bit version. We'll have to wait for someone who is smart enough to figure it out for version (2.1) I guess. There was already someone smart enough to figure it out for version (1.7) using improper 8 bit hardware ;)
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Sat Oct 06, 2012 7:56 pm

RCvertt wrote:
timecop wrote:...ah, that's too bad. not a problem on proper hardware ... Sorry, can't help with the 8bit version though :)
Too bad you can't help with the 8 bit version. We'll have to wait for someone who is smart enough to figure it out for version (2.1) I guess. There was already someone smart enough to figure it out for version (1.7) using improper 8 bit hardware ;)


Why not use a continue rotating servo with some sort of tilt switch or even an analog ACC feed back?
copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Sat Oct 06, 2012 8:13 pm

copterrichie wrote:Why not use a continue rotating servo with some sort of tilt switch or even an analog ACC feed back?
Would rather not use special servos or hack one. Not impossible but they are more difficult to find and usually more expensive. An external tilt switch or ACC feed back sounds like it would add unnecessary weight and be more mechanically complicated than it has to be. I even cut the plastic servo connectors off my servos to save weight. If you cut then all off you'll find you save close to 7 grams which means you can add on a key chain camera or something else for free or just have a better flying bird.

Other than that, why add a special servo and extra switches when it can be done in code by someone who has the smarts to add that functionality for us?
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Sat Oct 06, 2012 8:17 pm

Servos are easy to modify to make continuous and it maybe possible to use the internal potentiometer for feed back. I am sure there is a way.
copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Sat Oct 06, 2012 11:40 pm

In the past I have hacked servos with resistors in order to stretch them to 180 degrees but the hack adds more work to the build and the results aren't always desirable since the hacked servo's dead band also gets messed up to where the servo doesn't always go back to the same spot when centered.

I've had no such centering problems with the stretched 1.7 ISR code.

I own a couple of external servo stretchers that can be attached to a servo but it doubles the weight of a 7 gram servo which is not desirable for the VTOL models I like to build, which have to be as light as possible.
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Fri Oct 19, 2012 6:56 am

Bump to see if anyone is actively working on getting this servo stretching into a latest build?

Looks like cass has some files in a branch here but it didn't make it into a final release? Search for "stretch" in that file an you will see his entry.
http://multiwii.googlecode.com/svn-hist ... 5/config.h
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Fri Oct 19, 2012 11:54 am

copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Tue Nov 06, 2012 3:03 am

copterrichie wrote:Have you tried these servos?

http://www.hobbyking.com/hobbyking/stor ... Servo.html
Thanks but those are twice as heavy as the ones I am currently using.

So I take it no one is working on porting this to 2.1 or above? Really don't want to port all my MultiWii 1.7 code over to Arducopter just to keep 180 degree servo movement.
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Tue Nov 06, 2012 3:06 am

LOL, Design an aircraft what will carry a greater payload.
copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby dr.tom » Tue Nov 06, 2012 9:05 pm

I am happy how 180 servos linked above work :)

they are also very cheap.

http://www.youtube.com/watch?v=brk76oVfHY4
dr.tom
 
Posts: 141
Joined: Fri Mar 30, 2012 4:46 pm
Location: Croatia

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Tue Nov 06, 2012 9:50 pm

dr.tom wrote:I am happy how 180 servos linked above work :)

they are also very cheap.

http://www.youtube.com/watch?v=brk76oVfHY4



Looks good to me. :)
copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Tue Nov 13, 2012 8:51 am

copterrichie wrote:LOL, Design an aircraft what will carry a greater payload.
LoL thanks but I'm building an RC Osprey, not a real one 8-)
http://www.youtube.com/watch?v=mFJPGRHSwRw

After this small one I plan to build one that will require larger servos than the ones you linked to :D
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Tue Nov 13, 2012 1:33 pm

RCvertt wrote:
copterrichie wrote:LOL, Design an aircraft what will carry a greater payload.
LoL thanks but I'm building an RC Osprey, not a real one 8-)
http://www.youtube.com/watch?v=mFJPGRHSwRw

After this small one I plan to build one that will require larger servos than the ones you linked to :D


Nice however I really don't see why Weight should be an issue here, just increase the motor and props size and you be able to lift the kitchen sink. :D

P.S. From what I observed in the video, the added weight would help with stabilization.
copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Wed Nov 14, 2012 3:02 am

Thanks. Weight is an issue because like a scale Osprey, there is a significant part of the wing in the way of the prop air flow which takes away from lift. So weight is absolutely critical with this type of build. As for the stability, I found out after I landed that it's due to the pilot and mainly the motors being able to move around during flight as the hot glue holding them in place softened up during flight.

I see no reason to have to change my motors, which means I would have to change my flight battery to compensate for their extra weight and amp draw, which means I would have to have a larger wing to sustain the same wing loading I have now, which basically means a complete rebuild just to use those special HobbyKing servos you linked to.

Seams easier to me to make any servo capable of the 135 degree servo travel I have now by updating the 1.7 multiwill servo code I'm using and posted in this thread to 2.1 or above, but maybe it's just me.
Last edited by RCvertt on Fri Nov 16, 2012 6:09 am, edited 1 time in total.
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Wed Nov 14, 2012 3:08 am

Your choice and option. I am also building a tilt-rotor VTOL based upon the Doak VZ-4 and I really don't foresee any of the issues you have described here. I hope everything works out for you.
copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Thu Nov 15, 2012 10:26 pm

Servo_Angle_Schematic_180_3.8.jpg
(7.73 KiB) Not downloaded yet


As a point of clarity, is this what you are trying to achieve?
copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Fri Nov 16, 2012 6:07 am

That servo horn image is basically what I want. I only need about 135 degrees as shown by the red marks in this image.

copterrichie wrote:Your choice and option. I am also building a tilt-rotor VTOL based upon the Doak VZ-4 and I really don't foresee any of the issues you have described here. I hope everything works out for you.
The Doak VZ-4 is a nice ship. Should be a good build to watch. Looks like the Doak's motors are a lot closer to their tilting point so stability should be a lot better and easier to achieve than on an Osprey build. Also looks like no part of the wing is in the way of the prop thrust as it is on an osprey so your Doak should be more efficient and have more trust available than an Osprey build has.
Attachments
ServoRange.jpg
(38.14 KiB) Not downloaded yet
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Fri Nov 16, 2012 2:08 pm

I took a serious look at the servo code in the MWC and it is possible but I still believe the better solution is to 1, get a 180-260 degree servo or modify the existing servos by changing the positional potentiometer's resistance value. There are a few hacks out there showing how this is done but the easiest in my opinion is, just get a servo that will do the job. This way, the servo code will not require modification with new revisions.

P.S. I have a bunch of junk servos to experiment with and one thing is, there is a processor that reads the analog signal the PWM signals. I am curious if this processor can be hacked with new code. Will keep you updated.
copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby timecop » Fri Nov 16, 2012 2:25 pm

well, there's always the choice of switching to hardware that would allow this without dicking around with platform limitations, but...
I mean even tarduino due should handle this with one line change.
timecop
 
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Sat Nov 17, 2012 5:55 am

Thanks for the help on this. It is appreciated.

Just to clarify, I'm not looking to impliment something that hasn't been done before. I'm just looking to keep the functionality I already have.

Just to clarify the diagram shows the range of motion I need to keep in red. The video shows this range and what I am currently able to do with. Just looking to have this ported to 2.1.

http://www.youtube.com/watch?v=Bd7G2ICKEzs

If the new servo code can't do it, then a # define would be fine that allows me to switch to the ISR code method I am currently using.
Attachments
140degreeServoRange.jpg
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby ronco » Tue Nov 20, 2012 9:11 am

Hi,

as the current servo code isnt made for that long ranges (would be possible but its more easy and clean if we do it extern)

i made a code that does it stand alone .. as you just use two motors (and i if you are using a 328p / promini) timer 2 is free ;)

so remove all servo definitions (#define SERVO .. SERVO_FROM and SERVO_TO) and trie this one :)

init:
Code: Select all
static uint8_t transServoVal[2] = {100,100};

void initservos(){
  SERVO_4_PINMODE; // or any two servos you use
  SERVO_5_PINMODE;
  TIMSK2  |= (1<<OCIE2A); // enable T2A overflow interrupt

}


ISR
Code: Select all
ISR (TIMER2_COMPA_vect){
  static uint8_t state = 0;
  if(state == 0){
    OCR2A = 193; // enable the first pin if timer 2 is 500us before TOP
    state = 1;
  }else if(state == 1){
    SERVO_4_PIN_HIGH;
    OCR2A = transServoVal[0];  // range is now 0-250 so 500-2500us
    state = 2;
  }else if(state == 2){
    SERVO_4_PIN_LOW; // pin low
    state = 3;
  }else if(state == 3){ // the same for servo2
    OCR2A = 193;
    state = 4;   
  }else if(state == 4){
    SERVO_5_PIN_HIGH;
    OCR2A = transServoVal[1];
    state = 5;
  }else if(state == 5){
    SERVO_5_PIN_LOW;
    state = 0;   
  }
}


you can write the servo PWM values to transServoVal[0] & transServoVal[1] ... 0-250 = 500-2500

[edit]
.. some code corrections -.- .. i made this code for a 16- bit timer.
[/edit]

this code runs with ~80Hz so it should work for analog servos too.

regards Felix
ronco
 
Posts: 317
Joined: Thu Aug 18, 2011 2:58 pm

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Thu Nov 22, 2012 5:54 am

Thank you very much Felix. I will give it a try.
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Fri Nov 23, 2012 1:59 am

No joy I'm afraid. I get a lot of errors.

Is it possible for you to post a version of 2.1 that has your code changes in it and that actually compiles.
-Thanks
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Sat Nov 24, 2012 4:07 am

Just a little more info on why I think an internal solution is better than an external one...

Servo stretching works but we do loose some resolution. Hovering would most likely benefit from more resolution. Even though my servo travels 180 degrees I really only use about 45 degrees of movement at any given time as seen in the image. So what I am really doing is shifting this 45 degrees of control range up and down for forward flight and hover modes.

So the internal 180 servo stretching that I currently use in 1.7 is kind of a hack as well. It would be better to not stretch the servo travel but just shift the range up and down from a three position transmitter switch. If the signal can't be shifted then maybe we can switch between 4 ISR code blocks. One block would be stretched allowing the servo to seamlessly move up and down between flight mode positions and the other three ISR code blocks would be normal travel range but shifted into one of the three flight mode positions and take over once the servo is in that range as shown in the image.

180 stretching is ok for now but I'm just thinking ahead here.
Attachments
45degreeRangeInAnyFlightMode.jpg
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Sat Nov 24, 2012 12:27 pm

There is a maximum of 0-250 steps possible, a modified servo is the only answer in my opinion. I am presently looking for an external position sensor that I can use in conjunction with a continual rotating servo on my VTOL. I just don't see a software solution.
copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby ronco » Sat Nov 24, 2012 12:43 pm

i think the best solution for a good servo signal is uc with enough 16 bit timer .. so a HW generated PWM signal with 10bit (~1000steps) this is possible with pin 9 & 10 (timer 1)
on the 328p but on many pins with a 32u4 or a 2560.

because the 328p just has one 16 bit timer im currently doing a special Vtol/airplane and heli MWC version for the 32u4 (especially for the nanowii)
that can do 11 bit HW PWM in any combinations of servos or motors (different frequencys) on 6 pins


but im atm. still on the basics ;)


regards Felix
ronco
 
Posts: 317
Joined: Thu Aug 18, 2011 2:58 pm

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Sat Nov 24, 2012 12:57 pm

Please Share Felix, I have a 2560 setting doing nothing at the moment. :)
copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Sat Nov 24, 2012 1:44 pm

A little something I located during my morning search:

JP Serial Servo Motor Robot Controller (4ch) for Stamp Basic, Picaxe , Arduino

http://www.ebay.com/itm/JP-Serial-Servo ... 27cd4445ff
copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby copterrichie » Sat Nov 24, 2012 7:59 pm

copterrichie
 
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Wed Nov 28, 2012 7:32 am

ronco wrote:i think the best solution for a good servo signal is uc with enough 16 bit timer .. so a HW generated PWM signal with 10bit (~1000steps) this is possible with pin 9 & 10 (timer 1)
on the 328p but on many pins with a 32u4 or a 2560.

because the 328p just has one 16 bit timer im currently doing a special Vtol/airplane and heli MWC version for the 32u4 (especially for the nanowii)
that can do 11 bit HW PWM in any combinations of servos or motors (different frequencys) on 6 pins


but im atm. still on the basics ;)


regards Felix
1000 steps sounds good. Might give enough resolution even if the signal is stretched. I'm interested in the 2560 option you are cooking up since I don't have any 32u4 hardware to play with.

Take your time, no rush. Keep up the good work and thanks for working on this.
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby ronco » Wed Nov 28, 2012 4:51 pm

Hi,

sorry for the late replay .. i did this stuff ATM. just for the atmega32u4. but it is possible for the mega too.

so for the 32u4 i just have 6 channels with 0-2000us to be able to have each at 488, 244 or 60Hz to have 500-2500us with HW PWM we need the timer running with lower frequencys so this affekts all pins of the timer (mostly 3 pins per timer on the mega) but as it has enough it will work.

the MWC version im working on is very reduced because its meant for Vtols. ill tell you if i have something ~ stable ;)

i will do a modified output file for the mega that fits into mwc2.1 where you just have to set a custom mix setup.. but i cant tell when. because im very busy ATM.

regards

Felix
ronco
 
Posts: 317
Joined: Thu Aug 18, 2011 2:58 pm

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Thu Dec 06, 2012 5:04 am

I'm pretty happy with the 1.7 servo stretched code as seen in the vid but would like to test with 2.1 code since I heard the "stable" mode is better in 2.1
http://www.youtube.com/watch?v=4ayU82kM ... r_embedded
Last edited by RCvertt on Wed Mar 06, 2013 8:48 am, edited 1 time in total.
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Sun Dec 23, 2012 7:17 am

Any progress on getting some servo stretching in 2.1?

I'm about finished with my 1.7 testing...
http://www.youtube.com/watch?v=DuSyEYg_WJA
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Mon Apr 13, 2015 10:05 am

I see some 180 servo stretching was adding in (2.3). How do I activate this? I was unable to find anything in config.h for activating this.

"gimbal servo stretcher usable with HW PWM's. (r1384)
We can get 180 degrees servo move without servo modification.
- note about gimbal: settings for neutral&endpoints are no more in config.h, but only in GUI"
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Mon Apr 20, 2015 8:36 pm

No one knows how to get the gimbal 180 servo movement to work?
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Sat Aug 22, 2015 10:38 am

Been about three years now. Do we have 180 servo movement available on at least 4 servos or are you guys going to make me attempt to write my own? Not sure I'll live long enough to finish it if that's the case. :shock:

I just got the Arduino "Servo" library working with 2.4. Works smooth as silk if I copy in the example servo sweep code into (MultiWii.cpp). When I try to feed it values from rcCommad[ROLL] or rcData[ROLL] the servo is still as erratic and unusable as it has been from day one with MultiWii using that method. Not sure why the RC code interupts appear to be messing with the servo library. That's my guess anyways. rcData[ROLL] appears to spit out clean values when I use "debug", they are even in the range of 1000 to 2000 us so I don't see why it doesn't work with (myservo.writeMicroseconds(rcData[ROLL]). Would be sooooo simple to stretch a servo if it worked. :(
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Sun Aug 23, 2015 8:17 am

Not that painful after all. Got the tricopter servo stretched to 180 degrees now after looking at the ISR code again today. Sometimes you just have to let it marinate for 3+ years and get lucky with the copy and paste :D
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Fri Aug 28, 2015 3:22 pm

Cleaned up the stretched code a little. This is for (2.4). I'm using an arduino (nano V3). This will let the tricopter servo on pin 3 move 180 degrees. Hope someone finds this useful and hope this helps keep development on the Arduino boards.


These are the new lines of code...
Code: Select all
SERVO_CHANNEL+=125;

    }else if(state==2){                                                                 
      SERVO_CHANNEL+=atomicServo[SERVO_1_ARR_POS];
      state++; // count up the state           



This is where you add them to the ISR section in (Output.cpp)...
Code: Select all
  ISR(SERVO_ISR) {
    static uint8_t state = 0; // indicates the current state of the chain
    if(state == 0){
      SERVO_1_HIGH; // set servo 1's pin high
//      SERVO_CHANNEL+=SERVO_1K_US; // wait 1000us
      SERVO_CHANNEL+=125;
      state++; // count up the state
    }else if(state==1){
      SERVO_CHANNEL+=atomicServo[SERVO_1_ARR_POS]; // load the servo's value (0-1000us)
      state++; // count up the state
    }else if(state==2){                                                           
      SERVO_CHANNEL+=atomicServo[SERVO_1_ARR_POS]; // load the servo's value (0-1000us)
      state++; // count up the state                                                       
    #if defined(SERVO_2_HIGH)
...


My nano had no sensors on it during the test. I used this to move the servo so your mileage may vary.
Code: Select all
servo[5] = (-rcCommand[YAW]) + 1500; //REAR
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Mon May 30, 2016 2:18 am

Little example of the above code in use using MultiWii (2.4).

https://youtu.be/6Tei98UfoBs
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am

Re: v2.1- Servo stretching 180 degrees?

Postby RCvertt » Fri Sep 30, 2016 5:42 am

More fun with the above 180 servo stretching in MultiWii 2.4

https://youtu.be/MPSo0Njhmqg

https://youtu.be/yGJizrGwIo4
RCvertt
 
Posts: 170
Joined: Fri Sep 14, 2012 11:45 am


Return to Software development

Who is online

Users browsing this forum: No registered users and 14 guests