BLDC Brain

Alan B said:
grindz145 said:
What's hard about simply running the motor in generator mode is that you don't necessarily generate enough bemf to get a charge voltage higher than your pack voltage. Especially for overvolters.

The PWM works against the inductance of the motor to up convert the BEMF voltage (as it down converts when driving).

Forgive me; I’m not an EE so I need a bit of hand-holding…

grindz145: If the voltage is less than the battery pack, could we not employ a buck-booster circuit? :)

Alan B: I’d like to comprehend; are you saying that by virtue of the design to be a motor is not so great a design to be a generator?

Out of the box, KF
Possibly out of my tree too...
 
Kingfish said:
grindz145: If the voltage is less than the battery pack, could we not employ a buck-booster circuit? :)
That is what the PWM of the motor in regen mode does, (or more likely: the shorting of the coils momentarily then reopening them so that the resulting voltage spike as current flows again is much higher than the battery pack).

Kingfish said:
Alan B: I’d like to comprehend; are you saying that by virtue of the design to be a motor is not so great a design to be a generator?
No, just that any motor spinning at a particular speed relative to it's windings and magnets has a particular voltage it will generate, whether it is in motor mode or generator mode.

In motor mode that voltage is what limits the current you can force thru it (and thus the acceleration you can get out of it), as you have to have a difference between that voltage and the voltage you are feeding it from the controller to get current to flow. The higher the difference, the greater the motor power output.

In generator mode, that voltage is what can be tapped to feed a battery or a plug brake (resistive element). When feeding a battery, then again the difference in voltage between the battery and the motor output voltage will determine the current flow, and thus the load on the motor/generator, and thus any braking effect. Bigger difference, bigger current, bigger load and bigger braking effect. The speed at which the particular motor/generator is spinning determines how high that raw voltage (BEMF) is, if you do nothing to boost it.

But if you use the controller to boost it (one way is I think called synchronous rectification), then you can increase the effect of the braking, although if I understand correctly you are not boosting the average voltage from the motor, only the peaks (because now it is not producing the voltage all of the time, just in PWMed spikes). I think the average voltage remains the same.

But even though that average voltage might be the same, the peaks are high enough relative to the battery voltage to cause current flow and a load and braking, whereas the constant voltage of just the unmodified motor output might be equal to or less than the battery voltage, causing no current flow and no load and no braking.

When I use regen braking with my Lyen 6FET and a 9C, for instance, then it feels pretty constant using a 36V NiMH pack braking from about 15-18MPH. But using a 48V pack, all other conditions being equal, it feels weak and "pulsey", like it's vibrating, because only the peaks of the voltage during motor rotation are causing current flow and braking, rather than most of the percentage of the motor rotation time.

I may be misunderstanding or misinterpreting what is happening, or misexplaining it, so if I am, please correct me. :)

(edited to fix my quotes)
 
Ah so! <bowing low> :idea:

In consideration to energy conservation, the following statements can be made:
  • At Speed-X, running in Motor-mode takes Y-amount of energy (inclusive of resistances).
  • At Speed-X, running in Generator-mode emits < Y-amount of energy (inclusive of losses).
  • These two modes cannot be equal (least we imply a perpetual motion machine); motoring will always take more energy than generating when the hub is turning at the same speed.

Allow me to throw out an idea:
Some have thought of using a super-cap to capture the regen power. What about using a fast battery, nano-tech seems like a good candidate, couple of Ahs worth of capacity; enough to soak up a long downhill. At the beginning of the regen cycle, these fast batts are drained; idled at the minimum charge. When regen begins the load will be large/largest. When regen ceases, or at some predefined point a buck-charging circuit kicks in, refilling the main batts by draining the fast-batts. Rinse & repeat.
This system would then always have maximum breaking regardless of battery voltage, and without the artifacts of pulse-braking. The fast-batts could be sized to suit, as could the limiting thresholds and frequency of refill. :)

Whatcha think? Hair-brained, or pea-brained?
? KF ¿
 
