Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 18th December 2004, 06:48 PM   (permalink)
Default Current Limiting

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
Attached Images
File Type: gif current_sense.gif (6.4 KB, 1653 views)
topo is offline  
Old 18th December 2004, 06:56 PM   (permalink)
Default

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.
checkmate is offline  
Old 18th December 2004, 11:42 PM   (permalink)
Default

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.
__________________
"Having to do with Motion Control"
motion is offline  
Old 19th December 2004, 01:23 AM   (permalink)
Default

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.
Oznog is offline  
Old 19th December 2004, 04:40 AM   (permalink)
Default

is there such a thing as 0.05 ohm resistor?
fabbie is offline  
Old 19th December 2004, 09:59 AM   (permalink)
Default

Quote:
Originally Posted by fabbie
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?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 21st December 2004, 08:22 AM   (permalink)
Default

Quote:
Originally Posted by Oznog
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.
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
fabbie is offline  
Old 21st December 2004, 10:40 AM   (permalink)
Default

Quote:
Originally Posted by fabbie
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.
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.

Quote:
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 21st December 2004, 11:24 AM   (permalink)
Default

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 is offline  
Old 21st December 2004, 12:37 PM   (permalink)
Default

Quote:
Originally Posted by fabbie
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 21st December 2004, 01:14 PM   (permalink)
Default

if im not wrong, AC-DC rectifiers also use low-pass filters to smoothen of the waveforms right?
?
fabbie is offline  
Old 21st December 2004, 01:45 PM   (permalink)
Default

Quote:
Originally Posted by fabbie
if im not wrong, AC-DC rectifiers also use low-pass filters to smoothen of the waveforms right?
Yes!.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 21st December 2004, 01:49 PM   (permalink)
Default

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 is offline  
Old 21st December 2004, 02:17 PM   (permalink)
Default

Quote:
Originally Posted by fabbie
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?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 21st December 2004, 02:40 PM   (permalink)
Default

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 is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 04:10 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker