Jump to content

EUC motor drive


esaj

Recommended Posts

Posted

I've been trying to get my head around how the motor control in EUCs (or in general with 3-phase brushless direct current motors, BLDC's) works, and been meaning to write this post for a good while (a "raw" -version of this has actually sat on my hard drive for months). @Henrik Olsen's question about the mosfets sparked me to finally get around to quickly read this through, make a few small additions and corrections and finally "publish" it here in the forums... So here goes, hopefully I corrected most of the typos etc, and it reads fairly easily, it's been written in parts every now and then, and sometimes I might jump from one topic to another a bit abruptly. :rolleyes:

I'm an amateur when it comes to this stuff, so I might use some "unorthodox" terminology and there could be many mistakes, factual errors and misunderstandings on my part, so I wish that the people who really know this stuff could chime in and correct if and when I've gone wrong. There are loads and loads of sources around the internet with more precise (and complex) articles and documents about how the motors work and how they're driven (or can be driven), but hopefully this could give a fairly good (albeit simplified) explanation of the basics of the motor drives.

I'll try to keep it simple (most of the time) and skip over a lot of things like inductance, magnetic fields, different motor builds, mathematics, and most of the details on electronics as I'd likely just get those parts wrong anyway :P, and mostly concentrate on a basic overview of how the motor is being driven (or at least what I understand of it) :)  Probably other people and sources can explain these parts better and in much more detail, if anyone's more interested.

To start off, I'm not going to talk about 3-phase brushless motors, but a basic brushed DC motors ("1-phase") at first, as it's easier to understand the basics of the half-bridges through such an example. I've also seen (small) 3-phase motors sold with "1-phase" connections (just power + and -, and maybe PWM-input or not even that), where the controlling circuitry is inside the motor, so this could be such a case too.

parts-of-dc-machine-19-1-14.jpg


Brushed_Anim.gif


DC_Motor.gif

 

In a brushed motor, as the name suggests, there are parts called "brushes" that actually have mechanical connection to the coils in the rotor (the moving part of the motor). The coils actually act as electromagnets, and if you've played with magnets some time in your life, you know that opposite poles (north and south) attract each other and similar poles (north and north or south and south) repel each other.