Well, I am an EE, but I didn't study motors in college. All that computer stuff was more interesting...

However lets see if we can work through some of this. When coasting the motor will generate a voltage proportional to the speed. This is the same voltage we usually call back EMF. If this voltage exceeds the battery voltage (must be a big downhill) the inherent body diodes in the FETS will cause uncontrolled charging of the battery. So this tells us that, if we go downhill at speeds greater than the unloaded speed of the motor we will get regeneration whether we want it or not. So catching the race bikers downhill not only requires a good gear ratio it also requires either a fast motor or some kind of disconnect. So this is not very useful, and not what we are talking about when we speak of regenerative braking.

So we need to use the FETs and the motor inductance to up-convert the back EMF to the battery voltage so we can get some charging. A voltage boost circuit.

With inductors we can get boost by interrupting the current in the inductor. The collapsing field will generate high voltage. For example if we manipulate the FETs to "short" the motor winding and create some current flow from the back EMF, then interrupt this short the resulting collapsing field will generate a pulse that will raise up in voltage until it reaches battery voltage and conducts through the diodes.

Synchronous Rectification is using the FETs instead of the diodes to make the current flow to the load. The FETs are lower in voltage drop than the diodes so using them with the right timing will be more efficient. But the timing has to be controlled properly.

I have not worked out the details of the pulses to do regenerative braking, but it is clearly possible with the FETs in the standard controller. But with a PWM twist to cause the up conversion of the back EMF to generate voltage higher than the batteries.

Plug braking would probably require more FETs. In that case the back EMF/generated voltage is routed to a load and generates braking.
 
I suspect the same limits that govern the motor current in operation govern it in regeneration, so we can only charge the batteries at the rate we drain them, minus some losses. So if the main battery can take charging at that rate we can brake as hard as we accelerate. If the batteries cannot take that rate then other alternatives might be worthwhile, keeping in mind that for a bicycle we have a lot of limitations in total system weight, volume and cost.
 
Alan B said:
I suspect the same limits that govern the motor current in operation govern it in regeneration, so we can only charge the batteries at the rate we drain them, minus some losses. So if the main battery can take charging at that rate we can brake as hard as we accelerate. If the batteries cannot take that rate then other alternatives might be worthwhile, keeping in mind that for a bicycle we have a lot of limitations in total system weight, volume and cost.
Gotcha. For the moment, let us presume cost/weight/volume are no object. I am interested in understanding the solution. Once that is completed then we can think about cost-effectiveness :)

Best, KF
 
With regard to regen -- I'm not sure I understand all the discussion....so i tried it on the bench instead.

Somehow the Infineon controllers are (supposedly) able to get regen out of a standard FET configuration, so a new brain should be able to do the same.

My theory that if you run a very small PWM in the reverse commutation direction, with the wheels spinning forward, it would generate back EMF enuf to create a reverse current. This is not the case. When spinning the wheels in the reverse direction with a small PWM in the forward direction, the small PWM INCREASED the load on the batteries, rather than reverse the current. There must be some magical mystery of phase excitation that produces the desired reverse current.

Mark.
 
You must do something that causes the motor's generated voltage (BEMF) to exceed that of the battery in order to get reverse current. AFAIK the way it's done is as described previously (though I have no details on the technical methods).
 
the regen devil is in the details.

I found this online blog about BLDC Regen: http://www.microchip.com/forums/m431354.aspx

You need to switch the lower side MOSFETs from 0 to 90% (what ever voltage you need) and upper side MOSFETs as OFF. The switching of lower side MOSFET and diodes from upper MOSFETs form a boost converter along with the Motor winding.

During braking, the motor winding will have voltages in them (due to back emf). If your duty cycle (for low side MOSFET) is big enough, you can boost the motor winding voltage greater than the bus voltage. This will cause the energy flow from motor to the battery.

and...


