hi ,thank u both jim and torben ,
but u see i still don't get it???
i mean the ultrasound transmitter has two legs:
one for the square signal and the other is for the ground!! so why in the above code they used both legs for transmitting signal?
and if i remove the loop will the MCU generate 40KHz too?
and how much time does the square wave stay high? and how much time does it stay low??
PING1:
PORTB = %00010000 ' 1st half of cycle
Delayus 10 ' Create a delay of 10uS
PORTB = %00100000 ' 2nd half of cycle
Delayus 9 ' Create a delay of 9uS
hi ,
thanks torben for ur reply but can u plz see my answer to it:
F=1/T , right?
ok, i have F which is equal to 40KHz, so if i want T it will be equal to 1/40K, right?
so by using that equation T must equal to 0.025ms which is also equal to 2.5us right?
but in the code here:
if as u said we supposed that the o/p square signal stayed high for 10us & low for 9us,Code:PING1: PORTB = %00010000 ' 1st half of cycle Delayus 10 ' Create a delay of 10uS PORTB = %00100000 ' 2nd half of cycle Delayus 9 ' Create a delay of 9uS
then the total time will be 19us and when i convert it into a frequency it will be equal to 52.6KHz!!!
so it won't really give 40KHz?!
After clearing the TIMER1 overflow flag (TMR1IF), the program then calls the
PING subroutine which transmits a 40KHz signal 8 times from PORTB.4.
Timing within the PING subroutine is deliberately accurate, as the amount of
cycles taken by each instruction dictates the frequency and duration of the
output signal.
i want to ask a question depending on the above code and the circuit connection "which i'll send later", is the output for the ultrasound transmitter sensor will be like the foolowing the circuit i send.
plz anyone check and tell me ?
thank u for ur help
PING1:
PORTB = %00010000 ' 1st half of cycle "[B]RB4=1[/B]"
Delayus 10 ' Create a delay of 10uS
PORTB = %00000000 ' 2nd half of cycle "RB4=0"
Delayus 9 ' Create a delay of 9uS
hi and i really thank u torben and jimmy , u helped me to understand the 19us thing
but now there's something else that i don't understand which is why the designer of that code used both legs of the transmitter with the MCU.
i mean what's the benifit of doing such a thing?
if he used one leg and let's suppose it's the one connected to RB4 and connected the other leg to the GND, and then he sent the following code:
isn't that going to make the same job??!!Code:PING1: PORTB = %00010000 ' 1st half of cycle "[B]RB4=1[/B]" Delayus 10 ' Create a delay of 10uS PORTB = %00000000 ' 2nd half of cycle "RB4=0" Delayus 9 ' Create a delay of 9uS
if not plz tell me why?
thanx alot for ur time
No it's not, the original way is a bridged connection, this doubles the voltage supplied to the transducer, quadrupling it's output power.
if the only reason for that way of connection is more power for ultrasound sensor, i can use a transistor as switch for more power,right?
i mean will that make the above code i wrote work??
thanx in advance
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?