Another attempt at building a motor controller

mxlemming said:
Determining the 0 or 180 phase had always stuck me as being the achilles heel of this saliency. Using the second order terms (essentially looking at the effect of saturation of the iron right?) has one significant problem - it involves driving close to saturation - high current.
Maybe it depends on the motor type. In my case for the hub motors the 40A is far from saturation, the effect is just the nonlinearity of the magnetic curve (B-H). When the current pushes the operating point farther from the origin then the slope of the displacement is lower than towards the origin. In these motors the rotor is not salient, the magnets are on the surface of the rotor and there are no gaps between them, so I think the variation of the inductance is only due to the nonlinearity of the stator core.
 
It would be nice if we could remodel this to not require the phase controlled pwm, because then it would be applicable to the stm32 controllers used in... Most things.
Unfortunately the lowest cost IC I can find that has arbitrarily-aligned PWM is the IMRXT1060 in the Teensy 4.0. If silent saliency detection was easy to do on the STM32 everyone would probably be doing already. The new RP2040 by Raspberry Pi might could probably do arbitrary PWM with it's PIO blocks but I haven't looked into it. Unfortunately it's about 6 months before the general public can buy those raw ICs.

My current setup to produce a low frequency pilot tone doesn't require phase-controlled PWM, but since the tone is at most 1/3 the frequency of the PWM, it will always be audible. A controller that is trying to be the best on the market needs to be silent though.

Using the second order terms (essentially looking at the effect of saturation of the iron right?) has one significant problem - it involves driving close to saturation - high current.
With average hub motor inductances and battery voltages, Lebowski was able to get enough ripple current at 20KHz to make the harmonic measurable just by offseting the phases. If the controller can't get a good signal with this (High inductance, low voltage), it can always ramp up the current by lowering the frequency. This will produce audible noise but it will only be for a few milliseconds as the motor finds out which pole is north / south. Due to how humans perceive sound, it will sound like a click at most.

And once the motor knows the correct polarity, it can follow it around forever until the motor stops with the pilot tone switched off.

Regarding your vibration-based polarity detection, I can maybe see it working for motors with slack in the mechanism (chain drive maybe?) but not at all for direct drive hubs.
 
peters said:
For the initial 180 degree detection I also tried a simple method earlier: applied 1 or 2 100% PWM cycles in forward and reverse directions for all phases (also 6 steps, same length pulses, 30..40Amps was needed for reliable detection, but had to wait for the decay of the current after each step) then calculated the difference and the sum of the measured forward and reverse currents. The sum gives the vector for the accurate position at the double frequency and the difference gives the +/-180 degree decision. Running Clark transform for both gave the angles.

I was thinking of doing something similar, but for compatibility with the broadest range of motors I will ramp up the oscillating voltage over a couple of cycles until I start to see the mean diverge noticeably from the median due to asymmetric currents (or I hit a limit). Once I know the leading 180 degrees, I'll switch back to inaudible, phase-shifted PWM until the handoff to sensorless FOC.

To prevent a click at every start, the user will be able to choose how long to leave the pilot tone running after the motor stops. With only 3-5 phase amps required to track position and almost all of that being reactive power, battery consumption / motor heating should be practically negligible.
 
Guess I found my next FET :bolt: :bolt: :bolt:
The IPP023N10N5 is TO-220 FET with only 2 mOhm typical @ 100 amps and 10 volts.
Gate capacitance is only 10 nf - Current UCC drivers could handle up to a 36-FET board.
Avalanche characteristics look great - Max avalanche current is 100 amps/FET for 10 us
Miller capacitance is only 80 pf, resulting in 0.7 volts max miller-induced gate bounce
Threshold voltage is a bit low at 3 volts, but a diode and resistor per gate drive channel would fix this pretty easy

Not made in China
Infineon parts have good reputation for quality and durability
Only $2.66 apiece if buying 25 at Arrow - Once I exhaust their supply of 54, only $3.83 for 100 at Mouser.
Edit: Newark has them at 2.29 per piece but shipping only makes this economical if buying 50+ parts

Unless you guys see anything wrong with this FET it's probably what I'll use for the version of the controller that I will initially sell. Right now, I'm looking at a sandwich-style design to minimize size.
First layer will be the heatsink.
Second layer will be the power board, with decoupling, 24 FETs, drivers, and current sensors, and space for the wires
Second layer will connect to the third with elongated header pins. I'll put some sheet aluminium between the second and third boards to shield from noise
Third layer will consist of power supply and brain board.
The controller will be around 2 inches wide, 6 inches long, and 3 inches deep.
Peak phase current will be 400 amps, and 200-250 continuous.
48-FET version could do 800 peak amps and 400-500 continuous for ~1.5x the BOM cost of the 24-FET
 
The board layout of the 24-FET will be similar to the current 12-FET, two copies mirrored along the long axis
The board layout of the 48-FET will also be mirrored along the long axis, but I won't design/build that one until I've sold at least a couple 24-FET ones.

Since I'm essentially building copies of a known-good design (after I eliminate the few remaining problems with my current 12-FET), it should be a pretty easy design. Differential pairs for gate drive crossing high current traces at 90 degrees will eliminate inductive turn-on.
 
For the 0 or 180 determination, I did not want to assume the rotor could actually move. What if it is locked solid with no movement, but you still want to generate a force in the coreect direction ?

The 2nd order signal needs quite some current to see, though proper complex analog filtering (so one that works on I and Q just to amplify a positive frequency, not the negative frequency) and amplification helps a lot.
 
My proposed method of initial position detection does not require that the rotor is moving. With high enough phase currents, the change in inductance with respect to current will do two things.

1: It will offset the mean of the sampled currents. The greater slope (less inductance) will be on the side of the line where the phase currents are reinforcing the field of the permanent magnets.
2: It will make the the peak current (with respect to the median, median should be zero) higher when the currents are reinforcing each other.
See graph: https://www.desmos.com/calculator/11tnsdw548

I'm not sure whether 1 or 2 will be more noise resistant, (2) would probably be easier to implement in my code so I'll try it first.
If the median current is significantly nonzero, that means BEMF is happening and I can get the correct pole that way.

I'll probably end up implementing a state machine to manage the motor.
0: Motor is off and not turning. FETs not switching, all low-side FETs on. Torque command moves to (1), Current detected moves to (2)
1: Motor is not turning, torque commanded. High current pilot tone applied to determine exact motor angle and move to (2)
2: Motor turning at zero or low speed. Torque commanded. Low current pilot tone to track position. If idle for a while, moves to (0)
3: Motor turning fast enough for BEMF-based FOC. Low current pilot tone shuts off.
4: Motor turning fast enough that PWM close to saturation. Field weakening used to extend usable speed range.
 
@Lebowski from what I understood about your paper, it appears that you are using external components and advanced math to filter the signal to reduce the amount of ADC bandwidth needed.

I can get away with much simpler mean and median calculations because my ADC can take ~800k samples per second with 11 bits of resolution and I have the horsepower to perform sorts, etc. on the data. I don't think the PIC you use has either the ADC or CPU necessary for my algorithm.

Only downside is the raw CPU costs $10 each and the breakout board (Teensy 4.0) costs an additional $10. But since I'm aiming for the high-end controller market this isn't that big of an issue. I'm supporting an amazing open-source project (Teensy/Arduino) as well.
 
You have roughly 40 times more samples and 1 extra bit, which equates to only 22 dB or 3.5 bit better performance than the ADC I use. The analog amplification and filtering will get you way more than that. With analog you can really bring down the main motor powering signals and have a lot of amplification for the signals you actually want to measure, so effectively I get much better performance with only a 10 bit ADC running at around 20kHz or so.

Sorting etc to me sounds not the right way to do things. You have to have a spectral domain view, and not deal with time domain signal style reasoning.

I am an analog-mixed signal IC design engineer by trade...

The processor I used cost around $5, I used less than half the processing power to run the drill (I used a BLDC drill for SFS development, as its easy to use it at full torque in a home lab setting)
 
RFNoise5v.jpg
I've found the reason why my ADC values are usually spot-on but sometimes are several measured amps off. The 12v-5v SMPS is spewing bursts of 100MHz RF noise onto the 5v line and everything it's attached to. Attaching additional decoupling capacitors doesn't help that much.

The ferrite bead and feedthrough capacitor in the next design will hopefully reduce this noise by several orders of magnitude. Until then, I'll be stuck with filtering it out digitally.

Lebowski said:
With analog you can really bring down the main motor powering signals and have a lot of amplification for the signals you actually want to measure
Since I have 3 unused analog pins, this is a really good idea. I can high-pass and amplify the current sensor signals before the ADC and get much finer inductance readings. All I'd need is a quad op-amp and a few resistors and capacitors. If my current board can't drive the motor perfectly smoothly while using less than a few watts of pilot tone, this circuit will definitely go on the next version.
 
did you looked on inductor ? does this SMPS runs in burst or continuous mode ? if you can change mode, try continuous..
 
Got sensorless from standstill working. Haven't made much external progress, a lot of it was refactoring the messy ADC code into something more manageable.

After I get the 20KHz pilot tone, the state machine, and initial position detection working, I will have something quite promising. @Lebowski Pretty sure I'll be implementing your analog filtering idea for the sellable version. Current setup will likely have no problems with my low-inductance QS205.

[youtube]CvqwonNvnY4[/youtube]

