Go to Post Why does 1114 have to be good at everything? ;) - Justin Montois [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 14-01-2014, 19:57
m1tche11d m1tche11d is offline
m1tche11d
FRC #1997
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2010
Location: Kansas
Posts: 21
m1tche11d is an unknown quantity at this point
Programming MaxSonar EZ1 Ultrasonic Rangefinder in Simple Robot Template

Our team is using the simple robot example as a template for our code for this year. We were wondering what the easiest way to wire and program the MaxSonar EZ1 rangefinder would be.

We looked at some other posts and it seems that we can wire it as either a digital or an analog input. Is there a "better" way to wire it, or are both equally good?

Finally, once we wire it, how would we declare it in our code, and how would we pull in a distance from the sensor?

Thanks,
Team 1997
Reply With Quote
  #2   Spotlight this post!  
Unread 22-01-2014, 10:04
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Programming MaxSonar EZ1 Ultrasonic Rangefinder in Simple Robot Template

If I remember correctly, the analog configuration is the default, and doesn't offer as many options but is very easy to setup.

In 2012 when I last used this sensor, there was no WPILib class that supported it, but if they've added one, you'll want to use it; otherwise you are welcome to use my 2012 code here:

https://github.com/TeamExcel/Project...angeFinder.cpp
https://github.com/TeamExcel/Project...gRangeFinder.h

You may have to configure the sensitivity ANALOG_RANGE_FINDER_DEFAULT_INCHES_PER_VOLT in the .h
Reply With Quote
  #3   Spotlight this post!  
Unread 23-01-2014, 15:20
Peter Cudmore Peter Cudmore is offline
Mentor
FRC #3543 (C4)
Team Role: Teacher
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Arnprior
Posts: 5
Peter Cudmore is an unknown quantity at this point
Re: Programming MaxSonar EZ1 Ultrasonic Rangefinder in Simple Robot Template

We used analog coming out of the 9201 module in the rio wire red to +5 black to fend and the signal to an on the sensor

I have some new coders so I am not bothering with subroutines so we just put the commands in the main program. So this is inelegant code but it works.



float volt,inches;
AnalogChannnel *range ;


Range =new AnalogChannel(1,1);

The command to call and convert to inches is
volt = range ->GetVoltage();
inches = volt/0.009766;

That is the conversion factor and for us seems quite accurate within 3 feet.
Just use inches wherever you need the range data

We can't seem to get readings above that so if anyone has a suggestion for boosting the power of his device to the supposed voltage of 5v I would appreciate an answer to that.
Reply With Quote
  #4   Spotlight this post!  
Unread 30-01-2014, 23:32
wadehas wadehas is offline
Registered User
FRC #1258
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2004
Location: Seattle
Posts: 8
wadehas is an unknown quantity at this point
Re: Programming MaxSonar EZ1 Ultrasonic Rangefinder in Simple Robot Template

We have been having a similar issue with the Sonar sensor. Using this sensor is not complicated and appears that you have it right.

We had this working a couple years ago, but never really had a need for it until this year.

We have ours wired with red (+5v) from analog port to +5v on the sensor, ground from the analog port to ground on the sensor, and signal from analog port to "An" pin on the sensor.

We confirmed with a multimeter that the sensor was getting +5v, so it was getting the appropriate power.

We then checked the signal voltage directly on the sensor, and it never read about .066v (66 mv) and matched what the software was reading from the analog port, and this was with the sensor pointed at the tile floor at about 3' above the floor, which should have resulted 0.3v, and pointing at it a whiteboard about 10-15' away still resulted in 0.066v...

We have concluded that the issue is with the sensor itself, and are going to be replacing the sensor.


------
Wade Hasbrouck
Team 1258
Seattle Lutheran HS
Programming Mentor
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 14:34.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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