Introduction: Infrared NEC Protocol Encoder and Decoder Board
Receives a raw modulated or demodulated NEC IR signal and converts it into bytes that are sent out the serial port. The serial baud rate is selectable from two default speeds. The default usage mode transmits out a command sequence with framing bytes, address high, address low, and the validated command byte. This device is designed to remove the work load of protocol decoding from the main processor, which could be a PIC, Arduino, FTDI, or other similar serial capable device. It supports full duplex communication when using an I.R. transceiver.
The output protocol was written to be easy to receive. The values 255 & 254 for byte framing followed by data bytes, the repeat codes are indicated by 250 & 253. None of those values would normally be in a NEC command sequence, or at least not in that order. Device expects the extended NEC Protocol, with 16-bit Address, rather than the specified 8-bit address with 8-bit inverse.This device accepts all addresses, and passes the received address to the host device.
The datasheet contains more information and details. Download The Datasheet
The project files can be downloaded as a ZIP from this step, or Visit GitHub to download.
Step 1: Parts and Tools
Parts: Some parts are not required for reception only usage.
- A limited amount of assembled device are available - NLEDshop.com
- Printed Circuit Board - Eagle Files Available in Projects Folder or GitHub
- PIC12F1572 or PIC12F1822/PIC12F1840(reception only)
- 38KHz Infra-red receiver such as TSOP38238 OR TFBS4711 transceiver.
- 1x 5mm Infrared LED suitable for I.R. transmission
- 2x 0.1uF 0805 SMD capacitor
- 2x 47ohm 0805 SMD resistor
- 1x NPN Transistor, SMD SOT-23 - BSR17A or similar
- Infrared remote control that uses the N.E.C. protocol - which is most cheap Chinese controllers - Find Some Here
- Electronics tools
- A way to reflow SMD boards - hot air gun, reflow oven, hotplate
Step 2: Assembly
Apply solder paste, place the parts, and reflow.
Reception Only Usage:
- Install a TSOP38238 or similar
- R1, R2, R3, and T1 are not required.
- Tie the CONFIG jumper to "PIN" or leave untied.
- Any of the compatible microcontrollers can be used.
Full Duplex / Bi-Directional Usage With Transceiver:
- Install a TFBS4711 or similar I.R. transceiver
- R2, R3, and T1 are not required.
- Tie the CONFIG jumper to "GND"
- Only the PIC12F1572 is compatible.
Full Duplex / Bi-Directional Usage With LED and Receiver:
- Install a TSOP38238 or similar
- Install a Infra-Red LED - 5mm domed or similar.
- R1 is not required.
- Tie the CONFIG jumper to "PIN" or leave untied Only the PIC12F1572 is compatible.
Remote Control: Most of the small cheap Chinese infrared controllers will work. They come in different shapes, sizes, and amount of keys. Used here is a 24-key remote, but remotes with more or fewer keys would work just the same.
Some custom decals were printed that are placed on the remote control with custom button graphics. This is not necassary but makes it a lot easier to use. The template for the 24-key(4x6 keys) is available.
Step 3: Firmware Details and Programming
The firmware is written in Assembly for the PIC12 series of processors. Assembly was required to achieve the required code efficiency using a relatively low powered(and cheap) microcontrollers. The project files include a MPLABX project and it utilizes the standard MPASM compiler.
As mentioned on step 1, this device simply reads the incoming NEC protocol based commands and converts them into standard 8-N-1 serial bytes that is easily readable by connected devices such as PICs, Arduninos, or other serial/COM based devices.
Pretty simple overall but complicated to look at. Both the modulated and demodulated signal is read and timed through interrupts. When complete command codes have been correctly received the firmware sets a flag for the received command codes to be converted into serial bytes and sent out the device's UART.
This device has two solder jumpers that can be used to define the devices usage. The BAUD jumper selects either slow or fast baud rate, which is set by default to 19,200 and 250,000. The firmware can be easily altered to use different baud rates. The CONFIG jumper is used to select if the device should expect to receive a modulated or demodulated signal. Both are described in more detail on the Data Sheet.
Step 4: Host Interface Details
The Host device can be anything with a TTL(3.3v or 5v) level serial port(UART). Anything like a FTDI, PIC, Arduino, ATMEL, etc can be used to interface with this device.
The project files has a TXT file with the example C code. While the code is written for XC16 and PIC24F processors, the syntax is fairly generic so porting to your language/compiler of choice should be trivial.
If you do write/modify the code for your own and would like to share it, message me and I will get it posted here.
Step 5: Completion and Usage
While this device was made to upgrade legacy NLED controllers for compatibility with infrared remotes. It could have many other uses with other devices, especially those that don't have the processing overhead to time and decode the NEC remote protocol. Receiving a string of serial bytes is fast and easy for most processors.
NLED controllers and software are in constantly improved and updated. Contact with any feature requests or bug reports.
Thanks for reading, please visit www.NLEDshop.com for Made In The USA LED Controllers and LED Products. Or find more projects that utilize NLED products on our Instructables Profile or the Projects Page on our website.
For news, updates, and product listings please visit www.northernlightselectronicdesign.com Please Contact Us with any questions, comments, or bug reports.
NLED is available for embedded programming, firmware design, hardware design, LED projects, product design, and consultation. Please Contact Us to discuss your project.
Participated in the