![]() |
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 |
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); |
Re: Programming for sonar with MaxRobotix Sensor
Quote:
|
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. |
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? |
Re: Programming for sonar with MaxRobotix Sensor
Quote:
|
Re: Programming for sonar with MaxRobotix Sensor
Quote:
The Analog input pins closest to the jumper. |
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