ExpressLRS icon indicating copy to clipboard operation
ExpressLRS copied to clipboard

PWM Servo Output Support

Open CapnBry opened this issue 5 years ago • 54 comments

Instead of CRSF output, generate PWM signals to drive servos.

It would be great to have ExpressLRS drive servos directly for fixed wings that wouldn't have a flight controller. The developers have already been discussing this feature and agree it would be welcome as long as it didn't reduce the performance of the existing ELRS code. Jye has already tried a proof of concept and found there to be far too much jitter in the servo output using a single timer interrupt and software pin toggling (using default Servo library). Raphael already has expressed desire for this feature as well and seems to have some ideas about the implementation already.

Challenges

  • 4 full resolution channel limit in ELRS 1.0. There is space in lower packet rates to increase the number of channels sent, but not to 16. We need to determine how many full-res channels we should support and what encoding methods would be used for the others. A hybrid switches approach could be used for some channels.
    • Possibly do 8 channels + 8 switches, but I am not sure there is bandwidth even for 8 channels + 1 byte for hybrid switches
  • Lack of pins on hardware. ESP8266 targets don't have enough pins to drive many servos. Extending this with 1 or more shift registers could be a possibility. Having SBUS output can work around this restriction, but SBUS output is a separate issue, although increasing the number of channels can go hand in hand with that.

This issue is for discussion if needed, please do not post "I want this" spam to this ticket.

CapnBry avatar May 09 '21 16:05 CapnBry

IMHO, Full ranga channels: Not that much more. Typical plane needs 4 servos (2 Ail, Ele, Rud) and a throttle. Sometimes flaps. Then there is a pan-and-tilt. So 8 analog will be good. Gear, lights and bombs might use switch channels. Typical big radio as FrSky or Radiomaster have 8 analog controls (sticks, pots and sliders) and the rest are switches. So I vote for 8 Analog + 8 Digital, at the cost of 1/2 packet rate. BTW, 50 Hz for the plane should be enough, as most servos use that timing.

Thought about the lack of PWM outputs: Most receivers like R9 series, or Ghost can have some PWM outputs. I suggest maybe output some channels as PWM and sbus (or PPM) signal with all channels on one line. Then users may use SBus to PWM decoder to drive the additional servos. It also may help building the larger planes, where it will be convinient not to connect all servos directly to the receiver.

Tygrys-1 avatar May 09 '21 17:05 Tygrys-1

IMHO, Full ranga channels: Not that much more. Typical plane needs 4 servos (2 Ail, Ele, Rud) and a throttle. Sometimes flaps. Then there is a pan-and-tilt. So 8 analog will be good. Gear, lights and bombs might use switch channels. Typical big radio as FrSky or Radiomaster have 8 analog controls (sticks, pots and sliders) and the rest are switches. So I vote for 8 Analog + 8 Digital, at the cost of 1/2 packet rate. BTW, 50 Hz for the plane should be enough, as most servos use that timing.

Thought about the lack of PWM outputs: Most receivers like R9 series, or Ghost can have some PWM outputs. I suggest maybe output some channels as PWM and sbus (or PPM) signal with all channels on one line. Then users may use SBus to PWM decoder to drive the additional servos. It also may help building the larger planes, where it will be convinient not to connect all servos directly to the receiver.

For race wings we might only need two pwm output's. One for throttle and one for elevon's. That way you can have a better packet rate. Not sure if you need 500hz for Racing FPV wings.. but might be better than 50hz?

brandonrc avatar May 09 '21 17:05 brandonrc

For race wings we might only need two pwm output's. One for throttle and one for elevon's. That way you can have a better packet rate. Not sure if you need 500hz for Racing FPV wings.. but might be better than 50hz?

To be honest - you need 3, there should be the motor somewhere :-) Typical analog servo refresh rate is 50 Hz, so there will be no benefit of faster RC rate. There are faster serwos, and some radios allow faster rates. The different story is the ESC, which could go up to 400 Hz. But on the plane it is not that important to have it sensitive, as the motor afects only the speed, not the stabilization nor attitude.

The main difference between the plane and a multirotor is that they do not need the flight controller. FC benefits from the faster rate to feed PID controller and do computations, on the plane we work with phycical surfaces with big inertia of the system, and the rate is not that critical. Of course we can still use flight controler for the plane - and the only change this might require is at least extra 2 full range channels. This is because all the mixing will be done on the transmitter (if no FC) and the receiver should be able to drive all surfaces on the plane directly. Or indirectly through the FC, but still with the full resolution.

