Controller Builders: Why High Amperage Shunts Suck

Teh Stork

1 kW
Joined
May 25, 2011
Messages
463
So you've got yourself a good understanding of a three phase bridge, controll methods and electronics 101 - but when trying to get a reasonable shunt feedback from your high-powered system at high speed, you only meet problems.

Because of their inductance and very low resistance - getting high bandwidth (for high electrical rpm operation) from a normal high powered shunt is troublesome. Take a 1000A 50mV shunt (50W dissapation at rated I). Even if the shunt was only 5 cm's long (~2inch): the inductance would already be 50nH. The L/R time constant would be 1ms. The -3db frequency would be ~160Hz. If I'm not mistaken a normal hubbie reaches around 140Hz running 24inch wheels and 40mph. Maybe ok for hubbies in other words, but a RC motor? Not a chance.

So, how do you overcome this?
Hall effect feedback. You've heard that this is expencive, subject to sorrounding electrical fields and generally hard to work with - but all those are blown out of proportions.
Allegro carries a line of 200A bidirectional IC's with built in hall effect sensor and amplification stage. These are plug and play.
Allegro also carries 'SIP' hall effect sensors. I'll do a write up once I've fully tamed them. You need shielding, a toroid to focus the field and a basic understanding of physics. I plan to calibrate them using the 200A ic's.

-Stork
 
3uS responce time.
I have 3 alegro 200 amp hall current sensors and now for my big controller I just got these! http://sccatalog.honeywell.com/imc/datasheet.asp?PN=CSLA2EN&FAM=current&P=1977
 
my main reason for not using shunts but ACS758 type current sensors from the get-go
is that the `output voltage` of a shunt is very low and that some sort of amplification would
be necessary.
If for instance you want to limit the power in the shunt to 10W then a 10A shunt gives you 1V,
a 200A shunt only 50 mV . The higher the current the lower the output voltage. And when you
realise a 10bit ADC running on 5V has only 5 mV per LSB you can see the resolution is very
very poor (20A per LSB). A 200A ACS758-bidirectional gives 2V out for 200A (this would
dissipate 400W if it were a shunt !), so 400LSB's or 0.5A per LSB
 
Well, decent microcontrollers do have a pre-set amplification for ADC. 20x for example. For 50mV shunt it would be 1V on differential ADC input. Not that bad.
Other question is noise... If resolution is not enough, you can always do oversampling, where noise not harms, but actually helps for the accuracy.
 
circuit said:
Well, decent microcontrollers do have a pre-set amplification for ADC. 20x for example. For 50mV shunt it would be 1V on differential ADC input. Not that bad.
Other question is noise... If resolution is not enough, you can always do oversampling, where noise not harms, but actually helps for the accuracy.

Oversampling kills the response time though, as what you're trying to sense is very rapid changes in current, plus it doesn't work well for non-repetitive signals anyway. If the controller cannot sense the current changes fast enough (which means sensing at around PWM fequency), then the FETs can blow. The Xiechang/Infineon/Lyen etc controllers get around the slow ADC problem by using a second, analogue, peak current shut down sense circuit. This is just an external comparator that sends an interupt to the µcontroller to shut the outputs down in the event of a rapid over-current event.

Also, the noise environment is grim in a controller - trying to sense mV levels is fraught with problems when there's substantial amounts of RFI inside the controller case and possible spikes on the rails. Far better to use an ADC with a fairly high full scale range and provide it with a conditioned, relatively noise-free, input and avoid getting into sub-mV measurement hassle.
 
Lebowski said:
my main reason for not using shunts but ACS758 type current sensors from the get-go
is that the `output voltage` of a shunt is very low and that some sort of amplification would
be necessary.
If for instance you want to limit the power in the shunt to 10W then a 10A shunt gives you 1V,
a 200A shunt only 50 mV . The higher the current the lower the output voltage. And when you
realise a 10bit ADC running on 5V has only 5 mV per LSB you can see the resolution is very
very poor (20A per LSB). A 200A ACS758-bidirectional gives 2V out for 200A (this would
dissipate 400W if it were a shunt !), so 400LSB's or 0.5A per LSB

Uhm, use a OP-amp to amplify the signal. It really is needed to use the whole ADC range. The problem with high-powered shunts is mainly the corner frequency, as indicated in the first post.

