News:


Advertise Here

  • January 20, 2022, 08:04:17 AM

Login with username, password and session length

Author Topic: Electric Motor Control - severe Geek speak  (Read 168 times)

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 705
  • I'm here purely for the fun of it.
Electric Motor Control - severe Geek speak
« on: January 12, 2022, 09:07:51 PM »
I have been working on a control for the electric motors for a while. I'm just about to the point of being ready to put it to actual code and testing. this header is a warning about the content which is highly technical but I tried to write clearly my approach to arriving at the conclusion I have. The architecture of this method is derived from my back ground in turbine engine controls and it draws from some loss of sensor accommodation logic and anticipation logic. Some of the methodology comes from this.

The basic control is a "timer" which my intent for my version is to be key fob start and stop with a timer for backup. I want this because it drives me crazy to have to wait for the timer to run down and something has happened or I am doing trim flights. Besides, I use the key fob for my stooge and it has some extra buttons that should do something.

Warning - there is engineering speak contained with the dialog
Life is good AMA 1488
Why do we fly? We are practicing, you might say, what it means to be alive...  -Richard Bach
“Physics is like sex: sure, it may give some practical results, but that’s not why we do it.” – Richard P. Feynman

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 705
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #1 on: January 12, 2022, 09:08:51 PM »
Control Line Model Airplane Motor Control - Timer.
Mark Wood – 3 January 2022 Any use of this content requires acknowledgement of the work of the author. Including any software or hardware generated as a result.

This is the fundamental idea. Rather than using a complex method of measuring attitude and acceleration for a given flight condition and attempting to set a thrust level to balance, why not calculate how much thrust is required for the commanded flight condition and set that thrust? Simple, all you have to do is figure out how much thrust is required. Not quite so simple but doable. Since the thrust required is a function of the maneuver command why not command both simultaneously? Again simple. The following is a dialog on how to accomplish this and make it adjustable enough to meet the demands of a broad spectrum of aircraft. Note that the derivation of the gain function contained herein can also be used to improve the performance of G and attitude based controls and is covered under my use conditional statement above.

I spent a bunch of time thinking about the best way of managing the power output of the electric motors for the control line models. I began a year ago to make a timer and controller for a variable pitch propeller which I think has lots of potential but has a significant number of challenges to overcome. When I review how the current technology timer work I see that they work reasonably well but I believe they can work even better. After reviewing Howard’s data, I’m convinced that an improvement can be made by shifting the power gain over to an input from the control position. After spending some time doing calculations I believe that this is really the only input necessary. The only time I can see where taking attitude as a gain calculation is likely just the wing over maneuvers. Everything else naturally works with control position. Even the wing over, I’m not convinced that attitude is necessary if the entry turn can be made with minimal energy loss.

Let me attempt to explain. The airplane flying in level un-accelerated flight is in balance between thrust and drag. The airplane is also in trim with respect to its aerodynamic surfaces. Whenever we wish to change altitude or attitude the elevator moves and the airplane follows. To do a maneuver such as a loop we must give the control even more deflection. Changing the angle of the elevator changes the angle of attack which increases or decreases the lift. Lift isn’t free and drag follows the lift. If the airplane is in balance when we impart a control the drag slows the airplane down unless we add thrust while we are inputting control.

I want to make a statement here which will follow in all of the derivations. In order to simplify the computations I make the assumption that the speed remains constant. The speed won’t necessarily remain and if it doesn’t it won’t change the resulting architecture but it will needlessly complicate the analysis. If it seems to be missing any part of discussion come back to the bold statement here.
Life is good AMA 1488
Why do we fly? We are practicing, you might say, what it means to be alive...  -Richard Bach
“Physics is like sex: sure, it may give some practical results, but that’s not why we do it.” – Richard P. Feynman

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 705
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #2 on: January 12, 2022, 09:10:45 PM »
The current crops of controls react to the onset of G which goes through a filter to remove noise. This causes a lag in response and requires over thrust to correct for the speed droop during the turn.

