View Single Post
  #3   Spotlight this post!  
Unread 12-03-2014, 16:26
Fej Fej is offline
Registered User
FRC #1672
 
Join Date: Jan 2014
Location: Mahwah, NJ
Posts: 8
Fej is an unknown quantity at this point
Re: VEX Ultrasonic Sensor not functioning

The connector labeled INPUT is plugged into digital I/O pin 2. OUTPUT is plugged into pin 1. Wires are black to black.

Constants:

Code:
public final int[] ULTRASONIC_PING_CHANNELS = {1, 3}; //The digital output channels where the cRIO sends a signal to the utrasonic sensor
public final int[] ULTRASONIC_PONG_CHANNELS = {2, 4}; // The digital input channels where the cRIO reads the output from the ultrasonic sensor
In the Robot() constructor:

Code:
leftSensor = new Ultrasonic(ULTRASONIC_PING_CHANNELS[0], ULTRASONIC_PONG_CHANNELS[0]);
leftSensor.setEnabled(true);
leftSensor.setAutomaticMode(true);
rightSensor = new Ultrasonic(ULTRASONIC_PING_CHANNELS[1], ULTRASONIC_PONG_CHANNELS[1]);
rightSensor.setEnabled(true);
rightSensor.setAutomaticMode(true);
Called every loop in operatorControl():
Code:
private void storeUltrasonicDistances() {
ultrasonicDistances[0] = leftSensor.getRangeInches();
ultrasonicDistances[1] = rightSensor.getRangeInches();
}
We're using SimpleRobot.

Since we don't know whether to plug the INPUT plug into the ping port and the OUTPUT plug into the pong port or vice versa, we tried both combinations (to no avail).

Thanks!

Last edited by Fej : 12-03-2014 at 16:28.
Reply With Quote