Simplified, as the brushes slide across conductors in the turning rotor, they cause current to flow through the winding coils ("energizing the coils"), which creates a magnetic field ("north"-pole in one and "south"-pole in the other) that keeps the motor turning in one direction, as the coils attract or repulse the (usually permanent) magnets in the stator (the stationary part of the motor). There are splits in the "ring" where the brushes touch, so the brushes will alternate between touching different "ends" of the coils of the motor, causing the magnetic field of the coils turn on and off and to change polarity (depending which brush they're touching or no brush at all) to keep the rotor moving as the poles of the permanent magnets attract / repel them.

If the motor would need to turn in opposite direction, the polarities of the wires connected to the brushes could be changed to the other way around, ie. you'd change the + and - wires going into the motor to the opposite connections. No complex electronics are needed to drive the motor (at least in one direction), simply plugging it into a power source will do. The downside is that the mechanical brushing causes friction, noise and the brushes wear down, so they need to be changed every now and then when they wear out. But how we (slowly) get from here to BLDC-motor control is a fairly simple circuit called H-bridge (not a half-bridge, a H-bridge).

Wikipedia explains an H-bridge simply as:

A H bridge is an electronic circuit that enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to allow DC motors to run forwards and backwards.

A H-bridge could be built using just four (mechanical) switches:

1.gif

 

So when switches S1 and S4 are closed, the VCC (+) and GND (-) of the power source are connected across the motor, running it in one direction. Open those switches and close S2 and S3, and the polarities will be opposite, running the motor in the other direction. Making the upper ("high-side") and lower ("low-side") switch (be it a mosfet or BJT or whatever) on the same side of the H-bridge conduct at the same time (like S1 & S3 or S2 and S4 above) would cause what is called a "shoot-through", ie. the current won't flow through the motor, but instead directly passes through the switches, causing a short circuit (only resistance in the current path is that of the switch-elements and the wires).

Now, using mechanical switches isn't that much more handy than just switching the wires in the opposite connections. That's why the H-bridge is usually built from transistors. Transistors can be controlled electronically and used as high-speed (non-mechanical) switches, so you basically use just two states for them: fully conducting (open) and not conducting (closed, although sometimes you could see these terms used vice versa, ie open = not conducting and closed = conducting, I'll just use terms "conducting" or "on" and "not conducting" or "off" to prevent any misunderstandings). Actually, transistors can be used in-between these two extreme states to make them conduct only partially, for things like (audio-)signal amplifying, but that's outside the scope of this, as only switching is needed for motor driving. Depending on the type of transistor, the conductivity over it can be controlled either by current or voltage.

In the below animation, bipolar junction transistors (BJTs) are used for and H-bridge, with signals coming from INA and INB to switch the different transistors between conducting and not conducting. Our wheels use what are called MOSFETs (metal-oxide-semiconductor field-effect transistor, a certain type of transistors) instead of BJTs. Mosfets are voltage-controlled, unlike bipolar junction transistors, which are current-controlled (but still need a certain amount of voltage to overcome the PN-junction... Yeah, I won't go into that here :P). There are more different types of transistors (J-Fets, IGBT's...), but I won't get to them here, as I only have some experience with BJTs and mosfets, and the wheels use mosfets anyway.

h-bridge-circuit-600w.gif

 

So, now we could have electronical directional control over a (brushed) motor by turning on two transistor in opposite sides of the bridge, one on the high-side and one on the low-side. The next step is to control the speed of the motor (don't worry, I'll get to BLDC's and how this all relates to them in a while).

A motor also acts as a generator, it actually produces it's own voltage when it's turning. This is called back-EMF (back electromotive force) or BEMF in some sources. When the motor is not turning, the back-EMF is 0 volts, and when it's running, it produces a voltage that raises linearly with the rotational speed of the motor. When the motor's turning in the "correct" direction caused by the voltage from the batteries, back-EMF polarity will be opposite to the voltage from the battery direction.

So, if you connect a battery with some voltage X to the brushed motor, if will start turning and reach some speed. If you take a battery with twice the voltage, 2 * X, it should rotate at twice that speed (assuming it can overcome the increasing friction and won't burn due to overvoltage/current etc etc :P).

This is probably a good point to mention about the current in the motor. When the battery is first connected to a non-moving motor, the motor isn't turning and the back-EMF is thus 0V. There's a voltage difference between the battery and the back-EMF, and it's this difference that causes the current to flow. Simplified, there's always some resistance in the circuit (for example the motors' internal resistance from the coil-wires, other wires, connectors etc), and current equals voltage divided by resistance.

So still keeping it simple, as the resistance stays (or here is assumed to stay) the same, the bigger the difference between the back-EMF voltage and the voltage from the battery, the higher the current. If there's a big difference, the current will be higher, if there's a small difference, the current will be lower, and if there's no difference (battery voltage = back-EMF), there's no current. Current is the thing causing torque in the motor, so when the battery with a constant voltage is first connected and the motor is not turning, the difference between these two voltages is at its greatest. This will cause high current to flow, causing high torque and getting the motor moving. As the motor speeds up, the current drops as the difference between the voltages becomes smaller (back-EMF goes up), and the current (and thus the torque) of the motor drop. Ideally, once the motor reaches the speed where the back-EMF equals the battery voltage, the current and the torque would drop to 0 and the motor would be "free wheeling". In reality, the back-EMF is probably slightly below the battery voltage, as the motor has to overcome friction from bearings etc, and there's some current always flowing when running at steady speed.

Some motors state constant factors called k-factors that can be used to calculate speed from voltage and torque from current, as they're both linear.

Back to the speed control. As the speed of the motor is relational to the back-EMF and the motor changes speed when back-EMF and applied voltage do not "match", we can actually control the speed of the motor by controlling the voltage applied to it. You could use a potentiometer (a variable resistor) to drop the voltage before the H-bridge, but that just wastes power by burning it off as heat in the potentiometer (which itself might burn if it needs to drop a lot of voltage), and you'd have to control it by hand. 

This is where the fast switching ability of the transistors steps in. You might first think that "partially" switching on the transistor could be used to control voltage, but it's not a very precise method (to my knowledge) with motors and also wastes power in the transistor (again, actually heating up the transistor, which could lead to it burning). Instead of trying to control the voltage by allowing the transistor to conduct only partially, a scheme known as pulse width modulation (PWM) is used.

atmega168a_pwm_02_lrg.jpg

 

I'll try to explain this as the best I can. PWM is a technique to produce a square wave signal (like those seen above) where the relation between the "on" time (full voltage) and "off" time (zero voltage) can be controlled. During one period, for some part of the period the full voltage is applied, and for the rest of the period, no voltage is applied. Controlling the "width" of the on-partion (full voltage pulse) of the period you get different "duty cycles". 100% duty cycle means that the voltage is at the full value throughout the period and 0% means there's no voltage in the entire course of the period. A single period is usually very short, and the frequency of the PWM is measured in hertz (1/s), meaning how many periods per second there are. Motor controls usually use "low" frequencies for PWM up to some tens of kilohertz (for example, 20kHz = 20000 hertz = 20000 times per second, about the upper limit of very good human hearing range). 20000 times a second might not sound "low", but in electronics-side, the "ITU"-specification for frequencies calls 3kHz-30kHz -range VLF = "very low frequency" ;)

When "sufficient" voltage is applied at the "gate" of the mosfet (that's one of the three pins in the mosfets, the other two are "drain" and "source", the functions of these are similar to base, emitter and collector in bipolar junction transistors), the mosfet will allow current to flow between it's drain and source. Depending on the voltage difference between the gate and source, the mosfet will either be fully off (not conducting), then start to partially conduct, and once the voltage difference is "large enough", it will fully conduct. I won't go into gate charges and how to go with driving high-side N-channels here... ;) 

Now, if we "drive" the gate of the mosfet with a PWM pulse (let's just assume that the on-part of the pulse is of "sufficient voltage", ok? ;)), the mosfet will conduct during the on-part (full voltage) of the PWM-period, and stop conducting during the off-part of the period. In reality, there is also some delay ("rise and fall times") between the transistor starting to fully conduct after the higher voltage is applied and before it stops conducting after the voltage drops to zero, but for the sake of simplicity, just assume it turns on and off pretty much instantly.

So, as the mosfet is switching between fully conducting and not conducting, the motor will get pulses of voltage applied to it. Again simplified, with the switching happening at a high frequency, what the motor "sees" as the incoming voltage is the "average voltage" between the "on"-part and "off"-part of the PWM-period. If the full voltage would be for example 5V, and the on-part of the period would last half of the period, and the off-part would last the second half of the period, the voltage applied to the motor would be half of the full voltage, 2.5V. Using the duty-cycle, it's then easy to calculate the voltages, using a fraction percent-value (100% = 1.0, 50% = 0.5, 10% = 0.1 etc):

100% duty cycle: 5V * 1.0 = 5V
80% duty cycle: 5V * 0.8 = 4V
60% duty cycle: 5V * 0.6 = 3V
40% duty cycle: 5V * 0.4 = 2V
20% duty cycle: 5V * 0.2 = 1V
0% duty cycle: 5V * 0.0 = 0V

Being able to change the duty-cycle, and thinking of the average voltage, you can create more complex waveforms than simple square wave. The below image shows a sine-wave -like voltage applied by changing the pulse width between the periods:

bBNPA.gif

 

The thick black line is the voltage applied to the motor, the thinner lines show the PWM-pulse going up and down, at different duty cycles in each period. Nevermind the horizontal line in the middle, it's not related to this. ;)

So, I hope from this you can see how using an H-bridge with 4 mosfets can be used to control the direction of the motor (by using "high-side" and "low-side" -mosfets from two opposite sides of the H-bridge) and how the speed of the motor in said direction can be controlled by quickly switching the transistors on and off, to apply different voltages to the motor. Actually, there's current flowing only when the transistors are conducting, the motor connections are "floating" during the off-state, and thus, no current (or very little) is flowing. So actually the motor's alternating between (almost) free-wheeling and motoring, but this happens fast, and "mass is slow", so it has very little effect (you won't notice it).

And now, to the "real deal", the 3-phase BLDC motor, which is what (at least most if not all) our wheels use.

BLDC:

brushless.gif


4-pole-bldc.gif

 

Both the above animations show an "inrunner" -BLDC motor. It means that the "inside" of the motor is rotor (the part that turns) with the permanent magnets. In our wheels, the structure is actually the opposite: the tire on the outer rim of the motor turns, while the stator is in the middle (an "outrunner"-motor). AFAIK, same principles of control apply to both, although the motor characteristics might be slightly different.

motorani256.gif


brushlessmotors7.jpg

http://i9.aijaa.com/b/00867/13659072.jpg

 

 

The basic idea is still the same as in the brushed motor driving: magnetic fields of the coils are used to attract / repel the permanent magnets. 

In the brushed motor, the brushes handled energizing the coils and it was simply enough to plug a power source into the two connectors of the motor. Here we have three connectors, that then are connected together inside the motor, there are two common patterns, the "wye" (or "y" or "star")-connection and the "delta" (or "triangle")-connection:

STMBLDCFig1.jpg

 

Personally, I must admit that I don't know the pros or cons of either configuration. To my knowledge, both can be run with similar principles, although the commutation order might differ(?)

The motors in EUCs have much more coils and poles than in the usual pictures, I believe this is to give a more precise control over the motor position, ie. finer control. 

Basically, the upside of a brushless motor is less friction (only mechanical connections are in the bearings), and thus less audible noise (unless you can hear the PWM-frequency like in some wheels ;)), longer lifetime and (I believe) higher efficiency, although this may vary. The downside is that a much more complex method of driving the motor is needed compared to brushed motors.

You can't just plug a battery over two phases and expect the motor to turn. It could maybe twitch a little if the magnetic fields of the coils happen to attract to/repulse from the nearest permanent magnets, and then stay there stationary, all the while heating up the coils and, if the battery/other power supply can supply enough current, probably sooner or later burning them or the power source. So don't do that. :P

To drive a 3-phase motor, you need to energize the phases (and thus the coils) in correct order and at correct time (well, at least some motors should start eventually turning and "catch up" just by energizing the phases in correct order at stable frequency, but that's not really "controlled" way of driving it). For controlling three phases, three half-bridges (not H-bridges) are used:

Half-bridge.jpg

STDiode1.jpg

 

Looks pretty similar to the H-bridge before? That's because a half-bridge is also known as "half-H-bridge". Each of those two mosfets on the high- and low-side form one half-bridge (half of a H-bridge). With three phases, you need three half-bridges (or "one and a half H-bridges"? ;) )

The reason I started with the brushed motors and the H-bridge is that if you understood the simpler H-bridge (how it can be used to control the direction and the speed of the motor), the same principles work here: the speed/current of the motor can be controlled with PWM and direction of the motor can be controlled based on which two phases are conducting at a time (high-side from one bridge, low-side from the other). The added complexity is that the phases need to be energized in correct order as the motor turns. For this, the controller needs to know the position of the rotor.

Typically, EUCs seem to use Hall-effect sensors (Hall-sensors) for detecting the rotor position (there are other ways, like rotary encoders, but I don't think they're used in EUCs). Wikipedia states that:

A Hall effect sensor is a transducer that varies its output voltage in response to a magnetic field. Hall effect sensors are used for proximity switching, positioning, speed detection, and current sensing applications.

A three sensor setup seems to be typical for our wheels and BLDCs in general. Many BLDC-driving documents / articles give out the commutation order of the phases either as a table or as a graph showing the sensor on/off -states and the high/low/floating -states for the phases (for one direction):

7711.rajne-2.png

 

So there are 6 different "states" (or combinations) of the bridges. The order of states can be different for different motors, so if you try to build your own motor controller, it might take some trial and error to find the correct sequence (and then reverse to run it in the other direction). Also, a brief period of both mosfet "off" (not conducting) is needed when the conducting mosfet on the bridge is changed from high to low (or vice versa), as the mosfet gates need to be "discharged" before the voltage drops below the conducting threshold. This is called "dead time insertion" (DTI), ie. a brief period is waited before continuing operation, otherwise there's a risk of bridge shoot-through (the other mosfet hasn't fully stopped conducting, and the other starts conducting -> potential short circuit through the bridge between battery plus and minus).

In addition to the position, the hall-sensors can be used to measure the speed (how fast the sensor states are switching from one position to another) and direction of the motor (the order in which the sensors switch on and off). Somebody also suggested that after certain speed, the EUCs could actually switch to sensorless speed/position-detection (maybe the hall-sensors don't switch up and down fast enough after certain speed?), using the back-EMF voltage from the floating phase to induce the rotation speed. I haven't studied the subject much, so I won't go into it, but I did learn that this requires fairly precise timing (otherwise you'll get false readings).

Earlier I mentioned that the voltage difference between the batteries (well, actually the average from the PWM-pulses, when using that for control) and the back EMF is what causes the current to flow. Now, as current causes the torque of the motor, and higher torque means higher acceleration (faster change in speed), the applied voltage can also be used to control torque. Larger voltage difference, larger current, larger torque. So in addition to controlling the speed, the wheels must control the torque to keep us from falling down.

The final piece of the puzzle for self-balancing is not actually in the motor, but of course the gyroscope/accelerometer in the mainboard (to my knowledge, the accelerometer is there only to make reading the gyroscope more accurate, I've understood it tends to wander and the acceleration info can be used to correct this in the filters). In principle, the idea is simple: the gyroscope is used detect the pitch (tilting back and forth for acceleration/deceleration) and roll (shutting down after falling on its side) of the wheel:

Roll,_pitch,_and_yaw-_the_plane_of_motio

 

When the wheel starts tilting forwards, the motor must be accelerated to a faster forward speed (or get moving if stationary, or decelerate if moving backwards) to keep it balanced. If tilting backwards, the motor must be slowed down to prevent falling backwards (when moving forwards). There might be some form of "dead-zone" allowing the wheel to tilt a little bit backwards or forwards before the motor reacts (one way of doing "soft"-riding mode), also some wheels allow the pedals tilt more when turning in slow speed (so probably they use the speed-, pitch- & roll-information for this).

Of course, the real deal is the balancing logics and fine tuning of the acceleration/speed control/dead-zone/allowing tilts when the wheel is turning (ie. the roll is different from zero) etc. That's what makes different wheels different to ride, and probably is one of the most, if not the most important asset of any single wheel-company, as that's what really distinguishes it from other similar wheels and gives the riding "feel" of the wheel.

There are a ton of more technical details I've skipped over above, like different and more complicated ways the PWM-drive can be done (sine-wave driving, space-vectors, field-oriented control, whathaveyou...), motor inductances, inductive spikes, etc etc., mostly because it goes beyond the scope of "basics", but also because I'd probably get a ton of details plain wrong :D 

But, were not really finished yet with the basic motor control: there is (at least) one more thing: braking (yeah, that's nice to have), namely, regenerative braking.

There are multiple ways to brake an electric motor: you could use mechanical brakes (yeah, well, not really with self-balancing wheels ;)), let it free-wheel to a stop (with self-balancing wheels, not really an option either), use resistive braking (which causes tons of heat that must be dissipated), "plugging-type" braking, where the motor control actually tries to drive the motor backwards (causing what is called "slipping"), dynamic/"rheostatic" braking (of which there are actually multiple different types of) and finally, regenerative braking. I haven't actually delved that deep into braking the motor, especially the dynamic/rheostatic -types, but I do know a little bit about the basics of regenerative braking.

The best fairly brief explanation of regenerative braking I've found is this:

http://electronics.stackexchange.com/questions/56186/how-can-i-implement-regenerative-braking-of-a-dc-motor  

Although it talks of a single-phase DC motor and H-bridge, I believe the same principle can be (and is being) used for 3-phase motors also, just that the phases must be switched in "correct order" and correct timing. For a much better explanation than mine, you probably should read through the accepted answer in that question.

As said before, the motor also acts as a generator/dynamo due to the back-EMF induced in it while it's turning. When you get moving with the wheel, you actually gain "kinetic energy" (E = mv2  or something along those lines?); that is, the chemical energy in the battery packs converts into electric energy, which then converts into heat (thermal energy) and motion (kinetic energy). Although we often talk about "energy losses" or "power losses", energy never actually disappears. The "losses" just mean that part of the energy turns into something we don't want (like heat instead of motion). But anyway, some part of the energy dissipated from the batteries has turned into motion (and some part has been "lost" to other forms of energy), but now you need to slow down or stop. Again, energy never disappears completely, so when you brake, the motor actually has to do "dump" the extra kinetic energy somewhere, it can't just disappear into thin air (well, technically, it CAN disappear into thin air, in the form of heat ;)). Purely resistive braking is a bit troublesome due to high power that must be dissipated, so to do braking with resistive load, huge power resistors with large heatsinks would be needed.

The basic idea of regenerative braking is (or at least seems to be, from what I've understood ;)) that low-sides of the half-bridges (probably two bridges at a time in a 3-phase motor) are conducting simultaneously, causing the current from motor to flow through them and back to the motor to brake and "charge" the magnetic fields of the motor coils, then one high-side is switched open (there could be some leakage through the high-side mosfet body-diodes?) to "shoot" off the charge (discharge the coil magnetic fields) into the battery (during which time the motor is not braking). Basically the back-EMF voltage must get (at least momentarily) higher than the battery voltage for the current to flow in "reverse" and charge up the packs. "Discharging" that into the packs, the voltage drops again, and then the low sides are opened again to brake more and charge up again. Repeating this fast, the motor is "switching" between braking and dumping the energy into the battery packs. As this is done fast (probably at the same PWM-frequency as when normally driving the motor), you feel it as constant braking (same as you do when you accelerate, you could say that the motor is actually switching "on" and "off" real fast, but the frequency is high and mass is slow, so you won't notice it). Probably (a large?) part of the energy is burned off as heat in different parts (motor coils, wiring, mosfets, even the battery cells), so it's nowhere near 100% efficient, more like "convenient" (and there is the upside that it does charge your packs, at least a little), as no extra parts are needed.

The rate of deceleration (or "negative acceleration", if you will) plays a role in the amount of (momentary) power generated during braking, and there have been reports of the mosfets actually burning on mainboards during strong braking. On Vee's MCM2s, I tested "not-that-aggressive-yet-strong" -braking, and got peaks above 2kW (if memory serves). Even if Gotway has that huge 1.5-2x error on the current measurements, it's still above 1kW at peak (but only for a moment). I don't know how high it could go with lots of mass and really strong braking, but I guess "pretty high" ;)  Apparently high enough to fry something, if you look at some experiences here. 

Well, that's pretty much my short(ish) explanation of the motor-drive... I was going to write about the details of things much more, but decided against it, as it would probably make this too long and there are many, many things I'm not that sure about ;)

Posted

Hi Esaj,

Well done... However, what is your intention? Write a review on EUC design? Create your own? Make it better than existing ones?

Posted

Amazing post

Posted

it is quite easy to take advantage of @esaj. This is how it works - Basically you just ask him a question and all kinds of goodness comes pouring out! One thing you gotta change, esaj, is stop calling yourself an " amateur". Pretty much nobody believes it by now! :) Fantabulous post!

Posted
13 hours ago, esaj said:

As the motor speeds up, the current drops as the difference between the voltages becomes smaller (back-EMF goes up), and the current (and thus the torque) of the motor drop. Ideally, once the motor reaches the speed where the back-EMF equals the battery voltage, the current and the torque would drop to 0 and the motor would be "free wheeling". In reality, the back-EMF is probably slightly below the battery voltage, as the motor has to overcome friction from bearings etc, and there's some current always flowing when running at steady speed.

This is very important to understand why a steady cruising speed may result in a less battery drain instead of a reduced range due to frequent accelerations and decelerations.

Thank you so much @esaj for your post.

Posted

Have you looked into current sensing topology much? I'm working on this at the moment but there's not a lot of information around. Three low side shunts are popular and are supposed to have an advantage over 2 shunts but shunts are an issue in terms of heat and voltage limits. However there are other options such as hall and fluxgate sensors which are immune to higher voltage and have little resistance, however I haven't seen a good comparison of the different solutions. The TI instaspin documentation implied 2 highside sensors performed as well as 3 low side shunts, while ST software is almost totally focused on low side shut resistors.

I'm not sure which is suited for motor control, low latency high sampling rates or if high dynamic range, low noise is more of a priority. There's relatively inexpensive ways to boost performance in either of those areas either by having dedicated highspeed ADCs for each phase rather than multiplexing one ADC on the MCU or by using high resolution delta-sigma ADC quality is more important than speed.

Posted
17 hours ago, micro said:

Hi Esaj,

Well done... However, what is your intention? Write a review on EUC design? Create your own? Make it better than existing ones?

There's really not any specific "ultimate" intention, just trying to learn about the wheels as much as possible in general... maybe sometime in the distant future I might try to build my own, but it would probably be dangerous as hell and I'd probably need a pretty good armor before trying such :D 

Designing an entire EUC is no easy job, and takes a lot of talent  in very different areas (electronics, bldc-motors, motor drives, physics, programming, shell design...). The best-known companies have probably been working & refining their wheels for years with teams that have expertise on these specific areas...

 

14 hours ago, Cloud said:

it is quite easy to take advantage of @esaj. This is how it works - Basically you just ask him a question and all kinds of goodness comes pouring out! One thing you gotta change, esaj, is stop calling yourself an " amateur". Pretty much nobody believes it by now! :) Fantabulous post!

Sort of like a verbal pinãta? ;)  I think "amateur" is pretty spot-on, if you look at the definition:

noun
1.  a person who engages in a study, sport, or other activity for pleasure rather than for financial benefit or professional reasons.

 

8 hours ago, Frankman said:

This is very important to understand why a steady cruising speed may result in a less battery drain instead of a reduced range due to frequent accelerations and decelerations.

Thank you so much @esaj for your post.

It's the acceleration-part that uses up the battery quicker, during deceleration, your battery gets charged (at least a bit). The most demanding (current & battery power -wise) situations are  likely climbing a hill, getting going from standstill and changing directions quickly. In the two latter cases, the motor is stalled (at least for a moment), and getting it turning again requires more power than "just" accelerating. Think of when you push a heavy box on a floor: you need more force to get it moving (overcoming static friction), than to keep it moving or accelerate it after it starts moving (dynamic friction).  The analogue might not work in all situations, but something similar, at least I think so :P

 

6 hours ago, lizardmech said:

Have you looked into current sensing topology much? I'm working on this at the moment but there's not a lot of information around. Three low side shunts are popular and are supposed to have an advantage over 2 shunts but shunts are an issue in terms of heat and voltage limits. However there are other options such as hall and fluxgate sensors which are immune to higher voltage and have little resistance, however I haven't seen a good comparison of the different solutions. The TI instaspin documentation implied 2 highside sensors performed as well as 3 low side shunts, while ST software is almost totally focused on low side shut resistors.

I'm not sure which is suited for motor control, low latency high sampling rates or if high dynamic range, low noise is more of a priority. There's relatively inexpensive ways to boost performance in either of those areas either by having dedicated highspeed ADCs for each phase rather than multiplexing one ADC on the MCU or by using high resolution delta-sigma ADC quality is more important than speed.

Not that much, but I do have (yet another) project that requires something similar: a milliohm -meter. In my case the idea is to use a constant current source to keep a known current flowing over an unknown resistor, and then measure the voltage drop over the unknown resistor to calculate the resistance-value based on current & voltage-drop. For measuring current, you take a known resistor and measure the voltage drop to calculate the current.

The problem with resistance-based measuring for a motor / half-bridges might be that the resistance increases with temperature, but if the drift isn't too much, you can probably get pretty good values with that too (depending how accurate you need). Also the resistance has to be very small, or the resistor might overheat and burn (for example, I have 0.1ohm = 100 milliohm 5W cement power resistors, and they start to dissipate that 5W at around 7A:   0.1ohm * 7A= 4.9W). Finding very small resistances with fairly low tolerances might not be easy, or they might cost a lot, maybe? I actually should order some 0.1% 1ohm (or below) resistors for calibrating purposes... My idea was to measure the voltage drop over the resistor by a unity-gain differential amplifier, and then feed the result to the Arduino 10-bit ADC (with Aref of something like 1.25V or 2.5V, to get more accurate "steps"),  but since I don't have anything but fairly cheap op-amps, I have to jump through some hoops :P  Namely, the "best" for this I have is OP07, but it can't get near the ground-rail (with single-supply), so I'll likely need another battery just to get double-sided supply for it. Then it seems (at least in simulation) pretty precise, with offset voltage at 150µV max and very low noise... Or shell out the cash for some decent unity-gain differential/instrumental amplifier ;) This might actually be a topic you know more of. Another "epiphany" I had was/is to use DAC to control the constant current source, so I can "sweep" the resistor with different currents for auto-ranging...

The hall-sensor -based solutions might be better, as they usually have very low internal resistance (if memory servers, the ACS712's have something like 1.2 milliohm resistance), is pretty much linear within it's spec'd amperage-range and can withstand out-of-spec pulses at least for a short while. ACS712 might not be the best solution for very high current (>30A) measuring, but there are probably better ones out there.   http://www.allegromicro.com/~/media/Files/Datasheets/ACS712-Datasheet.ashx

I don't know how much the actual topology really affects, ie. if it really even matters whether the resistors / sensors are placed below or above the bridges.

EDIT: About the sampling rate, this is just a guess, but I'd assume sensing during the "on"-phase of the PWM is required, and maybe as "late" (just before it starts to drop) as possible..? maybe a fast and accurate sample & hold for taking the samples before ADC? Averaging over multiple samples might also help with noisy signals and outliers...

Posted
On 4 мая 2016 г. at 8:57 PM, Cloud said:

it is quite easy to take advantage of @esaj. This is how it works - Basically you just ask him a question and all kinds of goodness comes pouring out! One thing you gotta change, esaj, is stop calling yourself an " amateur". Pretty much nobody believes it by now! :) Fantabulous post!

 

11 hours ago, esaj said:

Sort of like a verbal pinãta? ;)  I think "amateur" is pretty spot-on, if you look at the definition:

noun
1.  a person who engages in a study, sport, or other activity for pleasure rather than for financial benefit or professional reasons.

Oh-oh @esaj , now you are playing with fire. Lol :) . You are waking up the pedantic side of my personality. Hate that about myself but cant help it! So here it goes: 

