Maker Pro
Maker Pro

if there possible for pic to faulty?

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
I make circuit for LED.
But after I finish connect all component the led turn on it self.
If I connect the vss pin to ground the LED is turn off and circuit is not working like I'm program. If there any possible my PIC is faulty?
THX
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
If there any possible my PIC is faulty?

Yes, of course.

Show us your schematic. From the textual description we can't possibly tell.
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
This is my coding and my circuit. Actually its a simple led circuit.
Sorry I'm beginner.:eek:
 

Attachments

  • Untitled.png
    Untitled.png
    14.7 KB · Views: 130
  • my%20coding.png
    my%20coding.png
    9.1 KB · Views: 125

gorgon

Jun 6, 2011
603
Joined
Jun 6, 2011
Messages
603
Is there any more infrastructure around the micro, like power/ reset/ decoupling?

You say you put Vss to ground?
You are supposed to put Vss to ground(0V) and Vdd to +5V, for the PIC to work at all!

How do you know that you have programmed the PIC at all, and your program is running? How do you verify this?

Since I've never done PIC C, please forgive me if I'm wrong, but the way you use 'SW1' without refreshing it looks iffy to me. I could tell more if you listed the assembler code generated from your C code.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Since I've never done PIC C, please forgive me if I'm wrong, but the way you use 'SW1' without refreshing it looks iffy to me. I could tell more if you listed the assembler code generated from your C code.
"SW1" is #defined to a bit in an I/O port register, so every time it's tested in the while (1) loop, the actual pin state is being checked. (Those I/O register bits would also be declared as volatile in the header file.)
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
Actually I already run the simulation from proteus that how I verify it.
When i connect vdd to +5V the led is turn on and after that I connect vss pin or any pin to ground nothing happen. Power source is battery 9V I lower the voltage using VDR circuit and I get almost 6V voltage value. If there okay power up PIC with over 5.5V?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
By "VDR circuit", do you mean a voltage divider made with two resistors? No, you shouldn't use a voltage divider to provide power to the PIC. Use a small 5V regulator such as a 78L05 (see http://www.digikey.com/product-detail/en/MC78L05ACP/MC78L05ACPFS-ND/1049368). These need a decoupling capacitor (e.g. 0.1 uF ceramic) across the input, and another across the output.

Your circuit should have the PIC's VDD pin permanently connected to the supply rail, and the VSS pin permanently connected to the 0V rail. Turn the circuit on and off with a switch in series with the positive wire from the battery.
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
Owh, I see. So VDR circuit is not eficient to lower the voltage.
If there any possiblity pic faulty because of the voltage more than 5V?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
A voltage divider is inefficient, but it also will not provide a stable output voltage. This is because the current drawn by the PIC (which includes the current drawn by the LED, which flows through the PIC) affects the currents in the voltage divider, and this affects the output voltage.

In this case, the LED is the main load on the voltage divider. If you adjusted the voltage divider resistors to give roughly 5.5V when the LED was ON, then when the LED turns OFF (or tries to turn OFF), that load current will disappear, and the voltage divider's output voltage will increase.

A voltage divider will only produce a correct and stable output voltage if the current being drawn from it is a lot lower than the current flowing in the voltage divider resistors themselves. You can increase the "stiffness" of the voltage divider by reducing the resistor values, but this wastes more power in the voltage divider.

The simple answer is that voltage dividers are not normally used to provide power supply rails to circuits; an active regulator is needed. Using a 78L05 will reduce the wasted power, and increase the regulation of the PIC's power supply voltage.

Yes, it's possible that you have damaged the PIC with overvoltage. This is especially likely if you used low resistances in the voltage divider. What values did you use?
 
Last edited:

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
That's is good explaination sir. Now I'm understand.
Actually I try and error in my VDR circuit
R1=1K R2=10K or R1 and R2 is 10K. :D
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
OK, those resistances would limit the current that flows into the PIC, so it probably has not been damaged. It's possible that it's damaged, but try it with a regulator first; it may be fine.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
You also need to pull up the \MCLR pin in order for the PIC to run.

Bob
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
Voltage is okay now. But nothing happen.
I already change the pic and using voltage regulator.
If there anything involve with mclr pin?
:confused:
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Did you see Bob's post? He says you need to pull the -MCLR pin up. That means, connect it through a resistor (e.g. 10k) to VDD.
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
I already try connect mclr pin to vdd using 10k ohm resistor.
Still same result.nothing happen. I forgot to mention my pic model. Pic that I use is 16F877A.;)
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Were you able to program the PIC? Did you verify it?
Does it verify correctly now?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
The other problem could be your configuration word. Please change this from your hex constant to using the

__CONFIG()

macro with symbolic names for the settings. Then we can see if you have set something wrongly.

Bob
 

ikram1991

May 5, 2013
43
Joined
May 5, 2013
Messages
43
Hi guys thx for reply. My PIC already start working. I change configuration bit from HS oscillator to XT oscillator. Actually it just try and error, anyone can explain to me? Now I face another problem were I write source code for LED blinking but the LED is not blinking.
 
Top