Analog ultrasonic sensor class?

Has any one implimented a class for an analog ultrasonic sensor to go with the WPILib? We are using the Max Botix EZ1, and therefore cannot use the WPILib class–which is for a digital ultrasonic sensor. We have started to create such a class but we think that the FPGA does not oversample the channel we are using (module 1, port 3). Because we created our code to do this we are getting “fatal errors.” Have you found any documentation for the FPGA on the analog module?

Thanks:]

We found part of the problem, we were plugged into a none accumulator channel. Only ports 1 or 2 are!!!

But if you have created such a class still let us know, it would be great if I did not have to pull my hair out again…:ahh:

From the FAQ on the Maxbotix site, it looks like the output is a straight 10mV/inch signal.

I’m not sure why you want to use an accumulator for the ultra sonic sensor. I think you actually want to use the oversampling engine. The accumulator is for signals that need to be integrated, like gyros. The oversampling engine is for signals that could use some basic filtering. All analog input channels can be oversampled, but only the first two channels can use the accumulators.

Dear Phoenix Spud,

We have had a number of teams that have requested assistance with code support for the MaxSonar line of sensors. These are the EZ0, EZ1, EZ2, EZ3, EZ4, and the new WR1 (narrow beam sensor in a rugged PCV package).

All of these sensors are backward compatible with the Vex ultrasonic rangefinder, and the Daventech SRF04 rangefinder. As such the MaxBotix Inc., sensors are all compatible with software provided in the C/C++ WPI Robotics Library. For revision 0.5 – 28 December 2008 this is located on page 46.

Specifically the section “Ultrasonic rangefinder”.

The SRF04 is shown in the photo, but any of the MaxSonar sensors can be substituted. Just follow the pin out below.
http://app4.websitetonight.com/projects/3/4/4/0/34404/uploads/SRF04_MaxSonar_Pinout_Table.jpg
Then just follow the application note.

My team is trying to use the EZ4 version sensor. We don’t have any electrical people so we are having trouble figuring out how to wire it up. We used a pwm cable. The red and black wires are hooked up to GND and +5. The white wire is hooked up to the PW pin. The sensor is plugged into the analog bumper. The RX pin is not connected which means the sensor will send pings constantly. Does that sound right?

If we only connect the PW pin, will the Ultrasonic class still be usable? What would use as an arg for the ping channel for the constructor if we don’t have it hooked up?

We plugged in the PW signal pwm wire into the analog bumper, channel 3.
We tried instantiating an instance of Ultrasonic with ping channel = 0 and echo channel = 3. IsRangeValid() returns false and GetRangeInches() returns 0. We aren’t calling Ping() because the sensor should be sending out pings. We also tried instantiating with ping channel = 3 and echo channel = 3. Same result.

What are we doing wrong? Do we need to use a different class to use this sensor? Is the FPGA bug I’ve seen on other threads causing problems with readings?

Do we need to wire up the RX pin to another channel on the analog bumper? If so, do we only connect the white wire since the echo channel pwm already has power wires hooked up?

Thanks in advance.

Whoops! I was coding this, but never had the chance to test it.
I’ve attached a .zip with the .cpp and .h. It compiles, but I’m not sure if it works, and the coding style is not completely in line with WPILib. It should, however, be a good starting place.

analogultrasonic.zip (1.53 KB)


analogultrasonic.zip (1.53 KB)

All,

Here is the link http://first.wpi.edu/Images/CMS/First/C_CPP_Programming_Guide.pdf to the referenced document in the above post C/C++ WPI Robotics Library.For revision 0.5 – 28 December 2008 this is located on page 46.

If you have any question please let me know.

Dear Loafdog,

Please call me at MaxBotix Inc., (218) 764-2489 so we may discuss this in detail.

I look forward to your call.