Page 1 of 1

Help me with this source code...LV EZ1 Sensor

PostPosted: Tue Jan 04, 2011 10:47 pm
by diastreomers
// max vslue 2.55v = 2.55/5 *1024 - 1 = 522, resolution = 10mV/ inch, 10m/5*1024 =~ 2

What actually this mean???

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..

Thanks for any helps...

Re: Help me with this source code...LV EZ1 Sensor

PostPosted: Wed Jan 05, 2011 9:00 am
by robosang
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 8-)

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 :mrgreen:

Re: Help me with this source code...LV EZ1 Sensor

PostPosted: Wed Jan 05, 2011 2:26 pm
by diastreomers
Oke..
Thanks to you Mr robosang

Its mean whatever the Adresh value get, it is the converted analog voltage.....??
SO, i need a coding to convert the pure digital value to the inch....
Then, I will work about it...

Thanks anyway...

Re: Help me with this source code...LV EZ1 Sensor

PostPosted: Wed Jan 05, 2011 5:39 pm
by shahrul
Maybe you want see this ultrasonic range finder lesson.
You can connect with analog, serial or pulse width.

ADC 10bit reading convert into mV is multiply 4.888 ex: 4.888*read_a2d(0)
Then convert into cm
Image

Re: Help me with this source code...LV EZ1 Sensor

PostPosted: Wed Jan 05, 2011 6:01 pm
by ober
diastreomers WROTE:Its mean whatever the Adresh value get, it is the converted analog voltage.....??
SO, i need a coding to convert the pure digital value to the inch....
Then, I will work about it...


Yes, robosang is right, PR23 code is just showing the ADC value in decimal value on LCD. And just a reminder is ADRES, 10-bit, not ADRESH only, it include ADRESL too.

Re: Help me with this source code...LV EZ1 Sensor

PostPosted: Wed Jan 05, 2011 10:21 pm
by diastreomers
To Mr Shahrul...

Thanks for the equation anyway...So helpfull then....with the coding in ur pages/websites...

The video you are showing in ur pages are 3 methods AN, UART, and PWM...
However...the distance measured from three methods are too different..
Why this happend???
Should I take which method that will display the accurate value which I refering to your coding....???

I preferred to do ADC method....THen how the measured distance get from ADC differ from
Pwm and UART????
Then, the measured distance which the box moved is not synchronous, which the result seems not get real accurate for me...
Can u explain detailed?

Thanks....

Re: Help me with this source code...LV EZ1 Sensor

PostPosted: Wed Jan 05, 2011 10:44 pm
by shahrul
diastreomers WROTE:I preferred to do ADC method....THen how the measured distance get from ADC differ from
Pwm and UART????
Then, the measured distance which the box moved is not synchronous, which the result seems not get real accurate for me...
Can u explain detailed?

I think read ADC is enough. I don't know the ultrasonic performance, the 3 values differ. It's also about the ultrasonic reading side, it's not straight line. It's also detect at left, right, up and down. Maybe you should try for your own.

Re: Help me with this source code...LV EZ1 Sensor

PostPosted: Thu Jan 06, 2011 9:10 am
by robosang
Most accurate of course is the RS232 output because it is calculate by the ultrasonic sensor itself. If you take ADC and PWM width, there will be some error due to ADC resolution, Timer latency and also conversion tolerance in digital.

Re: Help me with this source code...LV EZ1 Sensor

PostPosted: Thu Jan 06, 2011 9:18 am
by shahrul
robosang WROTE:Most accurate of course is the RS232 output because it is calculate by the ultrasonic sensor itself. If you take ADC and PWM width, there will be some error due to ADC resolution, Timer latency and also conversion tolerance in digital.

Thanks 4 info. I did't realize that. The RS232 output is fixed 1-255 value in inch.

Re: Help me with this source code...LV EZ1 Sensor

PostPosted: Thu Jan 06, 2011 4:05 pm
by diastreomers
Thanks everyone...

Now I understand deep about EZ1 with its method to use it.... ;)