VEX Ultrasonic Sensor not functioning

Hey guys.

For a while, we have been trying to get the VEX Ultrasonic Rangefinders to work. We’re pretty sure they were plugged in correctly - one digital input and one digital output on the digital sidecar - but we swapped them anyway just to be sure. No dice. We flipped the connectors themselves as well, still nothing. The output changed from zero to infinity, though.

The code is in Java, and it’s very simple. We just create an instance of Ultrasonic with the digital input/output pins as arguments, and then put getRangeInches() in the command loop.

Is there anything you guys can think of that we may have done wrong?

Thanks!

The code and wiring should be pretty straightforward. Can you show us the relevant part of the program, and a picture of how the sensor is connected?

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

Constants:

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:

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

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!

Bump.

I am having the same issue so bump.

The “input” of the sensor is what you trigger to send out the pulse.

The “output” of the sensor is what the time loop is looking for.

You need to have the white wire connected since that’s the signal wire. Red is power, black is ground

In your example the sensor input would be 1,3. Output on 2,4