Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need help about distance measurement using ping ultrasonic sensor and PIC16f84a

Status
Not open for further replies.

rhee2

Newbie level 2
Joined
Jul 18, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,293
hello everybody,, :D
I've a problems in my project,,
I want to measure distance using ping ultrasonic sensor and PIC16f84a with 4Mhz xtall and display it in 8 bit data,, when the distance is 300cm led in PORTB show ffh
I've already made the program,, but this program doesn't run well,,
the counter is reset when the distance 125cm,,
the program list is below :
#include <htc.h>
#include <pic1684.h>
unsigned char a;
unsigned char c;

/*void interrupt isr()
{
TMR0=0;
c=TMR0;
if(T0IF!=1)
{
c++;
}
else if(T0IF==1)
{
T0IF=0;
}
T0IF = 0; /* Clear timer interrupt */
// }

void delay()
{
for(a=0; a<4; a++)
{}
}
void delay2()
{
for(a=0; a<1; a++)
{}
}
void delay1()
{
for(a=0; a<250; a++)
{}
}

void lambat()
{
a=254;
while(a<255)
{
a++;
}
}

void main()
{
unsigned char d;
TRISB=0x00;
PORTB=0x00;
//OPTION=0x07;
//INTCON=0xA0;
GIE=1;
while(1)
{
c=0;
//TMR0=0;
//c=TMR0;
T0IF=0;
TRISA=0x00;
RA2=1;
delay();
RA2=0;
delay1();
delay1();
delay1();
RA2=1;
delay();
TRISA=0x1f;
while(TRISA==0x1f)
{
// INTCON=0xA0;
while(RA2==1 && c<255)
{

c++;
#asm
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
#endasm
}
//PORTB=c;
while(RA2==0)
{PORTB=c;}
}
delay1();
}
}
can you help me to fix this program,,,
thanks for your attention,, :D
big respect,,
 

I use MPLAB IDE v7.60 with compilers Hitech ANSI C compiler,,
can you help me to fix this program Mr. jerin,,
thanks before,, :D
big respect,,
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top