News:



  • March 28, 2024, 05:50:40 PM

Login with username, password and session length

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

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 853
  • 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: 853
  • 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: 853
  • 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: 853
  • 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: 853
  • 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: 853
  • 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: 853
  • 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: 853
  • 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: 853
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #8 on: January 19, 2022, 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

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 853
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #9 on: February 14, 2022, 07:36:23 PM »
I flew the first prototype of my timer this evening on an Igor GeeBee foamy. During the period of beginning implementation, spelled learning a bucket load of code and how to use different devices, now our club became interested in the indoor foamy models which I made us a bunch of kits. While flying these it became obvious why Igor said a few times about the need for a different firmware for the indoor models. Flying and watching his models fly it became obvious that here needs to be an attitude input to the thrust function which drove me to figure out how to do it. This was always part of my original concept but had slid away partially after working out the control input and drag gain element.

The main difficulty with implementing solely a thrust gain based upon control position is that at times it will add too much thrust. For instance, during the high side of square maneuvers the turn to the vertical down line needs to have reduced thrust once the nose is pitching downward. And in a vertical eight type maneuver from basically the same position more thrust needs to be added in order to make the climbing turn. The trouble I was running in to is finding a simple solution to implement this. Most of the application attempt to use a linear gain based upon one of the acceleration axis. Being the propulsion guy, I'm thinking I don't need that exactly but what is necessary is enough thrust to compensate for the pull of gravity. Basically if there is a way of computing which way gravity is pointing then the thrust command can be determined as a function of the angle with respect to gravity.

It's easy enough to think that we could create a gain that works directly as a function of acceleration along the x axis, the line from nose to tail. The trouble with that is that when the airplane is accelerating or decelerating there is a resulting response.  Another way is to determine the actual attitude via an IMU and while this works, a Kalman filter takes a significant amount of computation time and the aircraft being tethered creates some special math problems as demonstrated by my previous derivations. It's not easy and the general form of that calculation is significantly more difficult than what I want to do.

In 2D space, the gravitational vector angle with respect to the nose is actually quite simple to determine using only an accelerometer.  In level flight the gravity vector is perpendicular to the x axis and has a value of one G. This is the Z axis. When the nose is pointed straight up the gravity vector is directly behind the airplane. Making an assumption in the operation of the previously developed control gain that the airplane made it through the corner without loosing energy it would now begin to decelerate since the level flight thrust just compensated for the drag and now gravity is adding to the drag force slowing the airplane.  The fix is simply adding enough thrust at this point to roughly equal the weight of the airplane. An interesting thing is that for a hard corner the increase in thrust is slightly more than that which is required to arrest the deceleration and all the control really needs to do is not cut the thrust back from the corner value.

It's not a very hard exercise to determine the amount of power required to compensate in this case. APC has some very wonderful data available on all of their propellers with thrust, RPM, speed and power required numbers which can be easily translated in to an RPM change and corresponding servo signal increase. Point the nose up, you have to increase the RPMs by 1,200 which results in x microseconds addition to the command going to the ESC. Simple.

To make this work smoothly the first step is to make a rough determination of the pitch attitude.  I fretted over this endlessly. If we do a simple statics calculation what we can easily sort out is the the thrust required to compensate for gravity is simply the weight times the sine of the pitch angle. In level flight the angle = 0 and sin(0) = 0 and at nose up the sin(90) = 1. As result there is a basis of calculating the gain. We just need an equation that goes attitude gain = a constant time the sine of the pitch angle. The missing part is a way to determine the angle.

There are a number of ways to calculate an angle from sensors or vectors. The form which computationally works in this case is to find the magnitude of the Gx and Gz vectors and use their vector sum to find the angle. Gt = sqrt( Gx^2 = Gz^2) and theta = arcsin(Gx / Gt). This has an inherent trouble in that the Gz value is quite high during the maneuver which will cause the computation to be off. I simplified the calculation of the angle while playing around with the IMU. It occurred to me that during the loaded portion of the maneuver it isn't necessary to know the attitude perfectly. Only to be working on the solution. By accident I realized that if the accelerometer were saturated at 2G's wrung a 6 G maneuver the calculation wouldn't be that far off. The result of doing this is a "better" idea of the pitch attitude and consequently  a better solution for setting the thrust.

