Go to Post I'm looking foward to the challenge! - Adrienne E. [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 14-01-2017, 18:03
randy_pham randy_pham is offline
Registered User
FRC #0498 (Cobra Commanders)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2016
Location: Arizona
Posts: 7
randy_pham is an unknown quantity at this point
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();
	}
}
Reply With Quote
  #2   Spotlight this post!  
Unread 14-01-2017, 18:32
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,590
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Maxbotics Ultrasonic Sensor Not Working

Double check your conversion factors.
Reply With Quote
  #3   Spotlight this post!  
Unread 14-01-2017, 19:35
randy_pham randy_pham is offline
Registered User
FRC #0498 (Cobra Commanders)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2016
Location: Arizona
Posts: 7
randy_pham is an unknown quantity at this point
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.
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 12: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