IR question

Status
Not open for further replies.

psecody

Member
Well I finally got some time to work on pics and I was going back to my plan of an IR switch...I've decided for the first switch I just want to make it turn on when it gets any IR signal from any remote (not be specific...yet) and I was wondering besides making the IR module trigger a transistor which throws a pin on the pic high is there anything else I'm missing? I'm just thinking since the IR is modulated the signal coming off it is modulated so in the pics program could I just write the main switching into the interrupt so that only the first pulse triggered it then it went through a delay before reseting to the rest of the program? Thanks
 
I can't belive I'm saying this, but a simple 38KHz IR detector and a one shot would do the trick. IR detectors strip out the 38KHz carrier, but they false trigger LOTS especially with fluorescent lamps nearby.
And yes a PIC can do this and would be able to detect false triggers.

Check out the Projects section of my site for a very primitive example of IR detecting with a PIC. (The Firefly has a typical IR sensor, the manual has the schematic)
 
Last edited:
So let me just post the schematic of what I think your saying and see if my idea will work. Ok the pic below is what I think you were talking about. What I had in mind was that once the first flash of IR signal from the remote was recieved the pic would go into an interupt and change a variable then delay a few milli seconds so that it wouldn't recieve anymore of the signal sent by that one button press. Then once it delays alittle then go back to the actual program and change the state of the pin due to the variable change.

Would this work? In my mind I think it would but physically building it I haven't got a clue and at the moment I have no perf board to mess around with, I gotta go pic some up sometime. I just like to have a plan before I buy stuff because I go into radio shack with like a list of $5 worth of stuff and somehow always come out with at least $100 worth of bits and pieces because I didn't have something and wanted to buy it just in case haha.

Also would this code essentially work for what I'm wanting to do?

Code:
LIST P=16F877A
#INCLUDE <P16F877A.INC>
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & PWRTE_ON & _HS_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF

           ORG 0x00
COUNT1 EQU 0x20
COUNT2 EQU 0x21
           GOTO MAIN

            ORG 0x04
            BTFSS PORTC, 0
            GOTO BIT_CLR
            MOVLW 0x00
            MOVWF PORTC
            BCF INTCON, 1
            RETFIE
BIT_CLR MOVLW 0x01
            MOVWF PORTC, 0
            BCF INTCON, 1
            RETFIE

MAIN     BSF STATUS, RP0
            MOVLW 0x00
            MOVWF TRISB
            MOVLW 0x00
            MOVWF TRISC
            BCF STATUS, RP0

            BSF INTCON, 7
            BSF INTCON, 4
            BCF INTCON, 1

            MOVLW 0x00
            MOVWF PORTB

START   CALL DELAY
            GOTO START

DELAY   DECFSZ COUNT1, 1
           GOTO DELAY
           DECFSZ COUNT2, 1
           GOTO DELAY
           RETURN

           END

I know your probably not generally supposed to do all that stuff in the interupt but it seemed easier to do in the interupt than to just change a variable then have to come out of the interupt and check it.
 

Attachments

  • Picture 2.png
    8.6 KB · Views: 143
Last edited:
Don't underestimate the problem of false triggers as pointed out by blueroomelectronics.

Since you anticipate using a PIC, here is a site that shows one way to correct for false signals.

http://users.frii.com/dlc/robotics/projects/botproj.htm

Scroll to the 12C508 project. There are also useful links therein to the Dallas group.

I can add my personal experience to that and say the approach works quite well. I recently posted a modified code on this site. Here's the link:

https://www.electro-tech-online.com...etection-using-tsop1738-with-pic16f628.30480/

John
 
Last edited:
psecody said:
MOVWF PORTC, 0
What is this?

Also you told that you are making a universal remote control circuit switch which means when you press the Remote, the output will go high due to delay in the main loop it will stop incoming IR signals but after delay finished if you still press & hold the Remote button the output will again make high repeats over & over. If you add long delay the switching speed will drop tone time this was happened to me also.
 
PORTC is the output..... no it will only delay long enough in the interupt to block out the rest of the signal coming from that one button press so that you don't get the lights turning on with the first part of the signal then turning off again once the interupt is over and the same signal is still sending. Also the code does a bit test on the output pin and if it is high then it kicks it low, if its low then it makes it go high. The delay in the main loop accomplishes nothing but to give the processor to do while its waiting for an interupt to occur.

thanks for the links jpanhalt that gave me some good ideas...I also found the whisker switch interesting as me and my friend are building a robot and we needed so simple sensors..
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…