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.

pic 16f877a troubleshoot

Status
Not open for further replies.

naim

New Member
hye..i new here..i need some help and advice..about pic 16f877a...this year i have a f.y.p(final year project),but now i have problem with my ic circuit.i think my program has true.because i has test it at training kit.my problem is..led is always on..without press the swicth button.??i dont know where the input coming.
 
that is my code.

main ()
{
port B=0b00000000;
port c=0b11110000;

while(1)

if (portc.f7)
{
port B=0b11111111;
delay_ms (1000);
port B=0;
delay_ms(1000);
}
}
 
for mike,that is my current circuit i use...

**broken link removed**
 
Last edited:
one more think..mybe someone can give circuit for connecting siren 12v to pic..using relay..accually i'm doing alarm system in my final year project..

thanks!
 
What compiler are you using, I dont recognise this

Code:
main ()
  {
   port B=0b00000000;
   port c=0b11110000;

   while(1)  
       {    // You will need statement braces here
       if (portc.f7)  <-  portc.f7 ???
                { 
                 port B=0b11111111;
                 delay_ms (1000);
                 port B=0;
                delay_ms(1000);
                }
      } //and here
  }
 
Last edited:
thanks ian..but the same think happen..i'm use micro c compiler..
ian,can you give an example using "counter" in programming...simple example is enough..thanks
 
Last edited:
Right! A simple counter on Portb pin 7 using polling!

I've used Hi-tec compiler (I haven't got MikroC)

Code:
#include <pic.h>

int counter = 0;

void main(void)
	{
	TRISB = 0xff;

	for(;;)
		{
		if(PORTB,RB7)
			{
			while(PORTB,RB7);
			counter++;
			}
		}
	}

I've tested this in ISIS

Cheers Ian
 
anyway my program is running well at training kit..but,when i put that same ic in my own circuit...the output pin automatically have voltage reading..i dont know where that voltage come from..i dont really understand about "active high"..and.."active low"...
 
Last edited:
Ian..one more question..i want a different output at same output port..example..when counter 1 at portb rb7..led on 5 second..when counter 2 at portb rb7..led on 10 second..i want to apply it at alarm system..in my final year project..i do hope u can help me..
 
Last edited:
If you are going to make an alarm system the counter example needs to be more transparent than it is now, if you look at the example all will work ok but the program will get stuck if the counter is on and stays on... If you need a sensor input then code this differently..

An LED must be current limited.. A PIC can source and sink 25mA on any one pin so they can drive an LED with a current limiting resistor of around 270 ohm.

An output for a siren really needs a transistor driver put a 470 ohm resistor from the output pin to the base of the transistor ( use a 2n222a or similar ) and power a siren up to 100mA.

Cheers Ian
 
counter example needs to be more transparent than it is now..i dont really understand what is does it mean..
 
It means that it is running solo, nothing else can affect it.. For your application you don't need a counter.. I have a similar situation where a switch must do one thing when switched once and another when switched again.. This requires a state machine where the state is monitored in the main loop while other situations are dealt with ie.. Sirens and LED outputs.

The switch de-bounce step in my code is in a simple while(); statement " not good for your application"

Cheers Ian
 
Usually active high / low is denoting chip selects or resets etc... pulling the voltage low on an active low input, activates the function.. ie.. on a pic, the reset is active low, so you need to pull it low to reset the chip.

Cheers Ian
 
Status
Not open for further replies.

Latest threads

Back
Top