It turns out this is a fairly simple thing to anticipate the onset of thrust required and the biggest challenge is to know how much thrust to add or subtract. This is the part that takes some effort and knowledge of the aerodynamics involved. Even in this the solution is quite simple but the path to get there is not so easy. At first consideration we think of drag as a direct relationship with lift but it isn’t quite that easy. Since drag is a combination of different elements it has a particular shape which appears to be an exponential function but it is more easily modeled by using a trig function, 1- Cosine. While not a perfect fit, it is close enough to be usable in a power plant control.

This lends itself for use in the control algorithm with a couple of constants which could cover a large range of aircraft gain = k1*(1-k2*cos(k3*alpha)). With three input constants, the gain can be adjusted to fit almost any application.



Photo taken at 45 degree in level ish flight. Notice the control indicator (~4°) and AOA (~4°) vane positions.




From the videos of the airplane equipped with the control position and Angle Of Attack vane indicators, we can get an idea of how the airplane is working in terms of lift coefficient, Cl and the resulting drag coefficient, Cd. Since the airplane is equipped with flaps a series of Cl curves plotted against AOA must be used. I didn’t take the time to plot the flight results so I’ll simply estimate behavior via a straight line. For some of the concept development, in order to simplify the math, I make an assumption of constant velocity. In a control system working on control position the loop would close in a near constant velocity so it makes sense to use this assumption. Give the ability to adjust gains and limits how solidly the control would hold a specific velocity would be something the operator could manage.

There are a couple of advantages associated with this approach the foremost of which is that minimal filtering is necessary of the control input and output. Position sensors tend to be low noise except that pots tend to get noisy with age so, in the powerplant control world, we like to use RVDTs or Hall Effect sensors. Any time a filter is necessary as in the case of accelerometers or gyros a delay is generated. This delay is added to the frame rate of the output and the acceleration time of the powerplant.

The other is an inherent closed control loop even though the specific powerplant control is an open loop architecture. An airplane in level flight will fly at a specific trim condition including the control position. If the airplane slows down, in order to maintain altitude the pilot in the loop, meat servo, has to increase the pitch attitude to maintain altitude. The control position required to increase the attitude will result in a change in power output, eventually stabilizing speed where the power available matches the power required to fly.

Of interest is the behavior in the triangular loops. Watching the AOA video, I notice about a 5 degree control position on the up leg and 0 degree control position on the down leg. Seems like the control would be okay there as well.

Life is good AMA 1488
Why do we fly? We are practicing, you might say, what it means to be alive...  -Richard Bach
“Physics is like sex: sure, it may give some practical results, but that’s not why we do it.” – Richard P. Feynman

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 705
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #3 on: January 12, 2022, 09:27:56 PM »
The Figures:

The first Figure, Figure 1, Cl v AOA, is a map of Cl versus AOA with a variation of the flap angle of a 25% chord flap. Each curve is an AOA sweep of Cl for a 5 degree incremental deflection of the flaps. The lowest curve is of an airfoil from 0 to some range near stall. Each dot on the curve is 1 degree change in AOA. Following a singular curve, such as the lowest curve would be representative of a non-flapped airplane. The lift would work as an increase in AOA along that curve. We’ll see that the idea of the 1-cos(x) gain works equally well for this configuration.

I’ve arbitrarily placed two lines on the curve chart to illustrate approximately how a coupled flap airplane would generate the lift as function of the combined effect of flap deflection and pitch angle. You could think of the lines as the ratio of elevator authority to flap pitch moment, kinda, sorta. The reason being is there is some velocity dependency as well. From testing I know that the AOA increases at times to around 15 degrees with flaps deployed.
 
Each line illustrates how the lift increases with control input the line being where control would be with respect to the lift curve which I’ll use the term Operational line. This is kind of how we control inlet guide vanes on turbine engine compressors so the term fits. The control angle, I make an assumption of 1:1 control to flap, from the origin to the crossing at the highest curve would be 45 degrees. As we trace each of the Op lines every curve crossing is an increase of 5 degrees in control position.

 
Figure 1, Cl v AOA -  Lift

