Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Breadboard and my microcontroller.

Status
Not open for further replies.

danielsmusic

New Member
Is this a bad idea? I've noticed my PIC16F877A is pulling a lot of current, voltage regulator is struggling to say the least (It's a LM7805). The PIC is driving an 8 bit shift register which is connected to LEDs through a 100ohm resistor.

The output pin is right next to a power pin (Can't remember which one). Assuming the rails are acting as 2nF capacitor and my PIC is driving the shift register at 4Mhz would this mean the "resistance" between the output pin and the power pin to be 0.02Ohms?
Would this be why it is pulling so much current? I've checked for short circuits and found nothing.
(Xc = 1/(2*PI*F*C))
(0.02 = 1/(2*3.141*4000000*0.000002))
 
About building uC circuits.

When I build a uC circuit I do it in stages. It makes debugging much easier.

First I build the regulator section and check to see that it is working.

Next I add the programming header (ICSP), processor, crystal, and caps. If all goes well the processor can be programmed and will run programs.

Next I add whatever other hardware is on the PCB in groups based on function. Each group is tested.


A smaller regulator will force less current through a badly wired circuit. I like to use a 100ma output regulator which is enough for many circuits. Some have reverse voltage and short circuit protection too.
 
I've checked the circuit and it's all wired correctly. Whenever I do anything high speed, it starts pulling a lot of current and fails. The regulator is 1A and it gets warm. It seems to be pulling >250mA.
 
I've checked the circuit and it's all wired correctly. Whenever I do anything high speed, it starts pulling a lot of current and fails. The regulator is 1A and it gets warm. It seems to be pulling >250mA.

Are you measuring the current the PIC is taking, or the entire circuit?.

Bear in mind your 8 LED's will be taking about 250mA.
 
he never said how many LEDs he has. Just that they are connected to the shift register. Also what type of leds?

Try to use instead of the 100 OHM resistors 220-330 ohm resistors.

Now since you are using a LM7805 what is the input(supply) voltage to that? What is the wall adapter rated @?

EDIT:
@ 5v using 100 ohm resistors. If all is on then it would take about 400mA for all 8 LEDs. (if my math is right)
 
Last edited:
I think, It's better to use 330 ohm for the LEDs.
is the LEDs are quite different from standard? ie high lumens, ulrabright etc.
are the all LEDs glow at a same time or one by one?
try using 78L05 instead of 7805...
I never saw such problem though, with breadboard. My first preference is breadboard for prototyping everything except VHF and high gain preamp projects.check for any faulty capacitors too
 
The regulator is 1A and it gets warm. It seems to be pulling >250mA.
What else gets warm? Does the PIC get warm?
As already mentioned, the high current draw probably is coming from the LEDs and not the PIC.
theo92 said:
try using 78L05 instead of 7805...
How would using a regulator rated for less current and power dissipation help?
 
It seems to be the LEDs, yes. I definitely underestimated their current draw. There is some very strange behaviour from the PIC though. I can use my shift-register to flash 1 LED on and off, but after 4 flashes it just stops. If I put an LED straight from an output on the PIC, I can make it flash and it doesn't stop. Just when I use the shift register.

EDIT: It is definitely not the code.
 
Last edited:
i knew that lol... (i just forget things :D)

So that a typical 1.2vdrop - 1.5vdrop / 100 Ohms * 8 = 304mA - 280mA.

You have to factor in the Wall Adapter tho. What if its giving only 9v @ 200mA. Dont think it would work well. Also if its giving too much Voltage then it can be harming the 7805 also if the current coming in isnt enough then its stressing everything.
 
It seems to be the LEDs, yes. I definitely underestimated their current draw. There is some very strange behaviour from the PIC though. I can use my shift-register to flash 1 LED on and off, but after 4 flashes it just stops. If I put an LED straight from an output on the PIC, I can make it flash and it doesn't stop. Just when I use the shift register.

EDIT: It is definitely not the code.

I wouldn't be that sure - I would suspect it almost certainly is the code - in that you're not feeding the shift register correctly.

But, as always, post the circuit you're using (and the code) - so we can see how you've connected it up, and if you've included all the required components.
 
I'm not using a wall adapter, I'm using a battery (7AH sealed lead acid).

Code:
#include <system.h>
#pragma DATA _CONFIG, _CP_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC


void test(unsigned char data) //stolen from a website, I can't remember where now
{
   unsigned char bits;
   for (bits=0x80; bits != 0; bits >>= 1)
   {
      if ((bits & data) == bits)  
      {     
          set_bit(portb,0);
      }
      else
      {
         clear_bit(portb, 0);
      }
      set_bit(portb, 1);   
      clear_bit(portb, 1);
   }
   set_bit(portb, 2);        
	clear_bit(portb, 2);
} 

void main()
{
	trisb = 0;
	portb = 0;
	unsigned char f = 0;
	
	while(1)
	{
		toggle_bit(f, 5);
		test(f);
		delay_s(1);
	} 
}

**broken link removed**
 
Last edited:
try:
Code:
void test(unsigned char data) //stolen from a website, I can't remember where now
{
   unsigned char x;
   for (x=0;x<8;x++)
   {
      if (data & 0x80) != 0)
          set_bit(portb,0);
      else
         clear_bit(portb, 0);

      set_bit(portb, 1);
      clear_bit(portb, 1);\

      data=data<<1;
   }
   set_bit(portb, 2);        
   clear_bit(portb, 2);
}
 
Last edited:
try:
Code:
void test(unsigned char data) //provided by atomsoft
{
   unsigned char bits,x;
   for (x=0;x<8;x++)
   {
      if (data & 0x80) != 0)
          set_bit(portb,0);
      else
         clear_bit(portb, 0);

      set_bit(portb, 1);
      clear_bit(portb, 1);
   }
   set_bit(portb, 2);        
   clear_bit(portb, 2);
}

That would not work because you're only testing the 8th bit. The function I have works fine, I have tested all the LEDs in different combinations.
 
danielsmusic,
You need at least 0.33uF on the input and 0.1uF on the output of the 7805 or it may become unstable. Put them as close as possible to the 7805. You should also have a 0.1uF close to the PICs power pins.
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top