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.

Distance measurement using range sensor

Status
Not open for further replies.

xilinx1001

Member level 3
Member level 3
Joined
Apr 3, 2013
Messages
60
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,781
Hi,

I am measuring the distance using range sensor SRFO5.

The sensor is having the maximum range of 400 cm.

When I trigger the sensor, it releases echo signal which is used to measure the distance of the object.

The echo signal will become zero when the object is detected.

The counter value increments which measures the echo width and beccomes zero when the object is detected.

This counter value should be divided by 58 to convert it to cm.

For division I am multiplying with 3 and then right shift by 13 places which converts the value to cm.

Code:
code:
process(echo, clk)
begin
  if clk'event and clk ='1' then
	if echo = '1' then    
	 range_cm <= count1(23 downto 0)* "11";   --measuring distance
	 input <=range_cm(21 downto 13);	 --
	 else
    output <=input;
	end if;
  end if;
end process;


I took only nine bits because the maximum range is 400 which can be represented in 9 bits

My professor told me that I need to consider MSB bits also. But I do not understand why I need to consider those bits



Regards
xilinx1001
 

Well you need to tell a few more details, like what is count1?? what is maximum value of count1, why are you multiplying with 3 etc. May be with that knowledge I can help you out in a better way
 

Hi shatruddha,

Thanks for ur reply

count1 is for mesuring the width of echo signal. When the sensor is triggered it releases echo signal(ulta sonic wave into air).

count1 will be incrementing when echo=1 and stops incrementing when echo= '0'(when object is detected)

The following equation converts it to centimeters(cm):

(X * 20) / (1000*58) = X/2900 = X (in cm)

You can find this calculation in the following data sheet

https://www.robot-electronics.co.uk/htm/srf05tech.htm


Dividing a number X with a big number like 2900 uses lot of hardware resources. Instead of using division this number is multiplied by 3 and the result is divided by 8192 which is not perfect, because 2900 multiplied by 3 is equal to 8700. But division by 8192 can be done simply by right shifting 13 positions.

(3 * X) / (3 * 2900) = (3 * X) / (8700) ≈ (3 * X) / (8192)

Can you tell me other way of implementing this logic

Regards
Vivek Alaparthi
 
Last edited:

well if you actually want to make a measurement unit which is accurate and precise, you should consider using those hardware resources. In the end you want to have a measurement unit, and I'm sure by the end you will have saved a lot of resources , so my question is do you really want to have those resources getting wast? and in turn getting an inaccurate value as well??

But anyways the question still remains unanswered, isnt it? :)
why did your prof. told you that you need to consider MSB as well, I think even he do not know, but all I know is that he wants you to make an accurate sensor, thats why he wants you to look at MSB also, and in turn I think, that doing those division will best help to make best sensor in terms of hardware :)
 

Hi shatruddha,

Thanks for ur reply

Is there any other way of implementing the logic without using hardware resources and getting the result as accurate?

Regards
xilinx1001
 

There can be ways for sure, but I think you should approach them step by step.
First you should make an accurate reading, doesnot matter how much resources you use. So that will give you a benchmark. Now try to improve while reducing the hardware requirement and keeping/increasing the accuracy.
If I was you, I would have planned it this way.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top