12 Channel Relay + 2 Channel Dimmer control by IR Remote and keyboard
16 bits for the address (address + inverse) require 27ms to transmit time .and the 16 bits for the command (command + inverse) also require 27ms to transmit time.
because (address + address inverse) or (command+command inverse) will always contain 8 ‘0’s and 8 ‘1’s so (8 * 1.125ms) + (8 * 2.25ms) == 27 ms .
according to this total time required to transmit the frame is (9ms +4.5ms +27ms+27ms) = 67.5 ms.
Extended NEC protocol (not used in this demonstration)
Repeat Codes
If the key on the remote controller is kept depressed, a repeat code will be issued, typically around 40ms after the pulse burst that signified the end of the message. A repeat code will continue to be sent out at 108ms intervals, until the key is finally released. The repeat code consists of the following, in order:
A 9ms leading pulse burst
A 2.25ms space
A 562.5µs pulse burst to mark the end of the space (and hence end of the transmitted repeat code).
the figures give blow show the timing of repeat codes
if user keeps the key depressed the repeat codes keep coming
Encoding NEC Protocol with microcontroller
As shown in the schematic and the pcb images this circuit use PIC12F615 as infrared encoder , the IR LED is driven by a separate npn transistor for longer range and the Coin cell Battery CR2032 is used to power the whole infrared remote. battery nominal voltage is 3.0V volts but as the datasheet says the PIC12F615 can work down to 2.0V.
for GP4,GP5,GP1,GP0 internal pullups are being used but the GP3 pullup can’t be used for GIPO as its is internally connected to MCLRE .
The current Consumption of the Circuit in sleep mode is around 35nA which is less then what datasheet claims. the CR2032 coin cell battery will last quite some time.
Hardware
Source Code
the Software utilize the internal PWM capability of the PIC12F615 to generate quite stable and accurate carrier frequency of 38Khz. most of the time Micro stay in the sleep mode ,even Brown out is enabled only when the wake mode to save battery. the current consumption is around 35nA when sleeping.
GitHub Repo.