The way this is implemented in to the control is by adding the control gain and the attitude gain together and limiting the output such that the total is never greater than a given value which can be made trimmable. The first flight test this value is fixed but my plan is to make it a trimmable parameter.  I currently don't have a programming box and am setting the power and gain via a potentiometer.  By using this approach the gain output will saturate during the hard maneuver and when the control is relaxed the attitude gain will have caught up and take over. During pitch down maneuvers towards the ground the attitude gain is subtracting from the control gain and the reduction is realized. Again the flight actually demonstrated this to work better than I expected as the attitude solution was working more quickly than I expected.

In order to better communicate this, I need to make some illustrations. However, I wanted to get his down in words.
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 Tim Wescott

  • 2016 supporter
  • Trade Count: (0)
  • Admiral
  • *
  • Posts: 12804
Re: Electric Motor Control - severe Geek speak
« Reply #10 on: February 14, 2022, 08:31:40 PM »
If you need to know how to use a 6-axis IMU to give a vertical gyro function ask and I'll help out.

The short story is that over time the average acceleration is always 1g downwards, even if it's doing short-term gyrations because of maneuvering.  With gyros to tell you where you are in the short term and accelerometers to tell you where you are pointing in the long term, you can write up code that'll always tell you which way is up.

Vertical gyros work pretty well even in untethered flight -- at FLIR we used them on our broadcast camera gimbals to maintain the camera at horizontal -- keeping the aircraft tethered to the hemisphere should help out even more.

This is much more interesting if it's done with mechanical gyros and mercury tilt switches, but a five pound lump of 1950's tech the size of a big soup can is kinda big for a control line stunt model.

Or dig around the wild world web to see if it's out there waiting for you to download.
AMA 64232

The problem with electric is that once you get the smoke generator and sound system installed, the plane is too heavy.

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 853
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #11 on: February 15, 2022, 07:21:29 AM »
If you need to know how to use a 6-axis IMU to give a vertical gyro function ask and I'll help out.


Thanks Tim. I have one working like that but the required solution isn't that difficult and the simple accelerometer solution works.  If you don't include the code to used to configure the IMU, what I'm using is four lines of code minus filtering. There's more code to debounce the switch than calculate the thrust command.  The sensor I'm using is fully functional but that is because it is less expensive than a basic 3 axis accelerometer. I have a couple IMU code variations which I understand well enough to use. However, the reality is that it isn't necessary to get good performance with such a complex solution. Of course it could be made more perfect if a better attitude solution is there.

As a result of using the saturated Z axis there is an error in the angle solution and it could be made more perfect. With one test flight in, it is hard to say. What I can say is the throttle cut turning from high to low either upright or inverted and the throttle push from the control input followed by the push from the attitude gain was very impressive. The lag from using the saturated calculation wasn't immediately obvious. The reason is that the attitude gain is masked by the control gain which is saturating the output already.

The round maneuvers seemed to be good as well. Keeping in mind that this test airplane is a light draggy foamy. How a PA airplane will respond is open but there's enough gain trim flexibility to adjust.   

The one thing that isn't working really nice is that there is some oscillation present. That is likely due to the way the foamy airplanes shake from the prop blast and that is getting in to the control position pot, gutted servo, which I'm going to add a filter to. None of the inputs currently have any filtering. Today I am implementing a simple rolling average in to the control input signal and add a small bit of dead band which I had initially planned but didn't implement.
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 AMV

  • Trade Count: (0)
  • Commander
  • ****
  • Posts: 152
Re: Electric Motor Control - severe Geek speak
« Reply #12 on: February 15, 2022, 09:24:36 AM »
...Of course it could be made more perfect if a better attitude solution is there...

Madgwick AHRS solved this problem twelve years ago. Significantly cheaper computationally than the Kalman filter, and easily results in <2 degrees of heading accuracy with a $10 9-DoF IMU after proper IMU calibration.

