Ultrasonic ranging system with PIC16f684

Thread Starter

mathankumarrk

Joined Jun 2, 2011
3
Hello All,
I need a pic C program for the Ultrasonic ranging system with one mobile transmitter and two stable receivers. I am using PICkit 1 with PIC16f684 micro controller. The output should be displayed on the computer using RS232 serial communication.
The formula for the distance calculation is D= 340*T metres
Here T is the time of travel of the signal.
Please help me to solve this problem. I am bit confused:
 

Thread Starter

mathankumarrk

Joined Jun 2, 2011
3
HI,
This is my actual problem.
Actually the program has to start the two timer at a time by giving a signal to the transmitter to start transmit the signal. If the two receives receives the signal independently with different time, the timer has to be stopped in different time and the time is used to calculate the distance between the each receivers by using the formula. And the calculated distance should be displayed on the computer using rs232 serial communication.
 

John P

Joined Oct 14, 2008
2,025
First of all, do the transmitter and the receivers have simple logic-level inputs/outputs? You'd better hope so.

People often show up here saying "Give me a program to do some task" and nobody ever does it for them. What have you accomplished on your own?

As a start, if I had this assignment I'd be looking for a way to measure two time intervals simultaneously. The processor has timers, so you need to figure out how make one or more of those timers do what you need. And it's fairly obvious that the difference between the sound signal reaching the two receivers may be zero or very short, so you can't allow the processing for the first receiver to block the processing of the second receiver.

And another thing--the PIC16F684 hasn't got a serial port. Have you got a plan for how to communicate with the computer?

By the way, I don't think this is a beginner project at all. It looks possible, but you need to know a fair amount about how to use the processor.
 
Last edited:

Thread Starter

mathankumarrk

Joined Jun 2, 2011
3
Thanks all,
I have an idea that the serial port can be done using bit banging. I got the c code for bit banging as mentioned below.
// transmit byte serially, MSB first
void send_8bit_serial_data(unsigned char data)
{
int i;

// select device
output_high(SD_CS);

// send bits 7..0
for (i = 0; i < 8; i++)
{
// consider leftmost bit
// set line high if bit is 1, low if bit is 0
if (data & 0x80)
output_high(SD_DI);
else
output_low(SD_DI);

// pulse clock to indicate that bit value should be read
output_low(SD_CLK);
output_high(SD_CLK);

// shift byte left so next bit will be leftmost
data <<= 1;
}

// deselect device
output_low(SD_CS);
}


I don't Know how to combine this with the distance calculation and with PIC16f684.
 

John P

Joined Oct 14, 2008
2,025
Ummm...that's not a serial port.

Look, I don't want to be discouraging, but this doesn't seem to be starting well.
 
Top