SRF04 module measure distance

Status
Not open for further replies.

haohaodk46

Member level 4
Joined
Apr 8, 2012
Messages
77
Helped
1
Reputation
2
Reaction score
2
Trophy points
1,288
Visit site
Activity points
1,806
Hi all,
This is circuit for module SRF04



Why do The everyone know 2 pin P5.1 , P5.2 from STC11 connect to Max232. The STC11 will generate 40Khz on P51 , P5.2 both to ultrasonic 40T ?. If only using a pin of ultrasonic 40T and left pin connect then is it ok ?
How to code for STC11 or any microcontoller for control 40T and read frim 40R ? Anyone have code sample for this ?
Regard ,
Hao
 

Hello!
If you look for SRF04.c on the net you will find many examples.
That said, the best method would be to do it yourself and understand what you are doing. As far as I remember, it delivers a pulse (receive pulse), the length of which is related to the distance. So basically, here is how to measure.
- Set up a timer with some clock. The higher the frequency the better.
- Trigger your timer start with a rising edge interrupt
- Trigger your timer stop with a falling edge interrupt
That's it, you get the value.
Have fun!
Dora
 

You are wrong my mean . I mean that I want to control direct from STC11 ( above schematic ) . As SRF04 or other ultrasonic module , It is using a microcontoller that programmed. Thus I want to know how to that microcontroller work. As above schemtic , Why does It use 3 pin P5.1 and P5.2 instead of 1 pin P5.1 to generate to transmit ultrasonic ?
 

Hello!

As I think you use some kind of automatic translation software, it makes your request very difficult
to understand. Example

You are wrong my mean

???
Is it "You misunderstood my question"?

Beside this:

Why does It use 3 pin P5.1 and P5.2 instead of 1 pin P5.1

???
For my understanding, P5.1 and P5.2 are 2 pins. But "3 pin" is missing a s, so it may also mean P5.3 which is used to power the MAX3232.

Maybe you want to know why 2 pins instead of 1? You are sending a signal to the piezo device. One way is to put 1 pin to ground and drive the other pin. This is a single end transmission. The voltage at the piezo actuator will go like 0V, 5V, 0V, etc. The amplitude is therefore 5V. If you use both pins and drive them like from 01 to 10, then you will have -1V, 5V, -5V, etc, twice the amplitude.

Dora.
 
As I understand it, and of course I don't know what code is inside the STC11, P5.1 and P5.2 will be driven in software so they are always at opposite logic levels '01' or '10'. They connect to the two MAX3232 transmit channels so the 3.3V logic levels are increased in voltage to maybe 7 or 8V (whatever the MAX3232 output voltages happen to be). Driving them out of phase gives a greater drive voltage to the T40.

That is not the best way to drive the T40 for best results but it does increase the voltage and therefore range.

Brian.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…