diastreomers WROTE:// max vslue 2.55v = 2.55/5 *1024 - 1 = 522, resolution = 10mV/ inch, 10m/5*1024 =~ 2
What i understand is...2.55v is max analog output voltage...
Why it must divided to 5, then times with 1024????
So, this output distance mesured by pic is in inch or meter??
Please help me...I found this coding comment in cytron project PR23..
So you got this from Cytron DIY project? Not really gone through the PR23 code before. OK, let's take a look at it.
I think the 2.55V is the maximum output voltage you can get from ultrasonic sensor. The equation of 2.55/5*1024-1 should written in such way: 2.55/5*(1024-1). It is actually want to get the digital value for 2.55V, which the result is 522. So when you get 522 from the ADRES (10 bit result) it mean 2.55V. Why? Try to study the ADC. 5V will give you 1023 (10-bit full), that's why it divide 2.55 by 5 and multiple by 1023, simple mathematic I think
So back to the question of meter or inch. As far as I concern, this ultrasonic can only give you distance in inch. The formula that you show is neither giving you the value in inch nor meter, it is just pure ADC result, you will need to do some calculation on the result.
That, I leave it to you as you should do some study