You have to switch all 3 MOSFETs at the same time. Try varying duty from 10% to 90%. For higher duty cycle, the boost output gets higher.
Following steps can be done: -

1. Write the code to read potentiometer thro ADC and feed that value into PWM duty cycle register. All 3 lower MOSFETs should be switched at same time. So, you can select different duty cycle value while motor is running.

2. Try low value of PWM frequency, like 1KHz.

3. Run the BLDC motor thro another motor and while the motor is at some fixed RPM, say 1500RPM, increase the duty. You should see the bus voltage go up, or current flow in reverse direction, into the battery.

These are the steps -- straight.

Wild... but it sorta make sense. I'll try this tonight.
 
Good work; sounds quite optimistic. Wouldn’t it be great to be able to control that duty cycle through the throttle! :)

I couldn’t find anything useful from my other sources; in my extreme youth I worked down in the Engineroom on three different ships and it seemed to me that the generator used a brushed exciter to develop the fields, and the AC was rectified straight off. They were pushed by 600# steam turbines; makes one feel quite old thinking about it.

Answering bells, KF
ding ding ♪ ♪
 
{Puts on tin foil hat to communicate with the higher intelligence beings}

I am REALLY dumb when it comes to programming, but is there a way to read the code off an 846 chip? It has variable regen through throttle input.

{Crushes tin foil, throws at waste basket, two points!}
 
number1cruncher said:
{Puts on tin foil hat to communicate with the higher intelligence beings}

I am REALLY dumb when it comes to programming, but is there a way to read the code off an 846 chip? It has variable regen through throttle input.

{Crushes tin foil, throws at waste basket, two points!}

I dont know about the 846 specifically but often MCUs have code protection fuses that make dumping them difficult. Howerver in this case it would make much more sense to rig the controller in a bench setup and measure the commutation outputs with a scope or logic analyzer rather than trying to dissasemble firmware.
 
A new brain cell is born!

The pulsing of the lower fets while rotating the BLDC motor DID GENERATE REVERSE CURRENT. I was using a power supply, and only pulsing at about 3% at abuot 1K Hz. spinning the wheel by hand, and it generated about 50 mA. There was a noticeable drag on the wheel, and a whine (from the hub motor, not me).

Big deal you say? Well it just proves a theory that the "standard' BLDC FET configuration can generate 'SOME' current.

There are a couple simultaenous ideas: A brawn board using Jeremys brawn schematic, and this brain side. There is a new newer brain concept in the works that is better paired with the newer brawn board, as it has curent level inputs, voltage sensors, and a complete user interface. This brain concept needed more PIC pins and I've gone to a 28 pin PIC16F886. The reason for all this info is that the PIC16F886 has enuf pin to allow inputs for 2 brake inputs. The concept for brake inputs would be to stop forward commutation, and apply some regen on one brake, and more regen on two brakes. (has this ever been done before?)

Mark.
 
hardym said:
...

The pulsing of the lower fets while rotating the BLDC motor DID GENERATE REVERSE CURRENT. I was using a power supply, and only pulsing at about 3% at abuot 1K Hz. spinning the wheel by hand, and it generated about 50 mA. There was a noticeable drag on the wheel, and a whine (from the hub motor, not me).

Big deal you say? Well it just proves a theory that the "standard' BLDC FET configuration can generate 'SOME' current.

...

Excellent experiment and result, Mark. I just analyzed the circuit that makes and it is essentially a simplified version of what I was suggesting earlier. Closing all three lower FETs shorts all three phase coils in the motor. The generated voltage on the coils causes current through the FETs to rise, limited by the inductance, and store energy in the resulting magnetic field. Opening the FETs causes the field from this current to collapse and generate a voltage which adds to the generated voltage and together they exceed the battery voltage and diode drops and current flows into the battery. The diodes provide some loss in this configuration.

This is NOT synchronous rectification. It is not optimal, but is very simple.

Synchronous rectification would require using the hall information to control the FET timing and avoid the diode losses. PWM is still required to cause the voltage up conversion.