While the use of the word " amateur" wasnt technically incorrect, the word has several different connotations and the context you used it in implied a particular meaning - "amateur " as in "not knoweleable enough", or " prone to making mistakes" . However, the definition you listed is not restrictive to the word "amateur" and my point was that what you are can be better described by a different word.  "EXPERT" , for instance, is a word, which is in accord with the same definition, (providing that said expert is enjoying his field of expertise and doesnt get paid to engage in it). This word is, however, much better suited to describe your standing here :) 

Posted

I have one question and one remark

Question: What type of motor is normally being used in our EUCs? Is it a BLDC or a PMSM? There is often a confusion of terms, I think a special BLDC motor with sinusoidal back EMF caused by an accordingly wound stator is mostly called a PMSM (permanent magnet synchronous motor). This can be seen when a scope is connected over two phases and the motor is turned manually. (Is that correct?) The standard hoverboard motor in a 6.5" wheel is of that kind.

Remark on regenerative braking: As esaj himself pointed out, all alternatives are unreasonable. On the other hand, the half bridge is never closed as they incorporate the freewheeling diodes. In case they could be closed (try a diode in series:), either the motor or the FETs will break (not brake). The half bridge is by nature bidirectional. That is, current flows back and forth freely. It is the battery that brakes. Ever tried to turn a motor with shorted phases?

Posted
26 minutes ago, micro said:

I have one question and one remark

Question: What type of motor is normally being used in our EUCs? Is it a BLDC or a PMSM? There is often a confusion of terms, I think a special BLDC motor with sinusoidal back EMF caused by an accordingly wound stator is mostly called a PMSM (permanent magnet synchronous motor). This can be seen when a scope is connected over two phases and the motor is turned manually. (Is that correct?) The standard hoverboard motor in a 6.5" wheel is of that kind.

Remark on regenerative braking: As esaj himself pointed out, all alternatives are unreasonable. On the other hand, the half bridge is never closed as they incorporate the freewheeling diodes. In case they could be closed (try a diode in series:), either the motor or the FETs will break (not brake). The half bridge is by nature bidirectional. That is, current flows back and forth freely. It is the battery that brakes. Ever tried to turn a motor with shorted phases?

They are BLDC, PMSM are somewhat uncommon but there's not even an actual agreement as to what defines BLDC vs PMSM. You will see the terms interchanged often.

Posted
17 hours ago, Cloud said:

Oh-oh @esaj , now you are playing with fire. Lol :) . You are waking up the pedantic side of my personality. Hate that about myself but cant help it! So here it goes: 

While the use of the word " amateur" wasnt technically incorrect, the word has several different connotations and the context you used it in implied a particular meaning - "amateur " as in "not knoweleable enough", or " prone to making mistakes" . However, the definition you listed is not restrictive to the word "amateur" and my point was that what you are can be better described by a different word.  "EXPERT" , for instance, is a word, which is in accord with the same definition, (providing that said expert is enjoying his field of expertise and doesnt get paid to engage in it). This word is, however, much better suited to describe your standing here :) 

