A few days ago I made a post regarding the usage of an analog ultrasonic sensor. I was informed that it’s too powerful to be used on the Analog ports via the roboRio and was suggested to use the KoP Ultrasonic Sensor.
Looking at the wiring diagram, and the constructor for the Ultrasonic class, it made sense to use the 2nd pin for communication, and obviously the 6th and 7th for power and ground.
The sensor is connected into DIO port 0.
It is constructed with…
//int pingChannel, int echoChannel
ultrasonic = new Ultrasonic(1, 0);
ultrasonic.setEnabled(true);
ultrasonic.setAutomaticMode(true);
I tried 0,1, but received no values, and I receive values with 1,0 so I assume it is in the correct order.
To view the values, I’m using
ultrasonic.getRangeInches();
and displaying that on the SmartDashboard.
Here’s an example of the issue.
If I have my bumpers pushed up against a wall, I receive a value of 2 (normal according to the spec sheet). as I start to back away, the value will change from 3, to 25, to 2, to 15.
The sensor is mounted on a piece of lexan, just to the left of the bumper. I do not have a picture, but if needed I could draw something rather similar. If the sensor reads in a straight line, it should not pick up the bumper, but it is awfully close.
Perhaps it’s not wired right, mounted right, or constructed right, but if anyone knows the reason behind it, I would be more than grateful to hear it! Thanks!