v2.1- Servo stretching 180 degrees?
v2.1- Servo stretching 180 degrees?
Does MultiWii v2.1 allow servo movement of 180 degrees?
Re: v2.1- Servo stretching 180 degrees?
Mwii does not know about servo angles.
You must get a servo that has 180deg rangle range and then it should just work.
You must get a servo that has 180deg rangle range and then it should just work.
Re: v2.1- Servo stretching 180 degrees?
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...
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]; }
}
Re: v2.1- Servo stretching 180 degrees?
Ok I sse what you mean.
Re: v2.1- Servo stretching 180 degrees?
This is the same question I was asking here: http://www.multiwii.com/forum/viewtopic.php?f=13&t=2487
Re: v2.1- Servo stretching 180 degrees?
isn't it just a matter of specifying smaller servomin/max, and its done?
I.e. below1000 us...
I.e. below1000 us...
Re: v2.1- Servo stretching 180 degrees?
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.
Re: v2.1- Servo stretching 180 degrees?
If you can please do that for us with v2.1 it would be greatly appreciated.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.
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.
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.Hamburger wrote:Ok I sse what you mean.
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.
Re: v2.1- Servo stretching 180 degrees?
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

Re: v2.1- Servo stretching 180 degrees?
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 hardwaretimecop wrote:...ah, that's too bad. not a problem on proper hardware ... Sorry, can't help with the 8bit version though

-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
RCvertt wrote: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 hardwaretimecop wrote:...ah, that's too bad. not a problem on proper hardware ... Sorry, can't help with the 8bit version though
Why not use a continue rotating servo with some sort of tilt switch or even an analog ACC feed back?
Re: v2.1- Servo stretching 180 degrees?
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.copterrichie wrote:Why not use a continue rotating servo with some sort of tilt switch or even an analog ACC feed back?
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?
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
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.
Re: v2.1- Servo stretching 180 degrees?
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.
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.
Re: v2.1- Servo stretching 180 degrees?
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
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
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
Thanks but those are twice as heavy as the ones I am currently using.copterrichie wrote:Have you tried these servos?
http://www.hobbyking.com/hobbyking/stor ... Servo.html
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.
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
LOL, Design an aircraft what will carry a greater payload.
Re: v2.1- Servo stretching 180 degrees?
I am happy how 180 servos linked above work 
they are also very cheap.
http://www.youtube.com/watch?v=brk76oVfHY4

they are also very cheap.
http://www.youtube.com/watch?v=brk76oVfHY4
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
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.

Re: v2.1- Servo stretching 180 degrees?
LoL thanks but I'm building an RC Osprey, not a real onecopterrichie wrote:LOL, Design an aircraft what will carry a greater payload.

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

-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
RCvertt wrote:LoL thanks but I'm building an RC Osprey, not a real onecopterrichie wrote:LOL, Design an aircraft what will carry a greater payload.![]()
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
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.

P.S. From what I observed in the video, the added weight would help with stabilization.
Re: v2.1- Servo stretching 180 degrees?
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.
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.
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
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.
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
As a point of clarity, is this what you are trying to achieve?
Re: v2.1- Servo stretching 180 degrees?
That servo horn image is basically what I want. I only need about 135 degrees as shown by the red marks in this image.
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.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.
- Attachments
-
- ServoRange.jpg
- (38.14 KiB) Not downloaded yet
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
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.
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.
Re: v2.1- Servo stretching 180 degrees?
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.
I mean even tarduino due should handle this with one line change.
Re: v2.1- Servo stretching 180 degrees?
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.
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.
Re: v2.1- Servo stretching 180 degrees?
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:
ISR
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
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
Re: v2.1- Servo stretching 180 degrees?
Thank you very much Felix. I will give it a try.
Re: v2.1- Servo stretching 180 degrees?
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
Is it possible for you to post a version of 2.1 that has your code changes in it and that actually compiles.
-Thanks
Re: v2.1- Servo stretching 180 degrees?
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.
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.
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
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.
Re: v2.1- Servo stretching 180 degrees?
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
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
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
Please Share Felix, I have a 2560 setting doing nothing at the moment. 

-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
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
JP Serial Servo Motor Robot Controller (4ch) for Stamp Basic, Picaxe , Arduino
http://www.ebay.com/itm/JP-Serial-Servo ... 27cd4445ff
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: v2.1- Servo stretching 180 degrees?
Just posting for Reference: http://arduino.cc/playground/Code/MegaServo
Re: v2.1- Servo stretching 180 degrees?
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.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
Take your time, no rush. Keep up the good work and thanks for working on this.
Re: v2.1- Servo stretching 180 degrees?
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
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
Re: v2.1- Servo stretching 180 degrees?
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
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.
Re: v2.1- Servo stretching 180 degrees?
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
I'm about finished with my 1.7 testing...
http://www.youtube.com/watch?v=DuSyEYg_WJA
Re: v2.1- Servo stretching 180 degrees?
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"
"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"
Re: v2.1- Servo stretching 180 degrees?
No one knows how to get the gimbal 180 servo movement to work?
Re: v2.1- Servo stretching 180 degrees?
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.
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.

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.

Re: v2.1- Servo stretching 180 degrees?
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 

Re: v2.1- Servo stretching 180 degrees?
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...
This is where you add them to the ISR section in (Output.cpp)...
My nano had no sensors on it during the test. I used this to move the servo so your mileage may vary.
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
Re: v2.1- Servo stretching 180 degrees?
More fun with the above 180 servo stretching in MultiWii 2.4
https://youtu.be/MPSo0Njhmqg
https://youtu.be/yGJizrGwIo4
https://youtu.be/MPSo0Njhmqg
https://youtu.be/yGJizrGwIo4