[SOLVED] need help with my 1st led project

Status
Not open for further replies.

hesho90

Member level 4
Joined
Sep 3, 2012
Messages
78
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
egypt
Activity points
1,778
hello im makeing a led project with my PIC16F877A

and this my code


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
void main() 
{
 TRISA  = 0xFF;
 TRISB  = 0;
 
 loop:
 
 PORTB=0B1; delay_ms(500);
 PORTB=0B0; delay_ms(500);
 
goto loop;
}




and my designs and the led blink and open



but when i try it on my breadboread the led go on and dont blink and open its just open
 
Last edited by a moderator:

Hi,

If that is your actual circuit then I'm afraid it is totally wrong.

Have a look at this tutorial -
**broken link removed**

I will add a valid schematic for your 877a in a few minutes, though there is a chance you may have already damaged it as it can only cope with +5V.

Here is a complete diagram for your led flasher.

If you are not using In Circuit programming then you can leave out the 6 pin ICSP socket and D2.

The Reset switch is not essential either but can be handy.
 

Attachments

  • ScreenShot002.jpg
    124.9 KB · Views: 143
Last edited:
Reactions: hesho90

    hesho90

    Points: 2
    Helpful Answer Positive Rating
will iwana try it on my bread board so how to take 4v of from my 9v battrey

thankyou

- - - Updated - - -


this to big and dont what the code for that
and how do i chack if it broak or not

thank you
 

will iwana try it on my bread board so how to take 4v of from my 9v battrey

thankyou


Hi,

You really need to use a 5V regulator like that shown in the diagram.

Using a dropper resistor would work if your current was constant, but its not as the led is flashing on an off.
The 877A takes about 3ma and the led about 20ma so the voltage would fluctuate badly; the micro is designed for stable power only

The best solution would be to use a 4.5v battery or 3 x 1.5v cells connected in series.

You could possibly create a potential divider across the battery to produce 4.5 volts but thats not something I have tried.

To progress onto anything more complex you will need that voltage regulator.


Another thing to be careful of when using the breadboard, the 22pf capacitors and the xtal have very thin leads and they do not always make good connection into the beadboards sockets.
If possible solder some thicker wire onto them to make the connection stronger.
Also its important those three parts are as close to the 877s pins as possible.
 
Reactions: hesho90

    hesho90

    Points: 2
    Helpful Answer Positive Rating

the project you give me is good dont have componets make the 9V to 4.5V and i dont know if it need a code or not
and if you can till

like what is the componets instad of all this to make ues the 9v power
thank you

- - - Updated - - -

is there any way to use the 9v power or more simple diagram then this one i dont need a botton i just need
the wriet compntes to make the 9v to 4.5v to make the led blink and flashup

- - - Updated - - -

and also can you till me if my code is wrong and what wrong with it
 

Try this code with the circuit in the 2nd post.

Code:
void main() 
{
TRISA = 0xFF;
TRISB = 0x00;

while(1) {

PORTB=0b00000001; 
delay_ms(500);
PORTB=0b00000000; 
delay_ms(500);

}
}

- - - Updated - - -

Just omit the button in the circuit in the 2nd post and make the circuit. (v input is given to 7805 and 5v output is taken.
 


i did make that code and i but it on my pic and got the 4.5v power but it didnt blink



- - - Updated - - -


i did make that code and i but it on my pic and got the 4.5v power but it didnt blink

 

after the tris settings add CMCON = 0x07; and ADC)N1 = 0b00000111; and try.

-----------------uiupdate-------------------

you don't need these settings as you are not using port a. Have you set the clock frequency in mikroC and proteus properly? Are you using internal / external oscillator?
 

Hi,

Looking at your pictures the circuit is incomplete.

You must have the positive and negative connections to the Pic.
You must have a crystal and capacitors or some other form of oscillator.
You must have Pin1 Mclre pulled up to positve

Without these it can not work.
 

Attachments

  • ScreenShot001.jpg
    100.4 KB · Views: 133
Reactions: hesho90

    hesho90

    Points: 2
    Helpful Answer Positive Rating

hello

is my circet ok
this is my code with the things you said to add i but on the pic and try it on the same circet but dont blink

Code:
void main()
{
TRISA = 0xFF;
TRISB = 0x00;
CMCON = 0x07;
ADCON1 = 0b00000111;

while(1) {

PORTB=0b00000001;
delay_ms(500);
PORTB=0b00000000;
delay_ms(500);

}
}

and the clock frequency in mikroC and proteus is 8MHz

thank you
 
Last edited by a moderator:

is my circet ok

