Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Simple IR Transmitter Code

Status
Not open for further replies.

GatorGnet

New Member
I am looking for the simplest asm code for a 16F628A that sends a single character through an IR emitter to be received by an equally simple receiver.

The emitter would be connected to an output of the PIC and would transmit the data when a user presses a button. As I stated, I only want to transmit a single character.

I also need a simple code example for the receiver. I want it to wait for the IR signal and if that certain character is received, it will call a function in the PIC. When I get that working, I want to add other call functions when other characters are received.

I have a basic understanding of asm but I keep finding too many examples of over complicated code. Any help would be great.

Also, would it be best to connect the emitter directly to the PIC or use a transistor?
 
Wow 1 min response. Thank you Nigel. I went over yours and as always will be using it too. Just wanted to get more ideas.
 
Nigel code is is by far easiest to use you can brake it down to do what you want
 
Here is the easiest IR Protocol by far:

SB-Projects: IR remote control: SIRC protocol

Which was why I chose SIRC's for my tutorial, plus Sony remotes are commonplace.

The transmitter is the simplest thing to make. Its the receiver that will cause you headaches. heh

Again, that's why I chose SIRC's, it's easy to receive.

Ill see if tomorrow i can recreate Nigels code and see exactly how it works. i wish there was a flow chart for things like this :D

I've never used flowcharts, I've never seen the use of them?.
 
Flow charts are great. In every LCDs datasheet you can see one for the initialization.

Its nice to know all the steps needed in a easy english/code mix. Its better than seeing just code and comments because its large blocks and you can see the actual movement of data. I use it because i have a bad memory and seem to forget everything i do. :D

Its really a priceless solution.
 
Nigel,

I have a few questions about your 5.2 tutorial:


Can these values be anything you want to send?

Code:
But1		Equ	0x00			;numeric button ID's
But2		Equ	0x01
But3		Equ	0x02
But4		Equ	0x03
But5		Equ	0x04
But6		Equ	0x05
But7		Equ	0x06
But8		Equ	0x07
But9		Equ	0x08
ProgUp		Equ	d'16'
ProgDn		Equ	d'17'
VolUp		Equ	d'18'
VolDn		Equ	d'19'

Eg.

Code:
Mkupsmthing        Equ   d'##'

Can the ##'s be anything you want?

Code:
TX_Start	movlw	d'92'
		call	        IR_pulse
		movlw	d'23'
		call	        NO_pulse
		retlw	        0x00

Also, what are the d'92' and d'23' used for?
 
Nigel,

I have a few questions about your 5.2 tutorial:


Can these values be anything you want to send?
Can the ##'s be anything you want?

Yes, bearing in mind the limitations of the number of bits - although you could easily make the word length longer, but it wouldn't be correct for Sony gear then.

Code:
TX_Start	movlw	d'92'
		call	        IR_pulse
		movlw	d'23'
		call	        NO_pulse
		retlw	        0x00

Also, what are the d'92' and d'23' used for?

It's the number of IR pulses (or not pulses) that are sent.

So the start pulse is 92 IR pulses long, followed by a space the same length as 23 pulses.
 
Yes, bearing in mind the limitations of the number of bits - although you could easily make the word length longer, but it wouldn't be correct for Sony gear then.

Not too worried about Sony gear. This project will have it's own receiver build by us to accept what we tell it.


It's the number of IR pulses (or not pulses) that are sent.

So the start pulse is 92 IR pulses long, followed by a space the same length as 23 pulses.


Is this another necessity for Sony?
 
It will work just wire it up right. for the IR module your going to use. Any that works from 36 to 40khz works fine
 
A little off topic but would this **broken link removed** be an OK test utility to test this type of transmitter?
 
Last edited:
It should work it can read the data you send it. good find even if it don't make on for the cp any lol
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top