Shop OBEX P1 Docs P2 Docs Learn Events
my photoresitor burnt out so i bought a photo transitor, now trying to figure o — Parallax Forums

my photoresitor burnt out so i bought a photo transitor, now trying to figure o

jonduncanjonduncan Posts: 40
edited 2007-04-07 03:30 in Propeller 1
I put the phototransitor in with a 10K resistor it senses a ir remote control but it is not sensing my pulseout from the prop how would i do that? or maybe i could just use my last photoresceiver in the center but it doesn't work very well with only one photo reciever
I point the· ir transmitter directly at it and it doesn't work I am using this command

Pub main
· FDS.start( 31, 30, 0, 19200)
· pulseOut(6, 3000, 2000, -1, 0)
· repeat
··· 'FDS.str(String("test"))
··· if pulseOut( 1, 38500, 385, 0, 1)
····· FDS.str(String("Right"))
··· if pulseOut( 2, 38500, 385, 0, 1)
····· FDS.str(String("Left"))
·
·
Pub pulseOut(pin, freq, dur, checkPin, checkVal)
·· ctra := ctrb := 0························· ' Stop counters if running
·· frqa := calcFrq(freq)····················· ' Get FRQA for frequency
·· frqb := 1································· ' Neg edge -> PHSB + 1
·· phsb := phsa := 0························· ' Clear phases
·· outa[noparse][[/noparse]pin]~
·· dira[noparse][[/noparse]pin]~~······························· ' Pin to output low
·· ctra := %00100 << 26 | pin················ ' CTRA -> NCO
·· ctrb := %01110 << 26 | pin················ ' CTRB -> Negative edge
·· if dur···································· ' Go forever if dur = zero
····· repeat until phsb => dur··············· ' Cycle counting loop
········ if checkPin => 0
········· 'FDS.dec(ina[noparse][[/noparse]checkpin])
··········· if ina[noparse][[/noparse]checkPin] == checkVal····· ' Quit early if condition met
·············· result := true
·············· quit
····· waitpeq(0, |< pin, 0)·················· ' Make sure pin is zero
····· ctra := 0······························ ' Stop CTRA module
····· dira[noparse][[/noparse]pin]~····························· ' Make pin an input
····· ctrb := frqa := frqb := 0·············· ' Clear counter modules
························································
PRI calcFrq(f)
· {Solve FRQA/B = frequency * (2^32) / clkfreq with binary long division.}
·
· f <<= 1
· repeat 32·································· ' Binary long-division
··· result <<= 1
··· if f => clkfreq
····· f -= clkfreq
····· result++·······
··· f <<= 1

thanks for your help

Comments

Sign In or Register to comment.