Arlo1 said:
3uS responce time.
I have 3 alegro 200 amp hall current sensors and now for my big controller I just got these! http://sccatalog.honeywell.com/imc/datasheet.asp?PN=CSLA2EN&FAM=current&P=1977
Tried finding prices for the honeywell sensors, 45 usd :O Allegro's are cheap tho :)

Jeremy Harris said:
circuit said:
Well, decent microcontrollers do have a pre-set amplification for ADC. 20x for example. For 50mV shunt it would be 1V on differential ADC input. Not that bad.
Other question is noise... If resolution is not enough, you can always do oversampling, where noise not harms, but actually helps for the accuracy.

Oversampling kills the response time though, as what you're trying to sense is very rapid changes in current, plus it doesn't work well for non-repetitive signals anyway. If the controller cannot sense the current changes fast enough (which means sensing at around PWM fequency), then the FETs can blow. The Xiechang/Infineon/Lyen etc controllers get around the slow ADC problem by using a second, analogue, peak current shut down sense circuit. This is just an external comparator that sends an interupt to the µcontroller to shut the outputs down in the event of a rapid over-current event.

Also, the noise environment is grim in a controller - trying to sense mV levels is fraught with problems when there's substantial amounts of RFI inside the controller case and possible spikes on the rails. Far better to use an ADC with a fairly high full scale range and provide it with a conditioned, relatively noise-free, input and avoid getting into sub-mV measurement hassle.

Firstly, pre amplification often takes some conversion time - and also lessens accuracy. OP-amps are a relatively low cost improvement. I hated OP-amps before, but their functionality is awesome.

The AVR XMEGA that I use are ideal for oversampling. It's pipelined ADC allows for starting conversions while you're in a conversion. One value takes 7 cycles to get. Two values takes 11 cycles to get. I use 4 samples, and that takes me 19 cycles to get. ADC conversion time is really one of the lesser strains of the AVR core, since it can finish in the background while the ALU does other things. The event manager keeps things tidy ;P Sampling does not take much time compared to calculations required for FOC - so I'm actually going to use the AVR32 witch has a FPU so that the Park and Clarke (sin and cos) calculations goes faster.
 
Teh Stork said:
Firstly, pre amplification often takes some conversion time - and also lessens accuracy. OP-amps are a relatively low cost improvement. I hated OP-amps before, but their functionality is awesome.

The AVR XMEGA that I use are ideal for oversampling. It's pipelined ADC allows for starting conversions while you're in a conversion. One value takes 7 cycles to get. Two values takes 11 cycles to get. I use 4 samples, and that takes me 19 cycles to get. ADC conversion time is really one of the lesser strains of the AVR core, since it can finish in the background while the ALU does other things. The event manager keeps things tidy ;P Sampling does not take much time compared to calculations required for FOC - so I'm actually going to use the AVR32 witch has a FPU so that the Park and Clarke (sin and cos) calculations goes faster.

Op amps suck when it comes to doing this, big time, and are not really the part to use. Op amps excel when measuring differential signals, where noise is common mode, but fail when measuring single-ended low-level signals in a noisy environment, particularly where the noise is anything but common mode. Sensing a controller shunt is inherently single ended, as one end is tied to ground. That ground will be bouncing around all over the place with switching noise.

You can use a single ended low noise, low drift, instrumentation amp, as I did in my simple fuel gauge, to up the shunt voltage to something a typical 10 bit ADC can read, but it's not ideal as there is still a fairly high level of noise floating around, which will get through the amp and tend to screw up any fast ADC readings.

You can certainly use processors with faster conversion times than those in the typical controller. Pretty much all of the controllers I've taken apart have used fairly slow processors, usually based on pretty old 8 bit topologies (more often than not 8051 based!). As such they tend to be slow, too slow to do accurate current measurement on the fly, hence the reason for the tacky add-on over current shut down comparator on the Xiechang's.
 
Teh Stork said:
Tried finding prices for the honeywell sensors, 45 usd :O Allegro's are cheap tho :)
Digikey sold them to me for $33 each. I had to talk to one of the online people and said my buinsess does 3 phase motor control development and that I found them for $33 each elseware so they price matched them.
 
At least in some AVR8's (like the tiny261/461/861), you can have the analog comparator automatically shutdown the PWM.
 
Well, lets say we have a 8bit AVR controller running at 16MHz. It can do 10bit ADC conversions at like 2 MS/s. Oversample it a couple of times and get 12bit at 250 kS/s. Seems to me like its fast enough for 16kHz PWM.
Usually these micros have not only a differential 20x opamp on ADC input, but also the analog comparator (not all of them). If you lay out your board traces in correct way, this should be good enough to get accurate control.

