Current Limiting

Status
Not open for further replies.

topo

New Member
I have a Pic 16F88 controlling a half bridge with a 8khz PWM. It works correctly. I am trying to add some current limiting to this controller. I have installed a ..005 ohm resistor from the low side mosfet source to ground, and I measure the voltage across the resistor. All Ok . My Question is what do I have to do to this signal to make it acceptable to
Pic ADC or the comparators. The software for the adc & comparators I can Handle, it is the signal conditioning that has me stumped.


SEE SKETCH



Your help is greatly appreciated.

George
 

Attachments

  • current_sense.gif
    6.4 KB · Views: 1,821
The voltage feedback is not normally fed directly into the PIC for the obvious reason that the PIC's response is simply too SLOW to ofer any form of viable protection. Most of the time, the PIC provides the reference voltage for the current limiting circuit.
 
I have successfully used a PIC16F873 to control the current of a stepper motor driver in a full bridge circuit. A PIC16F88 can be similarly used. Here are some design tips:

1. Notice that in your circuit, the current through the sense resistor is not ON all the time. The current is pulsed because of the PWM transistor. You have to time the A/D conversion to be synchronous with the PWM signal. Of course, sampling time restrictions of the PIC A/D converter apply.

2. You need to amplify the signal from the sense resistor so that the output voltage of the amplifier ranges from 0 to 5V. You would need a relatively fast amplifier because the voltage is pulsed by the PWM signal.

3. A separate hardware over-current limited portection is required. You can use a comparator to detect an over-current condition and the signal can be used to reset a flip-flop which in turn gates OFF the PWM signal.
 
The PIC is not too slow at all! It will do fine as long as you filter the current to a DC level rather than trying to sample every pulse. Your schematic is wrong for this though. Move R1 between Rsense and C1 and you have the desired lowpass filter. Make the bandwidth of the filter less than the 8KHz PWM freq. Also make R1 less than 2.5k because the PIC accuracy suffers when filter impedance goes above that. 1k would be better if you have a large enough cap handy.

However, the problem is that the signal level from a low-ohm resistor will only be a few mV. This is a bit hard to read since the minimum grad of the PIC's 10 bit ADC with a 5V vref is about 5mV. And there is an unpredictable offset error to consider, which may be several codes. But you can still get good results, especially if you only limit high currents thus don't require fine tune control.

You can condition the signal with a low offset op amp. If you do this, the 2.5k filter impedance is no longer a limitation either.
 
fabbie said:
is there such a thing as 0.05 ohm resistor?

A carefully measured piece of wire :lol:

Although there's probably no need to go so low in this application, but it obviously depends on the current demands of the motor?.
 

I dont really get how a RC filter can produce a DC level. I thought that a lowpass filter of 8000hz will cutoff anything above 8000hz. Anything below 8000hz will have its voltage level and frequency intact. Pls explain how the RC filter can smoothen it out.
Unless i got it wrong, and you are using a capacitor to smoothen the voltage. then a resistor wouldnt be needed
 

A smoothing capacitor is just a simple low pass filter, you can use a low pass filter to provide a DC level from a much higher frequency - it's VERY common practice!.

An 8000Hz filter doesn't "cut off" everything above 8000Hz, it merely smooths it, rolling the frequencies off the higher they get.

For this application you would use a filter far lower than 8000Hz, but if it's too low the response time will be slowed down - as with any system like this, it's a compromise between response time and smoothing.

Unless i got it wrong, and you are using a capacitor to smoothen the voltage. then a resistor wouldnt be needed

Adding a resistor greatly improves the performance of a filter, using two resistors and two capacitors is even better - basically each improvement increases the slope of the filter roll off.

MicroChip have an application note about using PWM as a D2A, try having a read of it.
 
Mind teaching me the calculation?

To calculate the C, if im not wrong, im suppose to use this:
Xc= 1 / ( 2 x pi x f x c )

but how do i calculate the R?
 
fabbie said:
Mind teaching me the calculation?

To calculate the C, if im not wrong, im suppose to use this:
Xc= 1 / ( 2 x pi x f x c )

but how do i calculate the R?

The circuit is just a potential divider, so the turnover frequency is when R is equal to Xc. The actual value you choose will depend on the input and output impedances either side of the filter.
 
Argh...im quite lost now. If i want a 8Khz PWM pulse filtered to DC, what formula should i use?
I really dont understand how to calculate.
 
fabbie said:
Argh...im quite lost now. If i want a 8Khz PWM pulse filtered to DC, what formula should i use?
I really dont understand how to calculate.

Have you tried looking at the MicroChip application note I mentioned?.
 
Dont really get it
taken from microchip notes::

Choosing, the -3 dB point at 4 kHz, and using the
relation RC = 1/(2· p·f), we get R = 4 kohm, if C is chosen as 0.01mF:

R = 4.0 kohm
C = 0.01uF

Since the PWM frequency is selected as 20 kHz, the
fundamental noise peak to be filtered is at 20 kHz. Now,
lets calculate by how many dB the main peak of PWM
signal is cut-off at 20 kHz:
(dB) 20 kHz = -10·log[1+ (2.pi.f.RC)2] = -14 dB. <=== i seem to get 10db
 
Fabbie. The frequency of low pass filter is simply calculated as
Fc = 1/(2*pi*RC) As you are using a single RC network this will also be called as first order. If you use second RC network the system will become second order. Now calculation of freq. will be
Fc = 1/(2*pi*r1r2*c1c2) this will definately improve the filtering. Now the problem of -3db is very simple. As no system is ideal, it will not give you sharp cutoff frequencies. (in this case lower freq.) (Read lead lag compensation and stability of filters) So when the output gain will start falling down, daviatin the ideal line it will be called the first cutoff . Now for each RC network the output gain will decay 20db downwards for each logarithmic increment in frequency. That perticular point will decide the BANDWIDTH of your system. (Its all related to system stability and gain vs freq. plots) Google the first order freq responce and you will get everything about it.

A simple example of BANDWITH is you are using digital voltmeter and CRO for measuring voltage. BUt if the output voltage is pulsationg and its frequency is slowly increased, one point will come where voltmeter will be unable to catch (or say match) the speed of those pulses. So CRO came in existance. For very high freq. pulses meter will give almost constant voltage. (if input pulses are 0 to 5V, it will give output as 0 to 4.5 volt. And here is the loss of output. Loss of gain, loss of dB gain...)

If you r using stepper motors then you will be knowing that it does have its own speed limitations (because of electrical time constant L/R and mecahnical inertia T = J*D theta). Normally the BANDWIDTH of any stepper motor is restricted to 100 to 150Hz. The greater the bandwidth the better the system.

I think I am not deviated much from the subject. :lol:
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…