ZombieSS's power stage for Lebowski's controller video pg17

the IRFB4110 has a "gate-to-drain "miller" charge" of 43nC.

that is units of columbs but equation i=C*dv/dt .. the "C" is in units of farads. so check into that.
 
Highhopes, regarding your post about waiting for Arlo and zombiess to finish their gate driver designs, I did actually think of this because I'm aiming for the 200A just like zombies (my motor is 7kw, max 200A) and maybe I'm better of putting my work in my output stage and then use one of these designs that got all the protection features implemented and have been proven to work. So I think I'll read this thread from the beginning and take notes of all the important pieces of info.
 
Futterama said:
HighHopes said:
the IRFB4110 has a "gate-to-drain "miller" charge" of 43nC.

that is units of columbs but equation i=C*dv/dt .. the "C" is in units of farads. so check into that.
I don't see any other value regarding gate-to-drain capacitance or charge. So you lost me.

well 1 Farad is 1 coulomb/volt

also have a look at figure 5 (Typical Capacitance vs. Drain-to-Source Voltage) in the datasheet for the irfb4110
 
Everything is finally in the case and tested. Battery leads are all soldered, twisted 8 gauge wire, outputs have XT150s which I use on all my motor setups.

All I need to do now is hook it up to a 50V pack (12S) and see if it works on the bicycle after I retune it for the motor that is installed on the bike. I need to build a 24V supply. I'm currently using a AC-DC converter into a switching regulator at 24V, but I the DC-DC does not work at the 50-60V level. I can try 75V next, hopefully it will power up, if so I might start off with a 75V pack or I'll have to hook up a separate 30V battery to power up the controller/gate driver.
 
I went for my first ride tonight! I was successfully able to get my high speed Cromotor up and running on a 12S pack. Top speed feels around 25-30 mph.

The controller is not switching into sensorless mode properly all the time. If I pin the throttle it will fault out before switching into sensorless mode. If I hold the throttle just right it enters into sensorless mode OK. It also enters with less issues if I'm pedaling. I'm guessing this could be a current error issue.

Sensorless mode = can't even hear the motor. It's amazing how quiet it is, I can't hear anything but the freewheel noise. Sensorless control works well in the mid-high RPM range. If I slow down it still work sensorless, I just can't move the throttle to quickly or it will fault, I can feel it right before it faults by slowly increasing the throttle, I get a sort of mild rumble from the motor like it's losing sync. If I continue past that vs backing off I get a quick thunk from the motor and the controller faults to drive 0 and sometimes one of my gate drivers registers a fault, it's random based on the error code that blinks back to me signalling a different H/L driver of a different phase each time. It's like this until it reaches around 15mph, after that I can do what ever I want with the throttle.

Any suggestions on fixing the switch over fault issues and low speed fault issues? Could this be the error current in menu G options D,F&G? I had them all set at 60A after having some issues with having them set to 20A. Phase amps were set for 150A. I tried upping the battery current to 80A and it felt quicker, but it still had the same errors. Control feels really nice, once I can get to 100v, 200A phase things will probably feel much better.
 
can you post all the settings of all the menus ? Did you try the sensorless push-start ?

the issue can be error current settings too low, not enough filtering of the error
current, loop coefficients not correct, transition speeds not OK, too short a
transition time, FOC measurement not done with the correct battery voltage (i.e. a totally
different voltage)
 
FOC is turned off right now.

I'll go dump the screen really quick for you to hopefully review and tell me what I might have wrong.
 
These are my current settings.
VBuss is 12S LiPo so 50V fully charged, batteries were mostly discharged. 6Ah Turnigy nanotech 25-50C packs.

Motor is a 18KV 23 pole (very common hub motor config), 30uH, 37mh motor that has 2 turns around the stator tooth. This is a somewhat difficult motor to drive but I have used the Unipolar Xie Chang controller with it successfully for a while now, never a problem.

