Rickys High Power Flexable motor controller

Ricky_nz said:
I also have some insulating thermal sheet coming to put between the FETS and the heatsink. I just need to figure out how to put nice holes in it for the FET mounting holes. I will use one strip for the high side FETS and one for the low side ones.

If you've got any laying around, a quick and cheap way i've found works is using an RG316 ferrule and punching it through the sheet with a hammer.

P1010529_enl.JPG
 
boostjuice said:
If you've got any laying around, a quick and cheap way i've found works is using an RG316 ferrule and punching it through the sheet with a hammer.
Unfortunately I don't RG316 ferrules but I do have some complete crimp on N connectors for RG58 which the ferrule is too big but it looks like the back of the connector that goes under the braid may be big enough to clear the bolt and small enough to not allow the metal back of the FET to short so when the sheet arrives I will try that out, it looks sharp enough too.
Thanks for the idea off a make shift punch :), I'll let you know how it works out.
 
I bought a set of hollow punches from Harbor Freight for a couple of bucks on sale, but for punching insulators I use a hole punch from a craft store (or just drill it).
 
texaspyro said:
I bought a set of hollow punches from Harbor Freight for a couple of bucks on sale, but for punching insulators I use a hole punch from a craft store (or just drill it).

A hollow punch set with a range of sizes is the ideal tool for the job, but the cost can be avoided using something laying around for a one off job.

The common paper binder hole punches have too large a diameter for FET mounting holes. The metallic backing of the package will be exposed to the heatsink. You can't drill silicon sheet insulators, they are too thin, the drill-bit just grabs and rips.
 
what about a needle for drawing blood or giving shots? You can probably get those free at the local pharmacy. That's where I get my syringes for bleeding brakes. :D
 
etard said:
what about a needle for drawing blood or giving shots? You can probably get those free at the local pharmacy. That's where I get my syringes for bleeding brakes. :D

The appropriate sized syringe needle diameter for a FET pass-through clamp screw would only be used for tranquilizing elephants. good luck finding them at your local pharmacy :lol:
 
boostjuice said:
The common paper binder hole punches have too large a diameter for FET mounting holes. The metallic backing of the package will be exposed to the heatsink. You can't drill silicon sheet insulators, they are too thin, the drill-bit just grabs and rips.

Yes, plain office supply store hole punches are no good. I think that I bought my small punch from Michaels (the craft store). It punches perfectly sized holes.

To drill the insulator sheet, press the FET down firmly on the insiulator sheet/hardwood backer board. Drill through the fet mounting hole. Gives nice clean holes if you do it right.
 
Thanks everyone for your input :), nice to have more than one option.

texaspyro said:
To drill the insulator sheet, press the FET down firmly on the insiulator sheet/hardwood backer board. Drill through the fet mounting hole. Gives nice clean holes if you do it right.
I guess this would need a sharp drill and ensuring the sheet is clamped tightly so it can't move while drilling as the insulator is pretty thin.

etard said:
what about a needle for drawing blood or giving shots? You can probably get those free at the local pharmacy. That's where I get my syringes for bleeding brakes. :D
:shock: If anyone came at me with with a 3 - 4mm diameter needle I wouldn't be too happy about it :lol:.


boostjuice said:
A hollow punch set with a range of sizes is the ideal tool for the job, but the cost can be avoided using something laying around for a one off job.

I have just tried the back of a crimp on N connector intended for RG58 on a piece of paper as a test and it punches a neat hole that happens to be pretty much the same diameter as the hole through the insulating part of a TO-247 which means there is enough tolerance that if it is slightly off center the back metal plate will still not be able to short to the heatsink :D .

I will probably use this for the first unit and then go and find a punch of the correct side for any future boards.
When I'm finished I will crimp the connector on some coax for its intended use as I need to make a couple more patch leads.

The back of these connectors is tapered to a point to make it easier to slip between the braid and inner of the coax and I guess this helps with the cut.

I should have the insulator and a few other parts I ordered tomorrow. I just have to drop into the courier at lunchtime to pick them up.
 
Ricky_nz said:
I guess this would need a sharp drill and ensuring the sheet is clamped tightly so it can't move while drilling as the insulator is pretty thin.

