Tutorial on IR for 28X1?

PTTG

New Member
Hi, I'm looking to get two Picaxe 28x1s to send text back and forth via sony ir codes, but I've run into a snag getting signals to move back and forth. Does anyone have a reference for setting these guys up?

My code as it is:
TRANSMITTER:
Code:
Main:
	irout 1,1,65
	goto main
RECEIVER:
Code:
Main:
	debug
	irin [500,Main],0,b0
	goto main
I have a larger program that has a the input and LCD blocks, but I'm testing transmission with this.

I have a pair of "TSOP18 IR Receiver chips" that as far as I can tell are wired correctly with the nessicary circuit and connect to hardware pin 11, (in 0). My transmitters are using some standard Radio Shack IR diodes with a 270 ohm CLR off of hardware pin 22 (out 1). (H pin 23 (out 0) is connected to my LCD)

In case it matters, I'm using protoboards and a 5V power supply, though the end product will use batteries. The finial version will also be able to switch between modes as well, but this is not going to be implemented in this test.
Thanks for any help you can provide!

EDIT:
Just for fun, the rest of the code, in case anyone is curious. As I said above, other than an address change, this should be using the same transceiver code.

Code:
;Piotr Cymbalski - IR Tranciever 2009 - Ver. 5

Init:
	setfreq m8
	calibfreq 0
	pause 5000
;	serout 0,T9600_8,(254,0x01)			;Fixes the screen- sets it back to default. Find that code
	serout 0,T9600_8,(254,0x01)			;Blank the screen
	symbol CurChar = b0				;The current dial-selected Char
	symbol RecChar = b1				;The last Char recieved over IR
	symbol Outlength = b2				;This stores the number of chars in the outbox
	symbol Inlength = b3				;Stores the number of chars recieved
	CurChar = 95					;Avoids random char on LCD
	RecChar = 95					;Displays a space by default

Main:								;Comment out lines to disable sections. Code will not work with all enabled
	gosub GetCurrentChar
	gosub DisplayLCD
;	if pinX = 1 then gosub SendChar		;This will enable switching between send/rec
;	if pinX = 0 then gosub ReceveChar
;	gosub SendChar					;This line will be obsolete when SendRec is setup.
	gosub ReceveChar
;	gosub TypeChar
;	Debug
	goto Main
	
GetCurrentChar:						;Surprisingly, POT more complex than LCD
	readadc 1, CurChar				;Raw value
	CurChar = CurChar/8				;only 90 of the 256 values are used
	CurChar = CurChar+65				;adjusts for position of "A"
	If CurChar>90 Then gosub space		;Space key is 95; "Z" is 90. "A" is 65
	return

space:							;Does this need a separate line?
	CurChar = 95
	return
	
DisplayLCD:
	serout 0,T9600_8,(254,0x01)			;Blank the screen
	serout 0,T9600_8,(RecChar,CurChar)		;Print Recived charicter
	pause 500						;Avoids strobe
	return

;TypeChar:
;	Return

SendChar:
	irout 1,1,CurChar
	return

ReceveChar:
	irin [500,Main],0,RecChar
	return
 
Last edited:

westaust55

Moderator
Welcome to the PICAXE forum.

Cannot say I have seen a tutorial for IR comms. Only the information in PICAXE Manual 2.

I cannot see any problem with your test code.

What is the wavelength of the IR LED's you purchased form Radio Shack? :confused:

The TSOP18 have an optimum wavelength around 940-950 nm

hippy does have some IR related information (but not using the latest available commands) at:
http://www.hippy.freeserve.co.uk/picaxeir.htm
 
Last edited:

demonicpicaxeguy

Senior Member
from all the times i ever had to anything with Ir it is usaully best to keep the whole setup away from direct and relatively indirect sunlight at least until you get it working
 

hippy

Ex-Staff (retired)
It may be worth simplifying your test code and adjusting your timing -

TRANSMITTER:
Code:
Main:
	irout 1,1,65
        [b]pause 1000[/b]
	goto main
RECEIVER:
Code:
Main:
	debug
	[b]irin 0,b0[/b]
	goto main
 

PTTG

New Member
Thanks, Hippy, I've tried your changes. Unfortunately I'm getting the same behavior.

The Transmitter seems to be working; I can swap my IR for a LED and it pulses regularly.

The receiver is about 3 inches away and hangs forever.
 

westaust55

Moderator
Is the Radio Shack IR LED part No Model: 276-143? :confused:
If so, that is 940nm wavelength, so we can rule that out as well.
 

PTTG

New Member
Well, I've been toying with this all day, and no luck. I hope I can get something working tomorrow, because otherwise... there goes this class...
 

inglewoodpete

Senior Member
There are a couple of things you can test:

* Is the IR LED actually flashing? Use the digital viewfinder in a camera to check. If nothing, check the camera with another remote control (eg from your TV)

* Is the receiver receiving anything? Add an ordinary LED + resistor to an output (lets say O/P 1). Then change the receiver code to something like:

Code:
Main:  Do: Loop Until pin0 = 0  'Wait for any IR signal
       PulsOut 1, 1000          'Indicate that modulated IR has been received
       Goto Main
 

Technical

Technical Support
Staff member
IR LEDs are very current hungry, some only work well with a transistor buffer to increase the current capability. As suggested, look through a digital camera or mobile phone camera to see if you are getting a bright IR light.
 

wilf_nv

Senior Member
Are you are using a TSOP1838? It is the version that is compatible with the 28x1 IROUT signal 38kHz carrier frequency.
 
Top