Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Maxbotics Ultrasonic Sensor Not Working (http://www.chiefdelphi.com/forums/showthread.php?t=153672)

randy_pham 14-01-2017 18:03

Maxbotics Ultrasonic Sensor Not Working
 


We are trying to use the Maxbotics Ultrasonic sensor as an analog input. However, we are not getting responsive voltages from the sensor.

Code:

package org.usfirst.frc.team498.robot;

import edu.wpi.first.wpilibj.AnalogInput;

public class AnalogUltrasonicSensor2017 {
        AnalogInput AI;
        public AnalogUltrasonicSensor2017(Ports ports) {
                AI = new AnalogInput(ports.ULTRASONIC_SENSOR); // !!!MUY IMPORTANTE!!!
        }
       
        public double GetRangeMM() {
                double output = 0;
                output = AI.getVoltage();
                output = output / 1000; //Measured in millivolts
                output = output / 0.977;
                return output;
        }
       
        public double GetRangeInches() {
                double output = GetRangeMM();
                output = output * 25.4;
                return output;
        }
       
        public double GetVoltage() {
                return AI.getVoltage();
        }
}


Joe Ross 14-01-2017 18:32

Re: Maxbotics Ultrasonic Sensor Not Working
 
Double check your conversion factors.

randy_pham 14-01-2017 19:35

Re: Maxbotics Ultrasonic Sensor Not Working
 
We are getting unresponsive voltages. AnalogInput.getVoltage() just returns a value that hovers between 0.2 and 0.3.

The conversion factors may be off, but that isn't the problem we're trying to fix.


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

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