Most of the stuff that I have drilled is that fairly thick (1mm) thermal pad. I have drilled the smaller Kapton type insulators. I have a drill bit that does not come to a center point (looks sort of like a bit that was broken) that works very well.
 
Just picked up a new toy that should make calibrating the phase current sensors easier when I deicide to rescale them :D.clamp_meter.JPG
AC/DC current clamp meter :D.
Its definitely not a Fluke but it is more in keeping with my budget. It seems to work ok and its a lot cheaper than the Fluke ones.
I decided it was worth buying one rather than just borrowing one, much more convienant as I could only boirrow one for short periods of time.
True RMS for the AC side which is handy although the update rate isn't fantastic it will still be perfect for calibration where a slow update rate is a good thing.
An independent meter is also good for proving that my software isn't telling lies.

I think I have every thing I need for my 12 days of controller development starting on the 24th that I have planned over Christmas :). Too busy at work to take any more off this year :(.
I'll swap out the gate drive caps to the 20V versions tomorrow then cut & punch the insulating sheet and get things bolted up to the heatsink.

I can then experiment in tuning the DC bus capacitor combination and gate drive.
Currently the IRS21864 gate drive chips feed each FET with its own 10R resistor and I need to make sure that is the best option etc.
I wasn't too keen to tweak this until I have run the gate drive circuit at 15V.

I can only go so far until I get the ADC timing setup so that is a high priority for tomorrow too so I can get some software protection activated. I need to do this as I have been breaking the "golden rule" of power electronics development.
The rule being "Don't power up the power devices until the protections are proven" My excuse was that I had a very limited power supply feeding it but the time to up the power is coming and there is no way I am upping the power until I know it can protect itself :lol:.
The protections I want.
1) hardware current trip (cycle / cycle). -- appears to be working
2) fast software current trip
3) Gate drive voltage out of range trip
4) DC Bus High trip.

So really I just need to finalise the ADC conversion triggering and get the protection code comparisons running and latched etc. Not a big task.
 
Ricky_nz said:
Just picked up a new toy that should make calibrating the phase current sensors easier when I deicide to rescale them :D.
AC/DC current clamp meter :D.
Its definitely not a Fluke but it is more in keeping with my budget. It seems to work ok and its a lot cheaper than the Fluke ones.
I decided it was worth buying one rather than just borrowing one, much more convienant as I could only boirrow one for short periods of time.
True RMS for the AC side which is handy although the update rate isn't fantastic it will still be perfect for calibration where a slow update rate is a good thing.
An independent meter is also good for proving that my software isn't telling lies.

I think I have every thing I need for my 12 days of controller development starting on the 24th that I have planned over Christmas :). Too busy at work to take any more off this year :(.
I'll swap out the gate drive caps to the 20V versions tomorrow then cut & punch the insulating sheet and get things bolted up to the heatsink.


I can then experiment in tuning the DC bus capacitor combination and gate drive.
Currently the IRS21864 gate drive chips feed each FET with its own 10R resistor and I need to make sure that is the best option etc.
I wasn't too keen to tweak this until I have run the gate drive circuit at 15V.

I can only go so far until I get the ADC timing setup so that is a high priority for tomorrow too so I can get some software protection activated. I need to do this as I have been breaking the "golden rule" of power electronics development.
The rule being "Don't power up the power devices until the protections are proven" My excuse was that I had a very limited power supply feeding it but the time to up the power is coming and there is no way I am upping the power until I know it can protect itself :lol:.
The protections I want.
1) hardware current trip (cycle / cycle). -- appears to be working
2) fast software current trip
3) Gate drive voltage out of range trip
4) DC Bus High trip.

So really I just need to finalise the ADC conversion triggering and get the protection code comparisons running and latched etc. Not a big task.

I've had really good luck with the DC Inductive current clamps. I used it to calibrate the Shunt resistance in the controller and no cuttling/splicing necessary and no voltage drop! There's still no substitute for a finely calibrated small value shunt resistance with Kelvin measurement in some cases.... great to hear the progress!
 
And if you can score one, an AC/DC oscilloscope current probe. I have Tektronix units (A6302/6303/6304 plus AM503B/5030 probe amps) that go up to over 500 amps. Magic little beasties... unaffordable new/used equipment dealers, mostly unaffordable on ebay.
 