...
...

and the clock frequency in mikroC and proteus is 8MHz

It is unclear whether you are attempting to simulate the design in Proteus or implement the design in physical hardware.

Which is it?

The breadboard circuit shown in the photos is incomplete as wp100 mentioned.

BigDog
 
Reactions: hesho90

    hesho90

    Points: 2
    Helpful Answer Positive Rating
Hi,


The attached files show the working circuit flashing the led.

I have also provided the .hex code so you can simulate it first, then burn it in to your 877A and get it running, provided you use the circiut I showed in my last post.

I have not included the source code as it is in Assembly code not C.

I have also run it on my 877A chip and it flashes the led every 3 seconds using a 4Mhz crystal.
 

Attachments

  • 877A4v5.rar
    88.1 KB · Views: 111
Reactions: hesho90

    hesho90

    Points: 2
    Helpful Answer Positive Rating
If you are using the MikroC compiler, you must ensure the Configuration Register is properly set, particularly if an 8MHz Oscillator is required, it should be configured for HS mode.

These settings are available under Project->Edit Project... menu.



BigDog
 
Reactions: hesho90

    hesho90

    Points: 2
    Helpful Answer Positive Rating
It is unclear whether you are attempting to simulate the design in Proteus or implement the design in physical hardware.

Which is it?

The breadboard circuit shown in the photos is incomplete as wp100 mentioned.

BigDog

iwant to do it on my bread board with the pic

- - - Updated - - -

It is unclear whether you are attempting to simulate the design in Proteus or implement the design in physical hardware.

Which is it?

The breadboard circuit shown in the photos is incomplete as wp100 mentioned.

BigDog

i want to make it on my bread board with a pic

its blinking led projcet and will ues my bread board

- - - Updated - - -

It is unclear whether you are attempting to simulate the design in Proteus or implement the design in physical hardware.

Which is it?

The breadboard circuit shown in the photos is incomplete as wp100 mentioned.

BigDog

i want to make it on my bread board with a pic

its blinking led projcet and will ues my bread board
 

hesho90
iwant to do it on my bread board with the pic


Hi,


I think we are having problems in understanding each other.

Let us know if you do not understand anything, we are here to help.


The circuit diagram and pictures you show of your hardware are Wrong, they will not work.

The minimum circuit you can have to make it work is as I showed in posts #10 and # 13.

Have you built that circuit ?

Have you tried the proven flasher .hex code I also sent ?

What kind of programmer are you using ?
 
Reactions: hesho90

    hesho90

    Points: 2
    Helpful Answer Positive Rating
Fez877 PIC JDM Programmer for Microchip MCU
 

Hi,

Thats looking better with the correct parts but its not quiet right - simple to correct though.

The 100nf cap should be removed from the led, the led + should connect directly to your + rail.

What you are missing are the + pos and -neg connections to the 877A to give it the power to run !
The + pos should be connected to pins 11 and 32
The - neg should be connected to pins 12 and 31.

Then connect the 100nf cap across pins 31 and 32, this helps reduce any interference on the power lines.

The 27pf caps should be fine with your crystal

Hopefully that should work .. let us know how you get on.

It does get easier ... !:-D
 
Reactions: hesho90

    hesho90

    Points: 2
    Helpful Answer Positive Rating

IT WAAAAAAAAARKED :grin::smile::-o

Thank you very match man your post did post #13 and #18 really didit man



but in proteus the vdd and vss are not there

can i have the soers code to see the deffenc between maun and yours

and i relly didnt get the pins of the pic

but now i will make 8 leds project
 

but in proteus the vdd and vss are not there

Some Proteus devices, including the PIC microcontrollers, have both Vdd and Vss hided by default. However, there is a setting under the devices properties which displays these pins if desired. I should also mention both OSC1 and OSC2 are essentially nonfunctional, meaning the crystal and capacitor pairs do not have to be proper attached for the simulation to function properly. However, the oscillator/clock frequency must be properly set/configure under the device properties for the simulation to perform as expected.

It should be noted this is NOT the case with all microcontroller simulations in Proteus, designs with ARMs require both the Vdd, Vss and Oscillator/Clock source be properly attached in the design for the simulation to function as expected.

and i relly didnt get the pins of the pic

Do you not understand the function or location of pins of the PIC?

As wp100 suggested, I would study the Gooligum Tutorials:

**broken link removed**

While the tutorials utilize a different version of PIC, the concepts are generally the same and can be easily applied to the PIC16F877A, which is considered a Midrange PIC by the way.

BigDog
 
Reactions: hesho90

    hesho90

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…