I know about the connotations, and I don't disagree with them either. ;)  

Probably my view of what is an "expert" is very different, think of this: I was a "hobbyist" (ie. doing it as a hobby) programmer on and off for about 15 years, got a software-engineering degree and now have "professionally" worked in the field little less than 10 years. You know what? I don't consider myself an "expert" in programming either ;)

In my (narrow minded) view, a real-world "expert" is someone who has a long-term experience that usually concentrates around a more specific "sub-field" of some larger discipline. For an example, I'd consider someone who has worked (almost solely) on databases for a long time a "database expert". In programming-field, the term "expert" (and "guru" :D) is far too used. But at least usually nobody is called "programming expert", but expert on a much more confined area, like around a certain piece of technology or software, "MySQL expert", "Spring framework expert". My bosses probably consider me an "expert", but since my experience in the programming field covers quite a large "ground", I'd say I'm more like "good at most things, expert in nothing" :D

Again looking at (some) dictionary definition, an expert is:

noun 
1. a person who has a comprehensive and authoritative knowledge of or skill in a particular area.

My definition of particular area might be too "tight" though. ;)  

But, then when it comes to electronics in general, and the "sub-field" of motor-drives, I am certainly not knowledgeable enough. Consider this: it's true that I did have some basic formal training in electronics, but that was over 15 years back. I enrolled to a three-year "information technology "-line of a vocational institute (the degree I finally got from there several years later is something like "vocational upper secondary qualification in information technology" or some nonsense like that ;)), hoping they would actually teach programming. You know what? At that point, no "upper secondary"-institute in Finland was teaching programming. Only at "tertiary"-level institutes (universities/polytechnics) did that. What did they then teach us? The teachers were originally from electronics/radio/tv-lines. They taught us about AC/DC-electricity and electronics instead. I wasn't interested in the subject at that point, so I skipped a loot of classes... enough to fail courses many times, and in total, when I should have graduated in 2002, I finally graduated in the spring of 2005. :P I then immediately applied to software-engineering line in an "university of applied sciences", which is a fancy name for a polytechnic school, and graduated from there in 2010 (at which point I was already working in the field on the side).