Just a comment in case folks aren't aware, but AC RMS meters don't work correctly on PWM DC. The motor phase currents are effectively AC so it might be fine there (though the crest factor can cause serious accuracy issues at low PWM duty cycles), but on the DC supply side a meter with DC + AC RMS capability is required, and those are not common.
 
grindz145 said:
I've had really good luck with the DC Inductive current clamps. I used it to calibrate the Shunt resistance in the controller and no cuttling/splicing necessary and no voltage drop! There's still no substitute for a finely calibrated small value shunt resistance with Kelvin measurement in some cases.... great to hear the progress!
I figure that sufficient accuracy will be obtained using the current clamp.
It won't matter if there is 1/2A error out of several hundred :lol:

texaspyro said:
And if you can score one, an AC/DC oscilloscope current probe. I have Tektronix units (A6302/6303/6304 plus AM503B/5030 probe amps) that go up to over 500 amps. Magic little beasties... unaffordable new/used equipment dealers, mostly unaffordable on ebay.
Sound useful, They have some pretty expensive current measurement equipment along those lines at work.
Hopefully for now I can make do. I think I will be able to use one of the hall effect based CT's I have used in the controller combined with my oscilloscope to look at actual levels with. So far I have just been hooking the scope onto the output of the one on the board and since I haven't shunted any current around it its factory accuracy should be valid but nothing like an independent measurement.

Alan B said:
Just a comment in case folks aren't aware, but AC RMS meters don't work correctly on PWM DC. The motor phase currents are effectively AC so it might be fine there (though the crest factor can cause serious accuracy issues at low PWM duty cycles), but on the DC supply side a meter with DC + AC RMS capability is required, and those are not common.
Yes PWM does affect many meters and probably the one I brought so using it in the right application is key. I figure it should be good enough for motor phase currents as I use a similar one at work for software tests and it seems reasonable. Admittedly thats at 4KHz PWM with an actual output filter that won't be present on my motor drive but the motor/inductor does a pretty good job from what I have seen so far.

I think I will be able to use one of the hall effect based CT's I have used in the controller combined with my oscilloscope to look at actual levels with nasty crest factors etc. I have one In a box now and it works pretty well, I just need to rescale it with a copper shunt around it and then feed it some current so I can recalibrate it. My scope has a heap of waveform measurment functions and the CT has 120KHz bandwidth which should be good enough for most jobs.

Once I have the controller calibrated then the controllers internal RMS measurements should be good.
I have got the square root function sorted. I was going to use a taylor series for speed but instead decided to use one of the optimised ARM assembly iterative ones that is freely available. I don't think it will need to be done at the high rate so the difference of say 20 cycles of processor isn't worth the pain of writing it myself. If I needed to do it at the PWM rate then I would definitely look at the Taylor series method. The measurement code will probably run at around the 1ms rate so should be fast enough to calculate a good RMS which can be used for display purposes.
 
Depending upon your input range, desired resolution and available memory, a table lookup (with or without interpolation) will provide a very fast square root function.
 
In most cases the square root is not actually needed in realtime. You can instead square the value you are comparing with and work in the squared domain and avoid the realtime need for roots. I have done realtime per pulse PWM RMS feedback in an 8 pin AVR this way, though the PWM was lower frequency than this. But the CPU was running only 8mhz and 8 bits also.
 
Alan B said:
In most cases the square root is not actually needed in realtime. You can instead square the value you are comparing with and work in the squared domain and avoid the realtime need for roots. I have done realtime per pulse PWM RMS feedback in an 8 pin AVR this way, though the PWM was lower frequency than this. But the CPU was running only 8mhz and 8 bits also.
Thats how I intend to do any thing at high speed like junction thermal modeling etc.
The root is only for the user interface so speed isn't really a problem but keeping RAM for high speed code is more important.
It is more efficient to run from RAM than Flash even though the flash cache does help.
The user display will be really heavily filtered so slow is all that necessary.

Interesting link about fast iterative square roots on ARM http://www.finesse.demon.co.uk/steven/sqrt.html
 
Hi All
Its been rather humid here today, not the best for debugging so I had a lie down and now its after midnight...
A bit cooler as well and I finally solved my bug with my timer match triggered ADC conversion and I can now have the current sensor conversions triggered when I want automatically without software intervention.