P.S. The noise is from the FET inside the buck converter switching and the buck inductor's self-capacitance, so changing smps mode wouldn't help.
 
Say it like it is,

The only thing more impressive than getting this to work is that it's only taken you a few days to code and it's literally a few weeks since I was first making comments on your schematic. Really impressive.
 
Unless you changed the board a lot since your last layout pic, can't you just cut the 5V trace and drop a ferrite onto it? Looks like the easiest mod ever. Easy to find a ferrite with hundreds of ohms at 25MHz upwards.
 
mxlemming said:
The only thing more impressive than getting this to work is that it's only taken you a few days to code and it's literally a few weeks since I was first making comments on your schematic
That's the beauty of using Arduino for something like this. All of the boilerplate initialization and low-level code is already handled for you and you only have to use register manipulation when Arduino can't directly do what you need to. Although Arduino is often associated with (and used by) people who have no idea how the underlying code works, it is an extremely powerful tool if you know how to use it.

Can't you just cut the 5V trace and drop a ferrite onto it?
I was thinking of doing that, but I don't want to spend $5+ on shipping for a 10 cent part. Unless it holds up development, I'll save the ferrite for my next order of parts
 
mxlemming said:
Say it like it is,

The only thing more impressive than getting this to work is that it's only taken you a few days to code and it's literally a few weeks since I was first making comments on your schematic. Really impressive.

It took me a bit longer, but I started from complete scratch (with no example papers to read) and coded in Assembly...
 
Lebowski said:
It took me a bit longer, but I started from complete scratch (with no example papers to read) and coded in Assembly...

I think this makes you a very clever masochist?
 
I started from complete scratch (with no example papers to read) and coded in Assembly...
Impressive that you got that sort of performance from relatively cheap hardware. I have very little ASM experience and wouldn't even touch an assembly project of that magnitude.
...

With Divisional Basketball tournaments in a week and school-related projects coming due around the same time, I will be suspending work on this controller for about 10 days.
For people without (pricy) NFHS (live video) access, I created a live scoreboard program to help fans keep track of the basketball games while listening to the (free) radio. Due to COVID and capacity limits, my scoreboard (https://redhawksports.net/) has been quite popular with a peak of 125 unique IP addresses checking in for a game.
That program still needs quite a bit of work to make it smooth (Admin side is pretty janky) and I need to get that done before tournaments.

Also, there's a good chance I'll receive my QS205 3t around then (Vector shipped yesterday), so I should be able to start testing with much higher power after finishing the safety features. The low inductance of the 3t will make saliency much easier as well.
 
Basketball tournaments are over. We didn't do the best but we made it to state and won a game. Losses were very close.
Also, my QSMotor arrived 2 days ago and my existing saliency-based sensorless got it to spin. Screamed like a banshee though, I didn't have measurements but the low inductance of the QS probably set up oscillating phase currents of tens of amps. I'll definitely be doing HF current filtering and amplification in my next design, it will make saliency measurements 10x easier (and silent :D )

In the meantime (Haven't been in the shop in ages), I have been working on a version that uses 36 IRFB4110s instead of 12 super expen$$$ive IRF100P218s. Now that I think about it, the old FETs suck for several reasons. No wonder they're obsolete.

* The silicon current limit is 2x the bond wire limit. Limits the phase current to 400A even though the dies can take way more
* TO-247 has much higher inductance than TO-220, especially if you consider paralleling FETs lowers inductance even further. TO-247 has approx. 1/2 the package loop area, and I have 3x as many in parallel = 1/6 the FET inductance for TO-220 vs TO-247
* Price. The IRFB4110 costs 3x less than the IRF100P218.
* Thermal resistance. TO-247 is 0.5 c/w, 3x TO-220 is 0.3 c/w.
Never seen TO-247 FETs in a commercial ebike controller either.
 
My current layout doesn't have many issues, other than switching too fast for the layout / packages. Found out that TO-247 doesn't like switching in 80ns, ordered higher-value gate resistors, USPS is currently holding them, I'll pick them up this Monday.

Assuming the higher-value gate resistors fixes the issue, I will be good to go for my next design. I copied the power stage layout pretty much directly from my old board, except 18 TO-220s instead of 12 TO-247s. I replaced the gate drive twisted pairs (PITA to assemble) with traces running directly to the drain and source, crossing any high DI/DT zones at a right angle to prevent noise pickup.

Oh, and there's now two of them :lol: Two power rails, two sets of gate drivers, and two phase wires. With each side capable of 300 amp peaks (18x IRFB4110), the whole thing should be able to run peaks of 600 amps to feed my (amp-guzzling) 3T QS205 the power it needs for unbeatable off-the-line torque. The board is symmetrical and all the current paths are the same length * thickness, so current sharing should be nearly perfect, as I will be using equal-length power and phase wires for both sides.

Gate driver (Traces emulate twisted pairs which currently work well):
UltIR6-GateDrive.png

Front/Back of boardFront.pngBack.png


I've also decided to maybe add a ceramic capacitor in the gate drive circuit to form sort of a miller clamp. IRFB4110 are on the edge of miller being a problem (2.5v at 100v). The 20nf (or so) of X5R ceramic capacitance will absorb about 1/3 of the Miller charge but not interfere with the switching too much due to the capacitance falling to ~25% of it's rated value at the gate drive voltage. Oscilloscope measurements will determine if / what capacitor I use.AMD.png
 
If you're going to start doubling up gate drivers, using funny FETs with special Miller effect and having circuits to attempt Miller clamp, why not use some of the on semi gate drivers for like 6amp drive with all the protections etc... https://www.onsemi.com/products/discretes-drivers/gate-drivers/ncd57000

Basically the same price as the ti one and with the millery FETs a better choice.
 
Just keep in mind that the torque from 600A may break the motor axis.
IRF100P218 is fairly new, they may just had some problem with the first version and changed the manufacturing process, but it won't be obsolete soon, even if it is not available now: https://www.infineon.com/cms/en/product/power/mosfet/12v-300v-n-channel-power-mosfet/irf100p218/#!order
Surprising that the active part is not completely lead free.
 
mxlemming said:
Basically the same price as the ti one and with the millery FETs a better choice.
Only problem is that each SOIC-16W IC can only drive one gate, not a pair. I'd need 12 gate drivers, end up spending 2x as much, and probably run out of board space to boot. To me these gate drivers look like they are designed for larger IGBT's, not MOSFETs.
Chinese controllers (Lyen put 4110 in them and they work well) do just fine with fancy gate drivers, they just add a bit of ceramic capacitance gate-source to stop Miller.

That does give me an idea though, I can add an 0805 drain-source ceramic to prevent the Miller effect... Just 10nf per FET will cut Miller in half. Switching losses won't be excessive; My current gate drivers barely get warm.

If only they had a half bridge with a Miller clamp... There are room for 2 extra pins on the gate drivers I'm using... That could easily be used as a Miller clamp... But I'm not the one in charge of the features they put in their gate drivers.

peters said:
Just keep in mind that the torque from 600A may break the motor axis.
People regularly run peaks of 20+ KW into the QS205. With two clamping torque arms built into the Vector Typhoon, I don't think breaking the axle will be an issue at all. I'm also using the 3T motor. The 350 amp peak SVMC72150 that often gets used with the QS205 5T is about the same amp-turns as 600 amps into 3T.

If the IRF100P218 comes down to a reasonable price I might consider it again, depending on how well my 4110 board performs. If the lower inductance of TO-220 enables 2x faster switching without ringing, I'll most likely stick with the TO-220.
 
Planning a dual controller? Like... 2 motors?

What happened about the IPP023N10N5 you said you'd use before?

My experience so far is (for FETs)
On semi>Infineon>st>ti>poking yourself with a stick.

I was pleasantly surprised by the cr micro chinesium FETs i tried out on an early version of my board.

I've actually never managed to burn an on semi gate driver or FET. Maybe shear luck, but luck has value.
 
I managed to run 170 amps for a full minute before the FETs became too hot to comfortably touch. This was with just the heat spreader bar, the giant heatsink wasn't attached. The wires going to the QS205 got noticably warm, I'll definitely have to beef them up before running 600 amp peaks and carefully monitor the temperature.

Using the hall sensors with an interpolation algorithm, not sensorless yet. Accuracy was near-perfect at all but the lowest speeds. Now that I have a super-accurate position reference I can work on saliency.

Planning a dual controller? Like... 2 motors?
For now, I'm just using one motor with parallel output stages. Since my current power stage is working very well, I should be able to do 2x the current by paralleling with equal length wires. I'd rather not change the layout and possibly end up with something that didn't work.

IPP023N10N5 would be great, except for the price and TO-220 leg limit. Even though the die can probably handle 200 amps, I can't run more than 120 amps through the legs. This is the same as the IRFB4110 that costs less than 1/2 as much.
When I start selling these in a few months, I'll probably offer this FET as an upgrade for people who want full power without blowing air across the controller / putting it in the airstream.

On semi>Infineon>st>ti>poking yourself with a stick.
My experience has been similar. When I was playing with class D last summer, the only times I blew an IR FET is when I forgot to screw it to the heatsink or left the gate disconnected. I have a pile of dead ST FETs.
And for TI - I recently saw an ad from TI that claimed it had a FET equivalent to the 4110 but cheaper... It had 4x the Qrr :lol: Not even close.
 
Back
Top