Ultrasonic Range Meter Using Pic 16F877A.

Status
Not open for further replies.

sashah363

New Member
Hello ,
I am making ultrasonic range meter.I have attached circuit(find attachment).
Circuit diagram is taken from electronicsmaker.com.
Now i m stuck at programming part and i want to modify its c code.
so please help me out with it ,

The incomplete c source code :


#define PULSELEN 300
#define BUFSIZE 10
#define LCDPORT PORTD
#define LCDTRIS TRISD
unsigned char outOfRange ;
unsigned int buf[BUFSIZE] ;
void wait(void);
void ready(void);
void command(unsigned char);
void display(unsigned char*);
void busycheck(void);
void calllcd(unsigned short);
void calllcd5(unsigned long);
void calllcddistancecm(unsigned long);
void cal l lcd1(unsigned short);
void interrupt(void)
{
if (PIR1.TMR1IF)
{
outOfRange = 1 ;
PIR1.TMR1IF = 0 ;
}
}
void main()
{
unsigned char i;
unsigned int a1,a2,a3,a4;
unsigned int a5,a6,a7,a8;
unsigned long total ;
unsigned char str[5] ;
unsigned long distancecm;
TRISA = 0xff ;
PORTA = 0 ;
TRISC = 0 ;
PORTC = 0 ;
TRISD=0xff;
T1CON = 0b00001100 ;
command(0x28);
command(0x0E);
command(0x06);
command(0x01);
command(0x80);
PWM_Init(40000) ;
PWM_Change_Duty(128) ;
INTCON.GIE = 1 ;
INTCON.PEIE = 1 ;
PIE1.TMR1IE = 0 ;
PIR1.TMR1IF = 0 ;
 

Attachments

  • Ultrasonic Range Meter.jpg
    108.1 KB · Views: 963
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…