I was seeing weird results from the software and intermittent data. I got clued in after coming back to it an hour ago and something that was working wasn't any more. I started probing around the hardware and realised that there wasn't data from the ADC to the chip and on close inspection I found a bad solder joint :oops:. one pin on the micro hadn't had enough heat and wasn't soldered to the pad. Why is it that the pin this happens to is never something irrelevant but instead an important control signal?
I guess as the ambient temperature cooled the pin lost contact making an intermittent fault permanent or at least last long enough for me to realise it was a hardware issue.
My excuse this was the first flat pack chip I have soldered in about 4 years.
Oh well on the next boards I'm building up I have already soldered the micros on and they are looking much better as I changed my technique and gave them a better inspection. I need to finish building them up as first prototype is a bit tatty now.
Man I hate it when a hardware issue looks like a software timing issue!
A couple of hours debugging solved with 2 seconds of soldering iron a flux :evil:

Its all a bit annoying because the board seem to be operating reliably with manually triggered conversions several months ago so I didnt think it would be the hardware.
I think it was always faulty but maybe making better contact or the timing was less critical with manually triggered conversions than the automatic method. This could be becase as for the early manual tests I was using big delay loops and even if the pin was capacitively coupling it probably had enough time to work.

In summary all both pairs of conversions (4 * 12 bits) are now occurring every 83.3us (12KHz) the current PWM rate. I have a choice of where I position the current sensor one relative to the PWM waveform but the DC Bus conversion must be triggered in software so It will happen in the limit interrupt with the control code.
Ricky
 
Hi All,

More progress,
After sorting out my ADC conversion/reading issues detailed above I have now got the gain and offset parameters and scaling working on the high speed ADC inputs.
The calibration values are successfully being loaded from the calibration parameter file on each boot :).

The ADC values only jump around a few bits worst case at either 0A or at 48A so so far noise isn't an issue at this point.
At 12KHz 48A and the external inductor the output current is pretty smooth.

The CT zero output is within 160 counts worst case of zero and thats through the opamps this I probably won't fit on the next control board I build for this application. the other channel is within 10 counts of zero.

I guess I now need to decide what I want the base current to be for calibration purposes for the initial tests with standard CT's without rescaling.

For those not familiar with it I am using a 'per unit' system which allows me to use fixed point numbers and keep everything within the required ranges. The base current value is the current at which 1 will be represented in the fixed point system.
so a 0.25 per unit current is 25% of the base current so 0.25 in my software would represent 50A if the base current is 200A.

The base values are also used to convert values internally by the software into values a user can understand on the user interface.
basically the 'per unit' system is percentages of some defined value.
The per unit system also makes it fairly easy to scale a converter over a wide range of currents and voltages while running fixed point calculations internally.

I have cut the two insulator strips for the heatsink and punched holes in them using the back of a crimp on connector for RG58.
This cut a quite clean hole that is the perfect size :D, thanks boostjuice for the idea to use RF connectors as improvised punches :D .
Seems to work best on a slightly soft surface ( already damaged area of an old static mat ). Using the whole connector made it easy to hold and hit.


Ricky
 
Bad solder joints can be incredibly hard to troubleshoot, especially at the stage you're at! I spent about an hour scratching my head when a cold solder joint had disabled my buddies controller.

Nothing can stop you now.... :twisted:
 
grindz145 said:
Bad solder joints can be incredibly hard to troubleshoot, especially at the stage you're at! I spent about an hour scratching my head when a cold solder joint had disabled my buddies controller.
Yep, things like ADCs are worse because there is no way to 100% test them without software.
The other analog parts of the circuit ware easy to test in hardware.

grindz145 said:
Nothing can stop you now.... :twisted:
Hopefully not :).
Next on the list is software protection then I can really start thrashing/tuning the power stage.

I still need to tune the gate drive/DC Bus caps a little.
As it is this thing laughs at the 48A phase output I get in my initial tests :lol: so I really need to get that protection in place so I can confidently increase the current etc :twisted:.



Edit: late Sunday / very early Monday
Just performed a few more tests that aid my confidence in the protection.
I was concerned what would happen to the hardware when I halt the processor over JTAG.
Result:
1) PWM continues at the last specified duty cycle.
2) manually tripping the HW over current comparator briefly turns off all PWM outputs and latched them off until the processor is restarted.

