Thursday, January 5, 2012

Projector Control Circuit Details

 I have received several requests for schematics and source code for the control system i built for my projector. After several months of delays and procrastinating here they are:
 The circuit is relatively straightforward, the relay is sunk by an npn transistor... there is a protection diode to prevent any unfortunate kickback. The reset pin on the micro controller is puled up with a 1k resistor and there is a 0.01 uF capacitor to filter power. The micro controller listens for a control signal and a feedback signal is given by pulling it to ground using an npn transistor.

The code is extremely simple, the mcu waits for the control signal to be high for more than 250ms then enables the feedback signal and turns on the relay until the control signal goes low. The entire thing is in an infinite loop.

#include <htc.h>
#define _XTAL_FREQ 4000000


void main()
    TRISIO = 0b111010;
    ANSEL = 0;
    CMCON = 7;
        GPIO = 0b000000;
        // wait for power on signal
        for(int x = 0; x < 250; x++)
            if(GPIO1 == 0) x = 0;
        GPIO = 0b000101;
        // wait for power off signal