Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

IR remote using PIC microcontroller

Status
Not open for further replies.

wolf12

Advanced Member level 4
Joined
Mar 31, 2011
Messages
109
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
2,102
Im doing a project which requires a infrared module that will work for a continous 38kHz signal, the problem is its hard to find such IR module and i got only tsop 1538, which reduces its gain when continuous 38 kHz signal recieved. Since i cant find any other IR module Im thinking to send bursts. I only need 1 switch(when it recieves the signal turn on and when it doesnt, turn off). So whats the suitable pic microcontroller for this (for both Rx and Tx sides)? Also, please give me example code for this in assembly language or C. It would be easy for me if you give an example code for 16F84A.

Tsop 1538
http://www.datasheetcatalog.org/datasheets/2300/300987_DS.pdf
 

jpanhalt

Advanced Member level 3
Joined
Jun 28, 2010
Messages
724
Helped
216
Reputation
442
Reaction score
219
Trophy points
1,323
Activity points
6,964
Can you provide a little more information about the project? Why does it require a continuous 38 KHz signal? If it is continuous, how will you transmit any information?

John
 

hemanteda

Member level 1
Joined
May 5, 2011
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,550
I think you can use any PIC with a built in PWM (16f84 doesnt have). Use the PWM to send out 38Khz bursts and the INT0 interrupt for input side... just a thought
 

wolf12

Advanced Member level 4
Joined
Mar 31, 2011
Messages
109
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
2,102
Can you provide a little more information about the project? Why does it require a continuous 38 KHz signal? If it is continuous, how will you transmit any information?

John
No I dont need to transmit any information, I just want a remote switch, which turns ON if it recieves the signal, and should turn OFF if it doesnt recieve the signal, when using continuous signal tsop 1538 reduces its gain. So im thinking to send bursts. But i dont know how to.
 

jpanhalt

Advanced Member level 3
Joined
Jun 28, 2010
Messages
724
Helped
216
Reputation
442
Reaction score
219
Trophy points
1,323
Activity points
6,964
The bursts at 38KHz are extremely helpful in eliminating interferences, and there are a lot of them. I consider a command to turn on or off information. It is really quite easy to do with a microcontroller or even with two 555's.

I used a 12F508/509 to detect (on or off) position of a lever. I can provide the assembly code for that, if you want to go in that direction. It was modeled after a more complicated robotic application described here:
Robotics Projects

Scroll to the 12C508 project. There are also useful links therein to the Dallas robotics (DPRG) group.

John
 

ard

Full Member level 5
Joined
May 3, 2009
Messages
252
Helped
52
Reputation
104
Reaction score
50
Trophy points
1,308
Location
Mumbai, India
Activity points
2,783
Since you arent interested in transmitting any real information, I think John's idea of 2 555s (or a 556) is an excellent one; Wire up one 555 to oscillate at around 100hz, and use the output to control the 2nd 555 oscillating at 38khz. At the output of your TSOP, you should get your original 100hz signal; use this to drive a 555 monoshot to get a steady output depending on the presence/absence of the IR stream.

Regards,

Anand Dhuru
 

jpanhalt

Advanced Member level 3
Joined
Jun 28, 2010
Messages
724
Helped
216
Reputation
442
Reaction score
219
Trophy points
1,323
Activity points
6,964
@ard, Since you mention it, here is an LM556-based circuit for proper pulsing of a 38 KHz IR carrier. The component values shown gave decent timing on a breadboard. Wolf12 mentions using 16F84A, so I assume he has the ability to program that chip. The microcontroller version I mentioned was really my first project after blinking LED's with a PIC. When I realized how easy it was to use 12F508/509, I just never built the 556 version on a PCB.

John

IRED osillator.png
 

ard

Full Member level 5
Joined
May 3, 2009
Messages
252
Helped
52
Reputation
104
Reaction score
50
Trophy points
1,308
Location
Mumbai, India
Activity points
2,783
Absolutely, I agree; if using a microcontroller is an option, the smallest of PICs would do a wonderful job with virtually no extra components required.

Anand
 

wolf12

Advanced Member level 4
Joined
Mar 31, 2011
Messages
109
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
2,102
@ard, Since you mention it, here is an LM556-based circuit for proper pulsing of a 38 KHz IR carrier. The component values shown gave decent timing on a breadboard. Wolf12 mentions using 16F84A, so I assume he has the ability to program that chip. The microcontroller version I mentioned was really my first project after blinking LED's with a PIC. When I realized how easy it was to use 12F508/509, I just never built the 556 version on a PCB.

John

View attachment 56127
Sorry i tried to understand your code, but its way to complicated for my little knowledge, cant i send bursts and recieve bursts, since the signal should be 38kHz so i should 1 cycle should take 26uS right? beyond that i dont know, should i send few cycles then make a delay? how to program that?
And if i do it that way, cant i make the reciever to look for the 1st burst it gets and wait till its over and then, wait a delay corresponding to the delay between 2 bursts, then again look for the next burst ?
 

jpanhalt

Advanced Member level 3
Joined
Jun 28, 2010
Messages
724
Helped
216
Reputation
442
Reaction score
219
Trophy points
1,323
Activity points
6,964
The code in the link includes an error-correction algorithm. Basically, it monitors "hits" during the spaces when the burst is off. It then subtracts those "false" hits from the hits when the burst is on. It also uses a left and right sensor for directionality. I incorporated the error correction in my code, which I haven't posted yet. The device I wrote if for works well in a variety of lighting conditions, from bright sunlight to indoors.

That said, I don't think it is really needed for a single emitter/detector system.

In answer to your question, yes. The receiver can - should - look at bursts. I would require detection of at least 2 or 3 bursts to call it "on". That would probably be sufficient to avoid false signals. The waits can simply be done with a counter loop. My code was very crude. I didn't use any timers or interrupts. I just used polling, loops, and counted cycles.

John
 

wolf12

Advanced Member level 4
Joined
Mar 31, 2011
Messages
109
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
2,102
The code in the link includes an error-correction algorithm. Basically, it monitors "hits" during the spaces when the burst is off. It then subtracts those "false" hits from the hits when the burst is on. It also uses a left and right sensor for directionality. I incorporated the error correction in my code, which I haven't posted yet. The device I wrote if for works well in a variety of lighting conditions, from bright sunlight to indoors.

That said, I don't think it is really needed for a single emitter/detector system.

In answer to your question, yes. The receiver can - should - look at bursts. I would require detection of at least 2 or 3 bursts to call it "on". That would probably be sufficient to avoid false signals. The waits can simply be done with a counter loop. My code was very crude. I didn't use any timers or interrupts. I just used polling, loops, and counted cycles.

John
Ok basically what your code doing is, considering just 1 sensor output on an input pin, using three btfsc and three btfss commands you increment two counters, one for missed hits, one for hits, then you subtract missed hits from hits, then if the carry bit is 0, its a hit right?
I have a problem here, what is the maximum number any of this counters allow? 255?

2nd problem,
How do you generate 38kHz bursts?

Sorry im confused. Thanks alot for the help!
 

wolf12

Advanced Member level 4
Joined
Mar 31, 2011
Messages
109
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
2,102
@Wolf12 :
U don't need a controller for controlling just one switch.
Here is the simplest circuit for that :

•••> Electronics in DAM's way: IR remote controlled switch
yeah, my project is a infrared pathfinder, the problem i faced making it was tsop1538 reduces its gain for continous 38kHz, thats why i mentioned about it as a single switch to keep the question simple, if you explain me how to generate 38kHz bursts with a microcontroller and how to recieve it (programming part) my problem will be solved. I also made the continous 38kHz transmitter without a microcontroller, since i cant get more than 1 meter distance im trying to use a 16f84 for the transmitter too.
 

jpanhalt

Advanced Member level 3
Joined
Jun 28, 2010
Messages
724
Helped
216
Reputation
442
Reaction score
219
Trophy points
1,323
Activity points
6,964
Hi Wolf12,

I am afraid I may have confused you. As I understand your project, you do not want the IR detector and IR emitter to be electrically connected. My project used reflected light. The IR emitter and IR detector were on the same PCB. Nevertheless, I felt the principle and coding I used could serve at least as a guide. The link I provided was the model I based my code on. It is not my code.

I am attaching a zipped file that contains the schematic and board (Eagle) for what I did. I know yours will be different, but it might help to have the schematic to understand my code. The board was for development, and I was not sure of where the IRED should be placed, so I designed it for 3 possible placements. Eventually, I found the best location and used only that one.

Now for the code. I guess .asm files are not valid for uploading here, so I changed the extension to .txt. Just change the txt back to asm, and it should work. If it doesn't, I will zip and repost it. I didn't want to take up a lot of space here and post it as code. Besides, it is pretty crude and embarrassing. As mentioned above, it was my very first attempt after blinking an LED.

Now, I did use error correction based on the link I gave earlier. I do not think that is needed. The code will show you how to generate the pulse bursts and what to do with the received signal. This was all done about 5 years ago and my memory is pretty faded about the details. I will try to help, if I can, but no guarantees. Most important, if someone wants to jump in and provide better or cleaned up code, my feelings won't be hurt at all. I would welcome it.

John
 

Attachments


mehtadhaval

Member level 3
Joined
Sep 15, 2010
Messages
56
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,288
Activity points
1,616
@ Wolf12
If you want to generate 38khz bursts, then you shuold make a 555 based 38khz generator (which you have already made) and then give PWM or any GPIO pin of controller to the Reset pin of the 555 IC. This way, when you make the pin Logic High, it will transmit 38khz IR rays and when it is logic low, it will not transmit anything. So, if you write routine for PWM controllling, u can easily generate IR bursts.

And for detecting IR bursts, you have to make some logic that you have to sample the IR receiver pin at predetermined instants and according to that, you can know whether the IR rays are received or not.
 

BradtheRad

Super Moderator
Staff member
Joined
Apr 1, 2011
Messages
13,885
Helped
2,755
Reputation
5,507
Reaction score
2,663
Trophy points
1,393
Location
Minneapolis, Minnesota, USA
Activity points
103,603
I haven't see a tv remote control suggested here.
VCR, DVD, etc. These put out 40 kHz IR pulses last I heard.

Could be handy for experimentation. Is it important to use 38 kHz?

Years ago I purchased an IR detector module from Radio Shack.
It was more than a diode. It could filter out interference, the whole works.
Three wires. Two go to supply. The third goes hi for a moment when 40 kHz is detected. Low when not.

I found it responded to my audio receiver's IR remote control.
It could operate across the room.
Pressing any button caused a response from the IR module.
 

mehtadhaval

Member level 3
Joined
Sep 15, 2010
Messages
56
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,288
Activity points
1,616
I haven't see a tv remote control suggested here.
VCR, DVD, etc. These put out 40 kHz IR pulses last I heard.
You can use TV remote to generate pulses, but since you don't know the pattern of each and every remote control, it is difficult to know when the IR ray is reflected and received. SO, it is easy to use a simple burst created by the PWM generator.

It was more than a diode. It could filter out interference, the whole works.
Three wires. Two go to supply. The third goes hi for a moment when 40 kHz is detected. Low when not.
It is "THE TSOP1578 / TSOP1738 "
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top