IR-receiver with two legs

Pekari

Senior Member
How I connect to Picaxe 08M a IR-receiver which have only two leg?
Can I use that kind of component with Picaxe?
I want to do a IR-receiver which read a pulse and show a code.
 

ylp88

Senior Member
Can you provide us with some information about the device you have? A link to a product page? A model number? Even a photo?

I assume that it is not just a photo-diode as these have two legs, but won't do the job - they won't demodulate the 38kHz carrier from the IR signal.

ylp88
 

Pekari

Senior Member
That's right. Maybe it is a photo diode.

So I can't use it to read a pulse because Picaxe is too slow to read a pulse.

I have to make a automatically photo taker and I need to adjust a exposure before that, so I need to read a pulse first.

Can I use a Canon camera with Picaxe?
 

hippy

Ex-Staff (retired)
An IR photo-diode can detect an IR pulse. It would be possible to extend a pulse to be long enough that a PICAXE can handle. A PICAXE can also display a code.

Whether you can do all you're trying to do with a PICAXE would depend on exactly what it is you are trying to do and how.
 

Pekari

Senior Member
I try to do a pulse time saver.
This is what I do:
Code:
'	IR-pulse time saver.
'	Made by Pekari 10.10.2008.
#picaxe 08m
setfreq m4
	pause 1000
	serout 1,N2400,(0)
	pause 500
setfreq m8
main:
b1=0
b2=1
readadc 2,b0
if b0>99 then main
pulse:
b2=b2+1
readadc 2,b0
if b0<100 and b2<255  then pulse
write b1,b2
b1=b1+1
if b1>100 or b2=255 then show
b2=0
space:
b2=b2+1
readadc 2,b0
if b0>99 and b2<255 then space
write b1,b2
b1=b1+1
if b1>100 or b2=255 then show
goto pulse
show:
	setfreq m4
	serout 1,N2400,(254,128,"Length=",#b1,"   ")
	pause 4000
	for b3 = 0 to b1
	read b3,b0
	serout 1,N2400,(254,128,"Data=",#b3," = ",#b0,"  ")
	pause 1000
	next
goto main
It show me what time pulse is up and down and quantity of pulse.
Time is what it is.
I have try this with remote control and it show every time a different times, so Picaxe is too slow to get all data like this.

Circuit:
Pin 2:5,1 k ohm resistor to +.
Pin 2: photo diode to -.
Pin 1:AXE033 LCD (input).
 
Last edited:

hippy

Ex-Staff (retired)
I'll guess the main-pulse-space code is an attempt to time this pulse but it's a mistake to use READADC. I have no idea why WRITE is being used but that will make the code incredibly slow.

You will do better to use a circuit to allow the photodiode to be used with a digital input and use PULSIN to measure the pulse length. I've no idea on how to do that but Google can probably help.
 

Pekari

Senior Member
Thanks!
I get a data to more stable!
Which way is faster to save a times?
 
Last edited:

bgrabowski

Senior Member
Have you seen the recent thread on operating a Canon camera remotely using Picaxe? The title was "Controlling camera shutter using I.R. remote". The shutter code was established by using a piece of software that acted like a storage oscilloscope. This could be done for any other of the remotely controllable functions. If I were you I would try a similar technique.

What you are trying to do can be done but there is not time to store the readings as you are taking them. This means you have to keep them in w0,w1,w2,w3 etc which limits you to 6 readings at a time. The workaround is to build up the pulse readings by reading the signal say 16 times. On the first 8 runs through you read the pulse on a rising edge trigger, on the second 8 you read the pulse on a falling edge trigger. Start by reading w1,w2,w3,w4,w5 the first 5 pulses then store them in RAM. Then read w1,w2,w3,w4,w5,w1,w2,w3,w4,w5 that is overwriting the words so what you now have in w1-w5 are the second 5 pulses. Repeat this process as many times as you like to get the full data.

You will find it easier to press the button on the remote at the right time if you flash an LED connected to a spare output when the programme expects each pulse stream to start. This technique works with an 18X at 8 MHz but an 08M may not have enough code space.

After completing all the runs read the stored data back to an LCD or the PC screen.
 

Pekari

Senior Member
Now I get it to work.

Code:
'	IR-pulse time saver.
'	Made by Pekari 10.10.2008.
#picaxe 08m
pause 1000
serout 1,N2400,(0)
pause 500
w0=1
b13=1
main:
pulsin 2,0,w1
if w1=0 then main
pulsin 2,1,w2
pulsin 2,0,w3
b0=b0-1
if b0>0 then main
counter:
pulsin 2,1,w4
pulsin 2,0,w4
b13=b13+1
if w4>0 then counter
if b1=0 then serout 1,N2400,(254,128,"Quantity=",#b13,"  ")
pause 2000
endif
serout 1,N2400,(254,128,"Pulse=",#b1," = ",#w1,"  ")
b1=b1+1
pause 1000
serout 1,N2400,(254,128,"Space=",#b1," = ",#w2,"  ")
b1=b1+1
pause 1000
if w1>0 and w2>0 and w3>0 then
serout 1,N2400,(254,128,"Same again     ")
b0=b1/2
b0=b0+1
pause 500
else
serout 1,N2400,(254,128,"New code       ")
w0=1
pause 500
endif
goto main
First it shows quantity of pulse and then pulse and space length (*10 mS).
Next pulses have to read so many times than first time are indicated.

Now I have a problem to send this same pulse!

I ask this:
Will a Picaxe take a "pause" when it send a pulse?

Code:
pulsout 0,902
pulsout 1,48
pulsout 0,64
Will that program send this: pulse 9,02 mS+space 0,48 mS+pulse 0,64 mS to pin 0?
I haven't find a other way to hold such a short pause.:D
Now I have a problem to found that IR transfer diode!:(
 

bgrabowski

Senior Member
In my last posting in this thread I stated where you could find the programming technique for the solution of this problem. At least have a look at it!
 
Top