Go to Post *puts on flame suit and goes to hide in the corner* :D - Wayne Doenges [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-11-2012, 20:36
bs7280 bs7280 is offline
Registered User
FRC #3734
Team Role: Leadership
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Lake Forest
Posts: 80
bs7280 has a spectacular aura aboutbs7280 has a spectacular aura aboutbs7280 has a spectacular aura about
Programming for sonar with MaxRobotix Sensor

Hi, we are trying to get a reading from our MaxRobotix Sensor that we have plugged into pin 1 of the Analog input. We are using java (NetBeans) for programming. Some of our code:

Declaring variable:
public static final Button ultrasonicSensor = new AnalogIOButton(1);

And inside out Autonomous section, we simply print out ultrasonicSensor.get();

It would be greatly appreciated if someone could help us get a reading from our sensor so that we can work with it
Reply With Quote
  #2   Spotlight this post!  
Unread 16-11-2012, 23:05
thephpdev's Avatar
thephpdev thephpdev is offline
Registered User
AKA: Josh Larson
FRC #2502 (Talon Robotics)
Team Role: Programmer
 
Join Date: Mar 2012
Rookie Year: 2012
Location: Eden Prairie, MN
Posts: 16
thephpdev is an unknown quantity at this point
Re: Programming for sonar with MaxRobotix Sensor

You can get a reading from a sensor by getting the voltage output by the sensor. Which can be done like this:
Code:
private AnalogChannel ultrasonic = new AnalogChannel(1);
private double voltage = ultrasonic.getVoltage();
Reply With Quote
  #3   Spotlight this post!  
Unread 25-11-2012, 01:21
Skyehawk's Avatar
Skyehawk Skyehawk is offline
Nuts N' Bolts
AKA: Skye Leake
FRC #0876 (Thunder Robotics)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2011
Location: Northwood, ND
Posts: 204
Skyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to all
Re: Programming for sonar with MaxRobotix Sensor

Quote:
Originally Posted by thephpdev View Post
You can get a reading from a sensor by getting the voltage output by the sensor. Which can be done like this:
Code:
private AnalogChannel ultrasonic = new AnalogChannel(1);
private double voltage = ultrasonic.getVoltage();
To get inches from the sensor I THINK you need to multiply the output voltage by 100. again I'm not positive. This is info I carried over from Labview. I see no reason it would be different.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-12-2012, 15:11
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 429
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Programming for sonar with MaxRobotix Sensor

If you're using the maxbotix LV-MaxSonar-EZ sensor, there's a good guide here:
http://www.maxbotix.com/articles/016.htm

This page includes details on converting the measured analog value to a distance in inches.
__________________
http://team2168.org
Reply With Quote
  #5   Spotlight this post!  
Unread 02-12-2012, 18:06
AlexD744 AlexD744 is offline
Registered User
FRC #0744 (744 Shark Attack)
Team Role: Alumni
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Ft. Lauderdale, FL
Posts: 638
AlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond repute
Re: Programming for sonar with MaxRobotix Sensor

Hey,
So we used an unltrasonic sensor on two of the robots I worked on, and both times we used the .get() method, it returns integers that correspond to distance (in an arbitrary unit). Should work fine either way.

As for your problem, we noticed that we got strange issues when we had something connected to both analog 1 and 2, we're still not sure why, but if both were connected one or both wouldn't work (I don't remember the exact symptoms). We found this problem when working with a gyro, so it could have been specific to a gyroscope, but it might not be. Regardless, you could try switching the port you are using.

Also, I just realized you are using this as a AnalogIOButton object? Is this a sensor on the driver station or on the robot? If this sensor is plugged into the cRio Analog Card (which is what I had assumed, and the above information is referring to), then I believe this should be an AnalogChannel Object. If not, what is the purpose of the sensor? and what is it's use in autonomous mode, because driver station inputs are disregarded in autonomous?
__________________
www.sharkattack744.com
Reply With Quote
  #6   Spotlight this post!  
Unread 02-12-2012, 19:09
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 6,979
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Programming for sonar with MaxRobotix Sensor

Quote:
Originally Posted by AlexD744 View Post
we noticed that we got strange issues when we had something connected to both analog 1 and 2, we're still not sure why,
Isn't Analog1 used for battery voltage?
__________________

I am N2IRZ - What's your callsign?
Reply With Quote
  #7   Spotlight this post!  
Unread 02-12-2012, 19:16
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,753
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Programming for sonar with MaxRobotix Sensor

Quote:
Originally Posted by DonRotolo View Post
Isn't Analog1 used for battery voltage?
Analog input 8 is disabled/enabled by the breakout jumper for the battery feed.
The Analog input pins closest to the jumper.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 02-12-2012 at 19:29.
Reply With Quote
  #8   Spotlight this post!  
Unread 02-12-2012, 19:25
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 6,979
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Programming for sonar with MaxRobotix Sensor

Oh. I knew it was one of them at the end...
__________________

I am N2IRZ - What's your callsign?
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 09:58.

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