Cheers, H^^
-Andrey
Spice is the variety of life.

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 853
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #13 on: February 15, 2022, 10:28:16 AM »
Madgwick AHRS solved this problem twelve years ago. Significantly cheaper computationally than the Kalman filter, and easily results in <2 degrees of heading accuracy with a $10 9-DoF IMU after proper IMU calibration.

Cheers, H^^
-Andrey

That's $7-$8 more and 7 DOF more than is necessary to complete the necessary computation. The MPU6050 is $2 per.
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 Howard Rush

  • 22 supporter
  • Trade Count: (0)
  • Admiral
  • *
  • Posts: 7805
Re: Electric Motor Control - severe Geek speak
« Reply #14 on: February 15, 2022, 01:16:05 PM »
Madgwick AHRS solved this problem twelve years ago. Significantly cheaper computationally than the Kalman filter, and easily results in <2 degrees of heading accuracy with a $10 9-DoF IMU after proper IMU calibration.

That's $7-$8 more and 7 DOF more than is necessary to complete the necessary computation. The MPU6050 is $2 per.

Technical merit of this discussion aside, sensors have sure come a long way since 1980.
The Jive Combat Team
Making combat and stunt great again

Offline AMV

  • Trade Count: (0)
  • Commander
  • ****
  • Posts: 152
Re: Electric Motor Control - severe Geek speak
« Reply #15 on: February 15, 2022, 02:01:03 PM »
Technical merit of this discussion aside, sensors have sure come a long way since 1980.

...and to me, 1980 forever remains 20 years ago.  LL~ LL~
The other day I was watching a video interview of some average Joe recounting his memories from his youth in the 1950s. The interview was done sometime around 1980.  It dawned on me -- at the time of his interview, WWII was as fresh to him as 1980 is to us now.

Time flies like an arrow; fruit flies like a banana.
Spice is the variety of life.

Offline Mark wood

  • 22 supporter
  • Trade Count: (0)
  • Captain
  • *
  • Posts: 853
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #16 on: February 15, 2022, 02:11:46 PM »
Technical merit of this discussion aside, sensors have sure come a long way since 1980.

That's very true. I did consider using one of the Kalman integrated sensors but the reality is for the job it is way over kill. Besides, without a data collection flight to understand the impact of tethering on the data I don't have enough understanding to use one. The bottom line is that all you need to know is which way is the gravity pointing in relation to the direction the nose is pointing. That's a simple solution which can be determined easily enough using the Gx and Gz vectors. It works quite well even in the wingover maneuvers. As the airplane crosses over the pole Gx changes from positive to negative which drags the gain sign with it cause the output to go from adding thrust to reducing thrust. The only problem is preventing a divide by zero crash as the wingover involves a Gz = 0 and at the pole Gx and Gz are zero. So I added 0.01 to the dividend to keep the 1/0 daemon away.
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: 853
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #17 on: February 23, 2022, 01:56:01 PM »
Here is a first glimpse at the control functioning. After the first couple of successful flights, I had to mess with it. Needless to say that wasn't exactly a good idea, although it is ultimately necessary to bring the control to it's potential. The next feature I am going to incorporate is the RF terminator which will expand to inflight gain trimming. That will begin as soon as the PCBs arrive.



 
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: 853
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #18 on: February 23, 2022, 04:10:34 PM »
Here's a slightly better video with some discussion of what is happening with the control. My heater is running in the background since it is RF cold outside right now here. It's about 7 F and my shop isn't super well insulated.


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: 853
  • I'm here purely for the fun of it.
Re: Electric Motor Control - severe Geek speak
« Reply #19 on: February 27, 2022, 07:13:08 AM »
We didn't get any video of the control in the GeeBee flying yesterday but the performance is becoming very good. Several of us flew the airplane and the consensus is very positive. The turning from high to low is gaining a bit too much energy, as could be anticipated, otherwise the power and velocity are quite trimmable. I have a bias solution to cut back some of the maneuvering gain during the high turning low maneuvers. The trouble is that the attitude gain lags noticeably and doesn't catch up until just past the exit of the corner which is too late to prevent the acceleration.

I have some PCB boards coming to build a few of these in a more "professional" package.

Next time we have the gym for flying, I'm hoping to have the bias gain working. I'll be certain to get some video.
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