Very Neat!
 
hardym said:
The concept for brake inputs would be to stop forward commutation, and apply some regen on one brake, and more regen on two brakes. (has this ever been done before?)
Not that I've seen.

But it would be very useful to manyif you could spare an analog input instead, for the brake input. THen an analog hall could be used on a brake lever, or a second (possibly modified for reverse operation) throttle could be used, to control braking and braking level. (or even a dual-hall center-off throttle similar to Vectrix). But if using a switch-type hall, or reed/etc switch brake lever, it would still work (just as full-on/off instead of analog).

Just set the thresholds for an analog hall, with zero braking and digital off down at the 0.8(?)V level, and max braking up at the 4.2(?)V level, with any voltage outside that range treated the same as being at that level, and anything inside that range treated as an analog level of braking.

If necessary, set it up so that either a user-programming option or a jumper or something user-settable switches between the port being read as switched or analog.

I know that i don't like not being able to modulate the braking level when using regen, when it's easy with mechanical brakes. Instead i must pulse them manually which is harder on the forks, headset, dropouts, torque arms, etc. when doing this at relatively high speeds.
 
Since there still seems to be many questions on how a brushless controller does regen, I'll try to help out and explain it as simply as I can. Hopefully it won't sound too much like "rocket science" ... :roll: *edit*: Others have posted better regen explanations since I started writing this, but I'll post this as is anyways.

But before getting into the regen explanation I'll just clear up some things about commutation that were discussed earlier:

Commutation events:
First thing, regen is *not* accomplished by changing anything about the commutation sequence. Commutation events in a brushless motor happen at a relatively slow rate which is proportionnal to the motor's RPM, and their purpose is solely to rotate the motor coil's magnetic field to keep up with the permanent magnets spining on the rotor. Playing with these commutation event timings can be usefull, for example, to compensate for the motor's coil inductance effects at higher speeds (like Burtie is doing). There are many ways to play with commutation timing (having many fancy names), the simpler methods using guesswork to adjust the timing advance based on motor test results at various speeds and phase currents. The more complex methods aim for an adaptive timing adjustment based on the motor's true phase currents circulating in the three windings, and then using this info to determine the true orientation of the generated magnetic field in the motor. We then would compare the true magnetic field orientation found this way with the motor's BEMF or hall position information, the difference between these two positions being the necessary phase advance angle needed to compensate for the motor's current reaction lag at that given moment in time (meaning at that particular speed and load). This is what Rickie in New Zealand is working on doing in his controller. Anyways, sorry for the commutation subject tangent here but I wanted to explain what can and can't be done through manipulating the cummutation events (which is just hall sensor state changes or sensorless zero voltage crossing points).

Simple drive/ regen PWM:
Regen is performed instead by the much higher frequency PWM switching events (as many here already know). For BLDC motors with simple trapezoid control, PWM only happens on the one active phase at a time with a second phase usually being held low (ground) to complete the circuit. Amberwolf described pretty well how the voltage is built up in the two driven motor phase coils during a PWM cycle, which is most simply done by switching only the active phase's low side MOSFET(s) appropriately (versus switching only the active phase's high side FETs when normaly driving the motor). When doing regen in this mode you are using the high side FET's body diodes to conduct while the low one(s) are off. This will give you regen behavior similar to the regular drive mode behavior, but in reverse. So in this mode it is only possible to pump energy back into the batteries, but never the opposite. This mode could be a fairly good and simple solution to create a linear regen control based on a modified brake lever (fitted with an analog hall sensor).

Synchronous rectification (more complex type of PWM):
A more complicated but efficient mode of control for switching the MOSFETs is called synchronous rectification, which simply means switching both the high side *and* low side FETs of the active phase instead of only one or the other. This will improve the efficiency of your contoller quite a bit since the resistive drop of the FET(s) under load is usually much less than when using those same FET(s) as diode(s). However this comes at the price of control complexity, since your active phase's MOSFETs now make up a *bi-directionnal* energy converter --> which means no more possibility of the "coasting effect" in either drive or regen mode as when only switching one bank of MOSFETs. This means that a controller using synchronous rectification has to "simulate" the coasting effect if it is desired for the user (as it is on EV's). This is done by having the controller constantly adjust it's output to "track" the motor's BEMF, which results in no current flowing either way. This would usually be done using a phase current control loop.