One thing I no not understand in the "high current shunts suck" problem. To my understanding, if the shunt has relatively high inductivity, this slows down not the measurement speed, but the current rise itself. So why is there a problem?
 
circuit said:
Well, lets say we have a 8bit AVR controller running at 16MHz. It can do 10bit ADC conversions at like 2 MS/s.
Not an AVR 8. They do 65us/conversion @ 10bit or faster times at less bits resolution.
The tiny26 family does have differential input with 1x, 8x and 20x, but the bandwidth is even smaller than single-ended front end.
 
Njay said:
circuit said:
Well, lets say we have a 8bit AVR controller running at 16MHz. It can do 10bit ADC conversions at like 2 MS/s.
Not an AVR 8. They do 65us/conversion @ 10bit or faster times at less bits resolution.
The tiny26 family does have differential input with 1x, 8x and 20x, but the bandwidth is even smaller than single-ended front end.

Well, I'm talking about AT90PWM3B, which is purposed for 3 phase motor control. Few lines out of datasheet:
– 10-bit ADC
• Up To 11 Single Ended Channels and 2 Fully Differential ADC Channel Pairs
• Programmable Gain (5x, 10x, 20x, 40x on Differential Channels)
• Internal Reference Voltage
– 10-bit DAC
– Two or three Analog Comparator with Resistor-Array to Adjust Comparison Voltage
[...]
By default, the successive approximation circuitry requires an input clock frequency between 50
kHz and 2 MHz to get maximum resolution. If a lower resolution than 10 bits is needed, the input
clock frequency to the ADC can be higher than 2 MHz to get a higher sample rate.
[...]
A normal conversion takes 13 ADC clock cycles.
[...]
The actual sample-and-hold takes place 3.5 ADC clock cycles after the start of a normal conversion
and 13.5 ADC clock cycles after the start of an first conversion.

So 16 cycles (free running mode) at 2MHz (for full 10bit) then. 125 kS/s. Oversample it once and we get 31.25kS/s at 11 bits.

Okay, you were right, this is a bit on the slow side. :)

But lets say your signal is well conditioned to go over full ADC range. Then you don't really need 10 bits accuracy only for current limiting. 8bits would the good enough. So you can speed up the conversion two-four times (to get something like 7 bits of accurate data), then do oversampling once (just for noise immunity) and get 8bits at 62 or 128 kS/s. And this sounds good enough.

By the way, AT90PWM3B has a powerful power stage controller (that takes like half of the datasheet). The PSC hac hardware comparators and current limiting on all channels. All you have to do is to feed the PWM registers with SVPWM waveform data.
 
One of the reason I use a pic30f is that it can sample up to 4 signals at the same moment and then do the conversions sequentially. Is this the same for the AVRs ? The 30f has 4 sample and holds feeding 1 ADC
 
If you're going to use the ADC current measurement as the means to terminate a PWM pulse early to implement current limiting, then you need to be sure you can take an ADC reading, do whatever processing is needed and terminate the PWM pulse to implement current limiting before the current has risen to a destructive level. This depends a lot on the LR of the motor and phase wiring, and for a low inductance, low winding resistance motor you can find that the rate of rise of current will be pretty fast. If, say, you had a 20 kHz PWM rate, then I reckon you need around 10 current samples per PWM pulse to be confident of being able to do an early shut down reliably. A single PWM period is 50µS, so the time to do your ADC, run the code and terminate the PWM pulse early is around 5 µS. My guess is that you probably only want the ADC to take up maybe half that time, to allow enough time for the code to execute.

Lebowski's approach is great, as those fast ADCs allow tight current control, even under pretty extreme conditions. On the other hand, the Infineon/Xiechang/Lyen controllers can only sample the shunt slowly, far too slowly to provide fast enough current limiting for the pulse-by-pulse limiting technique, so they have to rely on the external comparator to detect a rapid rise time over-current event at the shunt and shut the controller down.
 
Anyway I don't think that active current limiting is the task for CPU to do. Things like this must be done in hardware, with additional layer of protection.
In my design current is being limited by hardware peripherals in the MCU. There is another overcurrent protection circuit in mosfer driver - in such event it triggers an interrupt and the MCU shuts down with proper manner.
 
Interesting, these AT90PWMx chips, never noticed that they had an ADC faster than the "normal" AVR8 chips. And a DAC. And several analog comparators. Cool :)
 
