Main Site Documentation

Fez Panda II using HC-SR04 Ultrasonic Module


#1

Easy to get working, just not getting advertised range. Only about 2 feet max.

I installed and ran on my Netduino; same thing.

Using both Interrupt events and PinCapture - same results. I have adjusted the trigger pulse from as fast as the Panda can run two lines of code up to about 1ms - (only need 10microsecond pulse to trigger the unit)

Any ideas to improve the maximum range on this thing getting closer to the advertised specifications?


#2

Not sure about that one, but my MaxSonar has the option of using 3V3 or 5V. You get longer range using the 5V option. You might see if yours has the same option.


#3

OK, here is an update.

It appears that PinCapture() is not working for this sensor or I am not using it (sensor or PinCapture() ) correctly.

I can’t get the Panda to do two things at once. The HC-SR04 required that you first toggle the trigger port high and then low, then you look for the length of the pulse returned on the echo pin. The echo pulse starts exactly when the trigger goes high, and the pulse width measures the time it takes for the sound to bounce off the remote object and return. Units are in microseconds.

It appears that the PinCaptre() method first clears any existing data in the read buffer, and then blocks to read any new data coming in. (I can confirm the blocking because all other Panda threads stop when reading is waiting for the timeout) I can’t confirm the buffer clear other than assume this based on the fact that I never read anything out of the buffer.

Still working, but any thoughts could be helpful…


#4

PinCapture will block everything as you wrote. I had this problem with my infrared module where i wanted to learn the incoming infrared code and respond to http requests about the learning status. I ended up using InterruptPort instead and calculating time difference between interrupts. You can see an example of this in codeshare, look for ‘infrared sender’.


#5

Gralin:
Thanks for your reply. I have three versions of code, the one you suggest is one of them. The only problem is I can only calculate a 23 inc max range using the interrupt method… (for some reason…)


#6

@ Axelg -
Can u share you code?

I use too HC-SR04 with my Panda, and have some problems.