Tygrys-1 avatar May 09 '21 18:05 Tygrys-1

I think Brandon might have been saying some hardware could work with just 2 channels using their existing pins, but that would only work for a 2ch glider (no motor like you say). I don't think anyone was suggesting we support fewer than our existing number of channels in the protocol though since our existing protocol already supports that at all packet rates. The challenge listed is for determining the extended number of channels we could support and at what rates, and a separate challenge for how many outputs we can run given hardware fan out limits.

CapnBry avatar May 09 '21 18:05 CapnBry

Maybe if multiple servo channels at some point are being considered (at costs of refresh rate), maybe PCA9685 I2C / PWM chip could be considered to be supported. It can adress 16servos and boards cost nothing.

Dropsleutel avatar May 09 '21 19:05 Dropsleutel

I vote for 8 full channels total, where the 6 is absolute minimum. Thinking about 8 full + 8 switch we will support most controls on the OpenTx radio and the packet rate should not go less than 2 times slower. It will be extra 5 bytes more on the single packet.

Tygrys-1 avatar May 09 '21 19:05 Tygrys-1

Maybe if multiple servo channels at some point are being considered (at costs of refresh rate), maybe PCA9685 I2C / PWM chip could be considered to be supported. It can adress 16servos and boards cost nothing.

This was implemented in Inav some time ago. The problem I see is that most receivers does not expose I2C, so it will be hard to implement everywhere. The better solution is to output SBus, as there always is a serial port and inverter if needed. AFAIR the servo refresh rate was low on I2C solution.

Tygrys-1 avatar May 09 '21 19:05 Tygrys-1

I also agree that 6 is the bare minimum but would prefer 8+8. I do not want to split the full resolution channels across multiple packets due to the possibility that only one of the two halves will arrive so we'd have to hold the first half and then throw it out if we don't get the second half, and that can get into a situation where we never update the servos again if we lose every other packet. I believe they all need to update together in case the user has an implied connection across the channels (e.g. CH3 high and CH6 low). It might be a limitation we'll have to accept though due to bandwidth, that CH1-4 are linked and CH5-8 are linked so arrange the channels so any interdependency you need is contained in one channel grouping.

CapnBry avatar May 09 '21 19:05 CapnBry

For race wings we might only need two pwm output's. One for throttle and one for elevon's. That way you can have a better packet rate. Not sure if you need 500hz for Racing FPV wings.. but might be better than 50hz?

To be honest - you need 3, there should be the motor somewhere :-) Typical analog servo refresh rate is 50 Hz, so there will be no benefit of faster RC rate. There are faster serwos, and some radios allow faster rates. The different story is the ESC, which could go up to 400 Hz. But on the plane it is not that important to have it sensitive, as the motor afects only the speed, not the stabilization nor attitude.

The main difference between the plane and a multirotor is that they do not need the flight controller. FC benefits from the faster rate to feed PID controller and do computations, on the plane we work with phycical surfaces with big inertia of the system, and the rate is not that critical. Of course we can still use flight controler for the plane - and the only change this might require is at least extra 2 full range channels. This is because all the mixing will be done on the transmitter (if no FC) and the receiver should be able to drive all surfaces on the plane directly. Or indirectly through the FC, but still with the full resolution.

You are right.. you would need at least Channel 1 = Left ELevon CHannel 2 = Right Elevon Channel 3 = Throttle

I was thinking you could do one channel for both elevons and have a y-split but that would not work because of pitch. up and down. They need to be mixed to seperate channels.

brandonrc avatar May 10 '21 00:05 brandonrc

Sbus? would allow use of sbus to pwm converters.

P-I-Engineer avatar May 10 '21 04:05 P-I-Engineer

You are right.. you would need at least Channel 1 = Left ELevon CHannel 2 = Right Elevon Channel 3 = Throttle

I was thinking you could do one channel for both elevons and have a y-split but that would not work because of pitch. up and down. They need to be mixed to seperate channels.

Technicaly you may have y-spliter on ailrons and a separate elevator, but this will work for unpowered gliders only, as @CapnBry mentioned.

Tygrys-1 avatar May 10 '21 06:05 Tygrys-1

Sbus? would allow use of sbus to pwm converters.

SBUs support is trivial, I have it currently on top of my CRSF cleanup branch. I think this could be merged after the cleanup is done ;-)

raphaelcoeffic avatar May 10 '21 10:05 raphaelcoeffic

You are right.. you would need at least Channel 1 = Left ELevon CHannel 2 = Right Elevon Channel 3 = Throttle I was thinking you could do one channel for both elevons and have a y-split but that would not work because of pitch. up and down. They need to be mixed to seperate channels.

Technicaly you may have y-spliter on ailrons and a separate elevator, but this will work for unpowered gliders only, as @CapnBry mentioned.

This is so 90s! It is a real pain as you need to setup the servos to be mechanically the same, rather than correcting linkage differences in the channel settings, as most pilots do nowadays.

that being said, “normal gliders”, even powered, need at most 8 channels. Jets, huge gliders (4-5m wingspan) use multiple servos for many things. These are always much easier to setup in the radio rather than mechanically.

For now, 8 full-res channels should be the first goal, IMHO.

raphaelcoeffic avatar May 10 '21 10:05 raphaelcoeffic

Typical analog servo refresh rate is 50 Hz, so there will be no benefit of faster RC rate.

most digital servos support 100Hz. Beyond is pointless. Some analog servos do support 100Hz as well, but I’ve seen some funny behavior with some that look like they support it, but behave strangely at once.

raphaelcoeffic avatar May 10 '21 10:05 raphaelcoeffic

SBUs support is trivial, I have it currently on top of my CRSF cleanup branch. I think this could be merged after the cleanup is done ;-)

And SBus will allow to directly use the SBus servos. :-)

Tygrys-1 avatar May 10 '21 13:05 Tygrys-1

SBUs support is trivial, I have it currently on top of my CRSF cleanup branch. I think this could be merged after the cleanup is done ;-)

And SBus will allow to directly use the SBus servos. :-)

If you find some ;-) apart from Futaba, I could not find any.

raphaelcoeffic avatar May 10 '21 16:05 raphaelcoeffic

SBUs support is trivial, I have it currently on top of my CRSF cleanup branch. I think this could be merged after the cleanup is done ;-)

And SBus will allow to directly use the SBus servos. :-)

If you find some ;-) apart from Futaba, I could not find any.

I think FrSky took the idea and has some Xact models. But they are FPort 2.0 compatible, not SBus.

Tygrys-1 avatar May 10 '21 16:05 Tygrys-1

sbus (inverted or not) seems to be a relatively easy option to make available for most ELRS RX. This could allow remote receiver/antenna placement with a centrally located pwm converter. A quick web search found several 4-10 channel sbus-pwm converters options for less than $15 (I do already have one).

Support for four servos like R9MM/Mini would be nice but it seems there are plenty of other improvements that are more widely desired / higher priority.

It also seems like a big mult-servo airplane would benefit from more fully proportional channels that are updated with more consistent frequency/priority.... So this makes me point back to an sbus/CRSF flight controller or a more traditional receiver with PWM outputs.

Just my $0.02 Thank you all, -p

somewhat related thought: Can RX be compiled without telemetry support other than what is required for binding? ... got to thinking about sbus input and making the receiver automatically pass another sbus signal out on fail-safe.

pitts-mo avatar May 10 '21 21:05 pitts-mo

For the more traditional fixed wing airplanes 8 channels full would suffice. But of course there are planes that need more than 8 channels. Especially sail planes (which often have 6 servos in the wings) need more channels. Planes using multiple engines, e.g. 4 IC engines with throttle and additional glow or ignition control and flaps and gear and special functions need 16 channels easily.

Traditional setups don't make much use of switch channels by the way, because even on/off functionality like a tow hook needs servo end point settings which are normally set up on the transmitter.

A good alternative to slowing down the complete protocol too much would be something like 8 full speed full channels and 8 low update rate full channels. Also combinations like 7+9 or 6+10 if that would fit bandwidth better would be viable options.

Or may be 4 full rate, 4 half rate, 8 slow rate channels (but all at full resolution). That would be a structure that reflects usage relatively good.

Maybe even better would be

  • 2 at full update rate
  • 2 at half update rate
  • 4 at quarter update rate
  • 8 at an eighth update rate

In sum this would result in an overall net data rate equivalent of 5 functions at full update rate.

If you need even more functionality you could go one step further and add

  • another 8 at an eighth update rate or even 16 at a sixteenth update rate

Since I'm unfortunately not aware of the details: What is the net data rate that the 886/915MHz Link provides?

MarkusPfaff avatar May 11 '21 11:05 MarkusPfaff

On a f3b or f3f modell 6 chanel in full res are enough. 8 chanel can be useful on a 3 flap wing. A sbus output was ok for me. Direct pwm out to direct connect servos isn't needed for all servo chanels. Because I install a sbus decoder in most cases direct in the wing and the fuselage servos direct to the receiver pwm output.

agetommy avatar May 15 '21 09:05 agetommy