If you could elaborate some more on how the options in menu d work it could be helpful
I do not understand the settings in menu e, but I tried to come up with some ball park values and follow the rules you specified in the documentation on the ratios certain settings need to follow. Any formulas to calculate estimated settings from a motors specs?

Do you have any suggested values to start off with for a hub motor (higher pole counts, lower RPM) for these settings? Am I close?
Are you going to be adding an option to download and load files into the controller? Would be handy to save different versions of settings.

Code:
########################################
#   (c)opyright 2013, B.M. Putter      #
#   Adliswil, Switzerland              #
#   bmp72@hotmail.com                  #
#                                      #
#  version 1.21                        #
#  experimental, use at your own risk  #
########################################


a] calibrate hall sensors
b] determine coil positions
c) PWM parameters
d) current settings
e) control loop parameters
f) throttle setup
g) running modes
h) CAN bus setup
i) Field Oriented Control
z) store parameters in EEPROM for motor use

------> a

a] number of e-rotations: 92
b] calibrate hall positions
c] table out hall signals
z] return to main menu



------> b

a] number of back-emf samples: 1400
b] calibrate coil positions
c] use only fundamental sine waves
d] reconstruct waveforms based on extracted parameters
e] table out data arrays
z] return to main menu


------> c

a) PWM frequency: 15kHz
b) deadtime: 533ns
c) dutycycle testsignal: 50%
d) toggle high side polarity, now active HIGH
e) toggle low side polarity, now active HIGH
f) test PWM signals
z) return to main menu



------> d

a) number of current sensors: 3
b) current sensor transimpedance: 10.00 mV/A
c) maximum motor phase current: 149.9 A
d) maximum battery current, motor use: 89.9 A
e) maximum battery current, regen: 0.0 A
f) maximum shutdown error current, fixed: 59.9 A
g) maximum shutdown error current, proportional: 59.9 A
h) IIR filter coefficient, throttle current: 3
i) IIR filter coefficient, error current: 5
j) use additional comb filter: NO
k) use offset calibration: NO
l) restore default calibration
z) return to main menu


------> e

a) loop sample frequency: 28.51 kHz
b) proportional phase loop coefficient: 820
c) 1st order phase loop integrator coefficient: 41.0000
d) 2nd order phase loop integrator coefficient: 1.0000
e) proportionale amplitude loop coefficient: 52
f) 1st order amplitude loop integrator coefficient: 2.5000
g) maximum amplitude: 111 %
z) return to main menu



------> f

a) calibrate throttle 1
b) calibrate throttle 2
c) polynomial coefficients throttle 1 (x, x^2, x^3): 0.0998, 0.3798, 0.5197
d) polynomial coefficients throttle 2 (x, x^2, x^3): -0.0002, -0.0002, -0.0002
e) use analog throttle 1: YES
f) use analog throttle 2: NO
   receive throttle over CAN: NO
g) TX throttle over CAN: NO
h) test throttle
z) return to main menu



------> g

a) sensored or sensorless: SENSORED
b} sensorless startup: PUSH START
c} e-rpm limit sensorless self start: 1462 erpm
d} minimum current push start: 3.9 A
e} push start current, error allowed: 11 %
f] erpm sensored to sensorless transition: 5201
g] transition time sensored to sensorless: 299 milli-sec
h) return to motor start below 200 erpm
i) controlled slowdown for direction change: NO
j) phase current for controlled slowdown: 0.0 A
k) motor maximum, forward: 89.98 k-erpm
l) motor maximum, reverse: 3.99 k-erpm
m) motor standstill voltage threshold: 0.74 V
n) enable low side pulsing in drive 0: NO
o) low side pulsing rate: 52 Hz
p) low side pulsing width: 20 usec
z) return to main menu



------> h

a) CAN 'address': 1
b) CAN CFG1 as per Microchip 30F manual: 0
c) CAN CFG2 as per Microchip 30F manual: 0
   RS232 output rate: 3564 Hz
z) return to main menu



------> i

a) use Field Oriented Control: NO
z) return to main menu
 
Ok, some quick things to try:

Current menu: change error current filtering to 7. Did you do offset calibration (turn on the option, spin motor for 30 sec in drive 3 at medium rpm, press setup button to store and
automatically turn off this option) ?

but your main issues are with menu e, settings are way too high. Change b, c and d to 250, 12 and 0.3 (maybe a bit lower, 0.1 to 0.2) . The rest looks OK, though typically I run at 41 kHz (and have 21 kHz pwm)
but this should not be a big deal.

lastly, in menu G, change f to around 1000 or even less (like 600 or so)
 
IN your current sensor set up menu you error currents options f and g seem really hi you should be ~ 10% of the phase current. I found for option I I needed a higher number but my setups have been different as well I could not run well at all without the FOC on.
 
If I continue past that vs backing off I get a quick thunk from the motor and the controller faults to drive 0 and sometimes one of my gate drivers registers a fault,

extra $20 in fault protection just paid for itself, 10x over.

exciting taking the bike out for that first ride though eh? :)
 
HighHopes said:
If I continue past that vs backing off I get a quick thunk from the motor and the controller faults to drive 0 and sometimes one of my gate drivers registers a fault,

extra $20 in fault protection just paid for itself, 10x over.

exciting taking the bike out for that first ride though eh? :)

Yup, that shoot through protection sure does come in handy. I probably would have killed 50 MOSFETs by now :lol: But instead of spending hours replacing them, I just reset the power and continue on.

I'm now up to 48V 100A battery, 200A phase and it's working really well, no more shoot through faults or any errors from the controller now that I've tweaked the control loop. I don't understand what I'm tweaking in the loop, but I made it work through a lot of trial and error with careful adjustment of the loop one part at a time. The motor runs totally silent and has good torque, but I need more voltage and more battery amps to make it fun. It has a top speed around 30mph right now. I'll post some video up tomorrow after work.
 
The current sensors them selves with lebowski's code saved me a few hundred times as well while I was sorting things out. Jeremy when you think you have it. See if you can transition at full throttle with no load on the wheel. Mine never would. But Im hoping with the new build and lebowski's updates it will.
 
Lebowski,

I did a ton of tweaking tonight and these are my parameters I have set now. My menu E settings are kind wonky compared to what I saw you write in the documentation. What I found out was the lower I make the "d) 2nd order phase loop integrator coefficient:", the better it would work in sensorless mode from a low RPM. Right now I have it set at 0.06. Please check my settings and make some recommendations as I don't understand the loop I'm tweaking. If you could explain how the control loop works then maybe these settings would make more sense to me. I have great torque in sensorless mode and I am transitioning at 1000 eRPM which on my motor is about 3mph I think, I can then creep it even slower, almost to the point of not being able to balance it and then slam the throttle WOT and it stays in sensloress mode without a fault. I get a very slight grumble when I do this from such a low speed, but this is not a common situation, usually I would be using part throttle which makes no odd noise.

48V pack 12Ah 12S Nanotech pack, 100A battery, 200A phase and running good now. I'll get some video tomorrow, then probably try to step up the pack voltage. The MOSFETs are just barely getting warm. I have a temp sensor on the case of one of them but I have not been monitoring it. My motor has been getting warmer (just above ambient) than the controller has felt. I need to rig up the cycle analyst to work with this controller so I can monitor the amps being drawn from the pack. I need to try out FOC control tomorrow.

How do I get field weakening to work on the controller? Right now I have the output limited to 111% so it's still sine wave, what will I gain by going to 200% and using trapezoidal wave forms?

I got all the parts in for my new smaller higher power setup which I'll be building next if this continues to work as well as it is and matching it with a normal Cromotor. The new design I have is sexy and fits in a long skinny case with a 10x3.5x0.25" aluminum heat spreader plate that attaches to the black anodized finned aluminum case. It's going to have 18 IRFP4568's.

This is so much better than a Xie Chang controller it's not funny.