So yeah, I could have got a more formal training in electronics at that point, and I did pick up a lot of things, but most of it I had already forgotten. Had someone asked me a year ago if I'd get into electronics as a hobby, the answer would have been a resound "NO". It was the wheels that caught my interest again, I could figure out that there had to be a gyro to detect the tilt, some software and a way to precisely control the motor to achieve self-balancing, but how does it all really work? Which is what set me on my current course. Last summer and autumn, I was researching on the subject, and in November I started ordering electronics components from Aliexpress (the cheap-kind, so some of them could very well be fakes, poor-quality knock-offs or factory rejects ;)) and built my first 3-phase controller (pretty much according to the half-bridge schematics of an e-bike controller and home-cooked software) that could run a 3-phase motor with 3 hall-sensors in one direction. And that's pretty much the point where that project is still :D

So the point of the above rambling is, that all-in-all, I have about 6 months of "experience" in electronics. I feel that I now know more about electronics in general than I did back in 2005 when I graduated (and yes, I regret now that I didn't really try to learn this stuff back then :rolleyes:). That hardly makes me an "expert" on electronics, let alone motor drives, so the connotation of "not knowledgeable enough" subjected to "amateur" pretty much stands. I can design simple circuits based on others (and sometimes even from scratch), but my design-process is hardly "professional", it's more like:  get an idea, research circuits around it, do a lot of simulations in LTSpice, find correct component values by best-guessing & trial-and-error, build it on breadboard, measure and test it, redesign/tweak as needed, redo the breadboard-testing, go back to tweaking as necessary, and finally build it on a vero/dot matrix/strip-board and test & measure it again. A real electronics expert could calculate the precise values needed and skip much of the trial-and-error -phase (although, real-world components do often behave at least somewhat differently than the "ideal" components used in simulations). Some of my designs might be unnecessary complicated or I could use "wrong" components (meaning like that some transistors I have might be better suited than the ones I ended up using etc), because I don't know enough/better. ;)

12 hours ago, micro said:

I have one question and one remark

Question: What type of motor is normally being used in our EUCs? Is it a BLDC or a PMSM? There is often a confusion of terms, I think a special BLDC motor with sinusoidal back EMF caused by an accordingly wound stator is mostly called a PMSM (permanent magnet synchronous motor). This can be seen when a scope is connected over two phases and the motor is turned manually. (Is that correct?) The standard hoverboard motor in a 6.5" wheel is of that kind.

I really don't know... I have the Firewheel motor out in the open, so I could plug it into my oscilloscope to see, though. But Lizardmech probably already answered your question.

Quote

Remark on regenerative braking: As esaj himself pointed out, all alternatives are unreasonable. On the other hand, the half bridge is never closed as they incorporate the freewheeling diodes. In case they could be closed (try a diode in series:), either the motor or the FETs will break (not brake). The half bridge is by nature bidirectional. That is, current flows back and forth freely. It is the battery that brakes. Ever tried to turn a motor with shorted phases?

Yes, from the little I know about the braking techniques, most others seem not to fit well into EUCs, due to size and/or power dissipation issues. Also, I should have probably made a different between a "free-wheeling" (coaching) motor and "free-wheeling" in electronics terms (which are two different things)... My understanding is that when the lower-sides of the bridges are open conducting (ie. the motor phases are shorted together) is the part that causes the braking (it is resistive braking at that point, right? Only the resistance is very small), and simultaneously "charges" the magnetic fields of the coils, which are then discharged towards the battery (and at that point, the motor is "coaching"?). In another electronics-stackexchange question it is pointed out that the half-bridges actually work like a boost-converter at this point:

http://electronics.stackexchange.com/questions/56170/why-should-i-worry-about-a-motor-causing-my-supply-voltage-to-shoot-up-when-the

And yes, shorting the phases should have a braking action, as it has been a common way to "diagnose" burned mosfets of the half-bridges by trying to turn the tire when the unit is off. If there's resistance, likely the mosfets have failed in "conducting" -state and two or all three of the motor-phases are shorted together.

 

Posted
14 minutes ago, electric_vehicle_lover said:

@esaj thanks for sharing!!

With all this knowledge, you really should participate on the OpenSource firmware!!!!!!!

I think you're way ahead of me, aren't you researching the more advanced PWM-controls (sine-wave/space-vector/field-oriented) already? At the very least, I should try to complete that simpler 3-phase motor controller first to gain further insight into the matter  ;)