Depending on the velocity and the elevator ratio the AOA would be somewhere between zero and allot wherever trim would be. I labeled one line Op line at constant velocity and the other Op line at decaying velocity. This is for illustration purposes and if there were a gain function based on control position the thrust would be increasing to close the difference. This condition wouldn’t likely be static. Whether the condition is or not is dependent upon the difference between the power available, that which is being commanded, and the power required to fly.

The next Figure and the following are of the Lift verses Drag or Cl v Cd. In the same manor I placed multiple curves on each chart for each of the flap positions and AOA sweeps. The interesting result is the kind of fractal growth appearance of the curves. The usefulness of these curves is that the thrust / power requirement can be derived from them.  Both power and thrust are a direct function of the coefficient of drag Cd. On the first chart I have done some calculating of the required lift coefficients and from that we can get an idea of the drag coefficient which would result from a combination of flap position and AOA. Notice that for most of these there are more than one possible solution. I’ve made these same charts for many flap configurations from 15% flap to 40% flap. When I’m heard making some seemly brash statement, it is the result of this kind of analysis.

 
Figure 2 Cl v Cd - Drag


A first pass walk through the analysis of power required to fly is the following. We begin with the first chart and move along the Op line for constant velocity. As we move upward along that line we cross the flap =0 degree line Cl curve and an AOA and Cl value. That Cl value is then translated to Figure 2. I have plotted an intersection for level flight I could have equally used an observed AOA, which I did, and made a point on the corresponding line. I was going to present that on a separate chart but it is so close to the blue line 1-Cos line on Figure 3 it is just as easy to say that is what it looks like.

The next interesting condition is the level flight at 45 degrees condition. This is an interesting analysis and one that absolutely must be done in order to draw the conclusion I have regarding the need to know and use attitude and G in the thrust control algorithm. Like indicated before, I don’t think so provided not too much energy is lost in the corner and after the derivation here, you’ll see that  it is very likely to be able to do exactly that. The limiting condition is how steady do we really want airspeed to remain constant as I think that is entirely achievable. Suffice it to say the G force, lift vector, required to fly tethered at 45 degrees constant speed for a given bank is equal to the G force of the tension in level flight. The weight of the airplane reduces the tension of the line. I’ll derive that later but it’s confirmable in the video and you can see on the captured photo above.

Moving up the scale to 6 G loops we cross the calculated Cl of about 0.98 and can see there is an intersection with the 10 degree flap deflection curve around 4 ish degrees AOA. Looking at the AOA video this seems to be nearly exactly the condition. It repeats again for the 10 G square corners.

 
Figure 3 Cl v Cd - Drag - Annotated
Life is good AMA 1488
Why do we fly? We are practicing, you might say, what it means to be alive...  -Richard Bach
“Physics is like sex: sure, it may give some practical results, but that’s not why we do it.” – Richard P. Feynman

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 705
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #4 on: January 12, 2022, 09:31:11 PM »
Implementation:


This is the beauty part as the implementation is super simple just a few lines of code and minimal filtering required. At least I think minimal filtering which is dependent on the input control. The input filtering can be as simple as creating a dead band. A dead band would not allow any gain signal to be generated unless the input was greater than a value. Some gain spikes may occur but the powerplant has inertia which will inherently work as a filter. 

Read input – POS

Filter through a dead band calculation POS_filt = |POS| > Kdb where Kdb could be tunable via external input for different devices or simply be set to be greater than the RMS noise level. Glitches would filter on the output calculation and the ESC governor output. In order to prevent oscillation it likely needs to be some level around 2 degrees control motion. If a linkage is used to a modified servo some play in that linkage wouldn’t be harmful.