A very nice feature to add to your chip is some way to tell what parameter was exceeded and caused the fault, you have 4 LEDs that could be used to output an error code ;) I'd love to help take your control chip to a larger market. I need to test the pure sensorless version on my new build. This is really exciting stuff. My current controller is big and ugly, but it's also beautiful in how it operates.

Code:
------>

########################################
#   (c)opyright 2013, B.M. Putter      #
#   Adliswil, Switzerland              #
#   bmp72@hotmail.com                  #
#                                      #
#  version 1.21                        #
#  experimental, use at your own risk  #
########################################


a] calibrate hall sensors
b] determine coil positions
c) PWM parameters
d) current settings
e) control loop parameters
f) throttle setup
g) running modes
h) CAN bus setup
i) Field Oriented Control
z) store parameters in EEPROM for motor use

------> a

a] number of e-rotations: 92
b] calibrate hall positions
c] table out hall signals
z] return to main menu



------> b

a] number of back-emf samples: 1400
b] calibrate coil positions
c] use only fundamental sine waves
d] reconstruct waveforms based on extracted parameters
e] table out data arrays
z] return to main menu


------> c

a) PWM frequency: 15kHz
b) deadtime: 533ns
c) dutycycle testsignal: 50%
d) toggle high side polarity, now active HIGH
e) toggle low side polarity, now active HIGH
f) test PWM signals
z) return to main menu



------> d

a) number of current sensors: 3
b) current sensor transimpedance: 10.00 mV/A
c) maximum motor phase current: 199.9 A
d) maximum battery current, motor use: 99.9 A
e) maximum battery current, regen: 0.0 A
f) maximum shutdown error current, fixed: 24.9 A
g) maximum shutdown error current, proportional: 24.9 A
h) IIR filter coefficient, throttle current: 3
i) IIR filter coefficient, error current: 5
j) use additional comb filter: NO
k) use offset calibration: NO
l) restore default calibration
z) return to main menu


------> e

a) loop sample frequency: 28.51 kHz
b) proportional phase loop coefficient: 350
c) 1st order phase loop integrator coefficient: 24.0000
d) 2nd order phase loop integrator coefficient: 0.0599
e) proportionale amplitude loop coefficient: 52
f) 1st order amplitude loop integrator coefficient: 2.5000
g) maximum amplitude: 111 %
z) return to main menu


------> e

a) loop sample frequency: 28.51 kHz
b) proportional phase loop coefficient: 350
c) 1st order phase loop integrator coefficient: 24.0000
d) 2nd order phase loop integrator coefficient: 0.0599
e) proportionale amplitude loop coefficient: 52
f) 1st order amplitude loop integrator coefficient: 2.5000
g) maximum amplitude: 111 %
z) return to main menu

------> f

a) calibrate throttle 1
b) calibrate throttle 2
c) polynomial coefficients throttle 1 (x, x^2, x^3): 0.0998, 0.3798, 0.5197
d) polynomial coefficients throttle 2 (x, x^2, x^3): -0.0002, -0.0002, -0.0002
e) use analog throttle 1: YES
f) use analog throttle 2: NO
   receive throttle over CAN: NO
g) TX throttle over CAN: NO
h) test throttle
z) return to main menu


------> g

a) sensored or sensorless: SENSORED
b} sensorless startup: PUSH START
c} e-rpm limit sensorless self start: 2375 erpm
d} minimum current push start: 0.9 A
e} push start current, error allowed: 65 %
f] erpm sensored to sensorless transition: 1000
g] transition time sensored to sensorless: 249 milli-sec
h) return to motor start below 200 erpm
i) controlled slowdown for direction change: NO
j) phase current for controlled slowdown: 0.0 A
k) motor maximum, forward: 89.98 k-erpm
l) motor maximum, reverse: 3.99 k-erpm
m) motor standstill voltage threshold: 0.74 V
n) enable low side pulsing in drive 0: NO
o) low side pulsing rate: 52 Hz
p) low side pulsing width: 20 usec
z) return to main menu

------> h

a) CAN 'address': 1
b) CAN CFG1 as per Microchip 30F manual: 0
c) CAN CFG2 as per Microchip 30F manual: 0
   RS232 output rate: 3564 Hz
