In this article I’ll talk about one of the popular drive-modes of H-bridges, the Sign-magnitude drive in detail. If you’re not familiar with H-bridges in general, I suggest you read the previous part of the series first, where we’ve looked at the basic operating principles of an H-bridge and went through the various meaningful operating modes.
在本文中,我将详细讨论 h 桥流行的驱动模式之一符号幅度驱动。如果您通常不熟悉 h 桥,我建议您首先阅读本系列文章的前一部分,其中我们了解了 h 桥的基本操作原理,并介绍了各种有意义的操作模式。
Let’s quickly review the basics first! Our H-bridge looks like this:We will also make use of our motor equivalent circuit that I’ve introduced before:
让我们先快速回顾一下基础知识!我们的 H桥是这样的: 我们还将使用我之前介绍过的电机等效电路:
2.Basic operation
基本操作
In sign-magnitude drive, we have four control modes to choose from(we use ‘0’ replace ‘close’ and ‘1’ instead ‘open’ ):
These modes describe the way we map the states of the four switches to the ‘on-time’ and the ‘off-time’ of our PWM control signal. If you carefully investigate these tables, you’ll see that the four options describe the four possibilities for two binary choices: whether to keep the a-side or the b-side in a constant state, and whether to keep the low-side or the high-side switch closed continuously.
You will see pretty soon that one of these binary choices is usually made statically, while a control signal is used to decide between the remaining two choices.
您很快就会看到,其中一个二进制选项通常是静态地执行的,而控制信号用于在其余两个选项之间做出选择。
However, for now, let’s just concentrate on mapping 1 and see, how the bridge operates! As the mapping tells us, during the on-time, Q1 and Q4 are closed. This means that the left-side of the motor is connected to Vbat, while the right-side is grounded. Current can flow from the supply through the motor:
When the off-time comes along, Q1 stays closed, but Q4 opens and Q3 closes instead. In this state, there’s no path from the supply to ground through the bridge. However, both of the motor terminals are connected to Vbat, basically short-circuiting the motor. If there was current flowing through the motor at the time the switch-over happened, that current can continue circulating around the in that loop:
From this equation something should be immediately obvious: this mapping can’t move the motor backwards. For that we would need to be able to apply a negative (average) voltage to the motor terminals, but that’s not possible: the motor voltage can only be adjusted between 0 and Vbat. That would be a problem, but if we do the same math for mapping 5, we’ll see that in that mode, the opposite is true: that mode can only turn the motor in the reverse direction and the average motor voltage can only be between 0 and -Vbat.
In order to make a functional H-bridge, we need to employ both of these mappings and introduce a control signal that can choose between the two. This is the origin of the name of the drive mode: one control signal – the one that chooses between the two mappings – is used to determine the ‘sign’ of the voltage applied to the motor, while the other – the PWM signal – is used to determine the ‘magnitude’ of that (average) voltage.
The remaining two mappings are only slightly different from the previous two: the difference is that, during the off-time, instead of the two high-side switches, the two low-side ones are turned on. This means that the motor terminals are both connected to ground instead of the battery, but they are still shorted together and the motor current still circulates inside the bridge during the off-time:
Let’s take a closer look now at the way the current flows in the system! During the ‘on-time’ the motor inductors see a voltage difference of Vbat-Vg (provided the motor rotates in the same direction, the bridge tries to rotate it). If we disregard the internal resistance of the motor for a minute (or assume that the switching frequency is much higher than the electrical resonance frequency of the motor) this voltage will create a linear current ramp on the inductor (dI/dt = V/Lm). Since we assume Vbat is constant, the slope of the current increase will be determined by Vg, or in other words by the speed of the motor.
When the motor runs under no load Vg is very close to Vbat, so the current will change very slowly. If the motor is stalled, the current will rise much faster, as Vg is 0. The fastest current rise will happen if we abruptly change the drive direction from full-speed one way to full-speed the other way. In that case Vg will be close to Vbat in absolute value, but reversed in polarity.
During the off-time, the motor is short-circuited. If we disregard the internal resistance of the switches and the motor, the current can flow without interruption, and the inductors see Vg between their terminals. The current will start decreasing linearly, determined by the generator voltage and the motor inductor.
We say the bridge operates in a steady state if the cycle-to-cycle averages if the various parameters (voltages, currents) remain constant. The motor doesn’t accelerate nor decelerates and outputs a constant torque.
If things don’t change from cycle-to-cycle, it means that the motor current at the beginning of a cycle must be the same as at the end. Of course this doesn’t mean that the current stays constant during the cycle and this current-change is called ripple-current. Assuming linear current change during both the on- and the off time, the current deltas are the following:
What we get is this: in a steady-state, the generator voltage must be equal to the average voltage the motor sees. The average current will be whatever it needs to be to reach that condition. Now, if we put this Vg back to the current equation, we get this:
This is a second-order function (a parabola) with its maximum at ton = tcycle/2. So the ripple current reaches its maximum at 50% duty cycle, and its value is:
If you recall, the generator voltage is proportional to speed and current is proportional to torque. From the previous chapter it seems as though we have perfect speed control: the speed which is proportional to the generator voltage is equal to the average voltage seen by the motor, which in turn only depends on the duty cycle of the PWM input, our control signal. The torque (current) on the motor will be whatever it has to be to make that happen.
There’s something wrong with that picture isn’t here? After all we know that DC motors don’t keep a constant speed under load changes without any control circuit. True, and it’s easy to see what the problem is: we disregarded the internal resistance of the motor (and the switches).
Once you take those into account, you’ll see, that the motor current drops some voltage on those resistors, and the inductor sees only the remainder. (In the following equation I’ve made the simplification to assume that the motor current doesn’t change much, so the voltage drop on the resistor is relatively constant during the on- and off-times.)
If you put this into our previous ripple-current equation, you’ll see the result is a current- (or torque-) dependent difference between our intended speed and the actual speed of the motor:
In the previous chapter we calculated the ripple current, but we kept saying that the average motor current (in the ideal case at least) will settle at whatever level it needs to to make Vg equal to Vmot_avg. This statement has an interesting consequence: we can’t predict the direction the current will flow during the on-time and the off-time. In fact, if Imot_avg is lower than half of Iripple, the motor current changes direction twice during the cycle:
Now, one of those direction changes happen during the off-time, when the motor is short-circuited, but the other happens when the motor is connected to the supply. What follows is that at the beginning of every on-time for a short while at least, the current flows out of the bridge. Most supplies can’t deal with this quick reversal of current flow and if the reverse-current can’t find its way back to the power supply, the supply voltage will start rising potentially to dangerous levels.
To handle this reverse current properly we need to put a capacitor on the input terminals of the bridge to temporarily soak up the current coming from the bridge. The capacitor will release it’s extra charge back into the motor in the part of the cycle when the current flows to the ‘proper’ direction:
But just how big this capacitor needs to be? Well, that depends on a lot of things, so let’s list them:
但是这个电容器到底需要多大呢?好吧,这取决于很多因素,所以让我们列出它们:
How much reverse-current can the power supply handle?
电源可以处理多少反向电流?
How much voltage-hike can the circuit live with?
电路能承受多少电压?
What are the motor characteristics (mostly inductance)?
电动机的特性(主要是电感)是什么?
What is the switching frequency and duty cycle of the bridge?
H桥的开关频率和占空比是多少?
How much torque the motor needs to output (the average current through the motor)?
电机需要输出多少扭矩(通过电机的平均电流) ?
Since some of these parameters are dependent on the operating conditions and the exact application, let’s first do some simplifications and assume worst-case conditions:
由于其中一些参数取决于操作条件和确切的应用,让我们首先进行一些简化,并假设最坏的情况:
Let’s assume the power supply can’t take any reverse current
我们假设电源不能接受任何反向电流
Let’s also assume that Imot_avg is 0, so the current changes direction exactly at half of the on-time. (The capacitor can’t be sized for the condition when even Imot_avg is reverse compared Vmot_avg, since in that case the capacitor can’t completely release its extra charge during the cycle. We will discuss that situation later).
Finally let’s assume that the ripple current is at its maximum, so the duty cycle is at 50%
最后,我们假设纹波电流达到最大值,占空比为50%
Under those conditions, the current will rise for 50% of the time, and cross 0 at 25% of the total cycle time:
在这些条件下,电流将上升50% 的时间,在25% 的总周期时间处变成0:
The total charge released back to the system during the first-half of the on-time is:
在上半个工作时间内释放回系统的总电荷如下:
Qrelease = 1/2*((Iripple_max/2)*ton/2)
Q = It = CU
We also know that
我们也知道
ton = tcycle/2
Finally we know our ripple current is at its maximum:
最后,我们知道我们的纹波电流达到了最大值:
Iripple_max = Vbat / Lm * tcycle/4
Putting these together and do some simplifications, we get:
把这些放在一起并进行一些简化,我们得到:
Qrelease = 1/64 * Vbat / Lm * tcycle2
If we assume that the power supply can’t take any of this charge as we’ve said before – in other words all of it needs to be stored in the capacitor – the capacitor voltage will rise:
So if we know how much change in the supply voltage we can tolerate, we get a capacitor value:
因此,如果我们知道我们能够容忍的电源电压的变化有多大,我们就得到了一个电容值:
C = Qrelease/Vmax_bat_ripple
Substituting Qrelease we get:
代换 Qrelease 我们得到:
C = 1/64 * Vbat/Vmax_bat_ripple / Lm * tcycle^2
Note that the term Vbat/Vmax_bat_ripple is the ratio between the supply voltage and the ripple voltage allowed on the it. If for example we allow for 5% ripple, this value is a constant 20 independent of the supply level. Also note that the capacitance value needed increases quadratically with the cycle time.
请注意,术语 Vbat/Vmax _ bat _ ripple 是电源电压和它所允许的纹波电压之间的比值。例如,如果我们允许5% 的纹波,这个值是一个常数20。还要注意,所需的电容值随周期时间二次增加。
I’ve measured a few motors, and the lowest inductance value I’ve seen was in the order of 30µH, but of course this value varies a lot from motor to motor. So, to give you actual numbers, let’s take that 30µH inductance value, allow for a 5% ripple on the power supply and a 20kHz switching frequency. With that, we get a minimum ~26µF of capacitance needed on the power supply. If we only want to switch at – let’s say – 1kHz though, the capacitance needed is more than 10000µF!
C = 1/64 * 20/(30*(10^-6)*(5*(10^-5))^2 = 2.6*10^-5 F = 26uF
按照这个公式,我电机电感0.23mH,假设允许10%的纹波,
C = 1/64 * 10/(0.23*10^-3)*(5*10^-5)^2 = 3.396*10^-7 F = 33.96uF
7.Transient states
瞬态
Whenever Vg is not equal to Vmot_avg, the bridge is not in steady-state. When it is lower, the motor is accelerating, when it is higher, it is braking. We’ve seen above that the on-time current change is:
In other words, the motor current changes from cycle to cycle proportionally to the difference between the intended generator voltage (Vmot_avg) and the actual generator voltage (Vg).
Since current is proportional to torque, this means that if there’s a difference between the two voltages, the torque will start changing linearly. In this simple model, the current would keep changing forever, but in reality that of course isn’t the case. For one, internal losses limit the maximum current as we’ll see in a minute, but eventually, the changed torque would hopefully change the motor speed as well, bringing it closer to Vmot_avg, slowing down the current change. Eventually a new steady-state is reached where Vg is equal to Vmot_avg and the torque changed to a new value that is needed in order to maintain that balance. (If you read the article on motor modeling, you’ll see that in many cases the motor and the attached mechanical system can be modeled as a large capacitor and some sort of loss. That capacitor, with the internal internal resistance of the motor determines the time-constant by which this new steady-state is reached, and the actual response will be closer to an exponential curve.)
Now, this is all fine for acceleration, but there’s something strange that happens during braking. When Vg is higher than Vmot_avg, the torque (current) will start decreasing. As the electrical time-constants are usually several orders of magnitude lower than the mechanical ones (again, see the article on motor modeling for the details), the current (and the torque) turns the opposite direction to the shaft rotation (generator voltage).
Let’s see how big this reverse current can be, but in order to do so, we’ll first have to re-introduce the motor resistance into our model. The reason is that without the resistor, the motor current will just keep decreasing (or increasing in the negative direction) until the generator voltage changes and becomes equal to Vmot_avg. In other words, without the resistor, the motor current can be an arbitrarily large negative number. With the resistor in place however, the bridge will quickly settle to a constant cycle-to-cycle current, as the voltage drop on the resistor will put an end to the current-increase over the inductor.
Once that happens, we can use our steady-state equations, to figure out the average current:
一旦这种情况发生,我们就可以用我们的稳态方程,计算出平均电流:
Vg = Vmot_avg – Imot_avg*Rm
and solving that to the current, we get:
然后求出当前的值,我们得到:
Imot_avg = (Vmot_avg-Vg)/Rm
The reason the system can be in steady-state, while Vg is not equal to Vmot_avg is the internal motor resistance. What happens is that the internal resistance of the motor makes the cycle-to-cycle current change zero, which was the initial assumption in deriving the steady-state equations.
You can also see, that the average motor current is negative, as expected. It means that the torque is in opposite direction to the shaft rotation, so we are in fact braking the motor.
During the off-time this current is circulating through the motor and either the two low- or the two high-side FETs. However, during the on-time, the only way for the current to flow is through the supply. While the current through the motor is always in the ‘negative direction’ – more precisely opposing the generator voltage – the same current flows into the supply in the positive or negative direction, depending on which way the FETs are open during the on-time:
This current either charges the battery (first case), which is called regenerative braking or dis-charges it (second case), which is called dynamic braking.
While one would think that re-charging the battery is a good thing, there are two serious limitations to the effectiveness of regenerative braking:
虽然有人会认为重新充电电池是一件好事,但再生制动的有效性有两个严重的限制:
As we’ve seen, the average current during braking depends on the difference between Vmot_avg and Vg, and reaches its maximum when Vmot_avg = -Vbat. However, re-charging only happens if the current flow goes against the battery voltage, so we can’t operate the bridge in the reverse direction. This limits the amount of torque that’s available during regenerative braking. If more torque is needed, the bridge needs to operate in the non-regenerative (dynamic braking) domain. The regenerative braking torque will also decrease as the speed (Vg) decreases: it’s not possible to provide a constant deceleration down to 0 using regenerative braking alone. 如前所述,制动期间的平均电流取决于Vmot_avg和Vg之间的差值,当 Vmot_avg = -Vbat时达到最大值。然而,重新充电只有在电流与电池电压相反的情况下才会发生,所以我们不能反向操作电桥。这限制了再生制动期间可用的扭矩量。如果需要更大的扭矩,桥梁需要在非再生(动态制动)领域运行。再生制动扭矩也会随着速度(Vg)的降低而减小:单独使用再生制动不可能提供一个恒定的减速度使得电机速度降到0。
Even though the motor braking current gets greater, as Vmot_avg gets further away from Vg, that doesn’t mean that all that current will re-charge the battery: only during the on-time does the current flow through the battery. As you decrease Vmot_avg to increase the braking current, tonwill decrease as well and the re-charging effect will decrease with it. To be more precise, the amount of energy transferred in each cycle to the battery is the following:Ere-charge = Vbat * Imot_avg * tonwhich becomes this after doing the proper substitutions for Imot_avg and Vmot_avg:Ere-charge = Vbat/Rm*(Vbat*ton/tcycle-Vg)*ton,As you can see this is a quadratic function of ton, and it reaches its maximum when ton = 1/2 * Vg/Vbat * tcycle,in other words when the Vmot_avg is half of Vg. This effect will further limit your ability to regenerate energy from the motor while braking, or your ability to quickly brake the motor while maintaining good re-generation efficiency, depending on which way you look at it. 即使马达制动电流越来越大,当Vmot_avg离Vg越来越远时,这并不意味着所有的电流都会重新给电池充电:只有在接通时,电流才会流过电池。当您降低Vmot_avg以增加制动电流时,Ton也会降低,重新充电效果也会随之降低。更准确地说,每个循环中传递给电池的能量量是以下:Ere-charge = Vbat/Rm*(Vbat*ton/tcycle-Vg)*ton,你可以看到这是一个关于ton的二次函数,当ton = 1/2 * Vg/Vbat * tcycle时,换言之。这种影响将进一步限制你在刹车时从马达中再生能量的能力,或者你在保持良好的再生效率的同时快速刹车的能力,这取决于你如何看待它。
Even if you’re fine with all the limitations above, the question still remains: what to do with the back-converted energy? If your system is battery operated, the battery may or may not absorb this energy, depending on its technology. Even more serious problem is that the amount of charge a battery can take depends on its charge level – a fully charged battery can’t take any more charge. This means that you either risk overcharging your battery or limit your braking capability at least under some circumstances. Neither options are too pleasing.
If you run your system from mains (and necessarily through a power supply, since mains is AC and we’re driving a DC motor here), you’re even more limited: unless you specially design your power supply, it simply can’t pump energy back into the power outlet.
In both cases it seems that your safest bet is to consume or store the regenerated energy locally. If you have other loads consuming power, of course you can power those loads up to their current requirements. You might have lights, computers, other motors, heaters, sensors, what not running at the same time, that need energy. All that is great, but you don’t want the brake distance depend on how much the seat-wormer is on in your car, do you?
In other words, all these options provide some, but not very deterministic or reliable places to put energy to. What you would really need is some sort of reliable energy storage device that is not as sensitive as a battery and can store a lot of energy. Effectively a capacitor. Trouble is, actual capacitors of the sizes needed (easily several Farads) are not feasible. There is however another way (you would have to read more on mechanical modeling to understand why): stick another motor with a big wheel attached to it into your system. When you have more energy then what you know what to do with, simply spin-up the wheel to store the energy. When you are in need of energy, use (again) regenerative braking on that wheel to regain the energy and supply your needs. This is called a flywheel, and is in fact used in certain systems.
Trains, subways and other large, but well controlled systems usually benefit from regenerative braking as well as they quite often have another consumer (another, accelerating train) that can use the regenerated energy.
As you can probably see from this much, the problem of safely and reliably putting the braking energy somewhere is a complex one. It requires full understanding of the complete electro-mechanical system, and there is no one-size fits all solution.
Let’s say you don’t want to use regenerative braking because of all the complexities involved. So you want to operate in the dynamic braking mode of the bridge, and avoid regenerative braking altogether. How do you do that? The first thing you need to do is to figure out if the system is in regenerative braking mode. You can go about it in two ways:
We know the bridge is in regenerative mode if Vg is higher than Vmot_avg but the same polarity. To use this, we need to measure Vg or something related to it. That’s not necessarily a simple thing to do. I will come back to techniques for doing so in a future article about speed-control mechanisms, but usually you will need a method to measure the shaft speed using an encoder for example. 我们知道,如果Vg高于Vmot_avg,但极性相同,则电桥处于再生模式。为了使用这个,我们需要测量Vg或与之相关的东西。这不一定是件简单的事。在以后的一篇关于速度控制机制的文章中,我将回到这样做的技术,但是通常您需要一种方法来使用编码器来测量轴速度。
Use the knowledge that the bridge is in regenerative mode if the bridge current flows in reverse direction compared to the battery voltage. This involves measuring the current through the bridge including it’s polarity.如果电桥电流与蓄电池电压反向流动,则应了解电桥处于再生模式。这包括测量通过电桥的电流,包括它的极性。
After you have the right feedback in place, you can adjust your drive direction to make sure that Vmot_avg is always reverse in polarity than Vg any time you’re braking. But there’s another complication: how do you know you need to brake? You only know that if you know the intended and the actual speed of the motor, so you need to measure the shaft-speed (or Vg somehow) and you have to implement some sort of a control circuit.
If you did all that, you can successfully avoid regenerative braking. Then another problem arises: how much torque can you apply in braking mode to the shaft, provided you would only want to operate in the dynamic braking domain? We know that torque is related to the motor current and we’ve also seen that the average motor current during braking is the following:
To make sure that the motor remains in the dynamic braking domain, you will have to make sure that Vmot_avg has the same polarity as the motor current, which is opposite to Vg. So if Vg is positive as in all of our examples so far, Vmot_avg will need to be negative. That has the unfortunate consequence that Imot_avg cannot be smaller (in absolute value) than a certain amount:
This is a problem because it tells us that we can’t brake the motor arbitrarily gently. The only way to achieve that is with regenerative braking. As a matter of fact, it also tells us that he minimum amount of braking torque we can apply to the motor depends on the speed and is proportional to it. So at high speeds we will have more abrupt braking than at low speeds.
By now you probably see that dealing with bridges in phase-magnitude drive is not simple. At first sight it seems you only need two control signals – a PWM input to set the average voltage on the motor and a digital signal to set the direction – and you’re ready to go.
Detailed analysis however shows that no matter how you operate your bridge, braking is a problem. You either use regenerative braking with all of its complications or try to avoid it which isn’t simple either. You probably need to monitor the bridge current and the supply voltage to make sure you you don’t over-charge your battery. If you want to avoid regenerative braking completely you’ll most likely have to somehow measure the motor speed as well.
The silver lining is that at least you have a fail-safe mode to go back to: you can always set the PWM to 0% duty-cycle, effectively short-circuiting the motor. That will safely brake it down to a halt (almost) without risking to over-charge your battery or causing any other harm to your system. When you do that however, you have no control over how long it will take for the motor to stop though, so while it sounds safe from an electrical perspective, it might not be from the mechanical side.
Also, if there’s an external torque applied to the motor, simply short-circuiting it will never completely stop it as the braking torque is proportional to the speed: your electrical car will never stop on a slope just by short-circuiting the motor. You’re battery won’t explode, so there’s some benefit, but you would still end up in the ditch.
Talking about safety, there’s another positive about sign-magnitude drive: you can set the input signals to a static state (0% PWM is basically a constant low- or high- voltage) at which point the motor won’t see any voltage from the battery. This is especially important in systems where some setup is needed on power-on before normal operation can start, like in the case of microcontrollers. You can configure the HW so that the default state of the control pins is such that the motor is safely stationary and only move out from that state only after the system initialization is complete.
All in all, sign-magnitude drive seems simple at first, but as with many things, the devil is in the details. For undemanding, simple applications it might be a good fit as it is, in most cases you’re probably going to need some sort of monitoring circuitry that can detect dangerous or unwanted situations and intervene to prevent them.
I will come back to the sign magnitude drive when we will talk about drive circuits and component selection. Before that however I will cover cover the other main drive mode, the lock anti-phase drive and compare the two to each other.