Atmel Power Stage Controller

Is 64K memory enough?

If you want to use AVRs for motor control, you probably should select one with the Power Stage Controller.

The AVRs with a power stage controller (there are a few chips that have it) have built-in hardware for limiting current and reacting in hard real-time to other inputs (for example e-brake input could be done this way, so the CPU would not be initially involved). There is a DAC for setting thresholds, a comparator, and the resulting output is fuse programmable in terms of what it does to the FET drive outputs. So it does not require interrupts or CPU activity to detect and shutdown the output.

The PSC also features analog sampling synchronization which is helpful, and multiple comparators for sensorless modes, and digital filters in hardware, and many other things designed for motor control support.

The ATMega32M1 and ATMega64M1 chips have this Power Stage Controller feature and are readily available from many suppliers.

http://www.atmel.com/Images/7647s.pdf
http://www.atmel.com/Images/doc8209.pdf
 
Lebowski said:
One of the reason I use a pic30f is that it can sample up to 4 signals at the same moment and then do the conversions sequentially. Is this the same for the AVRs ? The 30f has 4 sample and holds feeding 1 ADC

The AVR32 UC3's has two adcs, so you can sample two signals simutaneously. They also have two S/H circuits, but they give less accuracy than direct conversion.

circuit said:
Anyway I don't think that active current limiting is the task for CPU to do. Things like this must be done in hardware, with additional layer of protection.
In my design current is being limited by hardware peripherals in the MCU. There is another overcurrent protection circuit in mosfer driver - in such event it triggers an interrupt and the MCU shuts down with proper manner.

Active current limiting is kind of what Field Oriented Control is all about - and that is all in software. The AVR32 UC3's has double buffered outputs on nearly every setting in PWM, the chance for a glitch is extremely low. I employ a shutdown interrupt if the source voltage drops below a certain threshold - something that was first implemented to detect shoot-through, but it reacts fast to very high currents. It uses a simple falling-edge interrupt on a GPIO pin. A resistor network divider sets the approximate voltage it trips at.

Alan B said:
Atmel Power Stage Controller

Is 64K memory enough?

If you want to use AVRs for motor control, you probably should select one with the Power Stage Controller.

The AVRs with a power stage controller (there are a few chips that have it) have built-in hardware for limiting current and reacting in hard real-time to other inputs (for example e-brake input could be done this way, so the CPU would not be initially involved). There is a DAC for setting thresholds, a comparator, and the resulting output is fuse programmable in terms of what it does to the FET drive outputs. So it does not require interrupts or CPU activity to detect and shutdown the output.

The PSC also features analog sampling synchronization which is helpful, and multiple comparators for sensorless modes, and digital filters in hardware, and many other things designed for motor control support.

The ATMega32M1 and ATMega64M1 chips have this Power Stage Controller feature and are readily available from many suppliers.

http://www.atmel.com/Images/7647s.pdf
http://www.atmel.com/Images/doc8209.pdf

My FOC control takes up about 40kb of data, this could probably be improved somewhat too. I plan to implement other things aswell, as only 30% of the CPU is used running 100us controll loop and 100Hz slow loop (throttle update and other stuff)

Atmel focuses their avr32 uc3 series for motor controll, but their xmega is pretty potent too. The avr32 with a xmega adc would be perfect :p But as it is today the AVR32 rules as it has a FPU able to do sines cosines and square roots (and more).
 
I like the DAC to set current limits for hardware shutdown on the PSC, you can then adjust the shutdown current with software but have the reaction fast in the hardware, and the level of current shutdown can be adjusted dynamically as needed.

If the ATMega is insufficient, it may be time to go straight to an ARM processor, some of them have Power Stage Controller type hardware. For really advanced algorithms the ARM is probably the right choice.

I would also suggest putting the user interface into a separate chip and allowing the motor control chip to focus on that one activity. The user interface chip for example could be an Arduino programmed AVR which is easy to develop for.

A 16 MHz AVR is essentially 16 MIPS. The PIC processors use more clocks per instruction. The ARMs can run about 10-100x faster yet.
 
about having the user interface in a seperate chip and letting the controller concentrate on the
motor, this is exactly why I have throttle over CAN bus. The throttle (and reverse) is the only
thing the motor controller needs to know while on the road, it shouldn't be bogged down by things
like keeping track of amount of Ah's used etc...
 
Back
Top