Cenlasoft
04-02-2012, 02:27 AM
Hello,
I am trying to send a squarewave on two pins that are 180 degrees apart. I got that done I think. I am using an h-bridge to excite an ultrasonic transducer. from 5 V I will come out with a 10 vpp. It works. My spin code has something wrong. On the scope I see a squarewave (40KHZ). How do I time it to get .5 ms of the 40khz pulse then turnoff the h-bridge and listen for an echo.
Thanks, Cenlasoft
{{
Template.spin
Curtis Desselles
}}
Con
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
Pin1 = 0
Pin2 = 1
Var
Obj
Pub Main
repeat
TX_Out 'TX a pulse x 5
dira[Pin1..Pin2]~~ 'Make pins output
outa[Pin1..Pin2] := %00 'Turn off h-bridge
Pub TX_Out | i
repeat i from 0 to 4
ctra := %00101 <<26 + Pin2<<9 +Pin1
frqa := 1<<31 / (clkfreq / 80_000)
dira |= |<Pin1 + |<Pin2
Return
I am trying to send a squarewave on two pins that are 180 degrees apart. I got that done I think. I am using an h-bridge to excite an ultrasonic transducer. from 5 V I will come out with a 10 vpp. It works. My spin code has something wrong. On the scope I see a squarewave (40KHZ). How do I time it to get .5 ms of the 40khz pulse then turnoff the h-bridge and listen for an echo.
Thanks, Cenlasoft
{{
Template.spin
Curtis Desselles
}}
Con
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
Pin1 = 0
Pin2 = 1
Var
Obj
Pub Main
repeat
TX_Out 'TX a pulse x 5
dira[Pin1..Pin2]~~ 'Make pins output
outa[Pin1..Pin2] := %00 'Turn off h-bridge
Pub TX_Out | i
repeat i from 0 to 4
ctra := %00101 <<26 + Pin2<<9 +Pin1
frqa := 1<<31 / (clkfreq / 80_000)
dira |= |<Pin1 + |<Pin2
Return