[HELP]Modifying NewPing Library to work underwater

Good day guys,

I need help in modifying the NewPing Library to work underwater, I recently purchased an Ultrasonic Transducer Module, and replace the transducer that works underwater, I need to recalibrate the library to adapt and work underwater, I have researched that sound travels 4x faster in water than air,..

Any help or clue will do..

Thanks..!

alvinford: I have researched that sound travels 4x faster in water than air,..

Any help or clue will do..

There's your clue right there. You want the speed-of-sound value to be four times the current value.

In the NewPin.h file you'll want to change:

// Shoudln't need to changed these values unless you have a specific need to do so.
#define MAX_SENSOR_DISTANCE 500 // Maximum sensor distance can be as high as 500cm, no reason to wait for ping longer than sound takes to travel this distance and back.
#define US_ROUNDTRIP_IN 146     // Microseconds (uS) it takes sound to travel round-trip 1 inch (2 inches total), uses integer to save compiled code space.
#define US_ROUNDTRIP_CM 57      // Microseconds (uS) it takes sound to travel round-trip 1cm (2cm total), uses integer to save compiled code space.

to:

// Shoudln't need to changed these values unless you have a specific need to do so.
#define MAX_SENSOR_DISTANCE 500 // Maximum sensor distance can be as high as 500cm, no reason to wait for ping longer than sound takes to travel this distance and back.
#define US_ROUNDTRIP_IN 36     // Microseconds (uS) it takes sound to travel round-trip 1 inch (2 inches total) IN WATER, uses integer to save compiled code space.
#define US_ROUNDTRIP_CM 14    // Microseconds (uS) it takes sound to travel round-trip 1cm (2cm total) IN WATER, uses integer to save compiled code space.

thank you very much sir!

johnwasser:

alvinford: I have researched that sound travels 4x faster in water than air,..

Any help or clue will do..

There's your clue right there. You want the speed-of-sound value to be four times the current value.

In the NewPin.h file you'll want to change:

// Shoudln't need to changed these values unless you have a specific need to do so.
#define MAX_SENSOR_DISTANCE 500 // Maximum sensor distance can be as high as 500cm, no reason to wait for ping longer than sound takes to travel this distance and back.
#define US_ROUNDTRIP_IN 146     // Microseconds (uS) it takes sound to travel round-trip 1 inch (2 inches total), uses integer to save compiled code space.
#define US_ROUNDTRIP_CM 57      // Microseconds (uS) it takes sound to travel round-trip 1cm (2cm total), uses integer to save compiled code space.

to:

// Shoudln't need to changed these values unless you have a specific need to do so.
#define MAX_SENSOR_DISTANCE 500 // Maximum sensor distance can be as high as 500cm, no reason to wait for ping longer than sound takes to travel this distance and back.
#define US_ROUNDTRIP_IN 36     // Microseconds (uS) it takes sound to travel round-trip 1 inch (2 inches total) IN WATER, uses integer to save compiled code space.
#define US_ROUNDTRIP_CM 14    // Microseconds (uS) it takes sound to travel round-trip 1cm (2cm total) IN WATER, uses integer to save compiled code space.

Good Evening Sir, somehow, do you have any experience in underwater depth sensing?

alvinford: Good Evening Sir, somehow, do you have any experience in underwater depth sensing?

No, but I have a lot of experience in programming. :)

alvinford: Good day guys,

I need help in modifying the NewPing Library to work underwater, I recently purchased an Ultrasonic Transducer Module, and replace the transducer that works underwater, I need to recalibrate the library to adapt and work underwater, I have researched that sound travels 4x faster in water than air,..

Any help or clue will do..

Thanks..!

It's more like 4.3x faster, which makes US_ROUNDTRIP_IN about 34 and US_ROUNDTRIP_CM about 13. The salinity of the water also makes a difference, but probably not enough to really matter. Or, you could just use NewPing's ping() method which will give you the ping milliseconds. This way, you can apply your own calculation from time to distance, factoring in salinity, temp, etc. and using floating point values if that level of accuracy is important.

Also, if you do get it to work with NewPing, I'd like to know what the make and model of this transducer (where you got it from etc.). Underwater sensing is a common question and adding official support to NewPing along with a working transducer would be very helpful to the community.

Tim

regarding the library, are this factors, milliseconds in CM and IN are only thing that needs to be changed? how about the timing factor? or anything regarding how the sensor sends and receives echo?

Does your new transducer work at the same frequency as the one you replaced? The underwater transducers I have seen work at 200KHz or more, and most ultrasonic sensors for use in air work at 40KHz.

which was and how you modified Ultrasonic Transducer Module to work underwater? I have the SR-04, is possibly modify? http://jaktek.com/wp-content/uploads/2011/12/HC-SR04.pdf