Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Sonar Sensor help (http://www.chiefdelphi.com/forums/showthread.php?t=67467)

eagleslg 05-05-2008 00:40

Sonar Sensor help
 
Hey guys,
I am attempting to connect a MaxBotics EZ0 Sonar sensor http://www.sparkfun.com/commerce/pro...oducts_id=8502 to the 2008 FRC robot controller.
I have read through this post: http://www.chiefdelphi.com/forums/sh...ght=mike+sonar
and have attempted to use Mike's code to get data from my EZ0 sensor.
The code that Mike posted was designed for Parallax Inc. PING)) Ultrasonic Rangefinder and the Vex Robotics Ultrasonic Range Finder,
but is it possible to use the code with the MaxBotics sensor?
are there any other ways to get a signal from this sensor?
Any help i can get with this sensor is highly appreciated, from getting signal to general operation tips, because i am new to Sonar.
thank you in advance

dtengineering 05-05-2008 01:35

Re: Sonar Sensor help
 
The Maxbotics Sonars are great... and easy to work with, too. Probably the easiest out there to interface to the IFI controller, in fact. We have used them the past two years.

The simplest way to connect them is using the analog signal. If you look at the datasheet (find the link at the bottom of the page you referenced) you will see that there is an "AN" pin that gives you an analog output of the last measured range. If you hook up your +5, GND and AN (take a servo cable, cut one end off, and solder it to the appropriate points on the sonar, then plug it into the RC's analog I/O) then all you need to do is read the analog value of the appropriate pin whenever you need a distance measurement. (Page 16 of this document discusses reading the analog inputs.)

You might want to use a printf routine to show you the values that you get at different ranges.

There are more complex ways to use these sonars, too... but this should get you up and running.

Jason

gunsanbob 05-05-2008 11:26

Re: Sonar Sensor help
 
i would rather use the lego mindstorms ultrasonic sensor

which much easier to program

Here is the link http://mindstorms.lego.com/Products/...%20Sensor.aspx

Just have look at the other sensor and give me reply if they can be used with the FRC robots

dtengineering 05-05-2008 12:21

Re: Sonar Sensor help
 
Quote:

Originally Posted by gunsanbob (Post 745749)
i would rather use the lego mindstorms ultrasonic sensor

which much easier to program

Here is the link http://mindstorms.lego.com/Products/...%20Sensor.aspx

Just have look at the other sensor and give me reply if they can be used with the FRC robots

First off, pretty much ANY sensor can be made to work with any processor. The question is how much effort is involved.

The lego minstorms sensor is specifically designed to work with the LEGO platform, so when you refer to it being "easier to program" are you referring to it being easy to program on the NXT or on the IFI Robot Controller? It is certainly easy to program on the NXT because the NXT compiler contains code to interface with that specific sensor.

The Maxbotix sensor, however, is about the easiest sonar to interface to the IFI RC if you use the analog input (which is really, really easy to use... just one line of code!) This is that because rather than returning raw sensor data, the Maxbotix actually contains a PIC chip that processes the data and provides the information in a variety of formats suitable for a wide range of processors.

Jason

Kevin Sevcik 05-05-2008 12:43

Re: Sonar Sensor help
 
Quote:

Originally Posted by gunsanbob (Post 745749)
i would rather use the lego mindstorms ultrasonic sensor

which much easier to program

Here is the link http://mindstorms.lego.com/Products/...%20Sensor.aspx

Just have look at the other sensor and give me reply if they can be used with the FRC robots

As Jason said, pretty much anything can be made to work, but the LEGO NXT Ultrasonic sensor works off of I2C communications, as opposed to something simple like an analog output. So getting the LEGO NXT sensor to work on the IFI RC is going to be extremely difficult compared to the maxbotix. I2C is a whole communication protocol that you'd have to implement yourself on the RC using digital IOs. Think of it as akin to reading a speedometer by pressing a button to light up and individual segment/bar on a 7-segment LCD, versus looking at where the needle's pointing. You might get more accuracy if you do it the first way fast enough, but it'd be pretty painstaking.

Qbranch 05-05-2008 16:18

Re: Sonar Sensor help
 
As others have stated, the Parallax PING))) is just awesome. Here's a link to a place where I posted my driver for the PING))) sensor.

Only needs 1 pin/sensor, and have really narrow angle acceptance ranges (narrow beam) which is great for finding objects. Not to mention, the price isn't half bad either. ;)

Oh, and if you don't mind my asking... what are you using this sensor for?

-q

p.s. If anyone is interested, I have code that will run four PING)))-type ultrasonic sensors at once (simultaneously/asynchronously) that just needs a little clean up to be post worthy. Just let me know.

eagleslg 05-05-2008 17:51

Re: Sonar Sensor help
 
oh, so it should just be one easy line..
im using kevin's code, so Get_Analog_Value does not exist,
im trying to get a value with Get_ADC_Result, but it still comes up as 0.
Should Get_ADC_Result work?

oh btw this sensor will be used for avoiding obstacles

eagleslg 05-05-2008 18:03

Re: Sonar Sensor help
 
aha, finally got data,
i didnt configure adc.h to read from 2 channels instead f just 1 (we have a gyro taking that one up)

a preliminary thing ijust noticed is when i put my finger right on the sensor, to represent something being really close to it, instead of 0 it read 52, how come?

Qbranch 05-05-2008 18:19

Re: Sonar Sensor help
 
Quote:

Originally Posted by eagleslg (Post 745870)
aha, finally got data,
i didnt configure adc.h to read from 2 channels instead f just 1 (we have a gyro taking that one up)

a preliminary thing ijust noticed is when i put my finger right on the sensor, to represent something being really close to it, instead of 0 it read 52, how come?

The ultrasonic chirp may be coming back so fast the Maxbotix sensor misses the return echo.

-q

DonRotolo 05-05-2008 21:14

Re: Sonar Sensor help
 
Quote:

Originally Posted by gunsanbob (Post 745749)
which much easier to program

Easier than a single line?
Quote:

Originally Posted by eagleslg (Post 745863)
oh, so it should just be one easy line..
im using kevin's code, so Get_Analog_Value does not exist,

So write your own. It is just a single line to get an analog value, same as getting the value of a potentiometer. The FRC conrtroller gives 10 bits (0-1023) so your answer is in 1/4 inch increments.
Quote:

Originally Posted by eagleslg
when i put my finger right on the sensor

Too close, try 2 or 3 inches minimum.


All times are GMT -5. The time now is 17:59.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi