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.

PIC IR coding

Status
Not open for further replies.

timothyjackson

New Member
Just popping my head out of a PIC beginners book.

Any body have any links/advice/references to IR coding with a pic.

In essence, I'll aim to have;

10 buttons as 1 unit
An led matrix 2 metres away.

each one of the ten buttons lights up a section of the led matrix.

Looking forward to a little guidance.

Many thanks

Timbo :D
 
timothyjackson said:
Just popping my head out of a PIC beginners book.

Any body have any links/advice/references to IR coding with a pic.

In essence, I'll aim to have;

10 buttons as 1 unit
An led matrix 2 metres away.

each one of the ten buttons lights up a section of the led matrix.

Looking forward to a little guidance.

Many thanks

Timbo :D
i am sorry ? where does the Infrared come in??
using Infrared LEDs??
 
WillB, he wants to be able to push a button on one device, most likely a TV remote control with numbers 0-9, that will transmit an IR signal to some receiver. The IR receiver connected to a PIC will pick up the signal, and display different patterns on the LED matrix based upon the IR signal it received.
 
ok so the main problem as i see it is to get the signal into the pic .. one way is to use a radio shack IR Reciever ( i believe panasonic makes it)
the output of the device is an analog signal , which can be input to the PIC
on the A/D Pin..
 
apologies for the confusion.

Despite little (but growing knowledge) im aware that the set up will be as follows:

10 buttons, as input to a PIC. Each button, when pressed individually should activate the PIC to send a coded IR signal (using an IR LED).

This coded IR signal is subsequently recieved by the LED matrix, again, the PIC matching the coded IR signal as an input, and its output being the illumination of a pattern on the led matrix.

This is where im stumped (even at this conceptual level):
- How can the transmitted IR signal be coded (simply)....how...is it by timing a series of high and low points.. (1's and 0's)..?

How does the recieving PIC actually match a coded signal?...It should have the flexibility to match upto 10 coded signals...I can't get my head round how it constantly searches for the right coded signal....

Many Thanks..

Timbo
 
you seem to be mixing functions..
This coded IR signal is subsequently recieved by the LED matrix, again, the PIC matching the coded IR signal as an input, and its output being the illumination of a pattern on the led matrix.
the IR signal would be recieved by a special IR Reciever 'LED looking' device..
which would then transfer the signal to the recieving PIC to be decoded..
 
You must filter out low freq infrared light, which may be 1000 times more intense than your signal. Basically, sunlight, etc. Noise filtering is a bit tricky. I hear those Radio Shack receiver modules do a great implementation of noise filtering and signal conditioning.
 
you could do it using regular serial. a lot of PICs have built in USART which makes sending serial data very very easy. to transmit, you load the value into a register and set a transmit bit and it does the rest. to receive, it will set a flag when it has received a byte.

you can hook up a 40kHz oscillator (a simple 555 timer circuit will do, easy to find a schematic for that) to an IR LED, and use one of the radio shack sharp IR receivers to handle the decoding of the 40kHz IR. Then hook the output to the receive pin of the other pic.

probably the easiest way to do that is to try it without the IR stuff in the middle until you get the serial communication working... in other words, wire the transmit pin of one to the receive pin of the other. That will make debugging much easier since you won't have to worry about whether the IR stuff is working in case you have issues with the serial communication. there are TONS of examples of serial communication code all over the 'net that you can use to get that working. Once that works then it's literally a matter of just removing the wire and putting the IR stuff in its place.
 
There's plenty of information in my PIC tutorials about IR remote control, including all the hardware and software required to implement the Sony SIRC's remote control scheme for both transmitt and receive.

Also, in my keypad tutorial, I add a 16 button HEX keypad to create a 16 button Sony remote control transmitter.

As for suggestions of simply sending standard RS232 type serial data directly over an IR link, this isn't practical or reliable enough.
 
I really am open to a few macro explanations really, in terms of general functions. (I'm really new to PIC's & electronics)

i had alot at (Nigel the PIC god's) tutorial. A little too complicated at this stage. I'm unsure which of the 3 tutorials of the (TV remote) is the reciever? I know which one is the transmitter, and have printed it off to study the code.

As far as the transmitter, I gather that on a general level:

- Assign 10 buttons to 10 inputs
- When 1 of the buttons is pressed, it calls a coded "routine", and puts it into the output (IR led)
- 10 coded signals can be saved in the memory of the PIC, each 1 of the ten buttons would call the relevant coded delay message to the IR output.
- I think Im cool on the coded IR, basically a series of timed high's and lows, all on a 38MHz frequency?

This is what i DON'T generally understand - and... i WANT to.

- How does the PIC "read" a coded message,
- I assume that the PIC will start off by constantly "looking" to see if an ir signal is recieved?
- I assume that the coded signals will be saved in individual registers?
- I assume that, the PIC might somehow save a coded IR signal recieved by the reciever in a Register,,, and compare is with the "saved" coded messages... when it finds a match, a certain output is produced (certain LED pattern illumination).

????
:?
 
timothyjackson said:
This is what i DON'T generally understand - and... i WANT to.

- How does the PIC "read" a coded message,
- I assume that the PIC will start off by constantly "looking" to see if an ir signal is recieved?
- I assume that the coded signals will be saved in individual registers?
- I assume that, the PIC might somehow save a coded IR signal recieved by the reciever in a Register,,, and compare is with the "saved" coded messages... when it finds a match, a certain output is produced (certain LED pattern illumination).

Tutorials 5.1 and 5.3 are both receivers, 5.1 displays the codes received on an LCD, but 5.3 checks for received codes and turns LED's on accordingly (pretty well what you are after). The routine 'ProcKeys' checks which key press was received, also at it's beginning it checks for the device ID - in this case the TV ID code.
 
Nigel Goodwin said:
Tutorials 5.1 and 5.3 are both receivers, 5.1 displays the codes received on an LCD, but 5.3 checks for received codes and turns LED's on accordingly (pretty well what you are after). The routine 'ProcKeys' checks which key press was received, also at it's beginning it checks for the device ID - in this case the TV ID code.

Which one is the transmitter?/? :?

i've also been looking around for PIC's. In general terms, how much do they cost in bulk? Can they be purchased in SMT form?

Nigel, thanks.

timbo
 
your best bet for PICs, as long as you don't need huge quantities, is going to be free samples from microchip. they will let you order up to 15 PICs per sample order (maximum of 3 each of 5 different part numbers), and allow you 2 orders per month. That's about 1 PIC per day, if you think about it. For the average experimenter that should be a MORE than ample supply of PICs. not to mention, they will get them to you very quickly; I often get them within a week, which isn't bad considering they usually ship from somewhere in asia, and they are FREE.

and yes, they come in SMT form. Depending on the particular PIC you can get everything from DIP, to SOIC, to TSSOP, DFN, etc.
 
timothyjackson said:
Nigel Goodwin said:
Tutorials 5.1 and 5.3 are both receivers, 5.1 displays the codes received on an LCD, but 5.3 checks for received codes and turns LED's on accordingly (pretty well what you are after). The routine 'ProcKeys' checks which key press was received, also at it's beginning it checks for the device ID - in this case the TV ID code.

Which one is the transmitter?/? :?

Tutorial 5.2, there's also a version with 16 channels in the hex keypad tutorials.
 
evandude said:
your best bet for PICs, as long as you don't need huge quantities, is going to be free samples from microchip. they will let you order up to 15 PICs per sample order (maximum of 3 each of 5 different part numbers), and allow you 2 orders per month. That's about 1 PIC per day, if you think about it. For the average experimenter that should be a MORE than ample supply of PICs. not to mention, they will get them to you very quickly; I often get them within a week, which isn't bad considering they usually ship from somewhere in asia, and they are FREE.
DUDE! And I've been buying them all this time! :shock:

I figured a free sample was 1, so I've just been ordering all my parts.
 
I am guessing that the OP wants to build a pic based IR transmitter ala IRMAN, etc. Most remotes are 36-40kHz, though I have found that a system designed for 40 seems to work fine at 38, so there is some tolerance.

My suggestion is to use a PIC output to drive an IR led directly (or use a transistor for more power). The period of a 38kHz pulse is 26.3us. So in that time you need to turn the led on and off (the presence of the 38kHz represents one value to the receiver, while the absence is the other value). A 6Mhz system clock gives a good approximation for the on and off time. So you basically setup a counter with a value X, when X hits 0, the LED is toggled, you reload the counter with a new value and repeat. The value will represent how long the led is on or off which is how most IR systems are coded. A long on pulse followed by a short space is a 1 or something along those lines. That way the receiver has both high and low signals to sync to even if the bit pattern were all 1s.

I've built learning receivers this way and generic decoder algorithms for IR. I have one of them in a project that is just now going to final test before production.
 
Crust

Thanks for the explanation- this approach is really what I need (i.e. taught) - Still working through the PIC beginners book, and will refer to your explanations, and nigel's coding very soon.

rgds

Timbo
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top