Has anybody tried using an ultrasonic receiver instead of a PIN diode with an Atmel U2538B, T2526 or T2527 chip? It might simplify processing.Originally Posted by Melanie
Has anybody tried using an ultrasonic receiver instead of a PIN diode with an Atmel U2538B, T2526 or T2527 chip? It might simplify processing.Originally Posted by Melanie
I used the following code to test out a SRF-04 Ultrasonic sensor from Acroname with a 16f876 (I think, maybe an f84). I believe it worked fine. Results sent to a serial LCD or to Hyperterminal. I think it's on the lines of what Melanie is suggesting.
<code>
DEFINE LOADER_USED 1 'Only required if bootloader used to program PIC
DEFINE HSER_RCSTA 90h 'setup receive register
DEFINE HSER_TXSTA 20h 'setup transmit register
DEFINE HSER_BAUD 2400 'setup baud rate
'DEFINE HSER_SPBRG 25 'setup baud rate
' -----[ Variables ]-------------------------------------------------------
Dist VAR WORD 'setup variable to hold result of sonar conversion distance
fire VAR WORD 'setup variable to hold result of flame sensor
speed VAR WORD 'setup variable to hold result of next sensor
fire = 18 'dummy number for now
speed = 27 'dummy number for now
' -----[ Initialization ]--------------------------------------------------
'
portsetup:
PORTC = %00000000 ' all outputs off to start
TRISC = %00010000 ' All of Port c is outputs except RC4
' -----[ Main Code ]-------------------------------------------------------
main:
'Pause 10 'settle in time(may not be needed)
GoSub sr_sonar 'goto sonar code
GoSub hyperview
GoSub lcdview 'print on LCD and Hyperterminal
GoTo main 'Repeat forever
sr_sonar:
PORTC.4 = 0 'Be sure RC4 is low
PulsOut PORTC.4,2 ' 10us init pulse
PulsIn PORTC.5,1,Dist ' measure echo time
Dist = Dist / 15 ' convert to inches
Pause 100
Return
hyperview:
HSerout ["Distance to Object = ", DEC dist,13,10]
Pause 250
HSerout ["Magnitude of flame = ", DEC fire,13,10] 'output data to hyperterminal
Pause 250
Pause 250
HSerout ["Speed of Travel = ", DEC speed,13,10]
Return
lcdview
SerOut PORTB.6,0,[254,1] 'clear LCD screen
Pause 40
SerOut PORTB.6,8,[254,134,"FIRE"] 'List outputs to LCD
SerOut PORTB.6,8,[254,199,#fire]
SerOut PORTB.6,8,[254,128,"DATA"]
SerOut PORTB.6,8,[254,193,#Dist]
SerOut PORTB.6,8,[254,140,"SPED"]
SerOut PORTB.6,8,[254,204,#speed]
Pause 500
Return
End
</code>
It's been a few years since I've tried it. Hope it helps.
still problem
i add this program in my code
for transmit the signal
PORTA.4 = 0
PulsOut PORTA.4,2
for recieve i use amplifier for increase the voltage.
but stilll cant function.
can some one help me..
I think you would be better off understanding the basic principle of SONAR detection before just launching at this. I believe your receive configuration is missing some bias on the Q2 & Q3 transistor (or you have some resistors values that are just too big).
Take a look at this, it is the simplest approach. Take time to read it, don't just copy and paste the schematic and code (or you'll be back here or 'there' asking more of the same questions).
Getting any circuit like this to work can be a HUGE effort, as you have analog, digital and code issues all running together, and usually, unless everything works, nothing works.
So take it in steps... and do please tell me you have an osciloscope. Without an oscilloscope there isn't much you can do with a non-working circuit but say a prayer.
So first, make sure the transmitter is getting a pulse train at 40 KHz. If not, make it so. Once you have that, look at what the reveiver is doing. Q2 collector should show you a burst of 40KHz pulses that are the echo; trigger the scope on the transmit burst and see how long the return burst takes.
Once you see that, you can adjust one of the pots (R17, R18 and R190 so it triggers on the "meat" of this burst. I don't know why there are 3 comparitors there, only one is needed to tell when the return happens.
I have done a similar circuit, I did not use comparitors, just a transistor between my receive amp to "square off" the return signal and use that to trigger an interupt, the ISR then read a timer to determin time of flight. Using interupts isn't essential but would be a bit more accurate then polling the port pins.
thank
now i understand
how i can pause 10us for transmit the signal.
what cristal oscletor.
realy need help
Bookmarks