NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.7

Stanley:

teckel:
Did you wire it to use PWM passive control mode instead of the serial? Also, it's possible it needs a longer MAX_SENSOR_DELAY or trigger length. Anyway, if you can't get it to work correctly with 2 sensors using the serial method, you could send it to me and I'll try to get the PWM mode working with NewPing and then send you the sensor back. It seems as though with a little tweaking it would work. And if so, when you got the sensor back you could implement both sensors. I'd like to add support for this sensor so it's worth my time to try to get it working for you.

Tim

Tim,

I double check and wire the pins are correctly... now pin 4 = PWM, pin 5 = trigger

I tried the NewPing library again and this time I put it on a oscilloscope to "see" what's going on....

The URM37/echo pin seems to be working correctly as the pulse width decreases when range is near and pulse width increases when range is far away...

The serial monitor is still showing 0cm ....

I measured the width from the scope and here is what I got :-

1cm = 0.5ms ( 500us )
20cm = 1ms
30cm = 1.5ms
40cm = 2ms
100cm = 5.16ms
185cm = 8.00ms ( my ceiling height )

The period is 68ms for every distance measurement....

The codes is as per the NewPingExample and I only made changes to the defines below

#define US_ROUNDTRIP_CM 50
#define US_ROUNDTRIP_IN 127
#define TRIGGER_PIN 5
#define ECHO_PIN 4
#define MAX_DISTANCE 500

Please suggest what else should I try...

It appears the ping trigger process is working if you're getting activity on the echo pin. Does it look like a nice square wave? Is the pulse width measured high, low, or are both the same? NewPing waits up to MAX_SENSOR_DELAY for the echo pin to go high and then measures the time it's high. If the distance measurement is on the low state instead of high, it would obviously be wrong. Also, if you modify the sketch to trigger just one ping, how long will the echo pin give the PWM distance?

I'd try set the MAX_SENSOR_DELAY to a very large number, maybe a million. Also, set the ping rate to be very slow, like once every 5 seconds.

Tim