Calculate gain G_thrust = K1*(1-K2*(Cos(K3*POS_filt)) Where K1, K2 and K3 are externally tunable via input. The variable constants having different impact on the gain controls. K1 is the overall magnitude of the delta thrust, the larger its value, the more overall gain is available. K2 limits the authority of the position input and needs to be limited to 1 or less. K3 changes the position input to match the control, end point adjustment.

And maybe filter the output G_thrust [1/(n-3)] and give it limits G_thrust  > G_max = G_max. A simple running average filter to smooth noise slightly may or may not be necessary but is in a place for consideration.

Done.

My current timer is implementing this architecture and is set up to use a 4 button 833 Mhz radio Tx and Rx. Button 1 operates the stooge release. Button 2 operates the Start Stop function and buttons 3 and 4 are intended to adjust the Gain constants, 3 is increase and 3 is decrease. I haven’t yet sorted out the mode of operation but theoretically I could use the 3&4 INCR/DECR buttons to make different trimming modes. Mode 1 level flight speed. Mode 2 & 3 would be delta thrust gain tuning.

My selection of the Rx and Tx reflect my coding skill level. There are microprocessor systems today which have built in WiFi  and Bluetooth connectivity which are currently a bit over my head.

Life is good AMA 1488
Why do we fly? We are practicing, you might say, what it means to be alive...  -Richard Bach
“Physics is like sex: sure, it may give some practical results, but that’s not why we do it.” – Richard P. Feynman

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 705
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #5 on: January 12, 2022, 09:37:25 PM »
Derivations:

Drag function

The 1-cosine X is a basic approximation of drag of a flat plate. As a flat plate is rotated from 0 to 90 degrees the drag increases from 0 to one, with a bucket shape. Cosine goes from 1 to 0 in the same change of angle. By subtracting cosine from one the shape becomes that of the flat plate. A fairly simple derivation and useable for doing things like loads analysis and such, it isn’t perfect and we don’t need perfect. We just need close enough and some ability to adjust to fit. In this case, using coefficients, the overall magnitude, the rate of curvature and the sensitivity can be adjusted.

 
Figure 4 Cl v Cd - Drag – Annotated - 1-Cosine θ


Linear gain v 1- Cosine X

It only takes a casual inspection of the following Figure with linear gains plotted on top of the drag polars and 1-Cosine X gain function. It is impossible to match the required thrusts increase with a linear line and there is only one condition where the gain meets that requirement. The result is the gain will either under thrust or over thrust for given AOA (G) condition. Note that the normal operating range of the CL airplane is from the origin to the crossing of the two cosine function lines. The result of not following the thrust requirement is oscillations in flight velocity.

 

Figure 5 Cl v Cd - Drag – Linear Gain vs 1-Cosine X Gain


Life is good AMA 1488
Why do we fly? We are practicing, you might say, what it means to be alive...  -Richard Bach
“Physics is like sex: sure, it may give some practical results, but that’s not why we do it.” – Richard P. Feynman

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 705
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #6 on: January 12, 2022, 09:40:10 PM »
Flight Conditions

Refer to Figures 2 and 3, there is one them various flight conditions illustrating flight conditions of interest which are important in deriving the gain requirement for the control system. It is not necessary to derive further conditions since they are merely subsets conditions of these, call them principal, conditions. Each has its unique requirement for performance. The wing over is left out and has a further requirement which will be addressed later but is also a subset of the square corner maneuvers. In order to create a coefficient based structure it was necessary to solve several states. I picked level flight at zero azimuth angle, level flight at 45 degree azimuth angle, 6 G and 10 G looping maneuvers.

Level Flight

The interesting thing about level flight is that, if we make the bold constant velocity simplifying condition, all of the maneuvers become a simple function of the level flight tension induced G force. While this isn’t exactly how the airplane works, a gain derived from control position would converge on that condition with enough time. So, it is reasonable to make this assumption.

 

Figure 6 - Forces during Level Flight


A typical CLPA airplane flies on 65’ lines and has a lap time of about 5.2 seconds. From this we can calculate the accretion the airplane experiences as I travels the circular fight path:
V=d/t=2*pi*r/t

V =2 * 3.1416 * 65 / 5.2 = 408.4 ft / 5.2 s = 78.5 ft/s

And:
a=V^2/r=〖78.5〗^2/65=94.9 ft/s^2

G = a/g = 94.9 / 32.2 = 2.9 G’s

The result is the airplane is pulling 2.9 G’s on the line which is seen at the handle.
Life is good AMA 1488
Why do we fly? We are practicing, you might say, what it means to be alive...  -Richard Bach
“Physics is like sex: sure, it may give some practical results, but that’s not why we do it.” – Richard P. Feynman

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 705
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #7 on: January 12, 2022, 09:48:22 PM »
Tethered Level Flight with 45° Bank Angle

It’s an interesting condition to derive the tethered airplane flight with the same bank angle as the untethered aircraft. It is also a simple way of progressively deriving the vectors of the tethering state of the Cl model flying level at the 45° azimuth since the horizontal component will be the same. The vertical component will change when we derive that condition as well as the necessary G force to fly the condition. The reason to have look at this is to understand the impact that the horizontal lift component has on line tension.


 


Figure 8 – Forces during Tethered 45° Banked Level Flight
In order to cause the airplane to fly a smaller corner there are a number of solutions such as thrusters, side force generators and in our case a wire tether. So, this derivation will use a radius which would be the result of the airplane flying up to the 45° azimuth angle. This is the first step in the derivation of the total turning force and resulting line tension. In the same way as the untethered condition the lift vertical lift component must support the weight of the airplane.

The first step is finding the radius of the flight path with is the line length time the Cosine of 45 degrees resulting in 46 ft. From this we can determine the centripetal acceleration a=V^2/r From Figure 8 the radius is 46 ft and the velocity is 78.5 ft/s which result in an acceleration of 133.9 ft / s2. This can be reduced to a simple form which can be used for number of tasks such as calculating the tension in the lines. GTh = a/g = 133.9 / 32.2 = 4.2 G. This is the total horizontal G on the airplane and the tension in the line would be reduced by the contribution of the total lift vector, in this case 1 g so the line tension would be 4.2 – 1 = 3.2 G’s. If your airplane weighs 4 pounds the pull on the handle would be 4 x 3.2 = 12.8 lbs.


Ground Tethered Level Flight with 45° Bank Angle

When the airplane is tethered from a position off axis such as from the ground to the wing the forces change. The primary change is in the vertical lift component. This example is a progression from Figure 8 with the focus now on the vertical elements. All of the horizontal portions carry over. The impact of the tether being ground based is that it creates a vertical vector component which must be compensated for by increasing the lift on the wing.

 

Figure 9 – Forces during Wing Tethered 45° Banked Level Flight

Since the aircraft is flying around the same path as the previous calculation, the horizontal component is exactly the same and can be used to calculate the required total force necessary to be provided by the tension in the lines. Knowing the FTh we can find the total lift component FL ttl as follows:
FTh=FLttl*cos⁡θ

FLttl=FTh/cos⁡θ   


Again by dividing both sides by g we can coefficientwise this to terms of G. By doing that we get GL ttl = 5.9 G’s.  This is an interesting result in that the solution for the lift on the wing, G force, GL ttl to maintain level flight at a 45° azimuth is pretty much the same as that required for a loop scribing a 45° cone. This shouldn’t be surprising.
Life is good AMA 1488
Why do we fly? We are practicing, you might say, what it means to be alive...  -Richard Bach
“Physics is like sex: sure, it may give some practical results, but that’s not why we do it.” – Richard P. Feynman

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 705
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #8 on: Yesterday at 10:38:11 PM »
A friend of mine is helping me improve the English that I use to improve my communication skills. He didn't thin the 1-Cos X function fit and I had simply made some graphic representation for illustration. So, I worked up some plots with excel to show how well 1-Cos X can actually be made to fit. The attached snip is the excel plot over the graphic of the drag curves. Notice I was able to get a fairly decent fit by using only two constants.K1 and K2 which makes the equation

Drag gain = K2 * (1-Cos (  K1 * X))
Life is good AMA 1488
Why do we fly? We are practicing, you might say, what it means to be alive...  -Richard Bach
“Physics is like sex: sure, it may give some practical results, but that’s not why we do it.” – Richard P. Feynman


Advertise Here
Tags:
 


Advertise Here