Hope this helps and not confuses!

Pat
 
Great descriptions, Pat.

It seems to me that during regen braking using the diode techique that max braking would occur at or near 50% PWM which maximizes the voltage up conversion effect?

I also like the idea of an analog ebraking control. Perhaps a separate brake lever or smaller trigger since hydraulic brakes don't allow much motion before they come on and modifying them for dual action is difficult.
 
Slightly late to the morning conversation…

AW: Perhaps restating, the wish list should be programmable through firmware as:

  • Low Limit: 0 (default)
    High Limit: 4.5V (default); Pull up for full-throttle.
    Throttle Value: Analog (default) or Digital (encoder)

The Wheel positioning feedback should also have like potential by using either Analog signal or Digital encoding.

Privately with regards towards the throttle interpolation, it could be fun to speculate on ramps and gain but it might be a bit much to ask when we’re still trying to figure out how to use a bi-directional gate valve. Wouldn’t be great to have a visual simulator, figure out your optimum and remit the parameter? Just needs an interface… hmmm 8)

Pat: With regards to bi-directional FET et al, could we have coasting if there was a condition of Zero-Throttle and Zero-Brake values? To initiate either one would incur a few ms delay for sense to report and proper response. :?:

Illuminated by candlepower, KF
 
Alan B said:
Great descriptions, Pat.

It seems to me that during regen braking using the diode techique that max braking would occur at or near 50% PWM which maximizes the voltage up conversion effect?

I also like the idea of an analog ebraking control. Perhaps a separate brake lever or smaller trigger since hydraulic brakes don't allow much motion before they come on and modifying them for dual action is difficult.

That's what I forgot to explain! I knew something critical was missing... :oops:

Actually it's pretty simple to get a good idea of the current that might flow either during drive or regen mode. The variables are: motor speed / motor phase-to-phase BEMF (these are linked as we know), active phase's PWM duty cycle, motor's phase-to-phase coil resistance, and the battery pack voltage. So the variables are V_ph, DC_out, R_ph, and V_bat. Now if we average out the controller's output voltage based on it's duty cycle, we get V_out = V_bat * DC_out.

For zero current to flow (or not to flow I should say), the controller's average output voltage has to be equal to the motor phase's voltage. Any duty cycle lower than this will start to produce regen current, and anything over this will produce drive current. The difference between these voltage levels combined with the motor's resistance is what determines how much current actually flows in either situation:
I_ph = (V_out - V_ph) / R_ph
or I_ph = ([V_bat * DC_out] - V_ph) / R_ph

Now this possible bi-directionnal current flow control situation only occurs if we switch both the high side and low side active phase FETs together (known as synchronous rectification). If only the high side FETs are switched then controlling only drives currents are possible, any duty cycle less than this will result in no current flowing, meaning we coast with the throttle set under this point (we know this mode well). Now if we only switch the low side FETs instead of the top ones, then regen current will only flow if the duty cycle is lower than this point, and anything over this will again result in no current flowing. This "zero current flow" point of course changes proportionnaly with the motor's speed, which is something that ebikers can relate to when observing the throttle behavior of our bikes.

Pat
 
Thanks for the explanation.

I could be all wet here, but when I reduce throttle below the PWM level required for acceleration I get little to no regeneration. It just coasts.

It seems to me that to get the controller to up-convert the back emf to allow regeneration into the battery it needs a different cycle, not just a reduced PWM. The controller must use the FETs to short the back EMF and store energy in the motor coil field, and then open the path allowing the collapsing field to generate a voltage that adds to the back EMF producing a sum voltage that exceeds the battery voltage plus diode drops and flows current into the battery. (or manipulate the FETs to avoid the diode drops and use synchronous rectification).

