Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

How to attach IR Receiver to PIC12F683 ?

Status
Not open for further replies.

GrandAlf

Advanced Member level 2
Joined
Mar 9, 2002
Messages
520
Helped
47
Reputation
92
Reaction score
6
Trophy points
1,298
Location
UK
Activity points
4,730
I have a small project on 12F683 for PWM motor control using timer2 and output on GP2. Now this works fine, but I have a need to attach a IR receiver to read a few simple commands from a remote. Question is, I have GP0,1 and 5 available, can I use any of these pins as input from IR module along with timer1 and interrupts I presume. Will attempting to do this interfere with the PWM output timing? Do you think that this is the correct approach, if not any suggestions most welcome. Also appreciated any snippets of C code that may be useful. Still getting my head round this chip, usually using 16 or 18 devices. Many thanks.
 

IR Receiver can be interfaced with normal GPO, but better approach is interfaced to any interrupt pin( are you understand the interrupt pin means it is a hardware interrupt whenever external event (High or Low) the interrupt will be detected by the MCU) and this interrupt will not disturbed the PWM output timing. PWM timing is purely based on software interrupt.

---------- Post added at 12:17 ---------- Previous post was at 12:14 ----------

PWM in PIC is CCP(Capture ,compare and PWM ) module read the CCP module registers clearly . you can easily understand and C code snippets easily availble in the google or microchip websites.
 

Thanks for the reply. From reading the data sheet it appears that GP0 & GP1 supports interrupt on change, unless I have read it wrong.
 

GP0 and GP1 are used for serial programming (ICSP); GP5 is not. That may make a difference if you plan to use ICSP. Isolation techniques as described by Microchip can be used, of course, but it is simpler not to use those pins.

John
 

you can use any int0 or int1 like any interrupt pin is the best for IR Receiver interfacing.
 

From data sheet
An input change on GPIO change sets the GPIF
(INTCON<0>) bit. The interrupt can be enabled/
disabled by setting/clearing the GPIE (INTCON<3>)
bit. Plus, individual pins can be configured through the
IOC register.

Now it seems that only GP2 is the EXT-INT interrupt but its is also PWM output and I am already using this for that purpose so is not available for me.

What I am try to find out is can I use any other port with interrupt on change enabled along with a timer to read the data from from a IR receiver, or is it better to have a separate 12F683 for this and then use the proper int pin GP2.
 

Now it seems that only GP2 is the EXT-INT interrupt but its is also PWM output and I am already using this for that purpose so is not available for me.
What I am try to find out is can I use any other port with interrupt on change enabled along with a timer to read the data from from a IR receiver, or is it better to have a separate 12F683 for this and then use the proper int pin GP2.

Reference PIC12F683 Data Sheet, pg 32, 4.2.3 INTERRUPT-ON-CHANGE

Each of the GPIO pins is individually configurable as an
interrupt-on-change pin. Control bits IOCx enable or
disable the interrupt function for each pin. Refer to
Register 4-5. The interrupt-on-change is disabled on a
Power-on Reset.

For enabled interrupt-on-change pins, the values are
compared with the old value latched on the last read of
GPIO. The ‘mismatch’ outputs of the last read are OR’d
together to set the GPIO Change Interrupt Flag bit
(GPIF) in the INTCON register (Register 2-3).

The Interrupt On Change can be configure for any of the GPIO<5:0> pins of the PIC12F683 by setting the appropriate bits in the IOC register.

Another option in some scenarios is to the Analog Comparator Module to detect level changes, however the Interrupt On Change feature should suffice in this case.

BigDog
 

Yet another option, depending on the complexity of your code is to simply keep polling the IR module; the start of an IR sequence is usually long enough ( a couple ms), to be able to be detected. This way, you can use any pin, and your PWM need not get affected at all.

Regards,

Anand Dhuru
 

Thanks for the input guys,

I had initially thought of polling but considered it may not be reliable due to timing constraints. Essential will be just using 3-4 buttons on remote and dumping them into a variable. My thoughts where on using a different timer to the pwm one and setting up after masking, interrupt on change of state on GP0 say, then clearing the int after the complete word received. If that looks ok, I then need to read up on RC5 code and make some sense of it. I generally use CCS, so if anyone has any bits of working code it would certainly help things along.
 

Hi

I like use the GP3(MCLR pin) as Serial receiver , you may use the IOC feature as bigdog told you.

As example I Used this feature in a five channels serial servo controller at 19200bps and it works perfect. You should try the interrupt service instead polling,it's better and less complex than polling if you have other works to do.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top