| Electronics > Projects, Designs, and Technical Stuff |
| Question on PID for speed control of DC motor in treadmill application |
| << < (4/5) > >> |
| rstofer:
Treadmill controls are available for about $130, ready to use (on something). Google has a lot of hits for 'treadmill speed controller' including a lot of DIY projects. There is nothing to be gained by re-inventing the wheel (or speed controller). |
| Siwastaja:
--- Quote from: XaviPacheco on November 03, 2018, 12:56:54 am ---Wait.. what? Why multiple PI for this application? It's a 'simple' speed controller. --- Quote from: Yansi on November 02, 2018, 11:12:23 pm --- Never! control duty cycle of any (large) electric machine directly! Even if it is small. Large dangerous currents may still flow through the circuit. Any suggestion to control duty cycle directly is mostly wrong assumption (at least troublesome!), so is switching between different PI regulators for a single control loop. --- End quote --- What do you mean exactly by "directly"? --- End quote --- What he's telling you is the same I'm always telling everyone: you need to control the motor current, to prevent blowing up the power semiconductors, and this needs to be quick. (Torque control and motor protection are side products; they wouldn't need to be that quick, but you are fine with one quickly-acting control.) One way to do it is a PI loop; measured signal is the measured motor winding (not input) current, and setpoint is your desired torque. A fast comparator terminating a PWM cycle is equally fine, although a bit less precise. Often, both are used. If you use a comparator, there's nothing fundamentally wrong to control the "duty cycle directly" - it's just that this duty cycle is overridden by the current comparator at the PWM generator (timer module in MCU) level. |
| Yansi:
Look at it whatever you want, but the current through power stage should always be limited, if not directly controlled. With DC machines, torque is directly proportional to the armature current, rotational speed is proportional to armature voltage. The theory behind DC machines and their control is nothing complicated, but I understand general public and even average EE may be quite under-educated about these. So to put a bit of basic theory in here; please don't bash me for not trying to write another electrical machine textbook here. You can surely find one in your technical library yourself: A steady state voltage equation for armature is Ua = Ra*Ia + c*Phi*omega. "a" being the suffixes for armature. Ra is the DC resistance of the armature. Phi is the magnetic flux originated in the field windings or permanent magnets on the stator. Omega is the rotational speed (rad/s). "c" is a constant that is specific to the DC machine construction. Ua of course is the voltage across the armature terminals of the machine you connect your wires to. What a brisk mind might already see is that armature resistance is what causes the typical small motors to have low torque at low armature voltages. In fact, Ra directly affects how "stiff" the speed characteristic is, with increasing load torque. For further analysis, you need to add also the effect of inductance of the armature. It is especially important for a correct power stage design! The equation therefore is more like Ua = Ra*ia + c*Phi*omega + La*dia/dt. Note that La is the armature inductance, while ib being the instantaneous armature current. What comes important from this is that the switching frequency of the power stage needs to be high enough not to cause the current (torque) to ripple excessively. This and exactly this is what excuse me all dumb EE hobbyists do wrong. (More on that later.) Excessive current swing will damage the power stage (high current ripple increases the effective current value seen in the circuit), damages the motor winding and damages also the mechanics of the system by torque ripple. This is also a major consideration when going over few kW of power. Then even the torque cogging caused by the motor itself may be of an issue. (Typical culprit: switched reluctance motors) With some basic math you should be able to derive that the maximum current ripple value peak-peak Idelta for a specific switching frequency is Idelta = Vsrc / (4*La*fpwm), where Vsrc is the supply voltage for that typical "buck configuration" power stage. Note that the maximum current ripple happens at exactly 50% duty cycle. Of course we have neglected the armature resistance, but it is not that important for this ballpark calculation. But what is important is if we say the current ripple Idelta shall be low, typically below 10% of the motor nominal current, we can solve for the minimum pwm frequency as such: fpwm >> fpwm(min) = Vsrc / (0.4*La*In). For most typical motors it is a few kHz typically, 10-15 kHz is sufficient for most applications from few watts up to few tens of kW. Going excessively high with the switching frequency causes problems within the power stage itself (switching loss). The other equation I have not mentioned yet is the one for torque: M = c * Phi * Ia. I'd rather not come into much details why these two basic DC machine equations are exactly true or not for a real DC motor, but with these you can begin designing a lot stuff. Note that the "c" constant in theory should be the same as in the other equation, Phi is the same magnetic flux from either field winding or permanent magnets. The other thing I would like to appoint is that the rated power of any electrical machine is the output mechanical power on the shaft, not the maximum electrical input! The maximum electrical input is typically limited by the winding current. Pmech = M * omega. I have seen numerous times people to measure the power consumption of a motor with a wattmeter, comparing it to the nominal motor power (stamped on the nameplate) and considering this a check if a motor is not overloaded. Sure, it won't be, but you won't get the full output that way. Check for the input current instead. Now what really ticks me off is when some under-educated creep argues that "you need low PWM frequency otherwise it does not have any torque at low speed". Above you have a mathematical proof, that such argument is bullshit. I have already explained what is the cause of the speed drop when load is increased. With the equations above a brisk mind can already tell how to compensate for it. Hint: Increase the armature voltage proportionally to armature current to get rid of that Ra*Ia term in the first equation. In case of a typical "pwm regulator" you may build, you need to increase the duty cycle based on the motor current. Note that you can even overcompensate the term and obtain interesting torque-speed characteristic. This little trick is mostly used in dc motor wheel chair drives. Hence why the wheel chair with DC motors with high frequency PWM has no problems going over obstacles with high enough force. And yes, there is none speed feedback in most wheelchair drives. It is simply not needed. And the current is measured anyway, for obvious reasons of not blowing the controller into bits when someone mistakes the wheelchair for a bulldozer. What I would also like to point out at the end, regarding to the typical situation on image below taken from a typical machine textbook, is that the diode has to be rated for the same current as the mosfet is (in a typical application where the duty cycle is used from 0-100%, which inded is most of these applications). Also note that Ui is the c*Phi*omega term in the first equation. I hope this lengthy post may at least change the level of your confusion, if nothing else. Y. |
| XaviPacheco:
Thanks for your lengthy and useful post. It has helped me understand some important concepts. For now, I'm very interested in determining the model and characteristics/parameters of my motor. I attach the nameplate of the motor I'm controlling via PWM. |
| Yansi:
Using the math above I have supplied, you should be now able to determine the nominal output torque, the torque and speed constant cspeed and ctorque. Just try it... nothing complicated here. You need to also measure Ra and La for completing the model and all unknowns into the equations. You should be able to even plot some approximate characteristic (speed vs. torque) for different armature voltages of that motor, even other ones. Other measurements might be to determine the rotational inertia (angular mass) of the motor or the whole system - but these are a bit more advanced concepts that help design the PI regulator cascade, the speed regulator respectively. But both can be tuned with a good degree of success just "by hand". In fact, if you are going to control speed of the system, usually you even need a third PI regulator loop just for the speed sensor itself. To be exact, it is not a PI loop, but in fact a PLL, google for "angle tracking observer". This concept is utilized for many speed sensor types like resolver, including the obligatory quadrature encoder. When trying to implement some control loops in the real world, you will quickly learn, that the digital control loop needs to be run at constant frequency that is typically in sync with the power stage switching frequency (optimally, both the same) and that to feed the speed regulator, you need to know the instantaneous speed exactly n-times (typicaly fpwm i.e. 15kHz times) a second. Which, if you have ever programed any kind of speed measurement you shall know that is an interesting requirement: Most hobbyist program a digital speed meter as a frequency counter. That is nice as an indicator-level only, but can't be used for speed control. A frequency counter need to count pulses per given time and at 15kHz (67us gating interval), you would not count much pulses at low speeds, if any and you would need an encoder with extreme numbers of pulses per revolution to obtain ever slightly good resolution at low speeds. Measuring the time in between pulses will not get you anywhere either, as that would not give you speed measurement at an exact interval - would depend on the speed. Now you probably guess there is a trick to it - that is the tracking observer. What you need to realize is that an encoder does not give you speed, but (angular) position. It should be no surprise that by taking a derivative of position in time will get you the speed. But in real world, making a derivative of any real world signal is very problematic due to noise pickup, you do the exactly opposite: integrate. It looks like this: By taking integral of an estimated speed, you get back the angle position (based on the estimated speed). Now if you take the estimated position and calculate an error against the real position from the encoder, by feeding it to a PI regulator you can close the loop and let the PI regulator deal with guesstimating the speed. That is what basic observer is. It may sound complicated, but it is not. In real applications, you just count pulses from the encoder indefinitely and trying to guess them by the PLL (PI+ integrator), and the speed comes like byproduct of the loop. Modelling an tuning this PLL loop is very easy, as it does not depend on outer world, it just defines the dynamics of the sensor element in the whole system. I know that this is a lot to cover in just two posts, I would strongly recommend looking for some appropriate literature here. Y. |
| Navigation |
| Message Index |
| Next page |
| Previous page |