This regen mode adds the motor shorting PWM pulses to the usual cycle in order to get voltage boost needed for charging. Without a voltage boost there can be no charging.

"Regeneration" into a resistive load would not require this, but regen into the battery does.
 
Alan B said:
...
"Regeneration" into a resistive load would not require this, but regen into the battery does.

Suggestion: Replace the “resistive load” with a high-C repository, and periodic buck-boost back into the power stream, possibly triggered as frequently as the no-throttle condition: Greater chance of constant braking and potentially higher rate of energy recovery. :)

~KF
 
Alan B said:
I could be all wet here, but when I reduce throttle below the PWM level required for acceleration I get little to no regeneration. It just coasts.
ZapPat said:
If only the high side FETs are switched then controlling only drive currents are possible, any duty cycle less than this will result in no current flowing, meaning we coast with the throttle set under this point (we know this mode well).
Well those last two posts were pretty loooong. Maybe too much content in a single post tends to make people skim over them... I know 'cause I've seen it happens to me particularly when we have lots of new posts to read! Anyways, you are talking about the "high side FET(s) only" control mode, which is what we commonly have on ebike controllers (a buck type circuit with passive low side FET).

Your explanation above of how regen works is well illustrated. It describes the boost mode operation of the circuit - It switches only the active phase's low side side FET(s), and interacts with the motor's Vbemf and inductance to permit reverse current to flow just as you say. However, there is not something else "added to" the PWM cycle to have regen happen, it just happens when you control your FETs in one of the ways described above. Those three ways in which we can control the FETs are - High side only (drive current only mode), Low side only (regen current only mode), and finally high+low sides together (forced bi-directional current control mode).

Pat

PS: BTW when I talk about the duty cycle on the active phase, I am not talking about the individual low side or high side FET's duties, but rather the half bridge's duty cycle. Thus the same duty cycle will result in a different FET switch paterns depending on the drive mode (high only, low only, sync).
PPS: There is always a second phase I do not mention that has it's low side FET(s) conducting while the other "active" phase we are talking about does the PWM. It is of course possible to hold the second phase high instead of low, but then the effects of the PWM duty cycle is inverted on the active phase.
 
Hi Pat. Lots of good information. Thanks. I did read your long posts and they don't appear to address my question about the voltage boost mechanism.

Hopefully others on here are benefitting from our discussion and we are raising the level of thinking and understanding about these mechanisms.

If what is being done with the FETs is commutation and PWM switching, I don't see any opportunity for voltage boosting. If so it cannot regenerate and charge the battery. The back EMF alone is insufficient to overcome the battery voltage. The rate of change of the field from the motor's motion generating the back EMF is not enough to generate sufficient voltage to overcome the battery's potential. (until the motor speed exceeds the unloaded speed which is above where we operate these wheels and not useful for regenerative braking).

The only way I see to get voltage boost is to periodically short the motor coils to build up field and then interrupt the current and rely on flyback to generate sufficient voltage to provide charging. At least I don't yet see any other voltage boost mechanism available. Shorting of the coils does not occur in normal PWM and commutation. So I don't see any voltage boosting mechanism in that mode. PWM into a motor is a voltage bucking operation.

Where is the voltage boost in the normal PWM commutation cycle?

Edited to refine.
 
Alan B said:
I also like the idea of an analog ebraking control. Perhaps a separate brake lever or smaller trigger since hydraulic brakes don't allow much motion before they come on and modifying them for dual action is difficult.

Perhaps a simple hollow add-on lever to the face of the existng lever, rather like the unlocking lever on a set of vice grips, but outside the brake lever rather than inside like the vice grips. It could be setup with a hall and magnet easily enough. I've considered somethinglike this fro my pwm-ing of the regular digitalebrake lines,if i ever get to that experiment.
 
Back
Top