Goofy problem with getting an IR LED to be detected by a IR detector on a 2nd Prop
vanmunch
Posts: 568
Solved!
Hooked up the two different Props (one receiving and one sending and receiving) on two different computers and that worked. However, the the sender and the reciever also had to be carfully aimed at each other to get a distance of more than 8 inches. Not like the remotes that could bounce it off the walls. The big thing was that the board was unpluged from the computer so the USB was waking up when "FullDuplexSerialPluse" tried to talk to the computer, thanks Rayman! So it looked like I was doing two things wrong the "FullDuplexSerialPluse" was waking up the USB and causing the board to reset and the light needed to be carefully aimed because it was dim.
Hey all,
I'm sure that the answer is as plain as the nose on my face so can someone hold up a mirror and tell me what I'm missing?
I'm modifing the lab in the PEK book V1.1 pg 148. I'm trying to have one prop control an IR LED that is then detected by a second prop that has an IR detector connected to it. The IR detector detects my remote controls, but it doesn't respond to the prop controlled IR. I figured that something must be wrong with the IR LED so I replaced it with a normal LED and could see it flicker. Ok, so I put the IR LED back and wired up a second IR detector to the same prop. So now I have a prop with both the IR detector and IR LED attached and it detects it, however the IR detector attached to the second Prop still doesn't respond (but it still does to my remote). I've checked all of the connections, I think I'm missing something with the code...
IrObjectDetection.spin
''This code example is from Propeller Education Kit Labs: Fundamentals, v1.1.
''A .pdf copy of the book is available from www.parallax.com, and also through
''the Propeller Tool software's Help menu (v1.2.6 or newer).
''
'' IrObjectDetection.spin
'' Detect objects with IR LED and receiver and display with Parallax Serial Terminal.
CON
_clkmode = xtal1 + pll16x ' System clock → 80 MHz
_xinfreq = 5_000_000
' Constants for Parallax Serial Terminal.
HOME = 1, CR = 13, CLS = 16, CRSRX = 14, CLREOL = 11
OBJ
Debug : "FullDuplexSerialPlus"
SqrWave : "SquareWave"
PUB IrDetect | state
'Start 38 kHz square wave
SqrWave.Freq(0, 1, 38000) ' 38 kHz signal → P1
dira[1]~ ' Set I/O pin to input when no signal needed
'Start FullDuplexSerialPlus
Debug.start(31, 30, 0, 57600) ' Start FullDuplexSerialPlus
waitcnt(clkfreq * 2 + cnt) ' Give user time to click Enable.
Debug.tx(CLS) ' Clear screen
repeat
' Detect object.
dira[1]~~ ' I/O pin → output to transmit 38 kHz
waitcnt(clkfreq/1000 + cnt) ' Wait 1 ms
state := ina[0] ' Store I/R detector output
dira[1]~ ' I/O pin → input to stop signal
' Display detection (0 detected, 1 not detected)
Debug.str(String(HOME, "State = "))
Debug.Dec(state)
Debug.str(String(CR, "Object "))
if state == 1
Debug.str(String("not "))
Debug.str(String("detected.", CLREOL))
waitcnt(clkfreq/10 + cnt)
Hooked up the two different Props (one receiving and one sending and receiving) on two different computers and that worked. However, the the sender and the reciever also had to be carfully aimed at each other to get a distance of more than 8 inches. Not like the remotes that could bounce it off the walls. The big thing was that the board was unpluged from the computer so the USB was waking up when "FullDuplexSerialPluse" tried to talk to the computer, thanks Rayman! So it looked like I was doing two things wrong the "FullDuplexSerialPluse" was waking up the USB and causing the board to reset and the light needed to be carefully aimed because it was dim.
Hey all,
I'm sure that the answer is as plain as the nose on my face so can someone hold up a mirror and tell me what I'm missing?
I'm modifing the lab in the PEK book V1.1 pg 148. I'm trying to have one prop control an IR LED that is then detected by a second prop that has an IR detector connected to it. The IR detector detects my remote controls, but it doesn't respond to the prop controlled IR. I figured that something must be wrong with the IR LED so I replaced it with a normal LED and could see it flicker. Ok, so I put the IR LED back and wired up a second IR detector to the same prop. So now I have a prop with both the IR detector and IR LED attached and it detects it, however the IR detector attached to the second Prop still doesn't respond (but it still does to my remote). I've checked all of the connections, I think I'm missing something with the code...
IrObjectDetection.spin
''This code example is from Propeller Education Kit Labs: Fundamentals, v1.1.
''A .pdf copy of the book is available from www.parallax.com, and also through
''the Propeller Tool software's Help menu (v1.2.6 or newer).
''
'' IrObjectDetection.spin
'' Detect objects with IR LED and receiver and display with Parallax Serial Terminal.
CON
_clkmode = xtal1 + pll16x ' System clock → 80 MHz
_xinfreq = 5_000_000
' Constants for Parallax Serial Terminal.
HOME = 1, CR = 13, CLS = 16, CRSRX = 14, CLREOL = 11
OBJ
Debug : "FullDuplexSerialPlus"
SqrWave : "SquareWave"
PUB IrDetect | state
'Start 38 kHz square wave
SqrWave.Freq(0, 1, 38000) ' 38 kHz signal → P1
dira[1]~ ' Set I/O pin to input when no signal needed
'Start FullDuplexSerialPlus
Debug.start(31, 30, 0, 57600) ' Start FullDuplexSerialPlus
waitcnt(clkfreq * 2 + cnt) ' Give user time to click Enable.
Debug.tx(CLS) ' Clear screen
repeat
' Detect object.
dira[1]~~ ' I/O pin → output to transmit 38 kHz
waitcnt(clkfreq/1000 + cnt) ' Wait 1 ms
state := ina[0] ' Store I/R detector output
dira[1]~ ' I/O pin → input to stop signal
' Display detection (0 detected, 1 not detected)
Debug.str(String(HOME, "State = "))
Debug.Dec(state)
Debug.str(String(CR, "Object "))
if state == 1
Debug.str(String("not "))
Debug.str(String("detected.", CLREOL))
waitcnt(clkfreq/10 + cnt)
Comments
Maybe I'd try running 2 wires between the Props and try talking over fullduplexserial.
Or, actually it's probably easier to try fullduplexserial one at a time over USB or PropPlug...
You might try not starting fullduplexserial if it's connected to an FTDI chip that isn't connected to a PC...
Do you have a scope to check the carrier frequency of the remote-controls?
If the IR receiver has a different frequency it can still work, but with a dramatically decreased range.
The receivers are the ones that came with the Boe-Bot and PE kit. I don't have a scope and no idea how to use one, but maybe I'll get lucky with the "Free Friday giveaway" this Friday. I know that I really need to learn how to use one...
Anyhow, I'll let you know how it goes.
The other thing that caught me was that the Prop will only push 20ma through the pins (I think - it might be 40), but an IR emitter will soak up 150ma or so. You're better off to use a transistor with a small value current limiting resistor on it, or your range will be horrible.
Hooked up the two different Props (one receiving and one sending and receiving) on two different computers and that worked. However, the the sender and the reciever also had to be carfully aimed at each other to get a distance of more than 8 inches. Not like the remotes that could bounce it off the walls. The big thing was that the board was unpluged from the computer so the USB was waking up when "FullDuplexSerialPluse" tried to talk to the computer, thanks Rayman! So it looked like I was doing two things wrong the "FullDuplexSerialPluse" was waking up the USB and causing the board to reset and the light needed to be carefully aimed because it was dim.
@JasonDorie I like your "edit reason", but who can blam you? How can you read carefully when you have a bird attacking your eye? But seriously, I'm planning on either using a smaller resistor or an amplifier. Thanks!