View previous topic :: View next topic |
Author |
Message |
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
microcontroller parallel outputs for current improvement |
Posted: Sun Dec 08, 2013 7:15 am |
|
|
Hi,
on a 16F886 I connected RC5 and RC4 in parallel to increase the current capability (drive a buzer 5V 35 mA).
I made a small test program that makes a 0.5 Hz square wave.
The problem is that on those two pins it does not work, while it works on pin RC7, where I've put a second buzer. (test buzer)
I tried having RC5 and RC4 both as output, and also configuring the tris_C so that one is an input, and the other one output. ...but I never get to measure voltage in RC5 RC4 node.
Am I doing someting wrong or I just fried RC4 and RC5?
Code: |
#include <16F886.h>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=8M)
//definitions of the variables
int1 sm05;
//------------------------------------------------------------------------
void configure_pic(void){
//setup I/O
set_tris_a(0xFF);
set_tris_b(0x97);
set_tris_c(0x8A);
//C0 C1 C2 C3 |C4 C5 C6 C7
//1 0 0 0 | 1 0 0 1
}
//--------------------------------------------------------------------------
void main() {
configure_pic();
while(1){
sm05=!sm05;
//output_bit(PIN_C4, sm05); //buzer1 (parallel outputs)
output_bit(PIN_C5, sm05); //buzer1 (parallel outputs)
output_bit(PIN_C7, sm05); //test buzer
delay_ms(1000);
}
}
|
Last edited by webgiorgio on Sat Jan 18, 2014 12:32 pm; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Sun Dec 08, 2013 7:25 am |
|
|
hmm..
generally speaking you have to disable any other peripheral(ADC,DAC,comp,uart,etc.) that use I/O pins.
The default use of pins is NOT pure digital,some are ADC inputs.
this might be the problem.
Try putting an LED and 330r on each of the pins and cut code to toggle the LEDs at say a 1Hz rate, see what happens.
buzzer. hmm..wonder if it's a mechanical type and needs a snubbing diode across it's connections?
hth
jay |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Sun Dec 08, 2013 9:37 am |
|
|
That was my first thought - if that is a mechanical "buzzer" with a coil and vibrating contacts, those things generate all sorts of spikes and other garbage. A piezo type should be OK, but I would never consider driving the vibrating contact/coil type direct and would prefer to use a transistor with at least 30+ volt rating AND a snubber across the coil.
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sun Dec 08, 2013 10:43 am |
|
|
Quote: |
to increase the current capability
|
thats what transistors and mosfets were designed for
adding a single emitter follower as a pull UP will do the trick
as will a single N mosfet as a pull DOWN.
fortunately 4 U , "abuse of pics" is not a crime
|
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Sun Dec 08, 2013 10:54 am |
|
|
You also need to pay attention to the maximum output of the chip - the data sheet will tell you what the max output is for a given pin, but it will also tell you what the maximum output is for the chip - you can't simply put a bunch of pins in parallel to get 8x the output for example. For example, on the 18F26k22, it says "maximum current sunk for any I/O pin - 25ma", but the next line indicates "maximum current sunk by all ports 90ma" (section 25 "Electrical Specifications" for the 18F26K22) - the other chips all will have similar requirements.
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Sun Dec 08, 2013 11:17 am |
|
|
Lets say it is a much better idea to use external buffering instead of running things at their limits. You will have far fewer failures in your designs when you avoid pushing the limits and that will save you much time and money in the future. The other thing you need to pay attention to is the fact that while a pin may be able to source or sink 25ma, you forgot to look at the specs to see what the output voltage is at that current - it is not going to be 0 or 5 volts (sink or source).
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Dec 08, 2013 11:36 am |
|
|
Quote: | I've version 4.057. | This is a popular version for illegal downloads on the internet but is kind of useless because it was a beta release for the new v4 compiler and contains so many bugs that you are wasting your and our time. Even when you would get your current program to work then you will run into other problems quickly. The v4 compiler became usable again around the v4.070 version.
Get yourself a newer version or revert to the old and trusted v3.249
Quote: | I will try adding SETUP_SPI(SPI_SS_DISABLED) | This parameter should only be used on a SPI Slave device! The command as shown here will create an illegal configuration with unknown effects. This wrong command was present in your old compiler's Wizard but is hopefully fixed now.
Correct command is:
Quote: | Is it a bad idea to parallel two pins instead of adding a transistor and resistor? | I don't think there is a simple answer to that question. It all depends on whether you know the implications of your choice.
You have to understand that you are running the PIC up to its limits.
- None of the other pins are allowed to switch large currents because you are close to the maximum 90mA for the whole chip.
- The chip will get hotter because of the extra dissipation. Depending on your design, extra cooling might be required.
- Higher currents in the same chip as the sensitive digital circuits is best to be avoided if you want a stable system.
Even the short in rush current for a capacitance on a switched I/O port could cause a maximum overshoot and have your chip reset for 'unknown' reasons. These kind of problems are very difficult to find, not even to think about the costs to fix the devices already sold to customers.
Paralleling the internal I/O will by many people be considered as poor design, but, for some designs where size, weight and price are of ultimate importance, then paralleling 2 or 3 pins can be the best solution.
It just all depends on your project. How important is it to save a few cents on an extra FET when compared to the risk of a less stable system? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Sun Dec 08, 2013 3:41 pm |
|
|
It is also worth pointing out that at near maximum current, a PIC output does not give anything even close to 5v. 4.5v at 3mA, but drops to only about 3.7v at 20mA. The 'output impedance' is about 85R. I see Gpsmikey has made the same point.
Then to do this even remotely safely, the pins need to switch at the same time, not 'one after the other'.
Best Wishes |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Dec 09, 2013 8:13 am |
|
|
Probably someone already said this:
I would say you need to be carefull setting the pins state.
If you do this:
output_bit(PIN_C4, sm05);
output_bit(PIN_C5, sm05);
There will be a brief moment where c4 is high and c5 is low...
In my book, thats a short.
I would mask the pins & output to the port, instead of setting them individually.
Or... as suggested, save a pin, use a transistor.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
|