I am pleased that the /MCABORT input on the micro stays active when the processor is halted by the emulator and that it latches the state even though it cannot get into the interrupt due to being halted.
The staying on the current PWM output value is a small concern as it effectively generates DC on the output which could create high currents. It these go too high the hardware current trip will activate turning off all outputs.
Going to DC output with the motor running would not be good for the motor.

I will avoid halting the emulation with the motor turning. This isn't really a handicap as the control code needed to keep the motor turning is way to timing critical to step through etc. The JTAG interface will mainly be used for debugging the slow speed inputs etc which can be done without the motor turning.
The only other use for the JTAG is to load new code for debugging and again it can be done when the motor is stopped.

If I forget the hardware trip should activate if the currents get high enough which will shut everything down. There is a possibility for the outputs to generate a current below the current trip point that would heat the motor up so it is something to avoid if at all possible. Its probably a good idea to set the hardware current limit low when debugging with a motor connected.


ADC calibration:
I have set the gain for the ADC for a I base of 200A for now. The gain and offset values are nicely loaded after each boot so one less thing to worry about. For various DC currents the result seems to be correct when I multipy the internal value by 200 to get the real current.

Only 4 Days of work left before I can really start playing with my controller since I've taken Friday off :D.
There are some things on the controller I don't want to play with when I'm tired after work as mistakes can be expensive :lol:
I don't enjoy MOSFET smoke :lol:.
 
Hi All,

Just had another play this evening.
I decided to just fir the 1uf ceramic SMD caps across each FET and the main 4x680uF electros.

I did a few tests at the 50A I've limited it to at the moment and measured the ringing on the DC bus with 1 1uF cap per MOSFET pair and a couple across the input electros.
Its really hard to avoid noise pickup to make these measurements with a standard scope probe :lol: .
The earth clip lead works as a really good antenna. I wrapped the excess around the probe to reduce pickup.

There is still a small amount of ringing but some of that could still be pickup.
View attachment ADS00014.BMP
Occasionally there is a noisy burst (higher frequency) that isn't much worst in amplitude. I should really figure out what that is.

Since my scope and PC aren't isolated I disconnected the PC from the controller once I setup the test PWM levels and run the controller off isolated supplies. The only ground was through the scope.
I don't want an unexpected high current through a ground conductor. One of my work mates did that to his work PC :lol:. He took out the PSU & Motherboard and a pic debugger :shock: He was lucky the PC was about to be replaced anyway.


Originally I only fitted 1uF caps for just the phase I was testing on and the level was higher.
Now I have caps for all phases and a couple directly across the electros and I'm running my test inductor across 2 phases and level is as the above plot.
I can add more leaded caps but I still don't have the caps I would really want. I can also add some smaller SMD caps if necessary.
I will see how things go when I start pushing the current up.

I now have the correct bolts to bolt all MOSFETS to the heatsink so I'm closer to being able to push it harder.
Also I might allow me to determine if the caps are self heating. They are warm at the moment but then again the whole board is warm without the heatsink attached (conducted heat after running for a while at 50A with no heatsink).

I also have the correct bolts for terminating phase wires and battery connections to the PCB.


I took my test inductor and my 80100 180 into work today to confirm my inductance measurements of the motor and to see how my air cored inductor compared with the motor.
The motor measures between 17uH and 29uH between 2 phases depending on rotor position.

My inductor was a little high ( too much dew :?: :lol: ) Took off 3 turns and now it measures 27uH.
I can take off a few more If I want to be in the middle of the motors range.

I have been talking to a few mates and I'm tempted to go straight to vector control!
I can always go back to halls etc if it dosn't work in the time frame I want.

I am working on a development plan to get it running vector control if I go that way
below is some of the steps:
1) spin of turnigy on sinewave without sensors or sensorless code (open loop). I can use this to get the current controllers working.
This will not be that usable for real applications but I get to see/hear the turnigy spin. I have had one for almost a year and haven't had anything to spin it up on so this is a priority.
I would think I can have the motor spinning on sinewave is a relatively short space of time.
2) Implement a crude startup algorithm that spins up the motor for tests (probably open loop up to some defines speed).
3) write and debug sensorless vector control using back emf techniques for medium and high speed.
4) Improve startup algorithm to be proper sensorless (The are are lots of techniques for sensorless at low speed and I need to find one that works for ebikes).

There is a huge number of papers on sensorless but we need one that works under heavy load.

If I move to sinewave the Inductor won't see too much use as I will move over to the Motor as I don't have enough wire to wind another 2 inductors and I have to run all three phases to test the current controllers. I'm confident that on my limited supply I can't hurt the motor.

The inductor will still be useful for testing the controller at higher currents by reducing complexity by running just one phase as DC but the vector control current controllers will require a 3 phase load.

One more day of work then I am on holiday with plenty of time to play with motor controllers :D.
I get the feeling it is going to be a slow day at work :(.


Edit:
I have had the controller pumping between 45A and 50A through my inductor for a couple of hours now. The heatsink is warm. I need to beef up the copper on the top side of the board used for the phase outputs as it gets quite warm so for higher current I will need to beef it up like I did on the bottom. This is not unexpected as I originally calculated approx 20degC rise for 50A and always expected to have to beef it up. Pretty easy to do as I designed the board to be beefed up by having areas without solder mask etc.
The HK 8 gage wire gets quite hot when wound into a coil and run for a long time :twisted:.
The leads to and from the coil are warm. It really goes to show the difference between a wire in free air and one close to others.
There has been no airflow over the heatsink and for half the time it was fins down. I stood it up to stop the heat rising through the PCB etc.
Definitely getting a bit more confident in the basic operation so I better write some software for the DQ current controllers :).


Ricky
 
Hi All,
I'm now on holiday and have started playing with my motor controller after sobering up :wink:
I have got an integrator block working along with the high speed sinewave routines and modulator.

The test involved using the integrator to generate a ramp representing the angle and then feed that ramp into the sinewave function. I fed the output of that into the phase A PWM modulator and the inverse of it to phase B's PWM modulator.
This proves my integrator, sine and PWM modulator functions not only function correctly but are scaled correctly.

Changing the input to the integrator determines the frequency generated. I have tried several frequencies and it works.
I will be setting up the correct TS (sample time) in the calculations soon.
I will set things up so that TS is recalculated if the PWM frequency is changed as changing the PWM frequency changes the sample rate of the high speed control code meaning the integrator gains need rescaling etc.
I just hard coded one for now. The oddball output frequency is because I didn't calculate the correct TS. I just compiled in a rough estimate which I got wrong. But calculating back from it it looks like the integrator is fine.

[youtube]rXBrYuSKg_k[/youtube]

My inductor generates quite a bit of audible 730Hz :lol:

The test code will be part of the first code used to run the motor once I add the blocks to generate 3 phase AC. (very simple blocks).

I need to build a test stand for the 80-100 motor before I can start playing with combining it with the controller.
I can't go out the shed and start making noise at the moment as its 4:30am and I'm sure my neighbours wouldn't be happy if I started cutting up bits of wood now :lol:

Edit:
I have tracked down the source of the noise I thought was coming from the inductor. Most of it was coming from my audio amp :lol: .
What was happening was I have the debugger connected to the PC and I found when the scope ground was also connected to the board the noise is present. Looks like an untended earth loop. There isn't really any current in it but my audio amp connected to the PC picks up on it.
I had been very aware of disconnecting the PC when measuring high side stuff etc but when playing on the logic side I didn't see it as a big path.
With the grounds disconnected the inductor is silent until you do something silly like stick an aerosol can in it and then the can sings at 1KHZ :lol:
I do have an big 10A isolating transformer in the shed. Still not sure that isolating the scope with a transformer would help that much due to the transformers capacitance (The frequencies involved in the motor drive probably go straight though). Maybe I need to buy some USB isolators for the usb hub with the serial port hanging off it so at least I can isolate the PC from the power stuff.
Unfortunately I can't afford isolated differential probes for my scope.

Ricky
 
WOW, this is really fantastic and fast progress!!! I've personally been waiting for almost a decade for a good "torque control" motor drive and it looks like you're headed in that direction with the 2 phase current sensors.

What do you plan to use as a programming interface; a serial connection with attached PC software? I'm also curious if you are going to open source the software as well as the hardware? Anyhow, I'm in for a few drives myself if everything pans out as planned. FYI there is another gent working on something very similar at scolton.blogspot.com. He has working FOC and about a million pages of info on his blog.

David B.
 
Back
Top