z) return to main menu

------> i

a) use Field Oriented Control: NO
z) return to main menu
 
Arlo1 said:
The current sensors them selves with lebowski's code saved me a few hundred times as well while I was sorting things out. Jeremy when you think you have it. See if you can transition at full throttle with no load on the wheel. Mine never would. But Im hoping with the new build and lebowski's updates it will.

I can go to full throttle with no load, but I have to roll the throttle a little vs just pin it. If I just pin it, it will fault on the controller chip when it transitions to sensorless, probably because it's happening too fast.

My bike looks like it was built by a total hack, it's comical, wires everywhere, but it works!
 
zombiess said:
Arlo1 said:
The current sensors them selves with lebowski's code saved me a few hundred times as well while I was sorting things out. Jeremy when you think you have it. See if you can transition at full throttle with no load on the wheel. Mine never would. But Im hoping with the new build and lebowski's updates it will.

I can go to full throttle with no load, but I have to roll the throttle a little vs just pin it. If I just pin it, it will fault on the controller chip when it transitions to sensorless, probably because it's happening too fast.

My bike looks like it was built by a total hack, it's comical, wires everywhere, but it works!

you should be able to just pin it, try reducing options e and f in menu e (the amplitude loop coefficients)

At home I'm playing around with v2.10, where now I've added a sensorless start without HF tone. On my little RC motor I can just full throttle it and
it will spin to 98 k-erpm straight away. And while keeping it pinned, I can select reverse where it spools down under a pre-set regen level, after
which it will full-throttle spin to 98k-eprm the other way.
 
This is very exciting!

You mentioned the silence. It is so amazing how silent and smooth a hubmotor can be when powered with the right waveform.
 
There is no field weakening build into this controller. My 'philospohy' is that most important is max efficiency (as battery capacity is limited) and that if people
want to go even faster they'll just need to up the voltage. Because field weakening really kills efficiency, it's not funny anymore how bad it is. Going over 111%
will start clipping the sine waves. The motor speed will go up a bit but it will start to make noise.

Have you turned on the FOC ? This should improve efficiency and torque a (little) bit at high rpm and under high load....

I don't know what kind of throttle you have, but if you're using a grip twist, it may be fun to add a thumb throttle, connect this to the second throttle input
and configure it for variable strength regen (by setting negative coefficients in the throttle menu)

regarding the loop coefficient menu, you're close to the settings I use. I typically have 240, 12 and 0,07 for b, c and d respectively (and 60, 3 for e and f).

Coefficient d controls how much the internal variable for motor speed is updated. A high value will make that variable for motor speed will jump up and down a lot,
making everything that depends on motor speed more jumpy (like for instance when it transitions between drive modes)
Coefficient c controls how much the phase of the motor is updated. Together with d it determines how fast the controller can respond to (electrical) phase changes.
Coefficiency b is purely there to keep the controll loop stable.
Typically b-c-d have a ratio of 840-40-1 , but b can be higher or d can be lower. I typically keep the b-c ration at 21, but reduce d to get less jumping around between
drive modes.

Coefficient f determines how fast the amplitude of the sine waves to the motor can increase or decrease, with coefficient e there only for loop stability. A ratio of 21 is good.

If it conks out of drive_3 to drive_0, it is always an error current event.
 
liveforphysics said:
This is very exciting!

You mentioned the silence. It is so amazing how silent and smooth a hubmotor can be when powered with the right waveform.

Luke, it's super exciting and your right, it's amazing. There is literally no audible sound except wind and the freewheel buzzing and I'm only at 15khz. I'm so happy that I got this working, it's a monumental accomplishment for me because it's easily an order of magnitude, possibly 2 orders of magnitude more complex than any previous project I've attempted and encompasses so many fields! Lebowski sends me a 40 pin PDIP chip and schematic, then I have to do everything else! Talk about DIY! I even purchased a mini mill and am learning to use it so I can build heat sinks for prototypes and researching into paralleling MOSFETs. I'm kind of obsessed with gate drive / power stage design, so challenging.
 