Posted

I did read some information but still seams that current hardware is limited to a simple way to control.

You know, all the control code for the motor is already done on the firmware. There is code for fast direction charging and code for the high speed!!

I think now the firmware needs tunning and more experiment.

Posted
11 hours ago, lizardmech said:

They are BLDC, PMSM are somewhat uncommon but there's not even an actual agreement as to what defines BLDC vs PMSM. You will see the terms interchanged often.

This was already mentioned in my question. There is often stated that the motor types differ in their BEMF. True or not? Are our motors of the sinusoidal type?

Again, my point is that the battery brakes the motor via the freewheeling diodes. Has anyone ever seen something else?

Posted
4 minutes ago, micro said:

This was already mentioned in my question. There is often stated that the motor types differ in their BEMF. True or not? Are our motors of the sinusoidal type?

Again, my point is that the battery brakes the motor via the freewheeling diodes. Has anyone ever seen something else?

I'll go get the motor from the garage... :D

Posted

Ok, I got the motor and hooked it up into the oscilloscope (probe on one phase, ground on another):

aFsHG7S.jpg

Nevermind all the mess on the table. ;)

A couple of spins and screenshots later:

n3vvRS2.png

v6Em399.png

So, the signal certainly looks sinusoidal. But, does this actually prove that it is (or isn't) a PMSM-motor? I'd expect the signal to be sinusoidal, as the coils move across the magnets (getting closer and then further away) either way...

 

Posted

I get the motor rotating at higher speed/low noise/low current with SVM (sine waves??): https://github.com/generic-electric-unicycle/firmware-gen1_boards/blob/motor_SVM_36/src/bldc.c

// Space Vector Modulation PWMs values, please read this blog message:
// http://www.berryjam.eu/2015/04/driving-bldc-gimbals-at-super-slow-speeds-with-arduino/
// Please see file: BLDC_SPWM_Lookup_tables.ods

Posted
7 minutes ago, electric_vehicle_lover said:

I get the motor rotating at higher speed/low noise/low current with SVM (sine waves??): https://github.com/generic-electric-unicycle/firmware-gen1_boards/blob/motor_SVM_36/src/bldc.c

// Space Vector Modulation PWMs values, please read this blog message:
// http://www.berryjam.eu/2015/04/driving-bldc-gimbals-at-super-slow-speeds-with-arduino/
// Please see file: BLDC_SPWM_Lookup_tables.ods

Oh right, you mentioned that article some time before, but then I didn't have the time to read it at that point, and totally forgot about it... thanks for reminding me  :) 

Posted
9 minutes ago, electric_vehicle_lover said:

I get the motor rotating at higher speed/low noise/low current with SVM (sine waves??): https://github.com/generic-electric-unicycle/firmware-gen1_boards/blob/motor_SVM_36/src/bldc.c

// Space Vector Modulation PWMs values, please read this blog message:
// http://www.berryjam.eu/2015/04/driving-bldc-gimbals-at-super-slow-speeds-with-arduino/
// Please see file: BLDC_SPWM_Lookup_tables.ods

This has nothing to do with the type of motor. You can drive induction motors (true sine wave) with square waves as in the early days inverters did. You can drive both types of motors with sine wave PWM. It is often recommended for both types. But are there really advantages for BLDC motors with trapezoidal BEMF?

Posted
45 minutes ago, micro said:

...

Again, my point is that the battery brakes the motor via the freewheeling diodes. Has anyone ever seen something else?

Imho this would be a thermal desaster (forward voltage times breaking current would be way to much dissipated power) and imho @esajfound that n-channel mosfets are capable to be switched on with negative DS voltages. So imho this should be the way to handle regenerative breaking (since the firmware has to switch on the corresponding low side mosfet anyhow to enable the high side body diode/freewheeling diode to get conductive. So why not switch the high side mosfet on and save dissipated power?)

Posted

Again the braking issue:
 You can do a very simple test to see what I mean. Take your EUC, disconnect the battery, then turn the wheel. It spins freely.

Now take a little battery, say two NiMh AA cells andconnect them in place of the 60V battery. Now you can be sure that the control is not powered.  Then turn the wheel. You can still easily turn the wheel, however, you will feel and see the difference, the battery voltage rises, and I argue this is due to a certain current through the diodes. Be careful, the battery is small.

I wonder whether anyone had ever seen another brake on an EUC.

Posted

Interesting - without the low side mosfets switched on there are two diodes in the path and there can imho be no "conductive path" to raise the battery voltage? Maybe there are some side effects with the controller not being supplied with enough voltage, that (some of) the mosfets gets switched on?

edit: but both diodes are in the "same direction" and so could get conductive? I assume i have to rethink this at another time with a "clearer state of mind"

Posted
23 minutes ago, Chriull said:

Imho this would be a thermal desaster (forward voltage times breaking current would be way to much dissipated power) and imho @esajfound that n-channel mosfets are capable to be switched on with negative DS voltages. So imho this should be the way to handle regenerative breaking (since the firmware has to switch on the corresponding low side mosfet anyhow to enable the high side body diode/freewheeling diode to get conductive. So why not switch the high side mosfet on and save dissipated power?)

I agree in so far that the control is not cut off as the control does still try to balance us. But there is no specific control for the brake necessary.

Continuous forward currents of the diodes is in the range of 50A. And there are more than only one.

It is a problem for the battery if you will be going down a very long steep hill (best with a full battery).

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...