Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Programming for sonar with MaxRobotix Sensor (http://www.chiefdelphi.com/forums/showthread.php?t=109545)

bs7280 15-11-2012 20:36

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

thephpdev 16-11-2012 23:05

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();


Skyehawk 25-11-2012 01:21

Re: Programming for sonar with MaxRobotix Sensor
 
Quote:

Originally Posted by thephpdev (Post 1194441)
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.

otherguy 02-12-2012 15:11

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.

AlexD744 02-12-2012 18:06

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?

DonRotolo 02-12-2012 19:09

Re: Programming for sonar with MaxRobotix Sensor
 
Quote:

Originally Posted by AlexD744 (Post 1198085)
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?

Mark McLeod 02-12-2012 19:16

Re: Programming for sonar with MaxRobotix Sensor
 
Quote:

Originally Posted by DonRotolo (Post 1198102)
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.

DonRotolo 02-12-2012 19:25

Re: Programming for sonar with MaxRobotix Sensor
 
Oh. I knew it was one of them at the end... :o


All times are GMT -5. The time now is 09:58.

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