Lebowski said:
There is no field weakening build into this controller. My 'philospohy' is that most important is max efficiency (as battery capacity is limited) and that if people
want to go even faster they'll just need to up the voltage. Because field weakening really kills efficiency, it's not funny anymore how bad it is. Going over 111%
will start clipping the sine waves. The motor speed will go up a bit but it will start to make noise.

Have you turned on the FOC ? This should improve efficiency and torque a (little) bit at high rpm and under high load....

I don't know what kind of throttle you have, but if you're using a grip twist, it may be fun to add a thumb throttle, connect this to the second throttle input
and configure it for variable strength regen (by setting negative coefficients in the throttle menu)

regarding the loop coefficient menu, you're close to the settings I use. I typically have 240, 12 and 0,07 for b, c and d respectively (and 60, 3 for e and f).

Coefficient d controls how much the internal variable for motor speed is updated. A high value will make that variable for motor speed will jump up and down a lot,
making everything that depends on motor speed more jumpy (like for instance when it transitions between drive modes)
Coefficient c controls how much the phase of the motor is updated. Together with d it determines how fast the controller can respond to (electrical) phase changes.
Coefficiency b is purely there to keep the controll loop stable.
Typically b-c-d have a ratio of 840-40-1 , but b can be higher or d can be lower. I typically keep the b-c ration at 21, but reduce d to get less jumping around between
drive modes.

Coefficient f determines how fast the amplitude of the sine waves to the motor can increase or decrease, with coefficient e there only for loop stability. A ratio of 21 is good.

Thank you for taking the time to post this as it explains a lot. It's interesting that I ended up with similar settings to what you run. I'll try tweaking the settings a little more tomorrow. It seems like it's really close to being able to do sensorless start up. I'll try out FOC as well. Things really came together well when I set coefficient D to 0.06. I'm thinking 0.05 or even 0.04 might be better and eliminate the very slight judderI felt at VERY low speed after I upped the phase/battery amps. IT will climb my drive way at a walking pace without issue in drive mode 4 even with me holding the rear brake on a bit, that's pretty darn good sensorless controll! I'm so excited. I hope things keep working this well and I can get to 100V and around 17kW, I know that's a lofty goal.

I don't blame you for not doing field weakening for efficiency reasons, but I thought Arlo1 had posted that it was capable of it at one point. It does seem somewhat wasteful to use, but it's a nice option to have in some cases, such as wanting to keep the battery pack voltage down but not wanting to change motors. Besides, the amount used can always be adjusted.

Adding a 2nd throttle for variable regen is on my short list. I already have a thumb throttle just for this reason. All I need to do is hook it up and configure it.

Video of me riding tomorrow!
 
the very slight judder at low speed (in sensorless) is most propably caused by some uncompensated offset in the current sensors...

v2.10 will have continuous offset calibration. The problem with offset calibration always on is that for very large currents the current sensors are no longer linear.
When the motor is running the average current through each sensor is 0. With a very, very slow filter you can filter the signals from the current sensor and
use this as the offset compensation signal.
However, when the sensors are non-linear (which they are), this '0A' voltage will walk away for high current levels, the '0A' voltage is basically different for
low and high currents.
What has happened to me is that while climbing a hill the offset moved due to this effect, making the controller IC believe there was an error current and shutting down.

you can try this yourself. Turn on the current sensor offset calibration but do not press setup. This will keep the offset calibration running all the time.
There's a good change that after about a minute of running on the street (at high currents) the controller will conk out to drive_0 (because the incorrect
offset will seem to the controller IC to be an error current). The only way out is a reset.

I would reduce the transition rpm from sensored to sensorless to less than the 1000 you have at the moment, give 600 a try....

P.S. you just made post 2500 :mrgreen:
 
I don't understand what I'm tweaking in the loop
that will change. perhaps one day we'll all go through the control theory and get a deeper understanding of it all.
 
Back
Top