Close

Firmware Details

A project log for IR Light Dimmer v2 (1kB Challenge edition)

Infra-red light dimmer (220V/110V) that sits behind a switch in the wall. Powers itself from the mains, uses triac to turn on the bulb.

traxtrax 01/02/2017 at 19:050 Comments

Firmware details

Firmware is written in Microchip Assembly and does not require any libraries. It can be compiled for two PIC microcontrollers: PIC12F629 and PIC12F675. If you compile for PIC12F675 the firmware will be 2 words larger because of additional registers that need to be initialized for this PIC.

50/60Hz choice

You can compile the code for 50 or 60Hz mains frequency. There is a constant in the code that you need to un/comment for this:

;***** Mains frequency in Hz *****
; if defined it uses lookup table for 50Hz, else it uses 60Hz lookup table
#define		FREQ50 1

PIC12F629 Firmware

To compile for F629, you need to include appropriate header files like this:

;***** Declaration and PIC config *****

        PROCESSOR 12f629
        #include "p12f629.inc"

The resulting code will occupy exactly 559 words (978,25). There is one additional word at the end of program memory which is programmed in the Microchip factory. If we count that in as well, the size of program is 980 bytes.

PIC12F675 Firmware

To compile for F675, you need to include appropriate header files like this:

;***** Declaration and PIC config *****

        PROCESSOR 12f675
        #include "p12f675.inc"

The resulting code will occupy exactly 561 words (981,75 bytes). If we add that OSCCAL from the end, the size of program is: 983,5 bytes.

Discussions