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

Digital Fiber, Photoelectric, Laser Range, Optical, Temperature, Rotary Encoder, Ultrasonic, Gas, Gyro, Accelerometer, FlexiBend, Flexiforce, Compass......

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

Postby diastreomers » Tue Jan 04, 2011 10:47 pm

// 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...
diastreomers
Freshie
 
Posts: 4
Joined: Thu Sep 23, 2010 6:11 pm

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

Postby robosang » Wed Jan 05, 2011 9:00 am

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:
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

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

Postby diastreomers » Wed Jan 05, 2011 2:26 pm

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...
diastreomers
Freshie
 
Posts: 4
Joined: Thu Sep 23, 2010 6:11 pm

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

Postby shahrul » Wed Jan 05, 2011 5:39 pm

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
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

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

Postby ober » Wed Jan 05, 2011 6:01 pm

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.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

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

Postby diastreomers » Wed Jan 05, 2011 10:21 pm

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....
diastreomers
Freshie
 
Posts: 4
Joined: Thu Sep 23, 2010 6:11 pm

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

Postby shahrul » Wed Jan 05, 2011 10:44 pm

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.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

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

Postby robosang » Thu Jan 06, 2011 9:10 am

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.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

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

Postby shahrul » Thu Jan 06, 2011 9:18 am

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.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

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

Postby diastreomers » Thu Jan 06, 2011 4:05 pm

Thanks everyone...

Now I understand deep about EZ1 with its method to use it.... ;)
diastreomers
Freshie
 
Posts: 4
Joined: Thu Sep 23, 2010 6:11 pm


Return to Sensor

Who is online

Users browsing this forum: No registered users and 19 guests

cron