CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

microcontroller parallel outputs for current improvement

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
webgiorgio



Joined: 02 Oct 2009
Posts: 123
Location: Denmark

View user's profile Send private message

microcontroller parallel outputs for current improvement
PostPosted: Sun Dec 08, 2013 7:15 am     Reply with quote

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: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Dec 08, 2013 7:25 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Dec 08, 2013 9:37 am     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Sun Dec 08, 2013 10:43 am     Reply with quote

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
Very Happy Very Happy Very Happy
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sun Dec 08, 2013 10:54 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Dec 08, 2013 11:03 am     Reply with quote

Sorry for not specify. It is a magnetic with internal oscillator.
http://docs-europe.electrocomponents.com/webdocs/105f/0900766b8105f10a.pdf

The pins which I can't set to 5V are RC5/SDO and RC4/SDI/SDA.
I will try adding SETUP_SPI(SPI_SS_DISABLED)

Is it a bad idea to parallel two pins instead of adding a transistor and resistor? Rolling Eyes
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sun Dec 08, 2013 11:17 am     Reply with quote

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. Twisted Evil 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

View user's profile Send private message

PostPosted: Sun Dec 08, 2013 11:36 am     Reply with quote

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:
Code:
setup_spi(FALSE);


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: 19506

View user's profile Send private message

PostPosted: Sun Dec 08, 2013 3:41 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Dec 09, 2013 8:13 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group